Skip to content

Commit

Permalink
Revert "*: add a String method for Datum to make the log more friendly (
Browse files Browse the repository at this point in the history
#7426)" (#7435)

This reverts commit 7773b28.
  • Loading branch information
jackysp committed Aug 20, 2018
1 parent b1aef89 commit 233660a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 50 deletions.
2 changes: 0 additions & 2 deletions executor/insert.go
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
log "github.com/sirupsen/logrus"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -179,7 +178,6 @@ func (e *InsertExec) Open(ctx context.Context) error {
func (e *InsertExec) updateDupRow(row toBeCheckedRow, handle int64, onDuplicate []*expression.Assignment) error {
oldRow, err := e.getOldRow(e.ctx, e.Table, handle)
if err != nil {
log.Errorf("[insert on dup] cannot find the record whose handle is %d for the to-be-inserted row %v", handle, row.row)
return errors.Trace(err)
}
// Do update row.
Expand Down
2 changes: 0 additions & 2 deletions executor/replace.go
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
log "github.com/sirupsen/logrus"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -53,7 +52,6 @@ func (e *ReplaceExec) removeRow(handle int64, r toBeCheckedRow) (bool, error) {
newRow := r.row
oldRow, err := e.batchChecker.getOldRow(e.ctx, r.t, handle)
if err != nil {
log.Errorf("[replace] cannot find the record whose handle is %d for the to-be-inserted row %v", handle, r.row)
return false, errors.Trace(err)
}
rowUnchanged, err := types.EqualDatums(e.ctx.GetSessionVars().StmtCtx, oldRow, newRow)
Expand Down
35 changes: 0 additions & 35 deletions executor/write_test.go
Expand Up @@ -28,11 +28,8 @@ import (
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/store/mockstore"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/table/tables"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/testkit"
"golang.org/x/net/context"
)

type testBypassSuite struct{}
Expand Down Expand Up @@ -1999,35 +1996,3 @@ func (s *testSuite) TestUpdateAffectRowCnt(c *C) {
ctx = tk.Se.(sessionctx.Context)
c.Assert(ctx.GetSessionVars().StmtCtx.AffectedRows(), Equals, uint64(2))
}

func (s *testSuite) TestReplaceLog(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec(`create table testLog (a int not null primary key, b int unique key);`)

// Make some dangling index.
s.ctx = mock.NewContext()
s.ctx.Store = s.store
is := s.domain.InfoSchema()
dbName := model.NewCIStr("test")
tblName := model.NewCIStr("testLog")
tbl, err := is.TableByName(dbName, tblName)
c.Assert(err, IsNil)
tblInfo := tbl.Meta()
idxInfo := findIndexByName("b", tblInfo.Indices)
indexOpr := tables.NewIndex(tblInfo.ID, tblInfo, idxInfo)

txn, err := s.store.Begin()
c.Assert(err, IsNil)
_, err = indexOpr.Create(s.ctx, txn, types.MakeDatums(1), 1)
c.Assert(err, IsNil)
err = txn.Commit(context.Background())
c.Assert(err, IsNil)

_, err = tk.Exec(`replace into testLog values (0, 0), (1, 1);`)
c.Assert(err, NotNil)
expErr := errors.New(`can not be duplicated row, due to old row not found. handle 1 not found`)
c.Assert(expErr.Error() == err.Error(), IsTrue, Commentf("obtained error: (%s)\nexpected error: (%s)", err.Error(), expErr.Error()))

tk.MustQuery(`admin cleanup index testLog b;`).Check(testkit.Rows("1"))
}
3 changes: 2 additions & 1 deletion store/mockstore/mocktikv/cop_handler_dag.go
Expand Up @@ -170,8 +170,9 @@ func (h *rpcHandler) buildDAGExecutor(req *coprocessor.Request) (*dagContext, ex
func constructTimeZone(name string, offset int) (*time.Location, error) {
if name != "" {
return LocCache.getLoc(name)
} else {
return time.FixedZone("", offset), nil
}
return time.FixedZone("", offset), nil
}

func (h *rpcHandler) handleCopStream(ctx context.Context, req *coprocessor.Request) (tikvpb.Tikv_CoprocessorStreamClient, error) {
Expand Down
10 changes: 0 additions & 10 deletions types/datum.go
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/pingcap/tidb/types/json"
"github.com/pingcap/tidb/util/charset"
"github.com/pingcap/tidb/util/hack"
log "github.com/sirupsen/logrus"
)

// Kind constants.
Expand Down Expand Up @@ -1872,12 +1871,3 @@ func CopyRow(dr []Datum) []Datum {
}
return c
}

// String implements fmt.Stringer interface.
func (d Datum) String() string {
str, err := d.ToString()
if err != nil {
log.Info(err)
}
return fmt.Sprintf("(Kind: %s, Value: %s)", kind2Str[d.k], str)
}

0 comments on commit 233660a

Please sign in to comment.