diff --git a/executor/insert_test.go b/executor/insert_test.go index 2f4abad2328bf..d0d17199c13f7 100644 --- a/executor/insert_test.go +++ b/executor/insert_test.go @@ -379,7 +379,7 @@ func TestInsertWrongValueForField(t *testing.T) { tk.MustExec(`CREATE TABLE ts (id int DEFAULT NULL, time1 TIMESTAMP NULL DEFAULT NULL)`) tk.MustExec(`SET @@sql_mode=''`) tk.MustExec(`INSERT INTO ts (id, time1) VALUES (1, TIMESTAMP '1018-12-23 00:00:00')`) - tk.MustQuery(`SHOW WARNINGS`).Check(testkit.Rows(`Warning 1292 Incorrect timestamp value: '1018-12-23 00:00:00'`)) + tk.MustQuery(`SHOW WARNINGS`).Check(testkit.Rows(`Warning 1292 Incorrect timestamp value: '1018-12-23 00:00:00' for column 'time1' at row 1`)) tk.MustQuery(`SELECT * FROM ts ORDER BY id`).Check(testkit.Rows(`1 0000-00-00 00:00:00`)) tk.MustExec(`SET @@sql_mode='STRICT_TRANS_TABLES'`) @@ -1629,7 +1629,7 @@ func TestIssue10402(t *testing.T) { tk.MustExec("insert into vctt values ('ab\\n\\n\\n', 'ab\\n\\n\\n'), ('ab\\t\\t\\t', 'ab\\t\\t\\t'), ('ab ', 'ab '), ('ab\\r\\r\\r', 'ab\\r\\r\\r')") require.Equal(t, uint16(4), tk.Session().GetSessionVars().StmtCtx.WarningCount()) warns := tk.Session().GetSessionVars().StmtCtx.GetWarnings() - require.Equal(t, "[{Warning [types:1265]Data truncated, field len 4, data len 5} {Warning [types:1265]Data truncated, field len 4, data len 5} {Warning [types:1265]Data truncated, field len 4, data len 6} {Warning [types:1265]Data truncated, field len 4, data len 5}]", + require.Equal(t, "[{Warning [types:1265]Data truncated for column 'v' at row 1} {Warning [types:1265]Data truncated for column 'v' at row 2} {Warning [types:1265]Data truncated for column 'v' at row 3} {Warning [types:1265]Data truncated for column 'v' at row 4}]", fmt.Sprintf("%v", warns)) tk.MustQuery("select * from vctt").Check(testkit.Rows("ab\n\n ab\n\n", "ab\t\t ab\t\t", "ab ab", "ab\r\r ab\r\r")) tk.MustQuery("select length(v), length(c) from vctt").Check(testkit.Rows("4 4", "4 4", "4 2", "4 4")) @@ -1838,7 +1838,8 @@ func TestStringtoDecimal(t *testing.T) { tk.MustGetErrCode("insert into t values('1.2.')", errno.ErrTruncatedWrongValueForField) tk.MustGetErrCode("insert into t values('1,999.00')", errno.ErrTruncatedWrongValueForField) tk.MustExec("insert into t values('12e-3')") - tk.MustQuery("show warnings;").Check(testkit.RowsWithSep("|", "Warning|1292|Truncated incorrect DECIMAL value: '0.012'")) + // TODO: MySQL8.0 reports Note 1265 Data truncated for column 'id' at row 1 + tk.MustQuery("show warnings;").Check(testkit.RowsWithSep("|", "Warning|1366|Incorrect decimal value: '12e-3' for column 'id' at row 1")) tk.MustQuery("select id from t").Check(testkit.Rows("0")) tk.MustExec("drop table if exists t") } @@ -1852,7 +1853,7 @@ func TestIssue17745(t *testing.T) { tk.MustGetErrCode("insert into tt1 values(89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)", errno.ErrWarnDataOutOfRange) tk.MustGetErrCode("insert into tt1 values(89123456789012345678901234567890123456789012345678901234567890123456789012345678900000000)", errno.ErrWarnDataOutOfRange) tk.MustExec("insert ignore into tt1 values(89123456789012345678901234567890123456789012345678901234567890123456789012345678900000000)") - tk.MustQuery("show warnings;").Check(testkit.Rows(`Warning 1690 DECIMAL value is out of range in '(64, 0)'`, `Warning 1292 Truncated incorrect DECIMAL value: '789012345678901234567890123456789012345678901234567890123456789012345678900000000'`)) + tk.MustQuery("show warnings;").Check(testkit.Rows(`Warning 1264 Out of range value for column 'c1' at row 1`, `Warning 1292 Truncated incorrect DECIMAL value: '789012345678901234567890123456789012345678901234567890123456789012345678900000000'`)) tk.MustQuery("select c1 from tt1").Check(testkit.Rows("9999999999999999999999999999999999999999999999999999999999999999")) tk.MustGetErrCode("update tt1 set c1 = 89123456789012345678901234567890123456789012345678901234567890123456789012345678900000000", errno.ErrWarnDataOutOfRange) tk.MustExec("drop table if exists tt1") diff --git a/executor/showtest/show_test.go b/executor/showtest/show_test.go index 22fa53917515c..3c9130c48cb8a 100644 --- a/executor/showtest/show_test.go +++ b/executor/showtest/show_test.go @@ -692,9 +692,9 @@ func TestShowWarnings(t *testing.T) { tk.MustExec("set @@sql_mode=''") tk.MustExec("insert show_warnings values ('a')") require.Equal(t, uint16(1), tk.Session().GetSessionVars().StmtCtx.WarningCount()) - tk.MustQuery("show warnings").Check(testkit.RowsWithSep("|", "Warning|1292|Truncated incorrect DOUBLE value: 'a'")) + tk.MustQuery("show warnings").Check(testkit.RowsWithSep("|", "Warning|1366|Incorrect int value: 'a' for column 'a' at row 1")) require.Equal(t, uint16(0), tk.Session().GetSessionVars().StmtCtx.WarningCount()) - tk.MustQuery("show warnings").Check(testkit.RowsWithSep("|", "Warning|1292|Truncated incorrect DOUBLE value: 'a'")) + tk.MustQuery("show warnings").Check(testkit.RowsWithSep("|", "Warning|1366|Incorrect int value: 'a' for column 'a' at row 1")) require.Equal(t, uint16(0), tk.Session().GetSessionVars().StmtCtx.WarningCount()) // Test Warning level 'Error' diff --git a/executor/write_test.go b/executor/write_test.go index f79120c3666e9..0c28d521c61a1 100644 --- a/executor/write_test.go +++ b/executor/write_test.go @@ -212,7 +212,8 @@ func TestInsert(t *testing.T) { tk.MustExec("CREATE TABLE t(a DECIMAL(4,2));") tk.MustExec("INSERT INTO t VALUES (1.000001);") r = tk.MustQuery("SHOW WARNINGS;") - r.Check(testkit.Rows("Warning 1292 Truncated incorrect DECIMAL value: '1.000001'")) + // TODO: MySQL8.0 reports Note 1265 Data truncated for column 'a' at row 1 + r.Check(testkit.Rows("Warning 1366 Incorrect decimal value: '1.000001' for column 'a' at row 1")) tk.MustExec("INSERT INTO t VALUES (1.000000);") r = tk.MustQuery("SHOW WARNINGS;") r.Check(testkit.Rows()) @@ -249,15 +250,14 @@ func TestInsert(t *testing.T) { require.True(t, types.ErrWarnDataOutOfRange.Equal(err)) tk.MustExec("set @@sql_mode = '';") tk.MustExec("insert into t value (-1);") - // TODO: the following warning messages are not consistent with MySQL, fix them in the future PRs - tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1690 constant -1 overflows bigint")) + tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1264 Out of range value for column 'a' at row 1")) tk.MustExec("insert into t select -1;") tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1690 constant -1 overflows bigint")) tk.MustExec("insert into t select cast(-1 as unsigned);") tk.MustExec("insert into t value (-1.111);") - tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1690 constant -1.111 overflows bigint")) + tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1264 Out of range value for column 'a' at row 1")) tk.MustExec("insert into t value ('-1.111');") - tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1690 BIGINT UNSIGNED value is out of range in '-1'")) + tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1264 Out of range value for column 'a' at row 1")) tk.MustExec("update t set a = -1 limit 1;") tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1690 constant -1 overflows bigint")) r = tk.MustQuery("select * from t;") @@ -280,8 +280,8 @@ func TestInsert(t *testing.T) { tk.MustExec("create table t(a float unsigned, b double unsigned)") tk.MustExec("insert into t value(-1.1, -1.1), (-2.1, -2.1), (0, 0), (1.1, 1.1)") tk.MustQuery("show warnings"). - Check(testkit.Rows("Warning 1690 constant -1.1 overflows float", "Warning 1690 constant -1.1 overflows double", - "Warning 1690 constant -2.1 overflows float", "Warning 1690 constant -2.1 overflows double")) + Check(testkit.Rows("Warning 1264 Out of range value for column 'a' at row 1", "Warning 1264 Out of range value for column 'b' at row 1", + "Warning 1264 Out of range value for column 'a' at row 2", "Warning 1264 Out of range value for column 'b' at row 2")) tk.MustQuery("select * from t").Check(testkit.Rows("0 0", "0 0", "0 0", "1.1 1.1")) // issue 7061 @@ -527,7 +527,8 @@ func TestInsertIgnore(t *testing.T) { require.NoError(t, err) require.Empty(t, tk.Session().LastMessage()) r = tk.MustQuery("SHOW WARNINGS") - r.Check(testkit.Rows("Warning 1292 Truncated incorrect DOUBLE value: '1a'")) + // TODO: MySQL8.0 reports Warning 1265 Data truncated for column 'a' at row 1 + r.Check(testkit.Rows("Warning 1366 Incorrect bigint value: '1a' for column 'a' at row 1")) // for duplicates with warning testSQL = `drop table if exists t; diff --git a/expression/integration_test.go b/expression/integration_test.go index e7528e47a4683..eae81ee97565a 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -493,8 +493,8 @@ func TestConvertToBit(t *testing.T) { tk.MustExec("create table t(a tinyint, b bit(63));") tk.MustExec("insert ignore into t values(599999999, -1);") tk.MustQuery("show warnings;").Check(testkit.Rows( - "Warning 1690 constant 599999999 overflows tinyint", - "Warning 1406 Data Too Long, field len 63")) + "Warning 1264 Out of range value for column 'a' at row 1", + "Warning 1406 Data too long for column 'b' at row 1")) tk.MustQuery("select * from t;").Check(testkit.Rows("127 \u007f\xff\xff\xff\xff\xff\xff\xff")) // For issue 24900 @@ -502,8 +502,8 @@ func TestConvertToBit(t *testing.T) { tk.MustExec("create table t(b bit(16));") tk.MustExec("insert ignore into t values(0x3635313836),(0x333830);") tk.MustQuery("show warnings;").Check(testkit.Rows( - "Warning 1406 Data Too Long, field len 16", - "Warning 1406 Data Too Long, field len 16")) + "Warning 1406 Data too long for column 'b' at row 1", + "Warning 1406 Data too long for column 'b' at row 2")) tk.MustQuery("select * from t;").Check(testkit.Rows("\xff\xff", "\xff\xff")) } @@ -5255,7 +5255,7 @@ func TestIssue19892(t *testing.T) { tk.MustExec("TRUNCATE TABLE dd") tk.MustExec("INSERT INTO dd(c) values('0000-00-00 20:00:00')") - tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect timestamp value: '0000-00-00 20:00:00'")) + tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect timestamp value: '0000-00-00 20:00:00' for column 'c' at row 1")) tk.MustQuery("SELECT c FROM dd").Check(testkit.Rows("0000-00-00 00:00:00")) tk.MustExec("TRUNCATE TABLE dd") @@ -5269,7 +5269,7 @@ func TestIssue19892(t *testing.T) { { tk.MustExec("TRUNCATE TABLE dd") tk.MustExec("INSERT INTO dd(b) values('0000-0-00')") - tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect datetime value: '0000-0-00'")) + tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect datetime value: '0000-0-00' for column 'b' at row 1")) tk.MustQuery("SELECT b FROM dd").Check(testkit.Rows("0000-00-00 00:00:00")) tk.MustExec("TRUNCATE TABLE dd") @@ -5290,7 +5290,7 @@ func TestIssue19892(t *testing.T) { tk.MustExec("TRUNCATE TABLE dd") tk.MustGetErrMsg("INSERT INTO dd(c) VALUES ('0000-00-00 20:00:00')", "[table:1292]Incorrect timestamp value: '0000-00-00 20:00:00' for column 'c' at row 1") tk.MustExec("INSERT IGNORE INTO dd(c) VALUES ('0000-00-00 20:00:00')") - tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect timestamp value: '0000-00-00 20:00:00'")) + tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect timestamp value: '0000-00-00 20:00:00' for column 'c' at row 1")) tk.MustQuery("SELECT c FROM dd").Check(testkit.Rows("0000-00-00 00:00:00")) tk.MustExec("TRUNCATE TABLE dd") @@ -5341,7 +5341,7 @@ func TestIssue19892(t *testing.T) { { tk.MustExec("TRUNCATE TABLE dd") tk.MustExec("INSERT INTO dd(a) values('2000-01-00')") - tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect date value: '2000-01-00'")) + tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect date value: '2000-01-00' for column 'a' at row 1")) tk.MustQuery("SELECT a FROM dd").Check(testkit.Rows("0000-00-00")) tk.MustExec("TRUNCATE TABLE dd") @@ -5369,7 +5369,7 @@ func TestIssue19892(t *testing.T) { tk.MustExec("TRUNCATE TABLE dd") tk.MustGetErrMsg("INSERT INTO dd(b) VALUES ('2000-01-00')", "[table:1292]Incorrect datetime value: '2000-01-00' for column 'b' at row 1") tk.MustExec("INSERT IGNORE INTO dd(b) VALUES ('2000-00-01')") - tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect datetime value: '2000-00-01'")) + tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect datetime value: '2000-00-01' for column 'b' at row 1")) tk.MustQuery("SELECT b FROM dd").Check(testkit.Rows("0000-00-00 00:00:00")) tk.MustExec("TRUNCATE TABLE dd") @@ -5422,7 +5422,7 @@ func TestIssue19892(t *testing.T) { tk.MustExec("TRUNCATE TABLE dd") tk.MustGetErrMsg("INSERT INTO dd(b) VALUES ('2000-01-00')", "[table:1292]Incorrect datetime value: '2000-01-00' for column 'b' at row 1") tk.MustExec("INSERT IGNORE INTO dd(b) VALUES ('2000-00-01')") - tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect datetime value: '2000-00-01'")) + tk.MustQuery("SHOW WARNINGS").Check(testkit.Rows("Warning 1292 Incorrect datetime value: '2000-00-01' for column 'b' at row 1")) tk.MustQuery("SELECT b FROM dd").Check(testkit.Rows("0000-00-00 00:00:00")) tk.MustExec("TRUNCATE TABLE dd")