From 7d717719379e201a1fb202a4babe65cb499e7c21 Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Wed, 20 Sep 2023 00:58:42 +0800 Subject: [PATCH] tests: `integrationtest` support report warnings (#47010) ref pingcap/tidb#45961 --- .../r/expression/builtin.result | Bin 98371 -> 99769 bytes .../integrationtest/r/expression/cast.result | 10 +- .../r/expression/charset_and_collation.result | 4 +- .../r/expression/issues.result | 47 ++++--- .../integrationtest/r/expression/json.result | 6 +- .../integrationtest/r/expression/misc.result | 6 +- .../integrationtest/r/expression/time.result | 2 +- tests/integrationtest/run-tests.sh | 2 +- tests/integrationtest/t/common_collation.test | 4 - .../integrationtest/t/expression/builtin.test | 122 +++++++++--------- tests/integrationtest/t/expression/cast.test | 7 +- .../t/expression/charset_and_collation.test | 6 +- .../integrationtest/t/expression/issues.test | 46 ++++--- tests/integrationtest/t/expression/json.test | 5 +- tests/integrationtest/t/expression/misc.test | 7 +- tests/integrationtest/t/expression/time.test | 3 +- tools/check/ut.go | 2 +- 17 files changed, 142 insertions(+), 137 deletions(-) diff --git a/tests/integrationtest/r/expression/builtin.result b/tests/integrationtest/r/expression/builtin.result index eb4c6880e0c10ba7f8db1e43e295c2f574cd7ee0..3a60c50bad5aed2677a465fb5e022f0e1fcc7c6a 100644 GIT binary patch delta 2195 zcmbuAL2MgE6oxgFBwa&rn>dsvv`lc&0uJjL?|RqkG%6u+p@_1VF?Sh2TG41A*x=GIB-J(Q6X{Y0jaQSCr+G>t%};0 zmFEB6|Gzi0vo}6y{^nfsm+vPak!s&JZp^U^n-Qq06CrK0{Jg>DF_j{UqH2mlG+85h zIBW(&1ltSd+_Yt%$m6NZOoq+FhsnKgHPQLtg|3fC(3AYuE!4qH1Oq31z5vzl&2W9B z2c8@K{=qY>H}lwaKm4TJ0{R zhXg>(S6I!XonERDN}OUuktn4id_D0`1GzxMj+{z{2se)&X(05h38|xuPfj#YK2lXW z?zdCr*6W6Kyet1o*xRWt_~ckSth^zBH|2rz$DVKC)J`|!hWm3Jcf;;f$65*HK5>Iq z@h&)>y4e8p*0?%7o-&>&e*9(xVy> z2Uv!Ggg5We8LrFbose=tXv+?8bzA4|YVUu_QjS2uI>4{IHq%w^>c-@*u^{v?{(Svg zXH~q$ob!9`Qa}8DNrjgdhoQLmG~8Jf;l;~mAa{8WG%X#4kCrs}Whn?3SK46zvIu9F zpMf8j{hg*|rk&3Mw&ySnl0MJ+lZV2g73|1+;nx+lxgvwNuaF|U^4G&|ez|(%DMS^9 zjCli(+BS~cY^E1aXH4rjwoHaeFFx+Bxz9@R^lIs(3-?rERndjREX(W@3|n^Eu*@hH z&3r00D3->%(XD4|XCSawb(BV5MF;q=t4|w>4IX@bAdVLd>s`0r3sll{P1R*8 zD-ks$({RKLIA>1uRCBCf+dHt+I!PQtsq%HzT}|VXLz#t4 zK4UXH^&TdkWGo&V94+7k@|FG^LA~WY=&TPEqGRaO+IMgx&YdxIwd~lafW8lr(zYY$ fXQ4KDNF_o+OQXKR-6`}{t;PCUf9X~l*-!olg@Cmw delta 1731 zcmai!Ur1A77{>YLTJA8HZ2k#z9c89Y9auMo!n8st*^D(eA!W_k@|?4O&JBdhFsN?4 zk{8;Qu^lYKN_W4Sx8$2&Lk6!iKL*Dt2%L#^C4d7NKfQJj!honTppA zk8iapp1GD&guJuxo1nR12bhD`NaYSeE#WXhbs>qQXW<}36{ZVyfpwu1*6*5NcX5Zv zdX_qsPhlS;q|df~7`>!diuZ~-LT>%m4&`O)G4_)@tRxIDEp#->#Z2&4FcE4=LfO5~VV|vBnvynUZLQ zy|@_;)8{qLDvSCf7vXRuA_P5o3HX(C!n*_q6Up&LuH)Wo&XtCadc)9Mo5k1O(3rZa z<&-RS=Vpq7|MpjRZbv!zzN*n$-E}U0Q|r{@eopRaQmUEEun8@T$(#$r_1t9yPp2cX z$Wo>UKIVA%kQ+h<(BkOJG%4Fv2{QH0K@6R6%3ygMlmcF#xVR^=*Q43_hEQZ zwqfXzc?_en6T_^GD^sfS0I~a&@t3b2;!;${1@@jOOC6eF9%8kqPrWSOM9ks+>^`xn z48AG%)b-gHbF59R2H1!mN3#R-3@}!|%(DtH5hizs)utdjFyc(MEHGzQ5ZE)UsW(KH G>iz=?;<>*7 diff --git a/tests/integrationtest/r/expression/cast.result b/tests/integrationtest/r/expression/cast.result index 1f82bffc5e685..8c9d87e297002 100644 --- a/tests/integrationtest/r/expression/cast.result +++ b/tests/integrationtest/r/expression/cast.result @@ -1,28 +1,28 @@ select cast('' as signed); cast('' as signed) 0 -show warnings; Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '' select cast('12345abcde' as signed); cast('12345abcde' as signed) 12345 -show warnings; Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '12345abcde' select cast('123e456' as signed); cast('123e456' as signed) 123 -show warnings; Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '123e456' select cast('-12345abcde' as signed); cast('-12345abcde' as signed) -12345 -show warnings; Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '-12345abcde' select cast('-123e456' as signed); cast('-123e456' as signed) -123 -show warnings; Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '-123e456' select coercibility(binary('a')); coercibility(binary('a')) 2 diff --git a/tests/integrationtest/r/expression/charset_and_collation.result b/tests/integrationtest/r/expression/charset_and_collation.result index 92d52bd63dc62..c5399bbf7127d 100644 --- a/tests/integrationtest/r/expression/charset_and_collation.result +++ b/tests/integrationtest/r/expression/charset_and_collation.result @@ -817,16 +817,16 @@ a A select /*+ inl_hash_join(t2) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; b b a A -show warnings; Level Code Message +Warning 1815 Optimizer Hint /*+ INL_HASH_JOIN(t2) */ is inapplicable select /*+ inl_merge_join(t1) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; b b a A select /*+ inl_merge_join(t2) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; b b a A -show warnings; Level Code Message +Warning 1815 Optimizer Hint /*+ INL_MERGE_JOIN(t2) */ is inapplicable drop table if exists a, b; create table a(i int, k varbinary(40), v int, primary key(i, k) clustered); create table b(i int, k varchar(40), v int, primary key(i, k) clustered); diff --git a/tests/integrationtest/r/expression/issues.result b/tests/integrationtest/r/expression/issues.result index 391f903ad7d89..e4bb4e1cb4b99 100644 --- a/tests/integrationtest/r/expression/issues.result +++ b/tests/integrationtest/r/expression/issues.result @@ -50,16 +50,18 @@ t CREATE TABLE `t` ( drop table if exists t; create table t(a tinyint, b bit(63)); insert ignore into t values(599999999, -1); -show warnings; Level Code Message +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1406 Data too long for column 'b' at row 1 select * from t; a b 127 ÿÿÿÿÿÿÿ drop table if exists t; create table t(b bit(16)); insert ignore into t values(0x3635313836),(0x333830); -show warnings; Level Code Message +Warning 1406 Data too long for column 'b' at row 1 +Warning 1406 Data too long for column 'b' at row 2 select * from t; b ÿÿ @@ -93,8 +95,8 @@ drop table if exists t; create table t (id int NOT NULL DEFAULT 8); SET sql_mode = ''; insert into t values (1), (NULL), (2); -show warnings; Level Code Message +Warning 1048 Column 'id' cannot be null select * from t; id 1 @@ -203,8 +205,8 @@ insert into ft values(1234567890,123467890.1234,123467890.1234,'123467890.123400 SELECT FROM_UNIXTIME(tchar) from ft; FROM_UNIXTIME(tchar) 1973-11-30 08:38:10.123400 -show warnings; Level Code Message +Warning 1292 Truncated incorrect DECIMAL value: '123467890.1234000000000000000000100111111111' truncate table ft; insert into ft values(1234567890,123467890.1234,123467890.1234,'11111123467890.1234'); SELECT FROM_UNIXTIME(tchar) from ft; @@ -278,36 +280,36 @@ min max drop table if exists t_tiny, t_small, t_medium, t_int, t_big; create table t_tiny (c0 TINYINT UNSIGNED); INSERT IGNORE INTO t_tiny(c0) VALUES (1E9); -show warnings; Level Code Message +Warning 1264 Out of range value for column 'c0' at row 1 select * from t_tiny; c0 255 create table t_small (c0 SMALLINT UNSIGNED); INSERT IGNORE INTO t_small(c0) VALUES (1E9); -show warnings; Level Code Message +Warning 1264 Out of range value for column 'c0' at row 1 select * from t_small; c0 65535 create table t_medium (c0 MEDIUMINT UNSIGNED); INSERT IGNORE INTO t_medium(c0) VALUES (1E9); -show warnings; Level Code Message +Warning 1264 Out of range value for column 'c0' at row 1 select * from t_medium; c0 16777215 create table t_int (c0 INT UNSIGNED); INSERT IGNORE INTO t_int(c0) VALUES (1E20); -show warnings; Level Code Message +Warning 1264 Out of range value for column 'c0' at row 1 select * from t_int; c0 4294967295 create table t_big (c0 BIGINT UNSIGNED); INSERT IGNORE INTO t_big(c0) VALUES (1E20); -show warnings; Level Code Message +Warning 1264 Out of range value for column 'c0' at row 1 select * from t_big; c0 18446744073709551615 @@ -1357,8 +1359,8 @@ insert into t12205 values('-1038024704','-527892480'); select SEC_TO_TIME( ( `col_varchar_64` & `col_varchar_64_key` ) ),`col_varchar_64` & `col_varchar_64_key` from t12205; SEC_TO_TIME( ( `col_varchar_64` & `col_varchar_64_key` ) ) `col_varchar_64` & `col_varchar_64_key` 838:59:59 18446744072635875328 -show warnings; Level Code Message +Warning 1292 Truncated incorrect time value: '18446744072635875000' drop table if exists t; create table t(1e int); insert into t values (1); @@ -1400,8 +1402,8 @@ insert into t12206 values(73,0,0000); SELECT TIME_FORMAT( `col_tinyint_unsigned`, ( IFNULL( `col_double_unsigned`, `col_year_key` ) ) ) AS field1 FROM `t12206`; field1 NULL -show warnings; Level Code Message +Warning 1292 Truncated incorrect time value: '73' drop table if exists t12209; create table t12209(a bigint(20)); insert into t12209 values(1); @@ -1743,8 +1745,8 @@ a a b INSERT IGNORE INTO t1 VALUES (REPEAT(0125,200000000)); -show warnings; Level Code Message +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated select a from t1 order by a; a NULL @@ -1959,11 +1961,10 @@ create table t (c int primary key, c2 enum('a', 'b')); set session sql_mode = ''; insert into t values(4, 'a'); insert into t values(4, 0) on duplicate key update c=values(c), c2=values(c2); -show warnings; Level Code Message +Warning 1265 Data truncated for column 'c2' at row 1 +Warning 1265 Data truncated for column 'c2' at row 1 insert into t values(4, 'a') on duplicate key update c=values(c), c2=values(c2); -show warnings; -Level Code Message set @@sql_mode=default; drop table if exists t0, t1; CREATE TABLE t0(c0 BOOL, c1 INT); @@ -2242,23 +2243,21 @@ coercibility(lag(b, 1, 'B') over w) SELECT 'lvuleck' BETWEEN '2008-09-16 22:23:50' AND 0; 'lvuleck' BETWEEN '2008-09-16 22:23:50' AND 0 0 -show warnings; Level Code Message +Warning 1292 Truncated incorrect DOUBLE value: '2008-09-16 22:23:50' +Warning 1292 Truncated incorrect DOUBLE value: 'lvuleck' SELECT 'aa' BETWEEN 'bb' AND 0; 'aa' BETWEEN 'bb' AND 0 1 -show warnings; Level Code Message +Warning 1292 Truncated incorrect DOUBLE value: 'aa' +Warning 1292 Truncated incorrect DOUBLE value: 'bb' select 1 between 0 and b'110'; 1 between 0 and b'110' 1 -show warnings; -Level Code Message select 'b' between 'a' and b'110'; 'b' between 'a' and b'110' 0 -show warnings; -Level Code Message drop table if exists t; create table t(a set('a', 'b', 'c')); alter table t change a a set('a', 'b', 'c', 'c'); @@ -2686,9 +2685,15 @@ insert into t values('1e649'),('-1e649'); SELECT * FROM t where c < 1; c -1e649 +Level Code Message +Warning 1292 Truncated incorrect DOUBLE value: '-1e649' +Warning 1292 Truncated incorrect DOUBLE value: '1e649' SELECT * FROM t where c > 1; c 1e649 +Level Code Message +Warning 1292 Truncated incorrect DOUBLE value: '-1e649' +Warning 1292 Truncated incorrect DOUBLE value: '1e649' drop table if exists t; create table t(a int); insert t values (1); diff --git a/tests/integrationtest/r/expression/json.result b/tests/integrationtest/r/expression/json.result index 729c16fcf0e0c..3c00fe65885e6 100644 --- a/tests/integrationtest/r/expression/json.result +++ b/tests/integrationtest/r/expression/json.result @@ -513,18 +513,18 @@ Error 3144: Cannot create a JSON value from a string with CHARACTER SET 'binary' select cast(cast(b'010101' as json) as signed); cast(cast(b'010101' as json) as signed) 0 -show warnings; Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '"base64:type253:FQ=="' select cast(json_extract(json_objectagg('a', b'010101'), '$.a') as signed); cast(json_extract(json_objectagg('a', b'010101'), '$.a') as signed) 0 -show warnings; Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '"base64:type253:FQ=="' select cast(json_extract(json_objectagg('a', b'010101'), '$.a') as double); cast(json_extract(json_objectagg('a', b'010101'), '$.a') as double) 0 -show warnings; Level Code Message +Warning 1292 Truncated incorrect FLOAT value: '"base64:type253:FQ=="' drop table if exists t; create table t(a JSON); insert into t values ('{}'), ('true'), ('5'); diff --git a/tests/integrationtest/r/expression/misc.result b/tests/integrationtest/r/expression/misc.result index 4b3377525aa56..7e70071bfe4d6 100644 --- a/tests/integrationtest/r/expression/misc.result +++ b/tests/integrationtest/r/expression/misc.result @@ -55,8 +55,8 @@ Error 1292: Incorrect time value: '20171231235959.999999' select ADDDATE('2008-01-34', -1); ADDDATE('2008-01-34', -1) NULL -Show warnings; Level Code Message +Warning 1292 Incorrect datetime value: '2008-01-34' set sql_mode=''; drop table if exists t; create table t1(a decimal(10,5), b decimal(10,1)); @@ -237,12 +237,12 @@ create table t(a int); select /*+ unknown_hint(c1)*/ 1; 1 1 -show warnings; Level Code Message +Warning 1064 Optimizer hint syntax error at line 1 column 23 near "unknown_hint(c1)*/" select 1 from /*+ test1() */ t; 1 -show warnings; Level Code Message +Warning 1064 You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use [parser:8066]Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc. drop table if exists t; create table t(a bigint, b double, c decimal, d varchar(20), e datetime, f time, g json); insert into t values(1, 1.1, 2.2, "abc", "2018-10-24", NOW(), "12"); diff --git a/tests/integrationtest/r/expression/time.result b/tests/integrationtest/r/expression/time.result index ff87ec98f3572..aa4809fde0919 100644 --- a/tests/integrationtest/r/expression/time.result +++ b/tests/integrationtest/r/expression/time.result @@ -178,8 +178,8 @@ timestampadd(minute, 1.5, '2021-08-20 00:00:00.0001') SELECT timestampadd(year,1.212208e+308,'1995-01-05 06:32:20.859724') as result; result NULL -show warnings; Level Code Message +Warning 1441 Datetime function: datetime field overflow select DATE_ADD('2007-03-28 22:08:28',INTERVAL -2 SECOND_MICROSECOND); DATE_ADD('2007-03-28 22:08:28',INTERVAL -2 SECOND_MICROSECOND) 2007-03-28 22:08:27.800000 diff --git a/tests/integrationtest/run-tests.sh b/tests/integrationtest/run-tests.sh index d4533b201419c..91d22375e4c06 100755 --- a/tests/integrationtest/run-tests.sh +++ b/tests/integrationtest/run-tests.sh @@ -88,7 +88,7 @@ function build_mysql_tester() { echo "building mysql-tester binary: $mysql_tester" rm -rf $mysql_tester - GOBIN=$PWD go install github.com/defined2014/mysql-tester/src@1da6225968e19999d28be4d06c357b9378df8b78 + GOBIN=$PWD go install github.com/pingcap/mysql-tester/src@6891b636aa6ba666e426238f9c74deb502b846d2 mv src mysql_tester } diff --git a/tests/integrationtest/t/common_collation.test b/tests/integrationtest/t/common_collation.test index 184e7246ca0da..35ba964844022 100644 --- a/tests/integrationtest/t/common_collation.test +++ b/tests/integrationtest/t/common_collation.test @@ -1,7 +1,5 @@ set tidb_cost_model_version=1; ---disable_warnings drop table if exists t; ---enable_warnings create table t(a char(10) collate utf8mb4_unicode_ci, b char(10) collate utf8mb4_general_ci); insert into t values ('å•Š', 'æ’’æ—¦'); select coercibility(concat(a, b)) from t; @@ -11,9 +9,7 @@ select coercibility(convert('a' using utf8mb4) collate utf8mb4_general_ci); # test for coercibility and collation with json type # see details from https://github.com/pingcap/tidb/issues/31541 and https://github.com/pingcap/tidb/issues/31320#issuecomment-1010599311 ---disable_warnings drop table if exists t; ---enable_warnings create table t (a char(20), b blob(100), c text, d json, e timestamp, f set('a一','b二','c三','då››'), g text, h enum('a一','b二','c三','då››') default 'c三'); insert into t values ('你好', '你好', '你好', '{\"测试\": \"你好\"}', '2018-10-13', 1, '你好', 'a一'); select coercibility(a), coercibility(b), coercibility(c), coercibility(d), coercibility(e), coercibility(f), coercibility(g), coercibility(h) from t; diff --git a/tests/integrationtest/t/expression/builtin.test b/tests/integrationtest/t/expression/builtin.test index 389de7f8e4c71..bbeb29b7cec4f 100644 --- a/tests/integrationtest/t/expression/builtin.test +++ b/tests/integrationtest/t/expression/builtin.test @@ -278,27 +278,29 @@ select * from tb5; drop table tb5; create table tb5(a double, b float); insert into tb5 (a, b) values (184467440737095516160, 184467440737095516160); +--enable_warnings select * from tb5 where cast(a as unsigned int)=0; -show warnings; select * from tb5 where cast(b as unsigned int)=0; -show warnings; +--disable_warnings drop table tb5; create table tb5(a double, b bigint unsigned); insert into tb5 (a, b) values (18446744073709551616, 18446744073709551615); +--enable_warnings select * from tb5 where cast(a as unsigned int)=b; -show warnings; +--disable_warnings drop table tb5; create table tb5(a json, b bigint unsigned); insert into tb5 (a, b) values ('184467440737095516160', 18446744073709551615); +--enable_warnings select * from tb5 where cast(a as unsigned int)=b; -show warnings; select * from tb5 where cast(b as unsigned int)=0; -show warnings; +--disable_warnings drop table tb5; create table tb5(a json, b bigint unsigned); insert into tb5 (a, b) values ('92233720368547758080', 18446744073709551615); +--enable_warnings select * from tb5 where cast(a as signed int)=b; -show warnings; +--disable_warnings drop table tb5; create table tb5(a bigint(64) unsigned,b varchar(50)); insert into tb5(a, b) values (9223372036854775808, '9223372036854775808'); @@ -319,32 +321,31 @@ select cast("170102034" as datetime); select cast("1701020304" as datetime); select cast("1701020304." as datetime); select cast("1701020304.1" as datetime); +--enable_warnings select cast("1701020304.111" as datetime); -show warnings; +--disable_warnings select cast("17011" as datetime); select cast("150101." as datetime); +--enable_warnings select cast("150101.a" as datetime); -show warnings; select cast("150101.1a" as datetime); -show warnings; select cast("150101.1a1" as datetime); -show warnings; select cast("1101010101.111" as datetime); -show warnings; select cast("1101010101.11aaaaa" as datetime); -show warnings; select cast("1101010101.a1aaaaa" as datetime); -show warnings; +--disable_warnings select cast("1101010101.11" as datetime); select @@warning_count; +--enable_warnings select cast("1101010101.111" as datetime); -show warnings; +--disable_warnings select cast("970101.111" as datetime); select @@warning_count; select cast("970101.11111" as datetime); select @@warning_count; +--enable_warnings select cast("970101.111a1" as datetime); -show warnings; +--disable_warnings drop table if exists t; create table t (a int, b int, c int, d char(10), e datetime, f float, g decimal(10, 3)); insert t values (1, 0, null, null, null, null, null); @@ -355,61 +356,56 @@ select cast('-34 100:00:00' as time); DROP TABLE IF EXISTS t; CREATE TABLE t (ix TIME); SET SQL_MODE=''; +--enable_warnings select cast('10009010' as time); -show warnings; insert into t select cast('10009010' as time); -show warnings; select cast('239010' as time); -show warnings; insert into t select cast('239010' as time); -show warnings; select cast('233070' as time); -show warnings; insert into t select cast('233070' as time); -show warnings; select cast('23:90:10' as time); -show warnings; insert into t select cast('23:90:10' as time); -show warnings; select cast('23:30:70' as time); -show warnings; insert into t select cast('23:30:70' as time); -show warnings; select cast('239010.2' as time); -show warnings; insert into t select cast('239010.2' as time); -show warnings; select cast('233070.8' as time); -show warnings; insert into t select cast('233070.8' as time); -show warnings; +--disable_warnings set sql_mode = 'STRICT_TRANS_TABLES'; +--enable_warnings select cast('10009010' as time); -show warnings; +--disable_warnings -- error 1292 insert into t select cast('10009010' as time); +--enable_warnings select cast('239010' as time); -show warnings; +--disable_warnings -- error 1292 insert into t select cast('239010' as time); +--enable_warnings select cast('233070' as time); -show warnings; +--disable_warnings -- error 1292 insert into t select cast('233070' as time); +--enable_warnings select cast('23:90:10' as time); -show warnings; +--disable_warnings -- error 1292 insert into t select cast('23:90:10' as time); +--enable_warnings select cast('23:30:70' as time); -show warnings; +--disable_warnings -- error 1292 insert into t select cast('23:30:70' as time); +--enable_warnings select cast('239010.2' as time); -show warnings; +--disable_warnings -- error 1292 insert into t select cast('239010.2' as time); +--enable_warnings select cast('233070.8' as time); -show warnings; +--disable_warnings -- error 1292 insert into t select cast('233070.8' as time); select cast('18446744073709551616' as unsigned); @@ -570,42 +566,29 @@ create table t1(c1 int not null); insert into t1 values(1); select (case when null then c1 end) is null from t1; select (case when null then c1 end) is not null from t1; +--enable_warnings select case when b=0 then 1 else 1/b end from t; -show warnings; select if(b=0, 1, 1/b) from t; -show warnings; select ifnull(b, b/0) from t; -show warnings; select case when 1 then 1 else 1/0 end; -show warnings; select if(1,1,1/0); -show warnings; select ifnull(1, 1/0); -show warnings; +--disable_warnings delete from t; insert t values ('str2', 0); +--enable_warnings select case when b < 1 then 1 else 1/0 end from t; -show warnings; select case when b < 1 then 1 when 1/0 then b else 1/0 end from t; -show warnings; select if(b < 1 , 1, 1/0) from t; -show warnings; select ifnull(b, 1/0) from t; -show warnings; select COALESCE(1, b, b/0) from t; -show warnings; select 0 and b/0 from t; -show warnings; select 1 or b/0 from t; -show warnings; select 1 or 1/0; -show warnings; select 0 and 1/0; -show warnings; select COALESCE(1, 1/0); -show warnings; select interval(1,0,1,2,1/0); -show warnings; +--disable_warnings select case 2.0 when 2.0 then 3.0 when 3.0 then 2.0 end; select case 2.0 when 3.0 then 2.0 when 4.0 then 3.0 else 5.0 end; select case cast('2011-01-01' as date) when cast('2011-01-01' as date) then cast('2011-02-02' as date) end; @@ -613,8 +596,9 @@ select case cast('2012-01-01' as date) when cast('2011-01-01' as date) then cast select case cast('10:10:10' as time) when cast('10:10:10' as time) then cast('11:11:11' as time) end; select case cast('10:10:13' as time) when cast('10:10:10' as time) then cast('11:11:11' as time) else cast('22:22:22' as time) end; select cast(1234 as char(3)); +--enable_warnings select cast(1234 as char(0)); -show warnings; +--disable_warnings select CAST( - 8 AS DECIMAL ) * + 52 + 87 < - 86; select char(97, 100, 256, 89); select char(97, null, 100, 256, 89); @@ -934,8 +918,9 @@ select export_set(NULL, "1", "0", ",", 65); select export_set(7, "1", "0", ",", 1); select format(12332.1, 4), format(12332.2, 0), format(12332.2, 2,'en_US'); select format(NULL, 4), format(12332.2, NULL); +--enable_warnings select format(12332.2, 2,'es_EC'); -show warnings; +--disable_warnings select field(1, 2, 1), field(1, 0, NULL), field(1, NULL, 2, 1), field(NULL, 1, 2, NULL); select field("1", 2, 1), field(1, "0", NULL), field("1", NULL, 2, 1), field(NULL, 1, "2", NULL); select field("1", 2, 1), field(1, "abc", NULL), field("1", NULL, 2, 1), field(NULL, 1, "2", NULL); @@ -1089,14 +1074,16 @@ select 0.0 * -1; DROP TABLE IF EXISTS t; CREATE TABLE t(a DECIMAL(4, 2), b DECIMAL(5, 3)); INSERT INTO t(a, b) VALUES(-1.09, 1.999); +--enable_warnings SELECT a/b, a/12, a/-0.01, b/12, b/-0.01, b/0.000, NULL/b, b/NULL, NULL/NULL FROM t; -show warnings; +--disable_warnings -- error 1690 select 1e200/1e-200; SELECT 13 DIV 12, 13 DIV 0.01, -13 DIV 2, 13 DIV NULL, NULL DIV 13, NULL DIV NULL; SELECT 2.4 div 1.1, 2.4 div 1.2, 2.4 div 1.3; +--enable_warnings SELECT 1.175494351E-37 div 1.7976931348623157E+308, 1.7976931348623157E+308 div -1.7976931348623157E+307, 1 div 1e-82; -show warnings; +--disable_warnings -- error 1690 select 1e300 DIV 1.5; drop table if exists t; @@ -1105,11 +1092,13 @@ INSERT INTO t VALUE('abc', '12:00:00', 12, 0, 5, '2017-08-05 18:19:03', 'b'); select c_varchar div nonzero, c_time div nonzero, c_time div zero, c_timestamp div nonzero, c_timestamp div zero, c_varchar div zero from t; select c_enum div nonzero from t; select c_enum div zero from t; +--enable_warnings select nonzero div zero from t; -show warnings; +--disable_warnings select c_time div c_enum, c_timestamp div c_time, c_timestamp div c_enum from t; +--enable_warnings select c_int_unsigned div nonzero, nonzero div c_int_unsigned, c_int_unsigned div zero from t; -show warnings; +--disable_warnings SELECT CAST(1 AS UNSIGNED) MOD -9223372036854775808, -9223372036854775808 MOD CAST(1 AS UNSIGNED); SELECT 13 MOD 12, 13 MOD 0.01, -13 MOD 2, 13 MOD NULL, NULL MOD 13, NULL DIV NULL; SELECT 2.4 MOD 1.1, 2.4 MOD 1.2, 2.4 mod 1.30; @@ -1118,13 +1107,15 @@ CREATE TABLE t (c_varchar varchar(255), c_time time, nonzero int, zero int, c_ti INSERT INTO t VALUE('abc', '12:00:00', 12, 0, '2017-08-05 18:19:03', 'b'); select c_varchar MOD nonzero, c_time MOD nonzero, c_timestamp MOD nonzero, c_enum MOD nonzero from t; select c_time MOD c_enum, c_timestamp MOD c_time, c_timestamp MOD c_enum from t; +--enable_warnings select c_enum MOD zero from t; -show warnings; +--disable_warnings SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES'; drop table if exists t; CREATE TABLE t (v int); +--enable_warnings INSERT IGNORE INTO t VALUE(12 MOD 0); -show warnings; +--disable_warnings select v from t; select 0.000 % 0.11234500000000000000; -- error 1365 @@ -1137,8 +1128,9 @@ select sum(a) * 0.1 from t; drop table if exists t; create table t(a double); insert into t value(1.2); +--enable_warnings select * from t where a/0 > 1; -show warnings; +--disable_warnings DROP TABLE IF EXISTS t; CREATE TABLE t(a BIGINT, b DECIMAL(6, 2)); INSERT INTO t VALUES(0, 1.12), (1, 1.21); @@ -1220,13 +1212,15 @@ create table d(a varchar(100)); insert into t values('hello'), ('hello'); select group_concat(a) from t; set @@group_concat_max_len=7; +--enable_warnings select group_concat(a) from t; -show warnings; +--disable_warnings -- error 1260 insert into d select group_concat(a) from t; set sql_mode=''; +--enable_warnings insert into d select group_concat(a) from t; -show warnings; +--disable_warnings select * from d; set group_concat_max_len=default; set sql_mode=default; diff --git a/tests/integrationtest/t/expression/cast.test b/tests/integrationtest/t/expression/cast.test index 37f9a35650968..1834e7a09d31f 100644 --- a/tests/integrationtest/t/expression/cast.test +++ b/tests/integrationtest/t/expression/cast.test @@ -1,14 +1,11 @@ # TestCastStrToInt +--enable_warnings select cast('' as signed); -show warnings; select cast('12345abcde' as signed); -show warnings; select cast('123e456' as signed); -show warnings; select cast('-12345abcde' as signed); -show warnings; select cast('-123e456' as signed); -show warnings; +--disable_warnings # TestCastCoer select coercibility(binary('a')); diff --git a/tests/integrationtest/t/expression/charset_and_collation.test b/tests/integrationtest/t/expression/charset_and_collation.test index f2910d6b2391e..ef5ecffab1b88 100644 --- a/tests/integrationtest/t/expression/charset_and_collation.test +++ b/tests/integrationtest/t/expression/charset_and_collation.test @@ -401,11 +401,13 @@ select /*+ inl_join(t1) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; select /*+ hash_join(t1) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; select /*+ merge_join(t1) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; select /*+ inl_hash_join(t1) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; +--enable_warnings select /*+ inl_hash_join(t2) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; -show warnings; +--disable_warnings select /*+ inl_merge_join(t1) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; +--enable_warnings select /*+ inl_merge_join(t2) */ t1.b, t2.b from t1 join t2 where t1.b=t2.b; -show warnings; +--disable_warnings drop table if exists a, b; create table a(i int, k varbinary(40), v int, primary key(i, k) clustered); create table b(i int, k varchar(40), v int, primary key(i, k) clustered); diff --git a/tests/integrationtest/t/expression/issues.test b/tests/integrationtest/t/expression/issues.test index 4746ffeec84fd..1835a8cbef218 100644 --- a/tests/integrationtest/t/expression/issues.test +++ b/tests/integrationtest/t/expression/issues.test @@ -39,15 +39,17 @@ show create table t; # TestIssue20118 drop table if exists t; create table t(a tinyint, b bit(63)); +--enable_warnings insert ignore into t values(599999999, -1); -show warnings; +--disable_warnings select * from t; # TestIssue24900 drop table if exists t; create table t(b bit(16)); +--enable_warnings insert ignore into t values(0x3635313836),(0x333830); -show warnings; +--disable_warnings select * from t; # TestIssue9123 @@ -80,8 +82,9 @@ select 1 from t1 where char_length(c1) = 10; drop table if exists t; create table t (id int NOT NULL DEFAULT 8); SET sql_mode = ''; +--enable_warnings insert into t values (1), (NULL), (2); -show warnings; +--disable_warnings select * from t; set @@sql_mode=default; @@ -151,8 +154,9 @@ insert into ft values(1234567890,123467890.123456789,123467890.123456789,'123467 SELECT FROM_UNIXTIME(tchar) from ft; truncate table ft; insert into ft values(1234567890,123467890.1234,123467890.1234,'123467890.1234000000000000000000100111111111'); +--enable_warnings SELECT FROM_UNIXTIME(tchar) from ft; -show warnings; +--disable_warnings truncate table ft; insert into ft values(1234567890,123467890.1234,123467890.1234,'11111123467890.1234'); SELECT FROM_UNIXTIME(tchar) from ft; @@ -215,24 +219,29 @@ select min(if(apply_to_now_days <= 30,loan,null)) as min, max(if(apply_to_now_da # TestIssue41733 drop table if exists t_tiny, t_small, t_medium, t_int, t_big; create table t_tiny (c0 TINYINT UNSIGNED); +--enable_warnings INSERT IGNORE INTO t_tiny(c0) VALUES (1E9); -show warnings; +--disable_warnings select * from t_tiny; create table t_small (c0 SMALLINT UNSIGNED); +--enable_warnings INSERT IGNORE INTO t_small(c0) VALUES (1E9); -show warnings; +--disable_warnings select * from t_small; create table t_medium (c0 MEDIUMINT UNSIGNED); +--enable_warnings INSERT IGNORE INTO t_medium(c0) VALUES (1E9); -show warnings; +--disable_warnings select * from t_medium; create table t_int (c0 INT UNSIGNED); +--enable_warnings INSERT IGNORE INTO t_int(c0) VALUES (1E20); -show warnings; +--disable_warnings select * from t_int; create table t_big (c0 BIGINT UNSIGNED); +--enable_warnings INSERT IGNORE INTO t_big(c0) VALUES (1E20); -show warnings; +--disable_warnings select * from t_big; # TestInPredicate4UnsignedInt, TestIssue6661 @@ -855,8 +864,9 @@ create table t12205( `col_varchar_64_key` varchar(64) DEFAULT NULL ); insert into t12205 values('-1038024704','-527892480'); +--enable_warnings select SEC_TO_TIME( ( `col_varchar_64` & `col_varchar_64_key` ) ),`col_varchar_64` & `col_varchar_64_key` from t12205; ; -show warnings; +--disable_warnings # TestIssue21677 drop table if exists t; @@ -887,8 +897,9 @@ create table t12206( `col_year_key` year(4) DEFAULT NULL ); insert into t12206 values(73,0,0000); +--enable_warnings SELECT TIME_FORMAT( `col_tinyint_unsigned`, ( IFNULL( `col_double_unsigned`, `col_year_key` ) ) ) AS field1 FROM `t12206`; -show warnings; +--disable_warnings # TestIssue12209 drop table if exists t12209; @@ -1172,8 +1183,9 @@ select a from t1 order by a; -- error 1301 insert into t1 values (cast("a" as binary(4294967295))); select a from t1 order by a; +--enable_warnings INSERT IGNORE INTO t1 VALUES (REPEAT(0125,200000000)); -show warnings; +--disable_warnings select a from t1 order by a; # TestIssue32488 @@ -1272,10 +1284,10 @@ drop table if exists t; create table t (c int primary key, c2 enum('a', 'b')); set session sql_mode = ''; insert into t values(4, 'a'); +--enable_warnings insert into t values(4, 0) on duplicate key update c=values(c), c2=values(c2); -show warnings; insert into t values(4, 'a') on duplicate key update c=values(c), c2=values(c2); -show warnings; +--disable_warnings set @@sql_mode=default; # TestIssue38736 @@ -1463,14 +1475,12 @@ select collation(lag(b, 1, 'B') over w) from t window w as (order by b); select coercibility(lag(b, 1, 'B') over w) from t window w as (order by b); # TestIssue11177 +--enable_warnings SELECT 'lvuleck' BETWEEN '2008-09-16 22:23:50' AND 0; -show warnings; SELECT 'aa' BETWEEN 'bb' AND 0; -show warnings; select 1 between 0 and b'110'; -show warnings; select 'b' between 'a' and b'110'; -show warnings; +--disable_warnings # TestIssue19804 drop table if exists t; diff --git a/tests/integrationtest/t/expression/json.test b/tests/integrationtest/t/expression/json.test index 9126e1bc3851a..ca41e0b701fea 100644 --- a/tests/integrationtest/t/expression/json.test +++ b/tests/integrationtest/t/expression/json.test @@ -293,12 +293,11 @@ select json_object(b, a) from t; select json_objectagg(b, a) from t; # TestCastJSONOpaqueValueToNumeric +--enable_warnings select cast(cast(b'010101' as json) as signed); -show warnings; select cast(json_extract(json_objectagg('a', b'010101'), '$.a') as signed); -show warnings; select cast(json_extract(json_objectagg('a', b'010101'), '$.a') as double); -show warnings; +--disable_warnings # TestCompareJSONWithOtherType drop table if exists t; diff --git a/tests/integrationtest/t/expression/misc.test b/tests/integrationtest/t/expression/misc.test index a589f75762494..f3f34dff76db5 100644 --- a/tests/integrationtest/t/expression/misc.test +++ b/tests/integrationtest/t/expression/misc.test @@ -29,8 +29,9 @@ select time '2017-01-01 00:00:00'; select time '071231235959.999999'; -- error 1292 select time '20171231235959.999999'; +--enable_warnings select ADDDATE('2008-01-34', -1); -Show warnings; +--disable_warnings # TestTwoDecimalTruncate set sql_mode=''; @@ -164,10 +165,10 @@ select a+0 from t; # TestUnknowHintIgnore drop table if exists t; create table t(a int); +--enable_warnings select /*+ unknown_hint(c1)*/ 1; -show warnings; select 1 from /*+ test1() */ t; -show warnings; +--disable_warnings # TestValuesInNonInsertStmt drop table if exists t; diff --git a/tests/integrationtest/t/expression/time.test b/tests/integrationtest/t/expression/time.test index 6130f3aa1ad30..1a45d2a925219 100644 --- a/tests/integrationtest/t/expression/time.test +++ b/tests/integrationtest/t/expression/time.test @@ -81,8 +81,9 @@ select timestampadd(second, 9.9999e2, a) from t; select timestampadd(second, 1, '2021-08-20 00:00:01.0001'); select timestampadd(minute, 1.5, '2021-08-20 00:00:00'); select timestampadd(minute, 1.5, '2021-08-20 00:00:00.0001'); +--enable_warnings SELECT timestampadd(year,1.212208e+308,'1995-01-05 06:32:20.859724') as result; -show warnings; +--disable_warnings # TestDatetimeMicrosecond # for int diff --git a/tools/check/ut.go b/tools/check/ut.go index cbadb222d6740..f6bc45ab17014 100644 --- a/tools/check/ut.go +++ b/tools/check/ut.go @@ -831,7 +831,7 @@ func (n *numa) testCommand(pkg string, fn string) *exec.Cmd { } func skipDIR(pkg string) bool { - skipDir := []string{"br", "cmd", "dumpling", "tests", "tools/check"} + skipDir := []string{"br", "cmd", "dumpling", "tests", "tools/check", "build"} for _, ignore := range skipDir { if strings.HasPrefix(pkg, ignore) { return true