Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into bugfix-decimal-div
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 committed Feb 7, 2020
2 parents 1c28cbc + fd97efe commit 899bee4
Show file tree
Hide file tree
Showing 51 changed files with 1,026 additions and 808 deletions.
2 changes: 1 addition & 1 deletion ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ func (s *testIntegrationSuite5) TestPartitionAddPrimaryKey(c *C) {
testPartitionAddIndexOrPK(c, tk, "primary key")
}

func (s *testIntegrationSuite6) TestPartitionAddIndex(c *C) {
func (s *testIntegrationSuite1) TestPartitionAddIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
testPartitionAddIndexOrPK(c, tk, "index")
}
Expand Down
30 changes: 12 additions & 18 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ var _ = Suite(&testDBSuite3{&testDBSuite{}})
var _ = Suite(&testDBSuite4{&testDBSuite{}})
var _ = Suite(&testDBSuite5{&testDBSuite{}})
var _ = Suite(&testDBSuite6{&testDBSuite{}})
var _ = Suite(&testDBSuite7{&testDBSuite{}})
var _ = Suite(&testDBSuite8{&testDBSuite{}})
var _ = Suite(&testDBSuite9{&testDBSuite{}})

const defaultBatchSize = 1024

Expand Down Expand Up @@ -137,9 +134,6 @@ type testDBSuite3 struct{ *testDBSuite }
type testDBSuite4 struct{ *testDBSuite }
type testDBSuite5 struct{ *testDBSuite }
type testDBSuite6 struct{ *testDBSuite }
type testDBSuite7 struct{ *testDBSuite }
type testDBSuite8 struct{ *testDBSuite }
type testDBSuite9 struct{ *testDBSuite }

func (s *testDBSuite4) TestAddIndexWithPK(c *C) {
s.tk = testkit.NewTestKit(c, s.store)
Expand Down Expand Up @@ -230,7 +224,7 @@ func backgroundExec(s kv.Storage, sql string, done chan error) {
}

// TestAddPrimaryKeyRollback1 is used to test scenarios that will roll back when a duplicate primary key is encountered.
func (s *testDBSuite7) TestAddPrimaryKeyRollback1(c *C) {
func (s *testDBSuite5) TestAddPrimaryKeyRollback1(c *C) {
hasNullValsInKey := false
idxName := "PRIMARY"
addIdxSQL := "alter table t1 add primary key c3_index (c3);"
Expand All @@ -239,7 +233,7 @@ func (s *testDBSuite7) TestAddPrimaryKeyRollback1(c *C) {
}

// TestAddPrimaryKeyRollback2 is used to test scenarios that will roll back when a null primary key is encountered.
func (s *testDBSuite9) TestAddPrimaryKeyRollback2(c *C) {
func (s *testDBSuite1) TestAddPrimaryKeyRollback2(c *C) {
hasNullValsInKey := true
idxName := "PRIMARY"
addIdxSQL := "alter table t1 add primary key c3_index (c3);"
Expand Down Expand Up @@ -359,7 +353,7 @@ func (s *testDBSuite5) TestCancelAddPrimaryKey(c *C) {
tk.MustExec("drop table t1")
}

func (s *testDBSuite9) TestCancelAddIndex(c *C) {
func (s *testDBSuite3) TestCancelAddIndex(c *C) {
idxName := "c3_index "
addIdxSQL := "create unique index c3_index on t1 (c3)"
testCancelAddIndex(c, s.store, s.dom.DDL(), s.lease, idxName, addIdxSQL, "")
Expand Down Expand Up @@ -895,12 +889,12 @@ func (s *testDBSuite5) TestAddMultiColumnsIndex(c *C) {
s.tk.MustExec("alter table tidb.test add index idx1 (a, b);")
s.tk.MustExec("admin check table test")
}
func (s *testDBSuite6) TestAddPrimaryKey1(c *C) {
func (s *testDBSuite1) TestAddPrimaryKey1(c *C) {
testAddIndex(c, s.store, s.lease, false,
"create table test_add_index (c1 bigint, c2 bigint, c3 bigint, unique key(c1))", "primary")
}

func (s *testDBSuite6) TestAddPrimaryKey2(c *C) {
func (s *testDBSuite2) TestAddPrimaryKey2(c *C) {
testAddIndex(c, s.store, s.lease, true,
`create table test_add_index (c1 bigint, c2 bigint, c3 bigint, key(c1))
partition by range (c3) (
Expand All @@ -911,13 +905,13 @@ func (s *testDBSuite6) TestAddPrimaryKey2(c *C) {
partition p4 values less than maxvalue)`, "primary")
}

func (s *testDBSuite9) TestAddPrimaryKey3(c *C) {
func (s *testDBSuite3) TestAddPrimaryKey3(c *C) {
testAddIndex(c, s.store, s.lease, true,
`create table test_add_index (c1 bigint, c2 bigint, c3 bigint, key(c1))
partition by hash (c3) partitions 4;`, "primary")
}

func (s *testDBSuite7) TestAddPrimaryKey4(c *C) {
func (s *testDBSuite4) TestAddPrimaryKey4(c *C) {
testAddIndex(c, s.store, s.lease, true,
`create table test_add_index (c1 bigint, c2 bigint, c3 bigint, key(c1))
partition by range columns (c3) (
Expand All @@ -933,7 +927,7 @@ func (s *testDBSuite1) TestAddIndex1(c *C) {
"create table test_add_index (c1 bigint, c2 bigint, c3 bigint, primary key(c1))", "")
}

func (s *testDBSuite8) TestAddIndex2(c *C) {
func (s *testDBSuite2) TestAddIndex2(c *C) {
testAddIndex(c, s.store, s.lease, true,
`create table test_add_index (c1 bigint, c2 bigint, c3 bigint, primary key(c1))
partition by range (c1) (
Expand All @@ -950,7 +944,7 @@ func (s *testDBSuite3) TestAddIndex3(c *C) {
partition by hash (c1) partitions 4;`, "")
}

func (s *testDBSuite8) TestAddIndex4(c *C) {
func (s *testDBSuite4) TestAddIndex4(c *C) {
testAddIndex(c, s.store, s.lease, true,
`create table test_add_index (c1 bigint, c2 bigint, c3 bigint, primary key(c1))
partition by range columns (c1) (
Expand Down Expand Up @@ -1413,7 +1407,7 @@ func checkDelRangeDone(c *C, ctx sessionctx.Context, idx table.Index) {
c.Assert(handles, HasLen, 0, Commentf("take time %v", time.Since(startTime)))
}

func (s *testDBSuite8) TestAlterPrimaryKey(c *C) {
func (s *testDBSuite5) TestAlterPrimaryKey(c *C) {
s.tk = testkit.NewTestKitWithInit(c, s.store)
s.tk.MustExec("create table test_add_pk(a int, b int unsigned , c varchar(255) default 'abc', d int as (a+b), e int as (a+1) stored, index idx(b))")
defer s.tk.MustExec("drop table test_add_pk")
Expand Down Expand Up @@ -1547,7 +1541,7 @@ func (s *testDBSuite5) TestCreateIndexType(c *C) {
s.tk.MustExec(sql)
}

func (s *testDBSuite4) TestColumn(c *C) {
func (s *testDBSuite1) TestColumn(c *C) {
s.tk = testkit.NewTestKit(c, s.store)
s.tk.MustExec("use " + s.schemaName)
s.tk.MustExec("create table t2 (c1 int, c2 int, c3 int)")
Expand Down Expand Up @@ -1771,7 +1765,7 @@ LOOP:
// TestDropColumn is for inserting value with a to-be-dropped column when do drop column.
// Column info from schema in build-insert-plan should be public only,
// otherwise they will not be consist with Table.Col(), then the server will panic.
func (s *testDBSuite7) TestDropColumn(c *C) {
func (s *testDBSuite2) TestDropColumn(c *C) {
s.tk = testkit.NewTestKit(c, s.store)
s.tk.MustExec("create database drop_col_db")
s.tk.MustExec("use drop_col_db")
Expand Down
103 changes: 0 additions & 103 deletions ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,106 +665,3 @@ func (d *ddl) GetHook() Callback {

return d.mu.hook
}

func init() {
ddlMySQLErrCodes := map[terror.ErrCode]uint16{
mysql.ErrAlterOperationNotSupportedReason: mysql.ErrAlterOperationNotSupportedReason,
mysql.ErrBadField: mysql.ErrBadField,
mysql.ErrBadNull: mysql.ErrBadNull,
mysql.ErrBlobCantHaveDefault: mysql.ErrBlobCantHaveDefault,
mysql.ErrBlobKeyWithoutLength: mysql.ErrBlobKeyWithoutLength,
mysql.ErrCancelledDDLJob: mysql.ErrCancelledDDLJob,
mysql.ErrCantDecodeIndex: mysql.ErrCantDecodeIndex,
mysql.ErrCantDropFieldOrKey: mysql.ErrCantDropFieldOrKey,
mysql.ErrCantRemoveAllFields: mysql.ErrCantRemoveAllFields,
mysql.ErrCoalesceOnlyOnHashPartition: mysql.ErrCoalesceOnlyOnHashPartition,
mysql.ErrCollationCharsetMismatch: mysql.ErrCollationCharsetMismatch,
mysql.ErrConflictingDeclarations: mysql.ErrConflictingDeclarations,
mysql.ErrDependentByGeneratedColumn: mysql.ErrDependentByGeneratedColumn,
mysql.ErrDropLastPartition: mysql.ErrDropLastPartition,
mysql.ErrDropPartitionNonExistent: mysql.ErrDropPartitionNonExistent,
mysql.ErrDupKeyName: mysql.ErrDupKeyName,
mysql.ErrErrorOnRename: mysql.ErrErrorOnRename,
mysql.ErrFieldNotFoundPart: mysql.ErrFieldNotFoundPart,
mysql.ErrFieldTypeNotAllowedAsPartitionField: mysql.ErrFieldTypeNotAllowedAsPartitionField,
mysql.ErrFileNotFound: mysql.ErrFileNotFound,
mysql.ErrFunctionalIndexPrimaryKey: mysql.ErrFunctionalIndexPrimaryKey,
mysql.ErrGeneratedColumnFunctionIsNotAllowed: mysql.ErrGeneratedColumnFunctionIsNotAllowed,
mysql.ErrGeneratedColumnNonPrior: mysql.ErrGeneratedColumnNonPrior,
mysql.ErrGeneratedColumnRefAutoInc: mysql.ErrGeneratedColumnRefAutoInc,
mysql.ErrInvalidAutoRandom: mysql.ErrInvalidAutoRandom,
mysql.ErrInvalidDDLJob: mysql.ErrInvalidDDLJob,
mysql.ErrInvalidDDLState: mysql.ErrInvalidDDLState,
mysql.ErrInvalidDDLWorker: mysql.ErrInvalidDDLWorker,
mysql.ErrInvalidDefault: mysql.ErrInvalidDefault,
mysql.ErrInvalidGroupFuncUse: mysql.ErrInvalidGroupFuncUse,
mysql.ErrInvalidDDLJobFlag: mysql.ErrInvalidDDLJobFlag,
mysql.ErrInvalidDDLJobVersion: mysql.ErrInvalidDDLJobVersion,
mysql.ErrInvalidOnUpdate: mysql.ErrInvalidOnUpdate,
mysql.ErrInvalidSplitRegionRanges: mysql.ErrInvalidSplitRegionRanges,
mysql.ErrInvalidStoreVersion: mysql.ErrInvalidStoreVersion,
mysql.ErrInvalidUseOfNull: mysql.ErrInvalidUseOfNull,
mysql.ErrJSONUsedAsKey: mysql.ErrJSONUsedAsKey,
mysql.ErrJSONDocumentNULLKey: mysql.ErrJSONDocumentNULLKey,
mysql.ErrKeyColumnDoesNotExits: mysql.ErrKeyColumnDoesNotExits,
mysql.ErrLockWaitTimeout: mysql.ErrLockWaitTimeout,
mysql.ErrNoParts: mysql.ErrNoParts,
mysql.ErrNotOwner: mysql.ErrNotOwner,
mysql.ErrOnlyOnRangeListPartition: mysql.ErrOnlyOnRangeListPartition,
mysql.ErrPartitionColumnList: mysql.ErrPartitionColumnList,
mysql.ErrPartitionFuncNotAllowed: mysql.ErrPartitionFuncNotAllowed,
mysql.ErrPartitionFunctionIsNotAllowed: mysql.ErrPartitionFunctionIsNotAllowed,
mysql.ErrPartitionMaxvalue: mysql.ErrPartitionMaxvalue,
mysql.ErrPartitionMgmtOnNonpartitioned: mysql.ErrPartitionMgmtOnNonpartitioned,
mysql.ErrPartitionRequiresValues: mysql.ErrPartitionRequiresValues,
mysql.ErrPartitionWrongNoPart: mysql.ErrPartitionWrongNoPart,
mysql.ErrPartitionWrongNoSubpart: mysql.ErrPartitionWrongNoSubpart,
mysql.ErrPartitionWrongValues: mysql.ErrPartitionWrongValues,
mysql.ErrPartitionsMustBeDefined: mysql.ErrPartitionsMustBeDefined,
mysql.ErrPrimaryCantHaveNull: mysql.ErrPrimaryCantHaveNull,
mysql.ErrRangeNotIncreasing: mysql.ErrRangeNotIncreasing,
mysql.ErrRowSinglePartitionField: mysql.ErrRowSinglePartitionField,
mysql.ErrSameNamePartition: mysql.ErrSameNamePartition,
mysql.ErrSubpartition: mysql.ErrSubpartition,
mysql.ErrSystemVersioningWrongPartitions: mysql.ErrSystemVersioningWrongPartitions,
mysql.ErrTableCantHandleFt: mysql.ErrTableCantHandleFt,
mysql.ErrTableMustHaveColumns: mysql.ErrTableMustHaveColumns,
mysql.ErrTooLongIdent: mysql.ErrTooLongIdent,
mysql.ErrTooLongIndexComment: mysql.ErrTooLongIndexComment,
mysql.ErrTooLongKey: mysql.ErrTooLongKey,
mysql.ErrTooManyFields: mysql.ErrTooManyFields,
mysql.ErrTooManyPartitions: mysql.ErrTooManyPartitions,
mysql.ErrTooManyValues: mysql.ErrTooManyValues,
mysql.ErrUniqueKeyNeedAllFieldsInPf: mysql.ErrUniqueKeyNeedAllFieldsInPf,
mysql.ErrUnknownCharacterSet: mysql.ErrUnknownCharacterSet,
mysql.ErrUnknownCollation: mysql.ErrUnknownCollation,
mysql.ErrUnknownPartition: mysql.ErrUnknownPartition,
mysql.ErrUnsupportedDDLOperation: mysql.ErrUnsupportedDDLOperation,
mysql.ErrUnsupportedOnGeneratedColumn: mysql.ErrUnsupportedOnGeneratedColumn,
mysql.ErrViewWrongList: mysql.ErrViewWrongList,
mysql.ErrWrongColumnName: mysql.ErrWrongColumnName,
mysql.ErrWrongDBName: mysql.ErrWrongDBName,
mysql.ErrWrongExprInPartitionFunc: mysql.ErrWrongExprInPartitionFunc,
mysql.ErrWrongFKOptionForGeneratedColumn: mysql.ErrWrongFKOptionForGeneratedColumn,
mysql.ErrWrongKeyColumn: mysql.ErrWrongKeyColumn,
mysql.ErrWrongNameForIndex: mysql.ErrWrongNameForIndex,
mysql.ErrWrongObject: mysql.ErrWrongObject,
mysql.ErrWrongPartitionTypeExpectedSystemTime: mysql.ErrWrongPartitionTypeExpectedSystemTime,
mysql.ErrWrongSubKey: mysql.ErrWrongSubKey,
mysql.ErrWrongTableName: mysql.ErrWrongTableName,
mysql.ErrWrongTypeColumnValue: mysql.ErrWrongTypeColumnValue,
mysql.WarnDataTruncated: mysql.WarnDataTruncated,
mysql.ErrFunctionalIndexOnField: mysql.ErrFunctionalIndexOnField,
mysql.ErrFkColumnCannotDrop: mysql.ErrFkColumnCannotDrop,
mysql.ErrFKIncompatibleColumns: mysql.ErrFKIncompatibleColumns,
mysql.ErrSequenceRunOut: mysql.ErrSequenceRunOut,
mysql.ErrSequenceInvalidData: mysql.ErrSequenceInvalidData,
mysql.ErrSequenceAccessFail: mysql.ErrSequenceAccessFail,
mysql.ErrNotSequence: mysql.ErrNotSequence,
mysql.ErrUnknownSequence: mysql.ErrUnknownSequence,
mysql.ErrWrongInsertIntoSequence: mysql.ErrWrongInsertIntoSequence,
mysql.ErrSequenceInvalidTableStructure: mysql.ErrSequenceInvalidTableStructure,
mysql.ErrSequenceUnsupportedTableOption: mysql.ErrSequenceUnsupportedTableOption,
}
terror.ErrClassToMySQLCodes[terror.ClassDDL] = ddlMySQLErrCodes
}
2 changes: 1 addition & 1 deletion ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ func toTError(err error) *terror.Error {
}

// TODO: Add the error code.
return terror.ClassDDL.New(terror.CodeUnknown, err.Error())
return terror.ClassDDL.Synthesize(terror.CodeUnknown, err.Error())
}

// waitSchemaChanged waits for the completion of updating all servers' schema. In order to make sure that happens,
Expand Down
4 changes: 2 additions & 2 deletions distsql/select_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ func (r *selectResult) fetchResp(ctx context.Context) error {
r.selectRespSize = r.selectResp.Size()
r.memConsume(int64(r.selectRespSize))
if err := r.selectResp.Error; err != nil {
return terror.ClassTiKV.New(terror.ErrCode(err.Code), err.Msg)
return terror.ClassTiKV.Synthesize(terror.ErrCode(err.Code), err.Msg)
}
sc := r.ctx.GetSessionVars().StmtCtx
for _, warning := range r.selectResp.Warnings {
sc.AppendWarning(terror.ClassTiKV.New(terror.ErrCode(warning.Code), warning.Msg))
sc.AppendWarning(terror.ClassTiKV.Synthesize(terror.ErrCode(warning.Code), warning.Msg))
}
r.updateCopRuntimeStats(resultSubset.GetExecDetails(), resultSubset.RespTime())
r.feedback.Update(resultSubset.GetStartKey(), r.selectResp.OutputCounts)
Expand Down
2 changes: 1 addition & 1 deletion distsql/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (r *streamResult) readDataFromResponse(ctx context.Context, resp kv.Respons
return false, errors.Errorf("stream response error: [%d]%s\n", stream.Error.Code, stream.Error.Msg)
}
for _, warning := range stream.Warnings {
r.ctx.GetSessionVars().StmtCtx.AppendWarning(terror.ClassTiKV.New(terror.ErrCode(warning.Code), warning.Msg))
r.ctx.GetSessionVars().StmtCtx.AppendWarning(terror.ClassTiKV.Synthesize(terror.ErrCode(warning.Code), warning.Msg))
}

err = result.Unmarshal(stream.Data)
Expand Down
9 changes: 0 additions & 9 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,12 +1134,3 @@ var (
ErrInfoSchemaChanged = terror.ClassDomain.New(mysql.ErrInfoSchemaChanged,
mysql.MySQLErrName[mysql.ErrInfoSchemaChanged]+". "+kv.TxnRetryableMark)
)

func init() {
// Map error codes to mysql error codes.
domainMySQLErrCodes := map[terror.ErrCode]uint16{
mysql.ErrInfoSchemaExpired: mysql.ErrInfoSchemaExpired,
mysql.ErrInfoSchemaChanged: mysql.ErrInfoSchemaChanged,
}
terror.ErrClassToMySQLCodes[terror.ClassDomain] = domainMySQLErrCodes
}
Loading

0 comments on commit 899bee4

Please sign in to comment.