Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pingcap/tidb into fix-sha…
Browse files Browse the repository at this point in the history
…re-bit
  • Loading branch information
crazycs520 committed Apr 8, 2019
2 parents 51c5bea + bb23eac commit b7ece2c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
3 changes: 1 addition & 2 deletions statistics/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package statistics

import (
"context"
"fmt"
"math/rand"
"sort"

Expand Down Expand Up @@ -218,7 +217,7 @@ func (s SampleBuilder) CollectColumnStats() ([]*SampleCollector, *SortedBuilder,
return collectors, s.PkBuilder, nil
}
if len(s.RecordSet.Fields()) == 0 {
panic(fmt.Sprintf("%T", s.RecordSet))
return nil, nil, errors.Errorf("collect column stats failed: record set has 0 field")
}
for row := it.Begin(); row != it.End(); row = it.Next() {
datums := RowToDatums(row, s.RecordSet.Fields())
Expand Down
2 changes: 1 addition & 1 deletion store/mockstore/mocktikv/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (h *rpcHandler) handleCopChecksumRequest(req *coprocessor.Request) *coproce
}
data, err := resp.Marshal()
if err != nil {
panic(fmt.Sprintf("marshal checksum response error: %v", err))
return &coprocessor.Response{OtherError: fmt.Sprintf("marshal checksum response error: %v", err)}
}
return &coprocessor.Response{Data: data}
}
3 changes: 1 addition & 2 deletions store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package tikv
import (
"bytes"
"context"
"fmt"
"math"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -457,7 +456,7 @@ func (c *twoPhaseCommitter) prewriteSingleBatch(bo *Backoffer, batch batchKeys)
key := alreadyExist.GetKey()
conditionPair := c.txn.us.LookupConditionPair(key)
if conditionPair == nil {
panic(fmt.Sprintf("conn%d, conditionPair for key:%s should not be nil", c.connID, key))
return errors.Errorf("conn%d, conditionPair for key:%s should not be nil", c.connID, key)
}
logutil.Logger(context.Background()).Debug("key already exists",
zap.Uint64("conn", c.connID),
Expand Down
35 changes: 35 additions & 0 deletions util/kvencoder/kv_encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,41 @@ func (s *testKvEncoderSuite) TestAllocatorRebase(c *C) {
sql = "insert into t(id, a) values(2000, 'test')"
encoder.Encode(sql, tableID)
c.Assert(alloc.Base(), Equals, int64(2000))
c.Assert(alloc.End(), Equals, int64(2000)+step)
nextID, err := alloc.NextGlobalAutoID(tableID)
c.Assert(err, IsNil)
c.Assert(nextID, Equals, int64(2000)+step+1)
}

func (s *testKvEncoderSuite) TestError(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
alloc := NewAllocator()
encoder, err := New("test", alloc)
c.Assert(err, IsNil)
defer encoder.Close()
_, err = New("", alloc)
c.Assert(err, NotNil)
c.Assert(err, ErrorMatches, "*Incorrect database name ''")

err = encoder.ExecDDLSQL("x")
c.Assert(err, NotNil)
c.Assert(err, ErrorMatches, "*You have an error in your SQL syntax.*")

_, err = encoder.PrepareStmt("")
c.Assert(err, NotNil)
c.Assert(err, ErrorMatches, "*Can not prepare multiple statements")
_, _, err = encoder.EncodePrepareStmt(0, 0, 0)
c.Assert(err, NotNil)
c.Assert(err, ErrorMatches, "*Prepared statement not found")

encoder = &kvEncoder{}
err = encoder.SetSystemVariable("", "")
c.Assert(err, NotNil)
c.Assert(err, ErrorMatches, ".*please new KvEncoder by kvencoder.New.*")
_, ok := encoder.GetSystemVariable("")
c.Assert(ok, IsFalse)
c.Assert(err, ErrorMatches, ".*please new KvEncoder by kvencoder.New.*")
}

func (s *testKvEncoderSuite) TestAllocatorRebaseSmaller(c *C) {
Expand Down

0 comments on commit b7ece2c

Please sign in to comment.