Skip to content

Commit

Permalink
Revert "ddl, executor: fix test race in terror (pingcap#25405) (pingc…
Browse files Browse the repository at this point in the history
…ap#28198)"

This reverts commit 560b0da.
  • Loading branch information
windtalker committed Sep 26, 2021
1 parent c2b1540 commit 08296d0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
field_types "github.com/pingcap/parser/types"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/ddl/placement"
"github.com/pingcap/tidb/errno"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/kv"
Expand All @@ -54,6 +55,7 @@ import (
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/codec"
"github.com/pingcap/tidb/util/collate"
"github.com/pingcap/tidb/util/dbterror"
"github.com/pingcap/tidb/util/domainutil"
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/mock"
Expand Down Expand Up @@ -1408,7 +1410,8 @@ func buildTableInfo(
// Check clustered on non-primary key.
if constr.Option != nil && constr.Option.PrimaryKeyTp != model.PrimaryKeyTypeDefault &&
constr.Tp != ast.ConstraintPrimaryKey {
return nil, errUnsupportedClusteredSecondaryKey
msg := mysql.Message("CLUSTERED/NONCLUSTERED keyword is only supported for primary key", nil)
return nil, dbterror.ClassDDL.NewStdErr(errno.ErrUnsupportedDDLOperation, msg)
}
if constr.Tp == ast.ConstraintForeignKey {
for _, fk := range tbInfo.ForeignKeys {
Expand Down Expand Up @@ -1437,7 +1440,8 @@ func buildTableInfo(
} else {
hasBinlog := ctx.GetSessionVars().BinlogClient != nil
if hasBinlog {
return nil, errUnsupportedClusteredIndexWhenBinlogIsOn
msg := mysql.Message("Cannot create clustered index table when the binlog is ON", nil)
return nil, dbterror.ClassDDL.NewStdErr(errno.ErrUnsupportedDDLOperation, msg)
}
tbInfo.IsCommonHandle = true
tbInfo.CommonHandleVersion = 1
Expand Down
4 changes: 1 addition & 3 deletions ddl/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,5 @@ var (
// ErrUnknownEngine is returned when the table engine is unknown.
ErrUnknownEngine = dbterror.ClassDDL.NewStd(mysql.ErrUnknownStorageEngine)

errExchangePartitionDisabled = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("Exchange Partition is disabled, please set 'tidb_enable_exchange_partition' if you need to need to enable it", nil))
errUnsupportedClusteredSecondaryKey = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("CLUSTERED/NONCLUSTERED keyword is only supported for primary key", nil))
errUnsupportedClusteredIndexWhenBinlogIsOn = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("Cannot create clustered index table when the binlog is ON", nil))
errExchangePartitionDisabled = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("Exchange Partition is disabled, please set 'tidb_enable_exchange_partition' if you need to need to enable it", nil))
)
3 changes: 0 additions & 3 deletions executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package executor

import (
parser_mysql "github.com/pingcap/parser/mysql"
mysql "github.com/pingcap/tidb/errno"
"github.com/pingcap/tidb/util/dbterror"
)
Expand Down Expand Up @@ -50,6 +49,4 @@ var (
ErrBRIERestoreFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIERestoreFailed)
ErrBRIEImportFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEImportFailed)
ErrBRIEExportFailed = dbterror.ClassExecutor.NewStd(mysql.ErrBRIEExportFailed)

errTruncateWrongInsertValue = dbterror.ClassTable.NewStdErr(mysql.ErrTruncatedWrongValue, parser_mysql.Message("Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %d", nil))
)
7 changes: 6 additions & 1 deletion executor/insert_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/errno"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/meta/autoid"
Expand All @@ -37,6 +38,7 @@ import (
"github.com/pingcap/tidb/table/tables"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/dbterror"
"github.com/pingcap/tidb/util/execdetails"
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/memory"
Expand Down Expand Up @@ -306,7 +308,10 @@ func (e *InsertValues) handleErr(col *table.Column, val *types.Datum, rowIdx int
if err1 != nil {
logutil.BgLogger().Debug("time truncated error", zap.Error(err1))
}
err = errTruncateWrongInsertValue.GenWithStackByArgs(types.TypeStr(colTp), valStr, colName, rowIdx+1)
err = dbterror.ClassTable.NewStdErr(
errno.ErrTruncatedWrongValue,
mysql.Message("Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %d", nil),
).GenWithStackByArgs(types.TypeStr(colTp), valStr, colName, rowIdx+1)
} else if types.ErrTruncatedWrongVal.Equal(err) || types.ErrWrongValue.Equal(err) {
valStr, err1 := val.ToString()
if err1 != nil {
Expand Down

0 comments on commit 08296d0

Please sign in to comment.