Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: disable insert null to not-null column for single-row insertion in non-strict mode | tidb-test=pr/2410 #55477

Merged
merged 20 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/ddl/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ func reorgTypeFlagsWithSQLMode(mode mysql.SQLMode) types.Flags {

func reorgErrLevelsWithSQLMode(mode mysql.SQLMode) errctx.LevelMap {
return errctx.LevelMap{
errctx.ErrGroupTruncate: errctx.ResolveErrLevel(false, !mode.HasStrictMode()),
errctx.ErrGroupBadNull: errctx.ResolveErrLevel(false, !mode.HasStrictMode()),
errctx.ErrGroupTruncate: errctx.ResolveErrLevel(false, !mode.HasStrictMode()),
errctx.ErrGroupBadNull: errctx.ResolveErrLevel(false, !mode.HasStrictMode()),
errctx.ErrGroupNoDefault: errctx.ResolveErrLevel(false, !mode.HasStrictMode()),
errctx.ErrGroupDividedByZero: errctx.ResolveErrLevel(
!mode.HasErrorForDivisionByZeroMode(),
!mode.HasStrictMode(),
Expand Down
4 changes: 4 additions & 0 deletions pkg/errctx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ const (
ErrGroupDupKey
// ErrGroupBadNull is the group of bad null errors
ErrGroupBadNull
// ErrGroupNoDefault is the group of no default value errors
ErrGroupNoDefault
// ErrGroupDividedByZero is the group of divided by zero errors
ErrGroupDividedByZero
// ErrGroupAutoIncReadFailed is the group of auto increment read failed errors
Expand Down Expand Up @@ -214,6 +216,8 @@ func init() {
ErrGroupBadNull: {
errno.ErrBadNull,
errno.ErrWarnNullToNotnull,
},
ErrGroupNoDefault: {
errno.ErrNoDefaultForField,
},
ErrGroupDividedByZero: {
Expand Down
1 change: 1 addition & 0 deletions pkg/executor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ go_test(
"//pkg/store/helper",
"//pkg/store/mockstore",
"//pkg/store/mockstore/unistore",
"//pkg/table",
"//pkg/table/tables",
"//pkg/tablecodec",
"//pkg/testkit",
Expand Down
8 changes: 7 additions & 1 deletion pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,11 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) {
errLevels[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelWarn
errLevels[errctx.ErrGroupNoMatchedPartition] = errctx.LevelWarn
}
errLevels[errctx.ErrGroupBadNull] = errctx.ResolveErrLevel(false, !strictSQLMode || stmt.IgnoreErr)
// For single-row INSERT statements, ignore non-strict mode
// See https://dev.mysql.com/doc/refman/5.7/en/constraint-invalid-data.html
isSingleInsert := len(stmt.Lists) == 1
errLevels[errctx.ErrGroupBadNull] = errctx.ResolveErrLevel(false, (!strictSQLMode && !isSingleInsert) || stmt.IgnoreErr)
errLevels[errctx.ErrGroupNoDefault] = errctx.ResolveErrLevel(false, !strictSQLMode || stmt.IgnoreErr)
errLevels[errctx.ErrGroupDividedByZero] = errctx.ResolveErrLevel(
!vars.SQLMode.HasErrorForDivisionByZeroMode(),
!strictSQLMode || stmt.IgnoreErr,
Expand Down Expand Up @@ -2112,6 +2116,7 @@ func ResetUpdateStmtCtx(sc *stmtctx.StatementContext, stmt *ast.UpdateStmt, vars
errLevels := sc.ErrLevels()
errLevels[errctx.ErrGroupDupKey] = errctx.ResolveErrLevel(false, stmt.IgnoreErr)
errLevels[errctx.ErrGroupBadNull] = errctx.ResolveErrLevel(false, !strictSQLMode || stmt.IgnoreErr)
errLevels[errctx.ErrGroupNoDefault] = errLevels[errctx.ErrGroupBadNull]
errLevels[errctx.ErrGroupDividedByZero] = errctx.ResolveErrLevel(
!vars.SQLMode.HasErrorForDivisionByZeroMode(),
!strictSQLMode || stmt.IgnoreErr,
Expand All @@ -2133,6 +2138,7 @@ func ResetDeleteStmtCtx(sc *stmtctx.StatementContext, stmt *ast.DeleteStmt, vars
errLevels := sc.ErrLevels()
errLevels[errctx.ErrGroupDupKey] = errctx.ResolveErrLevel(false, stmt.IgnoreErr)
errLevels[errctx.ErrGroupBadNull] = errctx.ResolveErrLevel(false, !strictSQLMode || stmt.IgnoreErr)
errLevels[errctx.ErrGroupNoDefault] = errLevels[errctx.ErrGroupBadNull]
errLevels[errctx.ErrGroupDividedByZero] = errctx.ResolveErrLevel(
!vars.SQLMode.HasErrorForDivisionByZeroMode(),
!strictSQLMode || stmt.IgnoreErr,
Expand Down
10 changes: 10 additions & 0 deletions pkg/executor/executor_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelError
l[errctx.ErrGroupDupKey] = errctx.LevelError
l[errctx.ErrGroupBadNull] = errctx.LevelError
l[errctx.ErrGroupNoDefault] = errctx.LevelError
l[errctx.ErrGroupDividedByZero] = errctx.LevelError
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelError
Expand All @@ -360,6 +361,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelWarn
l[errctx.ErrGroupDupKey] = errctx.LevelError
l[errctx.ErrGroupBadNull] = errctx.LevelWarn
l[errctx.ErrGroupNoDefault] = errctx.LevelWarn
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelError
Expand All @@ -374,6 +376,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelWarn
l[errctx.ErrGroupDupKey] = errctx.LevelWarn
l[errctx.ErrGroupBadNull] = errctx.LevelWarn
l[errctx.ErrGroupNoDefault] = errctx.LevelWarn
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelWarn
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelWarn
Expand All @@ -388,6 +391,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelWarn
l[errctx.ErrGroupDupKey] = errctx.LevelWarn
l[errctx.ErrGroupBadNull] = errctx.LevelWarn
l[errctx.ErrGroupNoDefault] = errctx.LevelWarn
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelWarn
Expand All @@ -402,6 +406,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelWarn
l[errctx.ErrGroupDupKey] = errctx.LevelWarn
l[errctx.ErrGroupBadNull] = errctx.LevelWarn
l[errctx.ErrGroupNoDefault] = errctx.LevelWarn
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelError
Expand All @@ -416,6 +421,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelError
l[errctx.ErrGroupDupKey] = errctx.LevelError
l[errctx.ErrGroupBadNull] = errctx.LevelError
l[errctx.ErrGroupNoDefault] = errctx.LevelError
l[errctx.ErrGroupDividedByZero] = errctx.LevelIgnore
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelError
Expand All @@ -430,6 +436,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelWarn
l[errctx.ErrGroupDupKey] = errctx.LevelError
l[errctx.ErrGroupBadNull] = errctx.LevelError
l[errctx.ErrGroupNoDefault] = errctx.LevelError
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelError
Expand All @@ -444,6 +451,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelWarn
l[errctx.ErrGroupDupKey] = errctx.LevelError
l[errctx.ErrGroupBadNull] = errctx.LevelError
l[errctx.ErrGroupNoDefault] = errctx.LevelError
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelError
Expand All @@ -458,6 +466,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelError
l[errctx.ErrGroupDupKey] = errctx.LevelError
l[errctx.ErrGroupBadNull] = errctx.LevelError
l[errctx.ErrGroupNoDefault] = errctx.LevelError
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelWarn
Expand All @@ -472,6 +481,7 @@ func TestErrLevelsForResetStmtContext(t *testing.T) {
l[errctx.ErrGroupTruncate] = errctx.LevelError
l[errctx.ErrGroupDupKey] = errctx.LevelError
l[errctx.ErrGroupBadNull] = errctx.LevelError
l[errctx.ErrGroupNoDefault] = errctx.LevelError
l[errctx.ErrGroupDividedByZero] = errctx.LevelWarn
l[errctx.ErrGroupAutoIncReadFailed] = errctx.LevelError
l[errctx.ErrGroupNoMatchedPartition] = errctx.LevelWarn
Expand Down
28 changes: 28 additions & 0 deletions pkg/executor/insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/pingcap/tidb/pkg/executor"
"github.com/pingcap/tidb/pkg/meta/autoid"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/table"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/util"
"github.com/pingcap/tidb/pkg/util/execdetails"
Expand Down Expand Up @@ -592,3 +593,30 @@ func TestInsertLockUnchangedKeys(t *testing.T) {
}
}
}

func TestInsertNullInNonStrictMode(t *testing.T) {
joechenrh marked this conversation as resolved.
Show resolved Hide resolved
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t1 (id int primary key, col1 varchar(10) not null default '')")
tk.MustExec("create table t2 (id int primary key, col1 varchar(10))")
tk.MustExec("insert into t2 values (1, null)")
tk.MustExec("insert ignore into t1 values(5, null)")

tk.MustExec("set session sql_mode = ''")

err := tk.ExecToErr("insert into t1 values(1, null)")
require.EqualError(t, err, table.ErrColumnCantNull.GenWithStackByArgs("col1").Error())

err = tk.ExecToErr("insert into t1 set id = 1, col1 = null")
require.EqualError(t, err, table.ErrColumnCantNull.GenWithStackByArgs("col1").Error())

err = tk.ExecToErr("insert t1 VALUES (5, 5) ON DUPLICATE KEY UPDATE col1 = null")
require.EqualError(t, err, table.ErrColumnCantNull.GenWithStackByArgs("col1").Error())

tk.MustExec("insert into t1 select * from t2")
tk.MustExec("insert into t1 values(2, null), (3, 3), (4, 4)")
tk.MustExec("update t1 set col1 = null where id = 3")
tk.MustExec("insert ignore t1 VALUES (4, 4) ON DUPLICATE KEY UPDATE col1 = null")
tk.MustQuery("select * from t1").Check(testkit.RowsWithSep("|", "1|", "2|", "3|", "4|", "5|"))
}
1 change: 1 addition & 0 deletions pkg/executor/load_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func setNonRestrictiveFlags(stmtCtx *stmtctx.StatementContext) {
levels := stmtCtx.ErrLevels()
levels[errctx.ErrGroupDupKey] = errctx.LevelWarn
levels[errctx.ErrGroupBadNull] = errctx.LevelWarn
levels[errctx.ErrGroupNoDefault] = errctx.LevelWarn
stmtCtx.SetErrLevels(levels)
stmtCtx.SetTypeFlags(stmtCtx.TypeFlags().WithTruncateAsWarning(true))
}
Expand Down
1 change: 1 addition & 0 deletions pkg/executor/test/writetest/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func TestIssue18681(t *testing.T) {
levels := ctx.GetSessionVars().StmtCtx.ErrLevels()
levels[errctx.ErrGroupDupKey] = errctx.LevelWarn
levels[errctx.ErrGroupBadNull] = errctx.LevelWarn
levels[errctx.ErrGroupNoDefault] = errctx.LevelWarn

sc := ctx.GetSessionVars().StmtCtx
oldTypeFlags := sc.TypeFlags()
Expand Down
2 changes: 2 additions & 0 deletions pkg/expression/builtin_miscellaneous_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func TestSleepVectorized(t *testing.T) {
// non-strict model
var levels errctx.LevelMap
levels[errctx.ErrGroupBadNull] = errctx.LevelWarn
levels[errctx.ErrGroupNoDefault] = errctx.LevelWarn
sessVars.StmtCtx.SetErrLevels(levels)
input.AppendFloat64(0, 1)
err = vecEvalType(ctx, f, types.ETInt, input, result)
Expand Down Expand Up @@ -188,6 +189,7 @@ func TestSleepVectorized(t *testing.T) {

// for error case under the strict model
levels[errctx.ErrGroupBadNull] = errctx.LevelError
levels[errctx.ErrGroupNoDefault] = errctx.LevelError
sessVars.StmtCtx.SetErrLevels(levels)
input.Reset()
input.AppendNull(0)
Expand Down
6 changes: 5 additions & 1 deletion pkg/expression/contextsession/sessionctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ func TestSessionEvalContextBasic(t *testing.T) {
ctx.ResetSessionAndStmtTimeZone(time.FixedZone("UTC+11", 11*3600))
vars.SQLMode = mysql.ModeStrictTransTables | mysql.ModeNoZeroDate
sc.SetTypeFlags(types.FlagIgnoreInvalidDateErr | types.FlagSkipUTF8Check)
sc.SetErrLevels(errctx.LevelMap{errctx.ErrGroupDupKey: errctx.LevelWarn, errctx.ErrGroupBadNull: errctx.LevelIgnore})
sc.SetErrLevels(errctx.LevelMap{
errctx.ErrGroupDupKey: errctx.LevelWarn,
errctx.ErrGroupBadNull: errctx.LevelIgnore,
errctx.ErrGroupNoDefault: errctx.LevelIgnore,
})
vars.CurrentDB = "db1"
vars.MaxAllowedPacket = 123456

Expand Down
2 changes: 2 additions & 0 deletions pkg/expression/contextstatic/evalctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func getEvalCtxOptionsForTest(t *testing.T) ([]StaticEvalCtxOption, *evalCtxOpti
WithTypeFlags(types.FlagAllowNegativeToUnsigned | types.FlagSkipASCIICheck),
WithErrLevelMap(errctx.LevelMap{
errctx.ErrGroupBadNull: errctx.LevelError,
errctx.ErrGroupNoDefault: errctx.LevelError,
errctx.ErrGroupDividedByZero: errctx.LevelWarn,
}),
WithLocation(loc),
Expand Down Expand Up @@ -143,6 +144,7 @@ func checkOptionsStaticEvalCtx(t *testing.T, ctx *StaticEvalContext, s *evalCtxO
)
require.Equal(t, errctx.NewContextWithLevels(errctx.LevelMap{
errctx.ErrGroupBadNull: errctx.LevelError,
errctx.ErrGroupNoDefault: errctx.LevelError,
errctx.ErrGroupDividedByZero: errctx.LevelWarn,
}, ctx), ctx.ErrCtx())
require.Same(t, s.loc, ctx.Location())
Expand Down
2 changes: 2 additions & 0 deletions pkg/expression/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func TestSleep(t *testing.T) {
// non-strict model
var levels errctx.LevelMap
levels[errctx.ErrGroupBadNull] = errctx.LevelWarn
levels[errctx.ErrGroupNoDefault] = errctx.LevelWarn
sessVars.StmtCtx.SetErrLevels(levels)
d := make([]types.Datum, 1)
f, err := fc.getFunction(ctx, datumsToConstants(d))
Expand All @@ -129,6 +130,7 @@ func TestSleep(t *testing.T) {

// for error case under the strict model
levels[errctx.ErrGroupBadNull] = errctx.LevelError
levels[errctx.ErrGroupNoDefault] = errctx.LevelError
sessVars.StmtCtx.SetErrLevels(levels)
d[0].SetNull()
_, err = fc.getFunction(ctx, datumsToConstants(d))
Expand Down
1 change: 1 addition & 0 deletions pkg/lightning/backend/kv/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ func NewSession(options *encode.SessionOptions, logger log.Logger) *Session {

errLevels := vars.StmtCtx.ErrLevels()
errLevels[errctx.ErrGroupBadNull] = errctx.ResolveErrLevel(false, !sqlMode.HasStrictMode())
errLevels[errctx.ErrGroupNoDefault] = errctx.ResolveErrLevel(false, !sqlMode.HasStrictMode())
errLevels[errctx.ErrGroupDividedByZero] =
errctx.ResolveErrLevel(!sqlMode.HasErrorForDivisionByZeroMode(), !sqlMode.HasStrictMode())
vars.StmtCtx.SetErrLevels(errLevels)
Expand Down
2 changes: 1 addition & 1 deletion pkg/lightning/errormanager/errormanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const (
`

insertIntoConflictErrorData = `
INSERT INTO %s.` + ConflictErrorTableName + `
INSERT IGNORE INTO %s.` + ConflictErrorTableName + `
(task_id, table_name, index_name, key_data, row_data, raw_key, raw_value, raw_handle, raw_row, kv_type)
VALUES
`
Expand Down
7 changes: 5 additions & 2 deletions pkg/table/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ func (c *Column) CheckNotNull(data *types.Datum, rowCntInLoadData uint64) error
// error is ErrWarnNullToNotnull.
// Otherwise, the error is ErrColumnCantNull.
// If BadNullAsWarning is true, it will append the error as a warning, else return the error.
func (c *Column) HandleBadNull(ec errctx.Context, d *types.Datum, rowCntInLoadData uint64) error {
func (c *Column) HandleBadNull(
ec errctx.Context,
d *types.Datum,
rowCntInLoadData uint64) error {
if err := c.CheckNotNull(d, rowCntInLoadData); err != nil {
if ec.HandleError(err) == nil {
*d = GetZeroValue(c.ToInfo())
Expand Down Expand Up @@ -549,7 +552,7 @@ func GetColOriginDefaultValueWithoutStrictSQLMode(ctx expression.BuildContext, c
// But CheckNoDefaultValueForInsert logic should only check before insert.
func CheckNoDefaultValueForInsert(sc *stmtctx.StatementContext, col *model.ColumnInfo) error {
if mysql.HasNoDefaultValueFlag(col.GetFlag()) && !col.DefaultIsExpr && col.GetDefaultValue() == nil && col.GetType() != mysql.TypeEnum {
ignoreErr := sc.ErrGroupLevel(errctx.ErrGroupBadNull) != errctx.LevelError
ignoreErr := sc.ErrGroupLevel(errctx.ErrGroupNoDefault) != errctx.LevelError
if !ignoreErr {
return ErrNoDefaultValue.GenWithStackByArgs(col.Name)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/table/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func TestGetDefaultValue(t *testing.T) {
ctx.GetSessionVars().SQLMode = mysql.DelSQLMode(defaultMode, mysql.ModeStrictAllTables|mysql.ModeStrictTransTables)
}
levels := sc.ErrLevels()
levels[errctx.ErrGroupBadNull] = errctx.ResolveErrLevel(false, !tt.strict)
levels[errctx.ErrGroupNoDefault] = errctx.ResolveErrLevel(false, !tt.strict)
sc.SetErrLevels(levels)
val, err := GetColDefaultValue(ctx, tt.colInfo)
if err != nil {
Expand All @@ -506,7 +506,7 @@ func TestGetDefaultValue(t *testing.T) {
ctx.GetSessionVars().SQLMode = mysql.DelSQLMode(defaultMode, mysql.ModeStrictAllTables|mysql.ModeStrictTransTables)
}
levels := sc.ErrLevels()
levels[errctx.ErrGroupBadNull] = errctx.ResolveErrLevel(false, !tt.strict)
levels[errctx.ErrGroupNoDefault] = errctx.ResolveErrLevel(false, !tt.strict)
sc.SetErrLevels(levels)
val, err := GetColOriginDefaultValue(ctx, tt.colInfo)
if err != nil {
Expand Down
11 changes: 6 additions & 5 deletions tests/integrationtest/r/executor/insert.result
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,10 @@ ab

ab ab
ab ab
ab ab
ab

ab

select length(v), length(c) from vctt;
length(v) length(c)
4 4
Expand Down Expand Up @@ -1713,7 +1716,7 @@ insert into t(name, b) values("chb", 3);
Error 1062 (23000): Duplicate entry 'ch' for key 't.PRIMARY'
insert into t(name, b) values("测试", 3);
insert into t(name, b) values("测试", 3);
Error 1062 (23000): Duplicate entry '�' for key 't.PRIMARY'
Error 1062 (23000): Duplicate entry '�' for key 't.PRIMARY'
drop table if exists t;
create table t (i int unique key);
insert into t values (1),(2);
Expand Down Expand Up @@ -1866,9 +1869,7 @@ f1 f2
2 2
SET sql_mode='';
INSERT t1 VALUES (1, 1) ON DUPLICATE KEY UPDATE f2 = null;
show warnings;
Level Code Message
Warning 1048 Column 'f2' cannot be null
Error 1048 (23000): Column 'f2' cannot be null
SELECT * FROM t1 order by f1;
f1 f2
1 0
Expand Down
2 changes: 1 addition & 1 deletion tests/integrationtest/t/executor/insert.test
Original file line number Diff line number Diff line change
Expand Up @@ -1407,8 +1407,8 @@ show warnings;
SELECT * FROM t1 order by f1;

SET sql_mode='';
-- error 1048
INSERT t1 VALUES (1, 1) ON DUPLICATE KEY UPDATE f2 = null;
show warnings;
SELECT * FROM t1 order by f1;
set sql_mode=default;

Expand Down