Skip to content

Commit

Permalink
*: add the error check (#8770)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored and zz-jason committed Dec 24, 2018
1 parent 98b96cc commit bd69b15
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (s *testIntegrationSuite) SetUpSuite(c *C) {
session.SetSchemaLease(s.lease)
session.SetStatsLease(0)
s.dom, err = session.BootstrapSession(s.store)
c.Assert(err, IsNil)

se, err := session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
Expand Down
1 change: 1 addition & 0 deletions ddl/ddl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ func (s *testDDLSuite) TestCancelJob(c *C) {
Options: []*ast.ColumnOption{},
}
col, _, err := buildColumnAndConstraint(ctx, 2, newColumnDef, nil)
c.Assert(err, IsNil)
addColumnArgs := []interface{}{col, &ast.ColumnPosition{Tp: ast.ColumnPositionNone}, 0}
doDDLJobErrWithSchemaState(ctx, d, c, dbInfo.ID, tblInfo.ID, model.ActionAddColumn, addColumnArgs, &cancelState)
c.Check(errors.ErrorStack(checkErr), Equals, "")
Expand Down
3 changes: 3 additions & 0 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,9 @@ func (e *MaxOneRowExec) Next(ctx context.Context, chk *chunk.Chunk) error {

childChunk := e.children[0].newFirstChunk()
err = e.children[0].Next(ctx, childChunk)
if err != nil {
return errors.Trace(err)
}
if childChunk.NumRows() != 0 {
return errors.New("subquery returns more than 1 row")
}
Expand Down
1 change: 1 addition & 0 deletions privilege/privileges/privileges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func (s *testPrivilegeSuite) TestShowGrants(c *C) {

// This should now return an error
gs, err = pc.ShowGrants(se, &auth.UserIdentity{Username: "show", Hostname: "localhost"})
c.Assert(err, NotNil)
// cant show grants for non-existent
errNonexistingGrant := terror.ClassPrivilege.New(mysql.ErrNonexistingGrant, mysql.MySQLErrName[mysql.ErrNonexistingGrant])
c.Assert(terror.ErrorEqual(err, errNonexistingGrant), IsTrue)
Expand Down
2 changes: 2 additions & 0 deletions sessionctx/variable/varsutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ func (s *testVarsutilSuite) TestVarsutil(c *C) {
// 0 converts to OFF
SetSessionSystemVar(v, "foreign_key_checks", types.NewStringDatum("0"))
val, err = GetSessionSystemVar(v, "foreign_key_checks")
c.Assert(err, IsNil)
c.Assert(val, Equals, "OFF")

// 1/ON is not supported (generates a warning and sets to OFF)
SetSessionSystemVar(v, "foreign_key_checks", types.NewStringDatum("1"))
val, err = GetSessionSystemVar(v, "foreign_key_checks")
c.Assert(err, IsNil)
c.Assert(val, Equals, "OFF")

SetSessionSystemVar(v, "sql_mode", types.NewStringDatum("strict_trans_tables"))
Expand Down
1 change: 1 addition & 0 deletions store/tikv/gcworker/gc_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (s *testGCWorkerSuite) TestPrepareGC(c *C) {
close(s.gcWorker.done)
ok, _, err := s.gcWorker.prepare()
c.Assert(err, IsNil)
c.Assert(ok, IsFalse)
lastRun, err := s.gcWorker.loadTime(gcLastRunTimeKey)
c.Assert(err, IsNil)
c.Assert(lastRun, NotNil)
Expand Down
3 changes: 3 additions & 0 deletions table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,9 @@ func (t *tableCommon) Seek(ctx sessionctx.Context, h int64) (int64, bool, error)
}
seekKey := tablecodec.EncodeRowKeyWithHandle(t.physicalTableID, h)
iter, err := txn.Iter(seekKey, t.RecordPrefix().PrefixNext())
if err != nil {
return 0, false, errors.Trace(err)
}
if !iter.Valid() || !iter.Key().HasPrefix(t.RecordPrefix()) {
// No more records in the table, skip to the end.
return 0, false, nil
Expand Down
4 changes: 2 additions & 2 deletions util/admin/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ func (s *testSuite) TestScan(c *C) {
idxRow2 := &RecordData{Handle: int64(2), Values: types.MakeDatums(int64(20))}
kvIndex := tables.NewIndex(tb.Meta().ID, tb.Meta(), indices[0].Meta())
sc := &stmtctx.StatementContext{TimeZone: time.Local}
idxRows, nextVals, err := ScanIndexData(sc, txn, kvIndex, idxRow1.Values, 2)
idxRows, _, err := ScanIndexData(sc, txn, kvIndex, idxRow1.Values, 2)
c.Assert(err, IsNil)
c.Assert(idxRows, DeepEquals, []*RecordData{idxRow1, idxRow2})
idxRows, nextVals, err = ScanIndexData(sc, txn, kvIndex, idxRow1.Values, 1)
idxRows, nextVals, err := ScanIndexData(sc, txn, kvIndex, idxRow1.Values, 1)
c.Assert(err, IsNil)
c.Assert(idxRows, DeepEquals, []*RecordData{idxRow1})
idxRows, nextVals, err = ScanIndexData(sc, txn, kvIndex, nextVals, 1)
Expand Down
2 changes: 1 addition & 1 deletion util/ranger/detacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func DetachSimpleCondAndBuildRangeForIndex(sctx sessionctx.Context, conditions [
newTpSlice = append(newTpSlice, newFieldType(col.RetType))
}
ranges, accessConds, _, _, err = detachCNFCondAndBuildRangeForIndex(sctx, conditions, cols, newTpSlice, lengths, false)
return ranges, accessConds, nil
return ranges, accessConds, errors.Trace(err)
}

func removeAccessConditions(conditions, accessConds []expression.Expression) []expression.Expression {
Expand Down

0 comments on commit bd69b15

Please sign in to comment.