From 807e83b8144e366e7acadf2f2f6b37fd3b4c3004 Mon Sep 17 00:00:00 2001 From: shizhao Date: Fri, 6 Jan 2023 15:40:19 +0800 Subject: [PATCH] test(mtr): add some mtr test cases(#497) [summary] add test cases about unsigned/escape/replace into/zerofill --- mysql-test/suite/tianmu/r/escape.result | 121 +++ mysql-test/suite/tianmu/r/replace_into.result | 109 ++ mysql-test/suite/tianmu/r/unsigned.result | 153 +++ .../suite/tianmu/r/unsigned_greatest.result | 950 ++++++++++++++++++ .../suite/tianmu/r/unsigned_math.result | 247 +++++ mysql-test/suite/tianmu/r/zerofill.result | 70 ++ mysql-test/suite/tianmu/t/escape.test | 90 ++ mysql-test/suite/tianmu/t/replace_into.test | 100 ++ mysql-test/suite/tianmu/t/unsigned.test | 112 +++ .../suite/tianmu/t/unsigned_greatest.test | 173 ++++ mysql-test/suite/tianmu/t/unsigned_math.test | 128 +++ mysql-test/suite/tianmu/t/zerofill.test | 64 ++ 12 files changed, 2317 insertions(+) create mode 100644 mysql-test/suite/tianmu/r/escape.result create mode 100644 mysql-test/suite/tianmu/r/replace_into.result create mode 100644 mysql-test/suite/tianmu/r/unsigned.result create mode 100644 mysql-test/suite/tianmu/r/unsigned_greatest.result create mode 100644 mysql-test/suite/tianmu/r/unsigned_math.result create mode 100644 mysql-test/suite/tianmu/r/zerofill.result create mode 100644 mysql-test/suite/tianmu/t/escape.test create mode 100644 mysql-test/suite/tianmu/t/replace_into.test create mode 100644 mysql-test/suite/tianmu/t/unsigned.test create mode 100644 mysql-test/suite/tianmu/t/unsigned_greatest.test create mode 100644 mysql-test/suite/tianmu/t/unsigned_math.test create mode 100644 mysql-test/suite/tianmu/t/zerofill.test diff --git a/mysql-test/suite/tianmu/r/escape.result b/mysql-test/suite/tianmu/r/escape.result new file mode 100644 index 0000000000..8d7aeb4f1c --- /dev/null +++ b/mysql-test/suite/tianmu/r/escape.result @@ -0,0 +1,121 @@ +# +# Test escape +# +DROP DATABASE IF EXISTS escape_test; +CREATE DATABASE escape_test; +USE escape_test; +CREATE TABLE `st1` ( +`id` BIGINT(20) NOT NULL AUTO_INCREMENT, +`name` VARCHAR(255) DEFAULT NULL, +`uid` VARCHAR(11) DEFAULT NULL, +PRIMARY KEY (`id`) +) DEFAULT CHARSET=utf8; +INSERT INTO st1 (NAME,uid) VALUES('zhangsan','hello'); +INSERT INTO st1 (NAME,uid) VALUES('lisi_wu','world'); +INSERT INTO st1 (NAME,uid) VALUES('wangwu%','world'); +INSERT INTO st1 (NAME,uid) VALUES('%a','world'); +INSERT INTO st1 (NAME,uid) VALUES('%_','world'); +select * from st1; +id name uid +1 zhangsan hello +2 lisi_wu world +3 wangwu% world +4 %a world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "san", "%"); +id name uid +1 zhangsan hello +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "%", "%"); +id name uid +1 zhangsan hello +2 lisi_wu world +3 wangwu% world +4 %a world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\%", "%"); +id name uid +3 wangwu% world +4 %a world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\%", "%"); +id name uid +3 wangwu% world +4 %a world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "$%", "%") ESCAPE "$"; +id name uid +3 wangwu% world +4 %a world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\_", "%"); +id name uid +2 lisi_wu world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "a_", "%") ESCAPE "a"; +id name uid +2 lisi_wu world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE "a%_" ESCAPE "a" ; +id name uid +4 %a world +5 %_ world +SELECT * FROM st1 WHERE NAME LIKE "a%a" ESCAPE "a" ; +id name uid +4 %a world +drop table st1; +CREATE TABLE `st1` ( +`id` BIGINT(20) NOT NULL AUTO_INCREMENT, +`name` VARCHAR(255) DEFAULT NULL, +`uid` VARCHAR(11) DEFAULT NULL, +PRIMARY KEY (`id`) +) DEFAULT CHARSET=utf8; +INSERT INTO st1 (NAME,uid) VALUES('123hello','hello'); +INSERT INTO st1 (NAME,uid) VALUES('123hello123','world'); +INSERT INTO st1 (NAME,uid) VALUES('hello123','world'); +INSERT INTO st1 (NAME,uid) VALUES('_hello','world'); +select * from st1; +id name uid +1 123hello hello +2 123hello123 world +3 hello123 world +4 _hello world +select * from st1 where name like '%hello%'; +id name uid +1 123hello hello +2 123hello123 world +3 hello123 world +4 _hello world +select * from st1 where name like '_hello'; +id name uid +4 _hello world +select * from st1 where name like 'hello12_'; +id name uid +3 hello123 world +create table st2(id int ,column_2 varchar(10),column_3 varchar(10)); +insert into st2 values(1,'_a\\\\','111111'); +insert into st2 values(2,'12%','%12%'); +insert into st2 values(3,'a_a','a%'); +insert into st2 values(4,'_a\\','_12%'); +insert into st2 values(5,'\\a','\\\\_a%12%'); +select * from st2 where column_2 like '%\\\%' ; +id column_2 column_3 +1 _a\\ 111111 +4 _a\ _12% +5 \a \\_a%12% +select * from st2 where column_2 like '%\%' ; +id column_2 column_3 +2 12% %12% +select * from st2 where column_2 like '%\\%' ; +id column_2 column_3 +2 12% %12% +select * from st2 where column_2 like '%\_%' ; +id column_2 column_3 +1 _a\\ 111111 +3 a_a a% +4 _a\ _12% +select * from st2 where column_2 like '%?_%' escape '?'; +id column_2 column_3 +1 _a\\ 111111 +3 a_a a% +4 _a\ _12% +DROP DATABASE escape_test; diff --git a/mysql-test/suite/tianmu/r/replace_into.result b/mysql-test/suite/tianmu/r/replace_into.result new file mode 100644 index 0000000000..f016bd6c93 --- /dev/null +++ b/mysql-test/suite/tianmu/r/replace_into.result @@ -0,0 +1,109 @@ +# +# Test replace into +# +DROP DATABASE IF EXISTS replace_into_test; +CREATE DATABASE replace_into_test; +USE replace_into_test; +CREATE TABLE test ( +id INT NOT NULL, +test VARCHAR(64) DEFAULT NULL, +name TIMESTAMP NOT NULL, +PRIMARY KEY (id) +); +insert into test values(1,'old','2014-08-20 18:47:00'); +insert into test values(2,'old','2014-08-20 18:47:00'); +REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42'); +REPLACE INTO test VALUES (2, 'New', '2014-08-20 18:47:42'); +delete from test where id=1; +REPLACE INTO test VALUES (2, 'Newnew', '2014-08-20 18:47:42'); +REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42'); +REPLACE INTO test VALUES (1, 'Newnew', '2014-08-20 18:47:42'); +select * from test; +id test name +2 Newnew 2014-08-20 18:47:42 +1 Newnew 2014-08-20 18:47:42 +CREATE TABLE test1 ( +id INT NOT NULL, +test VARCHAR(64) DEFAULT NULL, +id1 int NOT NULL, +PRIMARY KEY (id,id1) +); +insert into test1 values(1,'old',1); +insert into test1 values(2,'old',2); +REPLACE INTO test1 VALUES (1, 'New', '8'); +REPLACE INTO test1 VALUES (1, 'New', '1'); +REPLACE INTO test1 VALUES (8, 'New', '2'); +select * from test1; +id test id1 +1 New 1 +2 old 2 +1 New 8 +8 New 2 +CREATE TABLE `insert_relpace_into_test` ( +`id` int(10), +`uniq_id` varchar(32), +`filed_a` varchar(32) DEFAULT '' , +`filed_b` varchar(32) DEFAULT '', +`version` int(10) DEFAULT '0', +PRIMARY KEY (`id`) +); +CREATE TABLE `insert_relpace_into_test2` ( +`id` int(10), +`uniq_id` varchar(32) DEFAULT NULL, +`filed_a` varchar(32) DEFAULT '', +`filed_b` varchar(32) DEFAULT '', +`version` int(10) DEFAULT '0', +PRIMARY KEY (`id`) +); +REPLACE INTO insert_relpace_into_test2 +VALUES +( 1,'1003', 'ziduan a', 'ziduan b', 1 ), +( 2,'1005', 'ziduan _2_2', 'ziduan b_2', 1 ); +REPLACE INTO insert_relpace_into_test +VALUES +( 3,'1003', 'ziduan a', 'ziduan b', 1 ), +( 4,'1005', 'ziduan _2_2', 'ziduan b_2', 1 ); +REPLACE INTO insert_relpace_into_test ( id,uniq_id, filed_a, filed_b, version ) +SELECT id,uniq_id, filed_a, filed_b, version FROM insert_relpace_into_test2; +select * from insert_relpace_into_test; +id uniq_id filed_a filed_b version +3 1003 ziduan a ziduan b 1 +4 1005 ziduan _2_2 ziduan b_2 1 +1 1003 ziduan a ziduan b 1 +2 1005 ziduan _2_2 ziduan b_2 1 +REPLACE INTO insert_relpace_into_test +SET id=5,uniq_id='1003',filed_a='ziduan _2_2',filed_b='ziduan b_2'; +select * from insert_relpace_into_test; +id uniq_id filed_a filed_b version +3 1003 ziduan a ziduan b 1 +4 1005 ziduan _2_2 ziduan b_2 1 +1 1003 ziduan a ziduan b 1 +2 1005 ziduan _2_2 ziduan b_2 1 +5 1003 ziduan _2_2 ziduan b_2 0 +REPLACE INTO insert_relpace_into_test +VALUES +( 3,'1003new', 'ziduan a', 'ziduan b', 1 ), +( 4,'1005new', 'ziduan _2_2', 'ziduan b_2', 1 ); +select * from insert_relpace_into_test; +id uniq_id filed_a filed_b version +3 1003new ziduan a ziduan b 1 +4 1005new ziduan _2_2 ziduan b_2 1 +1 1003 ziduan a ziduan b 1 +2 1005 ziduan _2_2 ziduan b_2 1 +5 1003 ziduan _2_2 ziduan b_2 0 +REPLACE INTO insert_relpace_into_test ( id,uniq_id, filed_a, filed_b, version ) +SELECT id,uniq_id, filed_a, filed_b, version FROM insert_relpace_into_test2; +REPLACE INTO insert_relpace_into_test +SET id=5,uniq_id='1003new',filed_a='ziduan _2_2',filed_b='ziduan b_2'; +select * from insert_relpace_into_test; +id uniq_id filed_a filed_b version +3 1003new ziduan a ziduan b 1 +4 1005new ziduan _2_2 ziduan b_2 1 +1 1003 ziduan a ziduan b 1 +2 1005 ziduan _2_2 ziduan b_2 1 +5 1003new ziduan _2_2 ziduan b_2 0 +drop table insert_relpace_into_test; +drop table insert_relpace_into_test2; +drop table test; +drop table test1; +DROP DATABASE replace_into_test; diff --git a/mysql-test/suite/tianmu/r/unsigned.result b/mysql-test/suite/tianmu/r/unsigned.result new file mode 100644 index 0000000000..6d8c49bb27 --- /dev/null +++ b/mysql-test/suite/tianmu/r/unsigned.result @@ -0,0 +1,153 @@ +# +# Test unsigned +# +DROP DATABASE IF EXISTS unsigned_test; +CREATE DATABASE unsigned_test; +USE unsigned_test; +create table st1 (ukey int, c1 tinyint unsigned, c2 smallint unsigned, c3 int unsigned, c4 bigint unsigned); +insert into st1 values (1,2,3,4,5), (2,127,32767,2147483647,9223372036854775807); +select 'q1', st1.* from st1 order by 1; +q1 ukey c1 c2 c3 c4 +q1 1 2 3 4 5 +q1 2 127 32767 2147483647 9223372036854775807 +insert into st1 values (3,-127,-32766,-2147483646,-9223372036854775806); +ERROR 22003: Out of range value for column 'c1' at row 1 +insert into st1 values (4,126,32766,2147483646,9223372036854775806),(5,125,32765,2147483645,9223372036854775805); +insert into st1 values (6,1255,165535,14294967295,118446744073709551615); +ERROR 22003: Out of range value for column 'c1' at row 1 +select 'q2', st1.* from st1 where ukey > 2 order by 1; +q2 ukey c1 c2 c3 c4 +q2 4 126 32766 2147483646 9223372036854775806 +q2 5 125 32765 2147483645 9223372036854775805 +insert into st1 values (7,NULL,NULL,NULL,NULL); +select 'q3', st1.* from st1 where ukey=7; +q3 ukey c1 c2 c3 c4 +q3 7 NULL NULL NULL NULL +update st1 set c4=-9223372036854775806 where ukey=1; +ERROR 22003: Out of range value for column 'c4' at row 1 +update st1 set c3=-2147483646 where ukey=1; +ERROR 22003: Out of range value for column 'c3' at row 1 +update st1 set c2=-32766 where ukey=1; +ERROR 22003: Out of range value for column 'c2' at row 1 +update st1 set c1=-127 where ukey between 0 and 2; +ERROR 22003: Out of range value for column 'c1' at row 1 +select 'q4', st1.* from st1 where ukey<2; +q4 ukey c1 c2 c3 c4 +q4 1 2 3 4 5 +update st1 set c3=2147483646 where ukey=4; +update st1 set c2=32766 where ukey=4; +update st1 set c1=125 where ukey between 4 and 5; +select 'q5', st1.* from st1 where ukey>3 order by 2; +q5 ukey c1 c2 c3 c4 +q5 4 125 32766 2147483646 9223372036854775806 +q5 5 125 32765 2147483645 9223372036854775805 +q5 7 NULL NULL NULL NULL +create table st2 (ukey int, c1 tinyint unsigned, c2 smallint unsigned, c3 int unsigned, c4 bigint unsigned); +insert into st2 values (8,125,32764,2147483645,9223372036854775800), (9,126,32766,2147483646,9223372036854775800),(10,127,32767,2147483647,9223372036854775801); +select 'q6', st2.* from st2 where c1 between 125 and 127; +q6 ukey c1 c2 c3 c4 +q6 8 125 32764 2147483645 9223372036854775800 +q6 9 126 32766 2147483646 9223372036854775800 +q6 10 127 32767 2147483647 9223372036854775801 +select 'q7', st2.* from st2 where c2 between 32764 and 32767; +q7 ukey c1 c2 c3 c4 +q7 8 125 32764 2147483645 9223372036854775800 +q7 9 126 32766 2147483646 9223372036854775800 +q7 10 127 32767 2147483647 9223372036854775801 +select 'q8', st2.* from st2 where c3 between 2147483645 and 2147483647; +q8 ukey c1 c2 c3 c4 +q8 8 125 32764 2147483645 9223372036854775800 +q8 9 126 32766 2147483646 9223372036854775800 +q8 10 127 32767 2147483647 9223372036854775801 +select 'q9', st2.* from st2 where c4 between 9223372036854775800 and 9223372036854775801; +q9 ukey c1 c2 c3 c4 +q9 8 125 32764 2147483645 9223372036854775800 +q9 9 126 32766 2147483646 9223372036854775800 +q9 10 127 32767 2147483647 9223372036854775801 +drop table if exists st1; +drop table if exists st2; +DROP TABLE if exists st3; +create table st3 (ukey bigint unsigned, c1 float unsigned, c2 double unsigned, c3 decimal(5,2) unsigned, c4 decimal(18,6) unsigned); +insert into st3 values (0,2.22507385E-18, 2.225073858507201E-307, 123.45, 1234567890.12345678); +Warnings: +Note 1265 Data truncated for column 'c4' at row 1 +select 'q10', st3.* from st3 order by st3.ukey; +q10 ukey c1 c2 c3 c4 +q10 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457 +insert into st3 values (0,-2.22507385E-18, -2.225073858507201E-307, -123.45, -1234567890.12345678); +ERROR 22003: Out of range value for column 'c1' at row 1 +select 'q11', st3.* from st3 order by st3.ukey; +q11 ukey c1 c2 c3 c4 +q11 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457 +insert into st3 values (0,0.0, 0.0, 43123.45, 34321234567890.12345678); +ERROR 22003: Out of range value for column 'c3' at row 1 +select 'q12', st3.* from st3 order by st3.ukey; +q12 ukey c1 c2 c3 c4 +q12 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457 +select 'q13', st3.* from st3 where c2 > 0 order by st3.ukey; +q13 ukey c1 c2 c3 c4 +q13 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457 +insert into st3 values (0,0.0, 0.0, 0.0, 0); +select 'q12', st3.* from st3 order by st3.ukey; +q12 ukey c1 c2 c3 c4 +q12 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457 +q12 0 0 0 0.00 0.000000 +DROP TABLE if exists st3; +DROP TABLE IF EXISTS st4; +CREATE TABLE st4 (ukey TINYINT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; +q13 ukey c1 +q13 0 1 +q13 0 2 +q13 0 3 +q13 0 4 +q13 0 5 +DROP TABLE IF EXISTS st4; +CREATE TABLE st4 (ukey SMALLINT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; +q13 ukey c1 +q13 0 1 +q13 0 2 +q13 0 3 +q13 0 4 +q13 0 5 +DROP TABLE IF EXISTS st4; +CREATE TABLE st4 (ukey INT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; +q13 ukey c1 +q13 0 1 +q13 0 2 +q13 0 3 +q13 0 4 +q13 0 5 +DROP TABLE IF EXISTS st4; +CREATE TABLE st4 (ukey BIGINT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; +q13 ukey c1 +q13 0 1 +q13 0 2 +q13 0 3 +q13 0 4 +q13 0 5 +DROP TABLE IF EXISTS st4; +DROP DATABASE unsigned_test; diff --git a/mysql-test/suite/tianmu/r/unsigned_greatest.result b/mysql-test/suite/tianmu/r/unsigned_greatest.result new file mode 100644 index 0000000000..8e6590708c --- /dev/null +++ b/mysql-test/suite/tianmu/r/unsigned_greatest.result @@ -0,0 +1,950 @@ +DROP DATABASE IF EXISTS unsigned_greatest_test; +CREATE DATABASE unsigned_greatest_test; +USE unsigned_greatest_test; +Create table datatypetestm ( +CIDX INTEGER, +CBIGINT BIGINT, +CDECIMAL1 DECIMAL(1), +CDECIMAL4 DECIMAL(4), +CDECIMAL4_2 DECIMAL(4,2), +CDECIMAL5 DECIMAL(5), +CDECIMAL9 DECIMAL(9), +CDECIMAL9_2 DECIMAL(9,2), +CDECIMAL10 DECIMAL(10), +CDECIMAL18 DECIMAL(18), +CDECIMAL18_2 DECIMAL(18,2), +CINTEGER INTEGER, +CSMALLINT SMALLINT, +CTINYINT TINYINT, +CDOUBLE DOUBLE, +CFLOAT FLOAT, +CDATE DATE, +CDATETIME DATETIME, +CCHAR1 CHAR(1), +CCHAR2 CHAR(2), +CCHAR3 CHAR(3), +CCHAR4 CHAR(4), +CCHAR5 CHAR(5), +CCHAR6 CHAR(6), +CCHAR7 CHAR(7), +CCHAR8 CHAR(8), +CCHAR9 CHAR(9), +CCHAR255 CHAR(255), +CVCHAR1 VARCHAR(1), +CVCHAR2 VARCHAR(2), +CVCHAR3 VARCHAR(3), +CVCHAR4 VARCHAR(4), +CVCHAR5 VARCHAR(5), +CVCHAR6 VARCHAR(6), +CVCHAR7 VARCHAR(7), +CVCHAR8 VARCHAR(8), +CVCHAR255 VARCHAR(255) +); +insert into datatypetestm values +(1,-72036854775806,-9,-999,-9.99,-999,-999999,-9999.99,-9999999,-9999999999999,-99999999999.99,-7483646,-766,-26,-1.797693231E+108,-3.402866E+18,'1997-01-01','1997-01-01 00:00:00','a','aa','aaa','aaaa','aaaaa','aaaaaa','aaaaaaa','aaaaaaaa','aaaaaaaaa','aaaaaaaaaa','a','aa','aaa','aaaa','aaaaa','aaaaaa','aaaaaaa','aaaaaaaa','aaaaaaaaaa'), +(2,-72036854775805,-8,-998,-9.98,-998,-999998,-9999.98,-9999998,-9999999999998,-99999999999.98,-7483645,-765,-25,-1.797693230E+108,-3.402865E+18,'1997-01-01','1997-01-01 00:00:01','a','b','c','d','e','f','g','h','i','j','a','b','c','d','e','f','g','h','j'), +(3,-72036854775804,-7,-997,-9.97,-997,-999997,-9999.97,-9999997,-9999999999997,-99999999999.97,-7483644,-764,-24,-1.797693229E+108,-3.402864E+18,'1997-01-02','1997-01-02 00:00:01','a','bb','cc','dd','ee','ff','gg','hh','ii','jj','a','bb','cc','dd','ee','ff','gg','hh','jj'), +(4,-72036854775803,-6,-996,-9.96,-996,-999996,-9999.96,-9999996,-9999999999996,-99999999999.96,-7483643,-763,-23,-1.797693228E+108,-3.402863E+18,'1997-01-03','1997-01-03 00:00:02','a','bb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj','a','bb','ccc','ddd','eee','fff','ggg','hhh','jjj'), +(5,-72036854775802,-5,-995,-9.95,-995,-999995,-9999.95,-9999995,-9999999999995,-99999999999.95,-7483642,-762,-22,-1.797693227E+108,-3.402862E+18,'1997-01-04','1997-01-04 00:00:03','a','bb','ccc','dddd','eeee','ffff','gggg','hhhh','iiii','jjjj','a','bb','ccc','dddd','eeee','ffff','gggg','hhhh','jjjj'), +(6,72036854775803,5,995,9.95,995,999995,9999.95,9999995,9999999999995,99999999999.95,7483643,763,23,1.797693227E+108,3.402862E+18,'2009-12-28','2009-12-31 23:59:56','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','sssssss','rrrrrrr','qqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','sssssss','qqqqqqq'), +(7,72036854775804,6,996,9.96,996,999996,9999.96,9999996,9999999999996,99999999999.96,7483644,764,24,1.797693228E+108,3.402863E+18,'2009-12-29','2009-12-31 23:59:57','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','rrrrrrrr','qqqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','qqqqqqqq'), +(8,72036854775805,7,997,9.97,997,999997,9999.97,9999997,9999999999997,99999999999.97,7483645,765,25,1.797693229E+108,3.402864E+18,'2009-12-30','2009-12-31 23:59:58','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','rrrrrrrrr','qqqqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','qqqqqqqqq'), +(9,72036854775806,8,998,9.98,998,999998,9999.98,9999998,9999999999998,99999999999.98,7483646,766,26,1.797693230E+108,3.402865E+18,'2009-12-31','2009-12-31 23:59:59','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','rrrrrrrrr','qqqqqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','qqqqqqqqqq'), +(10,72036854775807,9,999,9.99,999,999999,9999.99,9999999,9999999999999,99999999999.99,7483647,767,27,1.797693231E+108,3.402866E+18,'2009-12-31','2009-12-31 23:59:59','z','zz','zzz','zzzz','zzzzz','zzzzzz','zzzzzzz','zzzzzzzz','zzzzzzzzz','zzzzzzzzzz','z','zz','zzz','zzzz','zzzzz','zzzzzz','zzzzzzz','zzzzzzzz','zzzzzzzzzz'), +(11,0,0,0,0.00,0,0,0.00,0,0,0.00,0,0,0,0.00,0.00,'2009-12-31','2009-12-31 23:59:59',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +ALTER TABLE datatypetestm ADD COLUMN CUTINYINT TINYINT UNSIGNED; +ALTER TABLE datatypetestm ADD COLUMN CUSMALLINT SMALLINT UNSIGNED; +ALTER TABLE datatypetestm ADD COLUMN CUINTEGER INT UNSIGNED; +ALTER TABLE datatypetestm ADD COLUMN CUBIGINT BIGINT UNSIGNED; +UPDATE datatypetestm SET CUTINYINT=CTINYINT + 100; +UPDATE datatypetestm SET CUSMALLINT=CSMALLINT + 20000; +UPDATE datatypetestm SET CUINTEGER=CINTEGER + 1140000000; +UPDATE datatypetestm SET CUBIGINT=CBIGINT + 5223000000000000; +select cidx, CUBIGINT, GREATEST(CUBIGINT,CBIGINT,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +cidx CUBIGINT GREATEST(CUBIGINT,CBIGINT,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) +1 5150963145224194 5150963145224194 +2 5150963145224195 5150963145224195 +3 5150963145224196 5150963145224196 +4 5150963145224197 5150963145224197 +5 5150963145224198 5150963145224198 +6 5295036854775803 5295036854775803 +7 5295036854775804 5295036854775804 +8 5295036854775805 5295036854775805 +9 5295036854775806 5295036854775806 +10 5295036854775807 5295036854775807 +11 5223000000000000 5223000000000000 +select cidx, CDECIMAL1, CUSMALLINT, GREATEST(CDECIMAL1,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL1 CUSMALLINT GREATEST(CDECIMAL1,CUSMALLINT,CUTINYINT,10) +1 -9 19234 19234 +2 -8 19235 19235 +3 -7 19236 19236 +4 -6 19237 19237 +5 -5 19238 19238 +6 5 20763 20763 +7 6 20764 20764 +8 7 20765 20765 +9 8 20766 20766 +10 9 20767 20767 +11 0 20000 20000 +select cidx, CDECIMAL1, CUTINYINT, GREATEST(CDECIMAL1,CUTINYINT) from datatypetestm; +cidx CDECIMAL1 CUTINYINT GREATEST(CDECIMAL1,CUTINYINT) +1 -9 74 74 +2 -8 75 75 +3 -7 76 76 +4 -6 77 77 +5 -5 78 78 +6 5 123 123 +7 6 124 124 +8 7 125 125 +9 8 126 126 +10 9 127 127 +11 0 100 100 +select cidx, CDECIMAL1, CUBIGINT, GREATEST(CDECIMAL1,CUBIGINT) from datatypetestm; +cidx CDECIMAL1 CUBIGINT GREATEST(CDECIMAL1,CUBIGINT) +1 -9 5150963145224194 5150963145224194 +2 -8 5150963145224195 5150963145224195 +3 -7 5150963145224196 5150963145224196 +4 -6 5150963145224197 5150963145224197 +5 -5 5150963145224198 5150963145224198 +6 5 5295036854775803 5295036854775803 +7 6 5295036854775804 5295036854775804 +8 7 5295036854775805 5295036854775805 +9 8 5295036854775806 5295036854775806 +10 9 5295036854775807 5295036854775807 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL4, CUSMALLINT, GREATEST(CDECIMAL4,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL4 CUSMALLINT GREATEST(CDECIMAL4,CUSMALLINT,CUTINYINT,10) +1 -999 19234 19234 +2 -998 19235 19235 +3 -997 19236 19236 +4 -996 19237 19237 +5 -995 19238 19238 +6 995 20763 20763 +7 996 20764 20764 +8 997 20765 20765 +9 998 20766 20766 +10 999 20767 20767 +11 0 20000 20000 +select cidx, CDECIMAL4, CUTINYINT, GREATEST(CDECIMAL4,CUTINYINT) from datatypetestm; +cidx CDECIMAL4 CUTINYINT GREATEST(CDECIMAL4,CUTINYINT) +1 -999 74 74 +2 -998 75 75 +3 -997 76 76 +4 -996 77 77 +5 -995 78 78 +6 995 123 995 +7 996 124 996 +8 997 125 997 +9 998 126 998 +10 999 127 999 +11 0 100 100 +select cidx, CDECIMAL4, CUBIGINT, GREATEST(CDECIMAL4,CUBIGINT) from datatypetestm; +cidx CDECIMAL4 CUBIGINT GREATEST(CDECIMAL4,CUBIGINT) +1 -999 5150963145224194 5150963145224194 +2 -998 5150963145224195 5150963145224195 +3 -997 5150963145224196 5150963145224196 +4 -996 5150963145224197 5150963145224197 +5 -995 5150963145224198 5150963145224198 +6 995 5295036854775803 5295036854775803 +7 996 5295036854775804 5295036854775804 +8 997 5295036854775805 5295036854775805 +9 998 5295036854775806 5295036854775806 +10 999 5295036854775807 5295036854775807 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL4_2, CUSMALLINT, GREATEST(CDECIMAL4_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL4_2 CUSMALLINT GREATEST(CDECIMAL4_2,CUSMALLINT,CUTINYINT,10) +1 -9.99 19234 19234.00 +2 -9.98 19235 19235.00 +3 -9.97 19236 19236.00 +4 -9.96 19237 19237.00 +5 -9.95 19238 19238.00 +6 9.95 20763 20763.00 +7 9.96 20764 20764.00 +8 9.97 20765 20765.00 +9 9.98 20766 20766.00 +10 9.99 20767 20767.00 +11 0.00 20000 20000.00 +select cidx, CDECIMAL4_2, CUTINYINT, GREATEST(CDECIMAL4_2,CUTINYINT) from datatypetestm; +cidx CDECIMAL4_2 CUTINYINT GREATEST(CDECIMAL4_2,CUTINYINT) +1 -9.99 74 74.00 +2 -9.98 75 75.00 +3 -9.97 76 76.00 +4 -9.96 77 77.00 +5 -9.95 78 78.00 +6 9.95 123 123.00 +7 9.96 124 124.00 +8 9.97 125 125.00 +9 9.98 126 126.00 +10 9.99 127 127.00 +11 0.00 100 100.00 +select cidx, CDECIMAL4_2, CUBIGINT, GREATEST(CDECIMAL4_2,CUBIGINT) from datatypetestm; +cidx CDECIMAL4_2 CUBIGINT GREATEST(CDECIMAL4_2,CUBIGINT) +1 -9.99 5150963145224194 5150963145224194.00 +2 -9.98 5150963145224195 5150963145224195.00 +3 -9.97 5150963145224196 5150963145224196.00 +4 -9.96 5150963145224197 5150963145224197.00 +5 -9.95 5150963145224198 5150963145224198.00 +6 9.95 5295036854775803 5295036854775803.00 +7 9.96 5295036854775804 5295036854775804.00 +8 9.97 5295036854775805 5295036854775805.00 +9 9.98 5295036854775806 5295036854775806.00 +10 9.99 5295036854775807 5295036854775807.00 +11 0.00 5223000000000000 5223000000000000.00 +select cidx, CDECIMAL9, CUSMALLINT, GREATEST(CDECIMAL9,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL9 CUSMALLINT GREATEST(CDECIMAL9,CUSMALLINT,CUTINYINT,10) +1 -999999 19234 19234 +2 -999998 19235 19235 +3 -999997 19236 19236 +4 -999996 19237 19237 +5 -999995 19238 19238 +6 999995 20763 999995 +7 999996 20764 999996 +8 999997 20765 999997 +9 999998 20766 999998 +10 999999 20767 999999 +11 0 20000 20000 +select cidx, CDECIMAL9, CUTINYINT, GREATEST(CDECIMAL9,CUTINYINT) from datatypetestm; +cidx CDECIMAL9 CUTINYINT GREATEST(CDECIMAL9,CUTINYINT) +1 -999999 74 74 +2 -999998 75 75 +3 -999997 76 76 +4 -999996 77 77 +5 -999995 78 78 +6 999995 123 999995 +7 999996 124 999996 +8 999997 125 999997 +9 999998 126 999998 +10 999999 127 999999 +11 0 100 100 +select cidx, CDECIMAL9, CUBIGINT, GREATEST(CDECIMAL9,CUBIGINT) from datatypetestm; +cidx CDECIMAL9 CUBIGINT GREATEST(CDECIMAL9,CUBIGINT) +1 -999999 5150963145224194 5150963145224194 +2 -999998 5150963145224195 5150963145224195 +3 -999997 5150963145224196 5150963145224196 +4 -999996 5150963145224197 5150963145224197 +5 -999995 5150963145224198 5150963145224198 +6 999995 5295036854775803 5295036854775803 +7 999996 5295036854775804 5295036854775804 +8 999997 5295036854775805 5295036854775805 +9 999998 5295036854775806 5295036854775806 +10 999999 5295036854775807 5295036854775807 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL9_2, CUSMALLINT, GREATEST(CDECIMAL9_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL9_2 CUSMALLINT GREATEST(CDECIMAL9_2,CUSMALLINT,CUTINYINT,10) +1 -9999.99 19234 19234.00 +2 -9999.98 19235 19235.00 +3 -9999.97 19236 19236.00 +4 -9999.96 19237 19237.00 +5 -9999.95 19238 19238.00 +6 9999.95 20763 20763.00 +7 9999.96 20764 20764.00 +8 9999.97 20765 20765.00 +9 9999.98 20766 20766.00 +10 9999.99 20767 20767.00 +11 0.00 20000 20000.00 +select cidx, CDECIMAL9_2, CUTINYINT, GREATEST(CDECIMAL9_2,CUTINYINT) from datatypetestm; +cidx CDECIMAL9_2 CUTINYINT GREATEST(CDECIMAL9_2,CUTINYINT) +1 -9999.99 74 74.00 +2 -9999.98 75 75.00 +3 -9999.97 76 76.00 +4 -9999.96 77 77.00 +5 -9999.95 78 78.00 +6 9999.95 123 9999.95 +7 9999.96 124 9999.96 +8 9999.97 125 9999.97 +9 9999.98 126 9999.98 +10 9999.99 127 9999.99 +11 0.00 100 100.00 +select cidx, CDECIMAL9_2, CUBIGINT, GREATEST(CDECIMAL9_2,CUBIGINT) from datatypetestm; +cidx CDECIMAL9_2 CUBIGINT GREATEST(CDECIMAL9_2,CUBIGINT) +1 -9999.99 5150963145224194 5150963145224194.00 +2 -9999.98 5150963145224195 5150963145224195.00 +3 -9999.97 5150963145224196 5150963145224196.00 +4 -9999.96 5150963145224197 5150963145224197.00 +5 -9999.95 5150963145224198 5150963145224198.00 +6 9999.95 5295036854775803 5295036854775803.00 +7 9999.96 5295036854775804 5295036854775804.00 +8 9999.97 5295036854775805 5295036854775805.00 +9 9999.98 5295036854775806 5295036854775806.00 +10 9999.99 5295036854775807 5295036854775807.00 +11 0.00 5223000000000000 5223000000000000.00 +select cidx, CDECIMAL18, CUSMALLINT, GREATEST(CDECIMAL18,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL18 CUSMALLINT GREATEST(CDECIMAL18,CUSMALLINT,CUTINYINT,10) +1 -9999999999999 19234 19234 +2 -9999999999998 19235 19235 +3 -9999999999997 19236 19236 +4 -9999999999996 19237 19237 +5 -9999999999995 19238 19238 +6 9999999999995 20763 9999999999995 +7 9999999999996 20764 9999999999996 +8 9999999999997 20765 9999999999997 +9 9999999999998 20766 9999999999998 +10 9999999999999 20767 9999999999999 +11 0 20000 20000 +select cidx, CDECIMAL18, CUTINYINT, GREATEST(CDECIMAL18,CUTINYINT) from datatypetestm; +cidx CDECIMAL18 CUTINYINT GREATEST(CDECIMAL18,CUTINYINT) +1 -9999999999999 74 74 +2 -9999999999998 75 75 +3 -9999999999997 76 76 +4 -9999999999996 77 77 +5 -9999999999995 78 78 +6 9999999999995 123 9999999999995 +7 9999999999996 124 9999999999996 +8 9999999999997 125 9999999999997 +9 9999999999998 126 9999999999998 +10 9999999999999 127 9999999999999 +11 0 100 100 +select cidx, CDECIMAL18, CUBIGINT, GREATEST(CDECIMAL18,CUBIGINT) from datatypetestm; +cidx CDECIMAL18 CUBIGINT GREATEST(CDECIMAL18,CUBIGINT) +1 -9999999999999 5150963145224194 5150963145224194 +2 -9999999999998 5150963145224195 5150963145224195 +3 -9999999999997 5150963145224196 5150963145224196 +4 -9999999999996 5150963145224197 5150963145224197 +5 -9999999999995 5150963145224198 5150963145224198 +6 9999999999995 5295036854775803 5295036854775803 +7 9999999999996 5295036854775804 5295036854775804 +8 9999999999997 5295036854775805 5295036854775805 +9 9999999999998 5295036854775806 5295036854775806 +10 9999999999999 5295036854775807 5295036854775807 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL18_2, CUSMALLINT, GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL18_2 CUSMALLINT GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) +1 -99999999999.99 19234 19234.00 +2 -99999999999.98 19235 19235.00 +3 -99999999999.97 19236 19236.00 +4 -99999999999.96 19237 19237.00 +5 -99999999999.95 19238 19238.00 +6 99999999999.95 20763 99999999999.95 +7 99999999999.96 20764 99999999999.96 +8 99999999999.97 20765 99999999999.97 +9 99999999999.98 20766 99999999999.98 +10 99999999999.99 20767 99999999999.99 +11 0.00 20000 20000.00 +select cidx, CDECIMAL18_2, CUTINYINT, GREATEST(CDECIMAL18_2,CUTINYINT) from datatypetestm; +cidx CDECIMAL18_2 CUTINYINT GREATEST(CDECIMAL18_2,CUTINYINT) +1 -99999999999.99 74 74.00 +2 -99999999999.98 75 75.00 +3 -99999999999.97 76 76.00 +4 -99999999999.96 77 77.00 +5 -99999999999.95 78 78.00 +6 99999999999.95 123 99999999999.95 +7 99999999999.96 124 99999999999.96 +8 99999999999.97 125 99999999999.97 +9 99999999999.98 126 99999999999.98 +10 99999999999.99 127 99999999999.99 +11 0.00 100 100.00 +select cidx, CDECIMAL18_2, CUBIGINT, GREATEST(CDECIMAL18_2,CUBIGINT) from datatypetestm; +cidx CDECIMAL18_2 CUBIGINT GREATEST(CDECIMAL18_2,CUBIGINT) +1 -99999999999.99 5150963145224194 5150963145224194.00 +2 -99999999999.98 5150963145224195 5150963145224195.00 +3 -99999999999.97 5150963145224196 5150963145224196.00 +4 -99999999999.96 5150963145224197 5150963145224197.00 +5 -99999999999.95 5150963145224198 5150963145224198.00 +6 99999999999.95 5295036854775803 5295036854775803.00 +7 99999999999.96 5295036854775804 5295036854775804.00 +8 99999999999.97 5295036854775805 5295036854775805.00 +9 99999999999.98 5295036854775806 5295036854775806.00 +10 99999999999.99 5295036854775807 5295036854775807.00 +11 0.00 5223000000000000 5223000000000000.00 +select cidx, CINTEGER, CUINTEGER, GREATEST(CUINTEGER,CINTEGER,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +cidx CINTEGER CUINTEGER GREATEST(CUINTEGER,CINTEGER,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) +1 -7483646 1132516354 1132516354 +2 -7483645 1132516355 1132516355 +3 -7483644 1132516356 1132516356 +4 -7483643 1132516357 1132516357 +5 -7483642 1132516358 1132516358 +6 7483643 1147483643 1147483643 +7 7483644 1147483644 1147483644 +8 7483645 1147483645 1147483645 +9 7483646 1147483646 1147483646 +10 7483647 1147483647 1147483647 +11 0 1140000000 1140000000 +select cidx, CINTEGER, CUSMALLINT, GREATEST(CINTEGER,CUSMALLINT) from datatypetestm; +cidx CINTEGER CUSMALLINT GREATEST(CINTEGER,CUSMALLINT) +1 -7483646 19234 19234 +2 -7483645 19235 19235 +3 -7483644 19236 19236 +4 -7483643 19237 19237 +5 -7483642 19238 19238 +6 7483643 20763 7483643 +7 7483644 20764 7483644 +8 7483645 20765 7483645 +9 7483646 20766 7483646 +10 7483647 20767 7483647 +11 0 20000 20000 +select cidx, CINTEGER, CUTINYINT, GREATEST(CINTEGER,CUTINYINT) from datatypetestm; +cidx CINTEGER CUTINYINT GREATEST(CINTEGER,CUTINYINT) +1 -7483646 74 74 +2 -7483645 75 75 +3 -7483644 76 76 +4 -7483643 77 77 +5 -7483642 78 78 +6 7483643 123 7483643 +7 7483644 124 7483644 +8 7483645 125 7483645 +9 7483646 126 7483646 +10 7483647 127 7483647 +11 0 100 100 +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CSMALLINT CUSMALLINT GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) +1 -766 19234 19234 +2 -765 19235 19235 +3 -764 19236 19236 +4 -763 19237 19237 +5 -762 19238 19238 +6 763 20763 20763 +7 764 20764 20764 +8 765 20765 20765 +9 766 20766 20766 +10 767 20767 20767 +11 0 20000 20000 +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT) from datatypetestm; +cidx CSMALLINT CUSMALLINT GREATEST(CSMALLINT,CUSMALLINT) +1 -766 19234 19234 +2 -765 19235 19235 +3 -764 19236 19236 +4 -763 19237 19237 +5 -762 19238 19238 +6 763 20763 20763 +7 764 20764 20764 +8 765 20765 20765 +9 766 20766 20766 +10 767 20767 20767 +11 0 20000 20000 +select cidx, CSMALLINT, CUTINYINT, GREATEST(CSMALLINT,CUTINYINT) from datatypetestm; +cidx CSMALLINT CUTINYINT GREATEST(CSMALLINT,CUTINYINT) +1 -766 74 74 +2 -765 75 75 +3 -764 76 76 +4 -763 77 77 +5 -762 78 78 +6 763 123 763 +7 764 124 764 +8 765 125 765 +9 766 126 766 +10 767 127 767 +11 0 100 100 +select cidx, CUBIGINT from datatypetestm where GREATEST(CUBIGINT,CSMALLINT,CUTINYINT,10) <> CUBIGINT; +cidx CUBIGINT +select cidx, CUSMALLINT from datatypetestm where GREATEST(CUSMALLINT,CSMALLINT) <> CUSMALLINT; +cidx CUSMALLINT +select cidx, CUBIGINT from datatypetestm where GREATEST(CDECIMAL18,CUBIGINT,CUSMALLINT,CUTINYINT,10) <> CUBIGINT; +cidx CUBIGINT +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUSMALLINT) <> CDECIMAL18; +cidx CDECIMAL18 +1 -9999999999999 +2 -9999999999998 +3 -9999999999997 +4 -9999999999996 +5 -9999999999995 +11 0 +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUTINYINT) <> CDECIMAL18; +cidx CDECIMAL18 +1 -9999999999999 +2 -9999999999998 +3 -9999999999997 +4 -9999999999996 +5 -9999999999995 +11 0 +select cidx, CDECIMAL18_2 from datatypetestm where GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +cidx CDECIMAL18_2 +6 99999999999.95 +7 99999999999.96 +8 99999999999.97 +9 99999999999.98 +10 99999999999.99 +select cidx, CUSMALLINT from datatypetestm where GREATEST(CINTEGER,CUSMALLINT,CUTINYINT,10) <> CINTEGER; +cidx CUSMALLINT +1 19234 +2 19235 +3 19236 +4 19237 +5 19238 +11 20000 +select cidx, CINTEGER from datatypetestm where GREATEST(CINTEGER,CUTINYINT) <> CINTEGER; +cidx CINTEGER +1 -7483646 +2 -7483645 +3 -7483644 +4 -7483643 +5 -7483642 +11 0 +select cidx, CUSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +cidx CUSMALLINT +select cidx, CSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUTINYINT) <> CSMALLINT; +cidx CSMALLINT +1 -766 +2 -765 +3 -764 +4 -763 +5 -762 +11 0 +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CSMALLINT,CUTINYINT,10) <> CUTINYINT; +cidx CUTINYINT +6 123 +7 124 +8 125 +9 126 +10 127 +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CUTINYINT) <> CUTINYINT; +cidx CUTINYINT +UPDATE datatypetestm SET CUTINYINT=CTINYINT-1; +ERROR 22003: Out of range value for column 'CUTINYINT' at row 1 +UPDATE datatypetestm SET CUTINYINT=CTINYINT-1 WHERE CTINYINT > 0; +UPDATE datatypetestm SET CUSMALLINT=CSMALLINT-1; +ERROR 22003: Out of range value for column 'CUSMALLINT' at row 1 +UPDATE datatypetestm SET CUSMALLINT=CSMALLINT-1 WHERE CSMALLINT > 0; +UPDATE datatypetestm SET CUINTEGER=CINTEGER-1; +ERROR 22003: Out of range value for column 'CUINTEGER' at row 1 +UPDATE datatypetestm SET CUINTEGER=CINTEGER-1 WHERE CINTEGER > 0; +UPDATE datatypetestm SET CUBIGINT=CBIGINT-1; +ERROR 22003: Out of range value for column 'CUBIGINT' at row 1 +UPDATE datatypetestm SET CUBIGINT=CBIGINT-1 WHERE CBIGINT > 0; +select cidx, CUBIGINT, GREATEST(CUBIGINT,CBIGINT,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +cidx CUBIGINT GREATEST(CUBIGINT,CBIGINT,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) +1 5150963145224194 5150963145224194 +2 5150963145224195 5150963145224195 +3 5150963145224196 5150963145224196 +4 5150963145224197 5150963145224197 +5 5150963145224198 5150963145224198 +6 72036854775802 72036854775803 +7 72036854775803 72036854775804 +8 72036854775804 72036854775805 +9 72036854775805 72036854775806 +10 72036854775806 72036854775807 +11 5223000000000000 5223000000000000 +select cidx, CDECIMAL1, CUSMALLINT, GREATEST(CDECIMAL1,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL1 CUSMALLINT GREATEST(CDECIMAL1,CUSMALLINT,CUTINYINT,10) +1 -9 19234 19234 +2 -8 19235 19235 +3 -7 19236 19236 +4 -6 19237 19237 +5 -5 19238 19238 +6 5 762 762 +7 6 763 763 +8 7 764 764 +9 8 765 765 +10 9 766 766 +11 0 20000 20000 +select cidx, CDECIMAL1, CUTINYINT, GREATEST(CDECIMAL1,CUTINYINT) from datatypetestm; +cidx CDECIMAL1 CUTINYINT GREATEST(CDECIMAL1,CUTINYINT) +1 -9 74 74 +2 -8 75 75 +3 -7 76 76 +4 -6 77 77 +5 -5 78 78 +6 5 22 22 +7 6 23 23 +8 7 24 24 +9 8 25 25 +10 9 26 26 +11 0 100 100 +select cidx, CDECIMAL1, CUBIGINT, GREATEST(CDECIMAL1,CUBIGINT) from datatypetestm; +cidx CDECIMAL1 CUBIGINT GREATEST(CDECIMAL1,CUBIGINT) +1 -9 5150963145224194 5150963145224194 +2 -8 5150963145224195 5150963145224195 +3 -7 5150963145224196 5150963145224196 +4 -6 5150963145224197 5150963145224197 +5 -5 5150963145224198 5150963145224198 +6 5 72036854775802 72036854775802 +7 6 72036854775803 72036854775803 +8 7 72036854775804 72036854775804 +9 8 72036854775805 72036854775805 +10 9 72036854775806 72036854775806 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL4, CUSMALLINT, GREATEST(CDECIMAL4,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL4 CUSMALLINT GREATEST(CDECIMAL4,CUSMALLINT,CUTINYINT,10) +1 -999 19234 19234 +2 -998 19235 19235 +3 -997 19236 19236 +4 -996 19237 19237 +5 -995 19238 19238 +6 995 762 995 +7 996 763 996 +8 997 764 997 +9 998 765 998 +10 999 766 999 +11 0 20000 20000 +select cidx, CDECIMAL4, CUTINYINT, GREATEST(CDECIMAL4,CUTINYINT) from datatypetestm; +cidx CDECIMAL4 CUTINYINT GREATEST(CDECIMAL4,CUTINYINT) +1 -999 74 74 +2 -998 75 75 +3 -997 76 76 +4 -996 77 77 +5 -995 78 78 +6 995 22 995 +7 996 23 996 +8 997 24 997 +9 998 25 998 +10 999 26 999 +11 0 100 100 +select cidx, CDECIMAL4, CUBIGINT, GREATEST(CDECIMAL4,CUBIGINT) from datatypetestm; +cidx CDECIMAL4 CUBIGINT GREATEST(CDECIMAL4,CUBIGINT) +1 -999 5150963145224194 5150963145224194 +2 -998 5150963145224195 5150963145224195 +3 -997 5150963145224196 5150963145224196 +4 -996 5150963145224197 5150963145224197 +5 -995 5150963145224198 5150963145224198 +6 995 72036854775802 72036854775802 +7 996 72036854775803 72036854775803 +8 997 72036854775804 72036854775804 +9 998 72036854775805 72036854775805 +10 999 72036854775806 72036854775806 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL4_2, CUSMALLINT, GREATEST(CDECIMAL4_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL4_2 CUSMALLINT GREATEST(CDECIMAL4_2,CUSMALLINT,CUTINYINT,10) +1 -9.99 19234 19234.00 +2 -9.98 19235 19235.00 +3 -9.97 19236 19236.00 +4 -9.96 19237 19237.00 +5 -9.95 19238 19238.00 +6 9.95 762 762.00 +7 9.96 763 763.00 +8 9.97 764 764.00 +9 9.98 765 765.00 +10 9.99 766 766.00 +11 0.00 20000 20000.00 +select cidx, CDECIMAL4_2, CUTINYINT, GREATEST(CDECIMAL4_2,CUTINYINT) from datatypetestm; +cidx CDECIMAL4_2 CUTINYINT GREATEST(CDECIMAL4_2,CUTINYINT) +1 -9.99 74 74.00 +2 -9.98 75 75.00 +3 -9.97 76 76.00 +4 -9.96 77 77.00 +5 -9.95 78 78.00 +6 9.95 22 22.00 +7 9.96 23 23.00 +8 9.97 24 24.00 +9 9.98 25 25.00 +10 9.99 26 26.00 +11 0.00 100 100.00 +select cidx, CDECIMAL4_2, CUBIGINT, GREATEST(CDECIMAL4_2,CUBIGINT) from datatypetestm; +cidx CDECIMAL4_2 CUBIGINT GREATEST(CDECIMAL4_2,CUBIGINT) +1 -9.99 5150963145224194 5150963145224194.00 +2 -9.98 5150963145224195 5150963145224195.00 +3 -9.97 5150963145224196 5150963145224196.00 +4 -9.96 5150963145224197 5150963145224197.00 +5 -9.95 5150963145224198 5150963145224198.00 +6 9.95 72036854775802 72036854775802.00 +7 9.96 72036854775803 72036854775803.00 +8 9.97 72036854775804 72036854775804.00 +9 9.98 72036854775805 72036854775805.00 +10 9.99 72036854775806 72036854775806.00 +11 0.00 5223000000000000 5223000000000000.00 +select cidx, CDECIMAL9, CUSMALLINT, GREATEST(CDECIMAL9,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL9 CUSMALLINT GREATEST(CDECIMAL9,CUSMALLINT,CUTINYINT,10) +1 -999999 19234 19234 +2 -999998 19235 19235 +3 -999997 19236 19236 +4 -999996 19237 19237 +5 -999995 19238 19238 +6 999995 762 999995 +7 999996 763 999996 +8 999997 764 999997 +9 999998 765 999998 +10 999999 766 999999 +11 0 20000 20000 +select cidx, CDECIMAL9, CUTINYINT, GREATEST(CDECIMAL9,CUTINYINT) from datatypetestm; +cidx CDECIMAL9 CUTINYINT GREATEST(CDECIMAL9,CUTINYINT) +1 -999999 74 74 +2 -999998 75 75 +3 -999997 76 76 +4 -999996 77 77 +5 -999995 78 78 +6 999995 22 999995 +7 999996 23 999996 +8 999997 24 999997 +9 999998 25 999998 +10 999999 26 999999 +11 0 100 100 +select cidx, CDECIMAL9, CUBIGINT, GREATEST(CDECIMAL9,CUBIGINT) from datatypetestm; +cidx CDECIMAL9 CUBIGINT GREATEST(CDECIMAL9,CUBIGINT) +1 -999999 5150963145224194 5150963145224194 +2 -999998 5150963145224195 5150963145224195 +3 -999997 5150963145224196 5150963145224196 +4 -999996 5150963145224197 5150963145224197 +5 -999995 5150963145224198 5150963145224198 +6 999995 72036854775802 72036854775802 +7 999996 72036854775803 72036854775803 +8 999997 72036854775804 72036854775804 +9 999998 72036854775805 72036854775805 +10 999999 72036854775806 72036854775806 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL9_2, CUSMALLINT, GREATEST(CDECIMAL9_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL9_2 CUSMALLINT GREATEST(CDECIMAL9_2,CUSMALLINT,CUTINYINT,10) +1 -9999.99 19234 19234.00 +2 -9999.98 19235 19235.00 +3 -9999.97 19236 19236.00 +4 -9999.96 19237 19237.00 +5 -9999.95 19238 19238.00 +6 9999.95 762 9999.95 +7 9999.96 763 9999.96 +8 9999.97 764 9999.97 +9 9999.98 765 9999.98 +10 9999.99 766 9999.99 +11 0.00 20000 20000.00 +select cidx, CDECIMAL9_2, CUTINYINT, GREATEST(CDECIMAL9_2,CUTINYINT) from datatypetestm; +cidx CDECIMAL9_2 CUTINYINT GREATEST(CDECIMAL9_2,CUTINYINT) +1 -9999.99 74 74.00 +2 -9999.98 75 75.00 +3 -9999.97 76 76.00 +4 -9999.96 77 77.00 +5 -9999.95 78 78.00 +6 9999.95 22 9999.95 +7 9999.96 23 9999.96 +8 9999.97 24 9999.97 +9 9999.98 25 9999.98 +10 9999.99 26 9999.99 +11 0.00 100 100.00 +select cidx, CDECIMAL9_2, CUBIGINT, GREATEST(CDECIMAL9_2,CUBIGINT) from datatypetestm; +cidx CDECIMAL9_2 CUBIGINT GREATEST(CDECIMAL9_2,CUBIGINT) +1 -9999.99 5150963145224194 5150963145224194.00 +2 -9999.98 5150963145224195 5150963145224195.00 +3 -9999.97 5150963145224196 5150963145224196.00 +4 -9999.96 5150963145224197 5150963145224197.00 +5 -9999.95 5150963145224198 5150963145224198.00 +6 9999.95 72036854775802 72036854775802.00 +7 9999.96 72036854775803 72036854775803.00 +8 9999.97 72036854775804 72036854775804.00 +9 9999.98 72036854775805 72036854775805.00 +10 9999.99 72036854775806 72036854775806.00 +11 0.00 5223000000000000 5223000000000000.00 +select cidx, CDECIMAL18, CUSMALLINT, GREATEST(CDECIMAL18,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL18 CUSMALLINT GREATEST(CDECIMAL18,CUSMALLINT,CUTINYINT,10) +1 -9999999999999 19234 19234 +2 -9999999999998 19235 19235 +3 -9999999999997 19236 19236 +4 -9999999999996 19237 19237 +5 -9999999999995 19238 19238 +6 9999999999995 762 9999999999995 +7 9999999999996 763 9999999999996 +8 9999999999997 764 9999999999997 +9 9999999999998 765 9999999999998 +10 9999999999999 766 9999999999999 +11 0 20000 20000 +select cidx, CDECIMAL18, CUTINYINT, GREATEST(CDECIMAL18,CUTINYINT) from datatypetestm; +cidx CDECIMAL18 CUTINYINT GREATEST(CDECIMAL18,CUTINYINT) +1 -9999999999999 74 74 +2 -9999999999998 75 75 +3 -9999999999997 76 76 +4 -9999999999996 77 77 +5 -9999999999995 78 78 +6 9999999999995 22 9999999999995 +7 9999999999996 23 9999999999996 +8 9999999999997 24 9999999999997 +9 9999999999998 25 9999999999998 +10 9999999999999 26 9999999999999 +11 0 100 100 +select cidx, CDECIMAL18, CUBIGINT, GREATEST(CDECIMAL18,CUBIGINT) from datatypetestm; +cidx CDECIMAL18 CUBIGINT GREATEST(CDECIMAL18,CUBIGINT) +1 -9999999999999 5150963145224194 5150963145224194 +2 -9999999999998 5150963145224195 5150963145224195 +3 -9999999999997 5150963145224196 5150963145224196 +4 -9999999999996 5150963145224197 5150963145224197 +5 -9999999999995 5150963145224198 5150963145224198 +6 9999999999995 72036854775802 72036854775802 +7 9999999999996 72036854775803 72036854775803 +8 9999999999997 72036854775804 72036854775804 +9 9999999999998 72036854775805 72036854775805 +10 9999999999999 72036854775806 72036854775806 +11 0 5223000000000000 5223000000000000 +select cidx, CDECIMAL18_2, CUSMALLINT, GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CDECIMAL18_2 CUSMALLINT GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) +1 -99999999999.99 19234 19234.00 +2 -99999999999.98 19235 19235.00 +3 -99999999999.97 19236 19236.00 +4 -99999999999.96 19237 19237.00 +5 -99999999999.95 19238 19238.00 +6 99999999999.95 762 99999999999.95 +7 99999999999.96 763 99999999999.96 +8 99999999999.97 764 99999999999.97 +9 99999999999.98 765 99999999999.98 +10 99999999999.99 766 99999999999.99 +11 0.00 20000 20000.00 +select cidx, CDECIMAL18_2, CUTINYINT, GREATEST(CDECIMAL18_2,CUTINYINT) from datatypetestm; +cidx CDECIMAL18_2 CUTINYINT GREATEST(CDECIMAL18_2,CUTINYINT) +1 -99999999999.99 74 74.00 +2 -99999999999.98 75 75.00 +3 -99999999999.97 76 76.00 +4 -99999999999.96 77 77.00 +5 -99999999999.95 78 78.00 +6 99999999999.95 22 99999999999.95 +7 99999999999.96 23 99999999999.96 +8 99999999999.97 24 99999999999.97 +9 99999999999.98 25 99999999999.98 +10 99999999999.99 26 99999999999.99 +11 0.00 100 100.00 +select cidx, CDECIMAL18_2, CUBIGINT, GREATEST(CDECIMAL18_2,CUBIGINT) from datatypetestm; +cidx CDECIMAL18_2 CUBIGINT GREATEST(CDECIMAL18_2,CUBIGINT) +1 -99999999999.99 5150963145224194 5150963145224194.00 +2 -99999999999.98 5150963145224195 5150963145224195.00 +3 -99999999999.97 5150963145224196 5150963145224196.00 +4 -99999999999.96 5150963145224197 5150963145224197.00 +5 -99999999999.95 5150963145224198 5150963145224198.00 +6 99999999999.95 72036854775802 72036854775802.00 +7 99999999999.96 72036854775803 72036854775803.00 +8 99999999999.97 72036854775804 72036854775804.00 +9 99999999999.98 72036854775805 72036854775805.00 +10 99999999999.99 72036854775806 72036854775806.00 +11 0.00 5223000000000000 5223000000000000.00 +select cidx, CINTEGER, CUINTEGER, GREATEST(CUINTEGER,CINTEGER,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +cidx CINTEGER CUINTEGER GREATEST(CUINTEGER,CINTEGER,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) +1 -7483646 1132516354 1132516354 +2 -7483645 1132516355 1132516355 +3 -7483644 1132516356 1132516356 +4 -7483643 1132516357 1132516357 +5 -7483642 1132516358 1132516358 +6 7483643 7483642 7483643 +7 7483644 7483643 7483644 +8 7483645 7483644 7483645 +9 7483646 7483645 7483646 +10 7483647 7483646 7483647 +11 0 1140000000 1140000000 +select cidx, CINTEGER, CUSMALLINT, GREATEST(CINTEGER,CUSMALLINT) from datatypetestm; +cidx CINTEGER CUSMALLINT GREATEST(CINTEGER,CUSMALLINT) +1 -7483646 19234 19234 +2 -7483645 19235 19235 +3 -7483644 19236 19236 +4 -7483643 19237 19237 +5 -7483642 19238 19238 +6 7483643 762 7483643 +7 7483644 763 7483644 +8 7483645 764 7483645 +9 7483646 765 7483646 +10 7483647 766 7483647 +11 0 20000 20000 +select cidx, CINTEGER, CUTINYINT, GREATEST(CINTEGER,CUTINYINT) from datatypetestm; +cidx CINTEGER CUTINYINT GREATEST(CINTEGER,CUTINYINT) +1 -7483646 74 74 +2 -7483645 75 75 +3 -7483644 76 76 +4 -7483643 77 77 +5 -7483642 78 78 +6 7483643 22 7483643 +7 7483644 23 7483644 +8 7483645 24 7483645 +9 7483646 25 7483646 +10 7483647 26 7483647 +11 0 100 100 +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) from datatypetestm; +cidx CSMALLINT CUSMALLINT GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) +1 -766 19234 19234 +2 -765 19235 19235 +3 -764 19236 19236 +4 -763 19237 19237 +5 -762 19238 19238 +6 763 762 763 +7 764 763 764 +8 765 764 765 +9 766 765 766 +10 767 766 767 +11 0 20000 20000 +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT) from datatypetestm; +cidx CSMALLINT CUSMALLINT GREATEST(CSMALLINT,CUSMALLINT) +1 -766 19234 19234 +2 -765 19235 19235 +3 -764 19236 19236 +4 -763 19237 19237 +5 -762 19238 19238 +6 763 762 763 +7 764 763 764 +8 765 764 765 +9 766 765 766 +10 767 766 767 +11 0 20000 20000 +select cidx, CSMALLINT, CUTINYINT, GREATEST(CSMALLINT,CUTINYINT) from datatypetestm; +cidx CSMALLINT CUTINYINT GREATEST(CSMALLINT,CUTINYINT) +1 -766 74 74 +2 -765 75 75 +3 -764 76 76 +4 -763 77 77 +5 -762 78 78 +6 763 22 763 +7 764 23 764 +8 765 24 765 +9 766 25 766 +10 767 26 767 +11 0 100 100 +select cidx, CUBIGINT from datatypetestm where GREATEST(CUBIGINT,CSMALLINT,CUTINYINT,10) <> CUBIGINT; +cidx CUBIGINT +select cidx, CUSMALLINT from datatypetestm where GREATEST(CUSMALLINT,CSMALLINT) <> CUSMALLINT; +cidx CUSMALLINT +6 762 +7 763 +8 764 +9 765 +10 766 +select cidx, CUBIGINT from datatypetestm where GREATEST(CDECIMAL18,CUBIGINT,CUSMALLINT,CUTINYINT,10) <> CUBIGINT; +cidx CUBIGINT +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUSMALLINT) <> CDECIMAL18; +cidx CDECIMAL18 +1 -9999999999999 +2 -9999999999998 +3 -9999999999997 +4 -9999999999996 +5 -9999999999995 +11 0 +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUTINYINT) <> CDECIMAL18; +cidx CDECIMAL18 +1 -9999999999999 +2 -9999999999998 +3 -9999999999997 +4 -9999999999996 +5 -9999999999995 +11 0 +select cidx, CDECIMAL18_2 from datatypetestm where GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +cidx CDECIMAL18_2 +6 99999999999.95 +7 99999999999.96 +8 99999999999.97 +9 99999999999.98 +10 99999999999.99 +select cidx, CUSMALLINT from datatypetestm where GREATEST(CINTEGER,CUSMALLINT,CUTINYINT,10) <> CINTEGER; +cidx CUSMALLINT +1 19234 +2 19235 +3 19236 +4 19237 +5 19238 +11 20000 +select cidx, CINTEGER from datatypetestm where GREATEST(CINTEGER,CUTINYINT) <> CINTEGER; +cidx CINTEGER +1 -7483646 +2 -7483645 +3 -7483644 +4 -7483643 +5 -7483642 +11 0 +select cidx, CUSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +cidx CUSMALLINT +6 762 +7 763 +8 764 +9 765 +10 766 +select cidx, CSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUTINYINT) <> CSMALLINT; +cidx CSMALLINT +1 -766 +2 -765 +3 -764 +4 -763 +5 -762 +11 0 +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CSMALLINT,CUTINYINT,10) <> CUTINYINT; +cidx CUTINYINT +6 22 +7 23 +8 24 +9 25 +10 26 +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CUTINYINT) <> CUTINYINT; +cidx CUTINYINT +6 22 +7 23 +8 24 +9 25 +10 26 +ALTER TABLE datatypetestm DROP COLUMN CUTINYINT; +ALTER TABLE datatypetestm DROP COLUMN CUSMALLINT; +ALTER TABLE datatypetestm DROP COLUMN CUINTEGER; +ALTER TABLE datatypetestm DROP COLUMN CUBIGINT; +DROP DATABASE unsigned_greatest_test; diff --git a/mysql-test/suite/tianmu/r/unsigned_math.result b/mysql-test/suite/tianmu/r/unsigned_math.result new file mode 100644 index 0000000000..2ceb88eb4a --- /dev/null +++ b/mysql-test/suite/tianmu/r/unsigned_math.result @@ -0,0 +1,247 @@ +# +# Test unsigned_math +# +DROP DATABASE IF EXISTS unsigned_math_test; +CREATE DATABASE unsigned_math_test; +USE unsigned_math_test; +create table j1 (j1_key int); +insert into j1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(null); +ALTER TABLE j1 ADD COLUMN CUTINYINT TINYINT UNSIGNED; +ALTER TABLE j1 ADD COLUMN CUSMALLINT SMALLINT UNSIGNED; +ALTER TABLE j1 ADD COLUMN CUINTEGER INT UNSIGNED; +ALTER TABLE j1 ADD COLUMN CUBIGINT BIGINT UNSIGNED; +UPDATE j1 SET CUTINYINT=127; +UPDATE j1 SET CUSMALLINT=32767; +UPDATE j1 SET CUINTEGER=2147483647; +UPDATE j1 SET CUBIGINT=9223372036854775807; +SELECT 'ABS1', ABS(CUTINYINT) FROM j1 WHERE j1_key=1; +ABS1 ABS(CUTINYINT) +ABS1 127 +SELECT 'ABS2', ABS(CUSMALLINT) FROM j1 WHERE j1_key=1; +ABS2 ABS(CUSMALLINT) +ABS2 32767 +SELECT 'ABS3', ABS(CUINTEGER) FROM j1 WHERE j1_key=1; +ABS3 ABS(CUINTEGER) +ABS3 2147483647 +SELECT 'ABS4', ABS(CUBIGINT) FROM j1 WHERE j1_key=1; +ABS4 ABS(CUBIGINT) +ABS4 9223372036854775807 +SELECT 'CEIL1', CEIL(CUTINYINT) FROM j1 WHERE j1_key=1; +CEIL1 CEIL(CUTINYINT) +CEIL1 127 +SELECT 'CEIL2', CEIL(CUSMALLINT) FROM j1 WHERE j1_key=1; +CEIL2 CEIL(CUSMALLINT) +CEIL2 32767 +SELECT 'CEIL3', CEIL(CUINTEGER) FROM j1 WHERE j1_key=1; +CEIL3 CEIL(CUINTEGER) +CEIL3 2147483647 +SELECT 'CEIL4', CEIL(CUBIGINT) FROM j1 WHERE j1_key=1; +CEIL4 CEIL(CUBIGINT) +CEIL4 9223372036854775807 +SELECT 'FLOOR1', FLOOR(CUTINYINT) FROM j1 WHERE j1_key=1; +FLOOR1 FLOOR(CUTINYINT) +FLOOR1 127 +SELECT 'FLOOR2', FLOOR(CUSMALLINT) FROM j1 WHERE j1_key=1; +FLOOR2 FLOOR(CUSMALLINT) +FLOOR2 32767 +SELECT 'FLOOR3', FLOOR(CUINTEGER) FROM j1 WHERE j1_key=1; +FLOOR3 FLOOR(CUINTEGER) +FLOOR3 2147483647 +SELECT 'FLOOR4', FLOOR(CUBIGINT) FROM j1 WHERE j1_key=1; +FLOOR4 FLOOR(CUBIGINT) +FLOOR4 9223372036854775807 +SELECT 'DIV1', CUINTEGER DIV CUTINYINT FROM j1 WHERE j1_key=1; +DIV1 CUINTEGER DIV CUTINYINT +DIV1 16909320 +SELECT 'DIV2', CUINTEGER DIV CUSMALLINT FROM j1 WHERE j1_key=1; +DIV2 CUINTEGER DIV CUSMALLINT +DIV2 65538 +SELECT 'DIV3', CUBIGINT DIV CUTINYINT FROM j1 WHERE j1_key=1; +DIV3 CUBIGINT DIV CUTINYINT +DIV3 72624976668147841 +SELECT 'DIV4', CUBIGINT DIV CUSMALLINT FROM j1 WHERE j1_key=1; +DIV4 CUBIGINT DIV CUSMALLINT +DIV4 281483566907400 +SELECT 'DIV5', CUBIGINT DIV CUINTEGER FROM j1 WHERE j1_key=1; +DIV5 CUBIGINT DIV CUINTEGER +DIV5 4294967298 +SELECT 'DIV6', CUINTEGER DIV CUBIGINT FROM j1 WHERE j1_key=1; +DIV6 CUINTEGER DIV CUBIGINT +DIV6 0 +SELECT 'EXP1', EXP(CUTINYINT) FROM j1 WHERE j1_key=1; +EXP1 EXP(CUTINYINT) +EXP1 1.4302079958348105e55 +SELECT 'LN1', LN(CUTINYINT) FROM j1 WHERE j1_key=1; +LN1 LN(CUTINYINT) +LN1 4.844187086458591 +SELECT 'LN2', LN(CUSMALLINT) FROM j1 WHERE j1_key=1; +LN2 LN(CUSMALLINT) +LN2 10.397177190355384 +SELECT 'LN3', LN(CUINTEGER) FROM j1 WHERE j1_key=1; +LN3 LN(CUINTEGER) +LN3 21.487562596892644 +SELECT 'LN4', LN(CUBIGINT) FROM j1 WHERE j1_key=1; +LN4 LN(CUBIGINT) +LN4 43.66827237527655 +SELECT 'LOG1', LOG(CUTINYINT) FROM j1 WHERE j1_key=1; +LOG1 LOG(CUTINYINT) +LOG1 4.844187086458591 +SELECT 'LOG2', LOG(CUSMALLINT) FROM j1 WHERE j1_key=1; +LOG2 LOG(CUSMALLINT) +LOG2 10.397177190355384 +SELECT 'LOG3', LOG(CUINTEGER) FROM j1 WHERE j1_key=1; +LOG3 LOG(CUINTEGER) +LOG3 21.487562596892644 +SELECT 'LOG4', LOG(CUBIGINT) FROM j1 WHERE j1_key=1; +LOG4 LOG(CUBIGINT) +LOG4 43.66827237527655 +SELECT 'LOG21', LOG2(CUTINYINT) FROM j1 WHERE j1_key=1; +LOG21 LOG2(CUTINYINT) +LOG21 6.988684686772166 +SELECT 'LOG22', LOG2(CUSMALLINT) FROM j1 WHERE j1_key=1; +LOG22 LOG2(CUSMALLINT) +LOG22 14.999955971769559 +SELECT 'LOG23', LOG2(CUINTEGER) FROM j1 WHERE j1_key=1; +LOG23 LOG2(CUINTEGER) +LOG23 30.999999999328196 +SELECT 'LOG24', LOG2(CUBIGINT) FROM j1 WHERE j1_key=1; +LOG24 LOG2(CUBIGINT) +LOG24 63 +SELECT 'LOG101', LOG10(CUTINYINT) FROM j1 WHERE j1_key=1; +LOG101 LOG10(CUTINYINT) +LOG101 2.103803720955957 +SELECT 'LOG102', LOG10(CUSMALLINT) FROM j1 WHERE j1_key=1; +LOG102 LOG10(CUSMALLINT) +LOG102 4.515436681141699 +SELECT 'LOG103', LOG10(CUINTEGER) FROM j1 WHERE j1_key=1; +LOG103 LOG10(CUINTEGER) +LOG103 9.331929865381182 +SELECT 'LOG104', LOG10(CUBIGINT) FROM j1 WHERE j1_key=1; +LOG104 LOG10(CUBIGINT) +LOG104 18.964889726830815 +SELECT 'MD51', MD5(CUTINYINT) FROM j1 WHERE j1_key=1; +MD51 MD5(CUTINYINT) +MD51 ec5decca5ed3d6b8079e2e7e7bacc9f2 +SELECT 'MD52', MD5(CUSMALLINT) FROM j1 WHERE j1_key=1; +MD52 MD5(CUSMALLINT) +MD52 7cf91b300ff3ecef82c59dd47b89253a +SELECT 'MD53', MD5(CUINTEGER) FROM j1 WHERE j1_key=1; +MD53 MD5(CUINTEGER) +MD53 c588c0a459f4ccc6f3dd26518d24707a +SELECT 'MD54', MD5(CUBIGINT) FROM j1 WHERE j1_key=1; +MD54 MD5(CUBIGINT) +MD54 15767b252275cf5107bba9267b88e787 +SELECT 'MOD1', MOD(CUTINYINT,10) FROM j1 WHERE j1_key=1; +MOD1 MOD(CUTINYINT,10) +MOD1 7 +SELECT 'MOD2', MOD(CUSMALLINT,9) FROM j1 WHERE j1_key=1; +MOD2 MOD(CUSMALLINT,9) +MOD2 7 +SELECT 'MOD3', MOD(CUINTEGER,8) FROM j1 WHERE j1_key=1; +MOD3 MOD(CUINTEGER,8) +MOD3 7 +SELECT 'MOD4', MOD(CUBIGINT,16) FROM j1 WHERE j1_key=1; +MOD4 MOD(CUBIGINT,16) +MOD4 15 +SELECT 'NULLIF1', NULLIF(CUTINYINT,127) FROM j1 WHERE j1_key=1; +NULLIF1 NULLIF(CUTINYINT,127) +NULLIF1 NULL +SELECT 'NULLIF2', NULLIF(CUSMALLINT,32767) FROM j1 WHERE j1_key=1; +NULLIF2 NULLIF(CUSMALLINT,32767) +NULLIF2 NULL +SELECT 'NULLIF3', NULLIF(CUINTEGER,2147483647) FROM j1 WHERE j1_key=1; +NULLIF3 NULLIF(CUINTEGER,2147483647) +NULLIF3 NULL +SELECT 'NULLIF4', NULLIF(CUBIGINT,9223372036854775807) FROM j1 WHERE j1_key=1; +NULLIF4 NULLIF(CUBIGINT,9223372036854775807) +NULLIF4 NULL +SELECT 'NULLIF5', NULLIF(CUTINYINT,127) FROM j1 WHERE j1_key=1; +NULLIF5 NULLIF(CUTINYINT,127) +NULLIF5 NULL +SELECT 'NULLIF6', NULLIF(CUSMALLINT,32767) FROM j1 WHERE j1_key=1; +NULLIF6 NULLIF(CUSMALLINT,32767) +NULLIF6 NULL +SELECT 'NULLIF7', NULLIF(CUINTEGER,2147483647) FROM j1 WHERE j1_key=1; +NULLIF7 NULLIF(CUINTEGER,2147483647) +NULLIF7 NULL +SELECT 'NULLIF8', NULLIF(CUBIGINT,9223372036854775807) FROM j1 WHERE j1_key=1; +NULLIF8 NULLIF(CUBIGINT,9223372036854775807) +NULLIF8 NULL +SELECT 'POW1', POW(CUTINYINT,4) FROM j1 WHERE j1_key=1; +POW1 POW(CUTINYINT,4) +POW1 260144641 +SELECT 'POW2', POW(CUSMALLINT,4) FROM j1 WHERE j1_key=1; +POW2 POW(CUSMALLINT,4) +POW2 1.1527807735608115e18 +SELECT 'POW3', POW(CUINTEGER,4) FROM j1 WHERE j1_key=1; +POW3 POW(CUINTEGER,4) +POW3 2.1267647892944573e37 +SELECT 'POW4', POW(CUBIGINT,4) FROM j1 WHERE j1_key=1; +POW4 POW(CUBIGINT,4) +POW4 7.237005577332262e75 +SELECT 'ROUND1', ROUND(CUTINYINT) FROM j1 WHERE j1_key=1; +ROUND1 ROUND(CUTINYINT) +ROUND1 127 +SELECT 'ROUND2', ROUND(CUSMALLINT) FROM j1 WHERE j1_key=1; +ROUND2 ROUND(CUSMALLINT) +ROUND2 32767 +SELECT 'ROUND3', ROUND(CUINTEGER) FROM j1 WHERE j1_key=1; +ROUND3 ROUND(CUINTEGER) +ROUND3 2147483647 +SELECT 'ROUND4', ROUND(CUBIGINT) FROM j1 WHERE j1_key=1; +ROUND4 ROUND(CUBIGINT) +ROUND4 9223372036854775807 +SELECT 'SIGN1', SIGN(CUTINYINT) FROM j1 WHERE j1_key=1; +SIGN1 SIGN(CUTINYINT) +SIGN1 1 +SELECT 'SIGN2', SIGN(CUSMALLINT) FROM j1 WHERE j1_key=1; +SIGN2 SIGN(CUSMALLINT) +SIGN2 1 +SELECT 'SIGN3', SIGN(CUINTEGER) FROM j1 WHERE j1_key=1; +SIGN3 SIGN(CUINTEGER) +SIGN3 1 +SELECT 'SIGN4', SIGN(CUBIGINT) FROM j1 WHERE j1_key=1; +SIGN4 SIGN(CUBIGINT) +SIGN4 1 +SELECT 'SIN1', SIN(CUTINYINT) FROM j1 WHERE j1_key=1; +SIN1 SIN(CUTINYINT) +SIN1 0.972630067242408 +SELECT 'SIN2', SIN(CUSMALLINT) FROM j1 WHERE j1_key=1; +SIN2 SIN(CUSMALLINT) +SIN2 0.18750655394138943 +SELECT 'SIN3', SIN(CUINTEGER) FROM j1 WHERE j1_key=1; +SIN3 SIN(CUINTEGER) +SIN3 -0.7249165551445564 +SELECT 'SIN4', SIN(CUBIGINT) FROM j1 WHERE j1_key=1; +SIN4 SIN(CUBIGINT) +SIN4 0.9999303766734422 +SELECT 'SQRT1', SQRT(CUTINYINT) FROM j1 WHERE j1_key=1; +SQRT1 SQRT(CUTINYINT) +SQRT1 11.269427669584644 +SELECT 'SQRT2', SQRT(CUSMALLINT) FROM j1 WHERE j1_key=1; +SQRT2 SQRT(CUSMALLINT) +SQRT2 181.01657382681842 +SELECT 'SQRT3', SQRT(CUINTEGER) FROM j1 WHERE j1_key=1; +SQRT3 SQRT(CUINTEGER) +SQRT3 46340.950001051984 +SELECT 'SQRT4', SQRT(CUBIGINT) FROM j1 WHERE j1_key=1; +SQRT4 SQRT(CUBIGINT) +SQRT4 3037000499.97605 +SELECT 'TAN1', TAN(CUTINYINT) FROM j1 WHERE j1_key=1; +TAN1 TAN(CUTINYINT) +TAN1 4.185891831851989 +SELECT 'TAN2', TAN(CUSMALLINT) FROM j1 WHERE j1_key=1; +TAN2 TAN(CUSMALLINT) +TAN2 0.19089234430221486 +SELECT 'TAN3', TAN(CUINTEGER) FROM j1 WHERE j1_key=1; +TAN3 TAN(CUINTEGER) +TAN3 1.0523779637351338 +SELECT 'TAN4', TAN(CUBIGINT) FROM j1 WHERE j1_key=1; +TAN4 TAN(CUBIGINT) +TAN4 84.73931296875567 +ALTER TABLE j1 DROP COLUMN CUTINYINT; +ALTER TABLE j1 DROP COLUMN CUSMALLINT; +ALTER TABLE j1 DROP COLUMN CUINTEGER; +ALTER TABLE j1 DROP COLUMN CUBIGINT; +drop table j1; +DROP DATABASE unsigned_math_test; diff --git a/mysql-test/suite/tianmu/r/zerofill.result b/mysql-test/suite/tianmu/r/zerofill.result new file mode 100644 index 0000000000..aeececed0c --- /dev/null +++ b/mysql-test/suite/tianmu/r/zerofill.result @@ -0,0 +1,70 @@ +# +# Test zerofill +# +DROP DATABASE IF EXISTS zerofill_test; +CREATE DATABASE zerofill_test; +USE zerofill_test; +CREATE TABLE st1 (x INT(8) ZEROFILL NOT NULL, y INT(8) NOT NULL); +INSERT INTO st1 VALUES +(1, 1), +(12, 12), +(123, 123), +(1234567, 1234567), +(123456789, 123456789); +select * from st1; +x y +00000001 1 +00000012 12 +00000123 123 +01234567 1234567 +123456789 123456789 +CREATE TABLE st2(id int PRIMARY KEY,val TINYINT(10) ZEROFILL); +INSERT INTO st2 VALUES(1,12),(2,7),(4,101); +SELECT * FROM st2; +id val +1 0000000012 +2 0000000007 +4 0000000101 +SELECT val+1 FROM st2 WHERE id=2; +val+1 +8 +create table st3 (id1 int,id2 int(5)); +insert into st3 values (1,1); +alter table st3 modify id1 int zerofill; +alter table st3 modify id2 int(5) zerofill; +insert into st3 values (1,1234567); +select * from st3; +id1 id2 +0000000001 00001 +0000000001 1234567 +CREATE TABLE st4( +`id` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT, +`col2` varchar(20) NOT NULL, +`year` year(4) DEFAULT NULL, +`month` int(2) unsigned zerofill DEFAULT NULL, +`day` int(2) unsigned zerofill DEFAULT NULL, +PRIMARY KEY (`id`) +); +insert into st4 values(1,'test',2021,12,12); +alter table st4 MODIFY id int; +select * from st4; +id col2 year month day +1 test 2021 12 12 +CREATE TABLE st5( +num1 TINYINT, +num2 TINYINT UNSIGNED, +num3 INT, +num4 INT ZEROFILL, +num5 INT UNSIGNED ZEROFILL +); +INSERT st5(num1,num2) VALUES(-5,-5); +ERROR 22003: Out of range value for column 'num2' at row 1 +INSERT st5(num3,num4) VALUES(123,123); +INSERT st5 VALUES(0,0,0,0,0); +INSERT st5(num3,num4,num5) VALUES(123,123,123); +SELECT * FROM st5; +num1 num2 num3 num4 num5 +NULL NULL 123 0000000123 NULL +0 0 0 0000000000 0000000000 +NULL NULL 123 0000000123 0000000123 +DROP DATABASE zerofill_test; diff --git a/mysql-test/suite/tianmu/t/escape.test b/mysql-test/suite/tianmu/t/escape.test new file mode 100644 index 0000000000..dbd976c58e --- /dev/null +++ b/mysql-test/suite/tianmu/t/escape.test @@ -0,0 +1,90 @@ +--source include/have_tianmu.inc + +--echo # +--echo # Test escape +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS escape_test; +--enable_warnings + +CREATE DATABASE escape_test; +USE escape_test; + +CREATE TABLE `st1` ( + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `name` VARCHAR(255) DEFAULT NULL, + `uid` VARCHAR(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) DEFAULT CHARSET=utf8; + +INSERT INTO st1 (NAME,uid) VALUES('zhangsan','hello'); +INSERT INTO st1 (NAME,uid) VALUES('lisi_wu','world'); +INSERT INTO st1 (NAME,uid) VALUES('wangwu%','world'); +INSERT INTO st1 (NAME,uid) VALUES('%a','world'); +INSERT INTO st1 (NAME,uid) VALUES('%_','world'); +select * from st1; + +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "san", "%"); + +# If we want to match % or _, we must use \ to escape + +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "%", "%"); + +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\%", "%"); + +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\%", "%"); +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "$%", "%") ESCAPE "$"; + +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\_", "%"); +SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "a_", "%") ESCAPE "a"; + +SELECT * FROM st1 WHERE NAME LIKE "a%_" ESCAPE "a" ; +SELECT * FROM st1 WHERE NAME LIKE "a%a" ESCAPE "a" ; +#bug1157 SELECT * FROM st1 WHERE NAME LIKE "a%a_" ESCAPE "a"; + +drop table st1; +CREATE TABLE `st1` ( + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `name` VARCHAR(255) DEFAULT NULL, + `uid` VARCHAR(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) DEFAULT CHARSET=utf8; + +INSERT INTO st1 (NAME,uid) VALUES('123hello','hello'); +INSERT INTO st1 (NAME,uid) VALUES('123hello123','world'); +INSERT INTO st1 (NAME,uid) VALUES('hello123','world'); +INSERT INTO st1 (NAME,uid) VALUES('_hello','world'); + +select * from st1; + +select * from st1 where name like '%hello%'; +select * from st1 where name like '_hello'; +select * from st1 where name like 'hello12_'; +#bug1157 select * from st1 where name like '/_hello' escape '/'; + + +create table st2(id int ,column_2 varchar(10),column_3 varchar(10)); +insert into st2 values(1,'_a\\\\','111111'); +insert into st2 values(2,'12%','%12%'); +insert into st2 values(3,'a_a','a%'); +insert into st2 values(4,'_a\\','_12%'); +insert into st2 values(5,'\\a','\\\\_a%12%'); + +select * from st2 where column_2 like '%\\\%' ; + +select * from st2 where column_2 like '%\%' ; +select * from st2 where column_2 like '%\\%' ; + +select * from st2 where column_2 like '%\_%' ; + +select * from st2 where column_2 like '%?_%' escape '?'; + +#bug1162 select * from st2 where column_2 like '%?_a\\%'; +#bug1162 select * from st2 where column_2 like '%\_a\\%'; + +#bug1162 select * from st2 where column_2 like '%?_a?\%'; +#bug1162 select * from st2 where column_2 like '%\_a\\%'; + +# clean up +DROP DATABASE escape_test; diff --git a/mysql-test/suite/tianmu/t/replace_into.test b/mysql-test/suite/tianmu/t/replace_into.test new file mode 100644 index 0000000000..f14c9bdc7b --- /dev/null +++ b/mysql-test/suite/tianmu/t/replace_into.test @@ -0,0 +1,100 @@ +--source include/have_tianmu.inc + +--echo # +--echo # Test replace into +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS replace_into_test; +--enable_warnings +CREATE DATABASE replace_into_test; +USE replace_into_test; + +CREATE TABLE test ( + id INT NOT NULL, + test VARCHAR(64) DEFAULT NULL, + name TIMESTAMP NOT NULL, + PRIMARY KEY (id) +); +insert into test values(1,'old','2014-08-20 18:47:00'); +insert into test values(2,'old','2014-08-20 18:47:00'); +REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42'); +REPLACE INTO test VALUES (2, 'New', '2014-08-20 18:47:42'); +delete from test where id=1; +REPLACE INTO test VALUES (2, 'Newnew', '2014-08-20 18:47:42'); +REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42'); +REPLACE INTO test VALUES (1, 'Newnew', '2014-08-20 18:47:42'); +select * from test; + +CREATE TABLE test1 ( + id INT NOT NULL, + test VARCHAR(64) DEFAULT NULL, + id1 int NOT NULL, + PRIMARY KEY (id,id1) +); +insert into test1 values(1,'old',1); +insert into test1 values(2,'old',2); +REPLACE INTO test1 VALUES (1, 'New', '8'); +REPLACE INTO test1 VALUES (1, 'New', '1'); +REPLACE INTO test1 VALUES (8, 'New', '2'); +select * from test1; + +CREATE TABLE `insert_relpace_into_test` ( + `id` int(10), + `uniq_id` varchar(32), + `filed_a` varchar(32) DEFAULT '' , + `filed_b` varchar(32) DEFAULT '', + `version` int(10) DEFAULT '0', + PRIMARY KEY (`id`) +); + +CREATE TABLE `insert_relpace_into_test2` ( + `id` int(10), + `uniq_id` varchar(32) DEFAULT NULL, + `filed_a` varchar(32) DEFAULT '', + `filed_b` varchar(32) DEFAULT '', + `version` int(10) DEFAULT '0', + PRIMARY KEY (`id`) +); +REPLACE INTO insert_relpace_into_test2 +VALUES + ( 1,'1003', 'ziduan a', 'ziduan b', 1 ), + ( 2,'1005', 'ziduan _2_2', 'ziduan b_2', 1 ); + +REPLACE INTO insert_relpace_into_test +VALUES + ( 3,'1003', 'ziduan a', 'ziduan b', 1 ), + ( 4,'1005', 'ziduan _2_2', 'ziduan b_2', 1 ); + +REPLACE INTO insert_relpace_into_test ( id,uniq_id, filed_a, filed_b, version ) +SELECT id,uniq_id, filed_a, filed_b, version FROM insert_relpace_into_test2; + +select * from insert_relpace_into_test; + +REPLACE INTO insert_relpace_into_test +SET id=5,uniq_id='1003',filed_a='ziduan _2_2',filed_b='ziduan b_2'; + +select * from insert_relpace_into_test; + +REPLACE INTO insert_relpace_into_test +VALUES + ( 3,'1003new', 'ziduan a', 'ziduan b', 1 ), + ( 4,'1005new', 'ziduan _2_2', 'ziduan b_2', 1 ); + +select * from insert_relpace_into_test; + +REPLACE INTO insert_relpace_into_test ( id,uniq_id, filed_a, filed_b, version ) +SELECT id,uniq_id, filed_a, filed_b, version FROM insert_relpace_into_test2; + +REPLACE INTO insert_relpace_into_test +SET id=5,uniq_id='1003new',filed_a='ziduan _2_2',filed_b='ziduan b_2'; + +select * from insert_relpace_into_test; + +drop table insert_relpace_into_test; +drop table insert_relpace_into_test2; +drop table test; +drop table test1; + +# clean up +DROP DATABASE replace_into_test; diff --git a/mysql-test/suite/tianmu/t/unsigned.test b/mysql-test/suite/tianmu/t/unsigned.test new file mode 100644 index 0000000000..3b3b880a99 --- /dev/null +++ b/mysql-test/suite/tianmu/t/unsigned.test @@ -0,0 +1,112 @@ +--source include/have_tianmu.inc + +--echo # +--echo # Test unsigned +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS unsigned_test; +--enable_warnings + +CREATE DATABASE unsigned_test; +USE unsigned_test; + +create table st1 (ukey int, c1 tinyint unsigned, c2 smallint unsigned, c3 int unsigned, c4 bigint unsigned); +insert into st1 values (1,2,3,4,5), (2,127,32767,2147483647,9223372036854775807); +select 'q1', st1.* from st1 order by 1; +--error ER_WARN_DATA_OUT_OF_RANGE +insert into st1 values (3,-127,-32766,-2147483646,-9223372036854775806); +insert into st1 values (4,126,32766,2147483646,9223372036854775806),(5,125,32765,2147483645,9223372036854775805); +--error ER_WARN_DATA_OUT_OF_RANGE +insert into st1 values (6,1255,165535,14294967295,118446744073709551615); +select 'q2', st1.* from st1 where ukey > 2 order by 1; + +insert into st1 values (7,NULL,NULL,NULL,NULL); +select 'q3', st1.* from st1 where ukey=7; + +--error ER_WARN_DATA_OUT_OF_RANGE +update st1 set c4=-9223372036854775806 where ukey=1; +--error ER_WARN_DATA_OUT_OF_RANGE +update st1 set c3=-2147483646 where ukey=1; +--error ER_WARN_DATA_OUT_OF_RANGE +update st1 set c2=-32766 where ukey=1; +--error ER_WARN_DATA_OUT_OF_RANGE +update st1 set c1=-127 where ukey between 0 and 2; +select 'q4', st1.* from st1 where ukey<2; + +update st1 set c3=2147483646 where ukey=4; +update st1 set c2=32766 where ukey=4; +update st1 set c1=125 where ukey between 4 and 5; +select 'q5', st1.* from st1 where ukey>3 order by 2; + +create table st2 (ukey int, c1 tinyint unsigned, c2 smallint unsigned, c3 int unsigned, c4 bigint unsigned); +insert into st2 values (8,125,32764,2147483645,9223372036854775800), (9,126,32766,2147483646,9223372036854775800),(10,127,32767,2147483647,9223372036854775801); +select 'q6', st2.* from st2 where c1 between 125 and 127; +select 'q7', st2.* from st2 where c2 between 32764 and 32767; +select 'q8', st2.* from st2 where c3 between 2147483645 and 2147483647; +select 'q9', st2.* from st2 where c4 between 9223372036854775800 and 9223372036854775801; + +--disable_warnings +drop table if exists st1; +drop table if exists st2; +DROP TABLE if exists st3; +--enable_warnings + +create table st3 (ukey bigint unsigned, c1 float unsigned, c2 double unsigned, c3 decimal(5,2) unsigned, c4 decimal(18,6) unsigned); +insert into st3 values (0,2.22507385E-18, 2.225073858507201E-307, 123.45, 1234567890.12345678); +select 'q10', st3.* from st3 order by st3.ukey; + +--error ER_WARN_DATA_OUT_OF_RANGE +insert into st3 values (0,-2.22507385E-18, -2.225073858507201E-307, -123.45, -1234567890.12345678); +select 'q11', st3.* from st3 order by st3.ukey; + +--error ER_WARN_DATA_OUT_OF_RANGE +insert into st3 values (0,0.0, 0.0, 43123.45, 34321234567890.12345678); +select 'q12', st3.* from st3 order by st3.ukey; +select 'q13', st3.* from st3 where c2 > 0 order by st3.ukey; +insert into st3 values (0,0.0, 0.0, 0.0, 0); +select 'q12', st3.* from st3 order by st3.ukey; + +--disable_warnings +DROP TABLE if exists st3; +DROP TABLE IF EXISTS st4; +--enable_warnings + +CREATE TABLE st4 (ukey TINYINT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; + +DROP TABLE IF EXISTS st4; +CREATE TABLE st4 (ukey SMALLINT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; + +DROP TABLE IF EXISTS st4; +CREATE TABLE st4 (ukey INT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; + +DROP TABLE IF EXISTS st4; +CREATE TABLE st4 (ukey BIGINT UNSIGNED, c1 INT UNSIGNED); +INSERT INTO st4 VALUES (0,1); +INSERT INTO st4 VALUES (0,2); +INSERT INTO st4 VALUES (0,3); +INSERT INTO st4 VALUES (0,4); +INSERT INTO st4 VALUES (0,5); +SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey; +DROP TABLE IF EXISTS st4; + +# Clean UP +DROP DATABASE unsigned_test; diff --git a/mysql-test/suite/tianmu/t/unsigned_greatest.test b/mysql-test/suite/tianmu/t/unsigned_greatest.test new file mode 100644 index 0000000000..7a18833274 --- /dev/null +++ b/mysql-test/suite/tianmu/t/unsigned_greatest.test @@ -0,0 +1,173 @@ +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS unsigned_greatest_test; +--enable_warnings + +CREATE DATABASE unsigned_greatest_test; +USE unsigned_greatest_test; + +Create table datatypetestm ( +CIDX INTEGER, +CBIGINT BIGINT, +CDECIMAL1 DECIMAL(1), +CDECIMAL4 DECIMAL(4), +CDECIMAL4_2 DECIMAL(4,2), +CDECIMAL5 DECIMAL(5), +CDECIMAL9 DECIMAL(9), +CDECIMAL9_2 DECIMAL(9,2), +CDECIMAL10 DECIMAL(10), +CDECIMAL18 DECIMAL(18), +CDECIMAL18_2 DECIMAL(18,2), +CINTEGER INTEGER, +CSMALLINT SMALLINT, +CTINYINT TINYINT, +CDOUBLE DOUBLE, +CFLOAT FLOAT, +CDATE DATE, +CDATETIME DATETIME, +CCHAR1 CHAR(1), +CCHAR2 CHAR(2), +CCHAR3 CHAR(3), +CCHAR4 CHAR(4), +CCHAR5 CHAR(5), +CCHAR6 CHAR(6), +CCHAR7 CHAR(7), +CCHAR8 CHAR(8), +CCHAR9 CHAR(9), +CCHAR255 CHAR(255), +CVCHAR1 VARCHAR(1), +CVCHAR2 VARCHAR(2), +CVCHAR3 VARCHAR(3), +CVCHAR4 VARCHAR(4), +CVCHAR5 VARCHAR(5), +CVCHAR6 VARCHAR(6), +CVCHAR7 VARCHAR(7), +CVCHAR8 VARCHAR(8), +CVCHAR255 VARCHAR(255) +); + +insert into datatypetestm values +(1,-72036854775806,-9,-999,-9.99,-999,-999999,-9999.99,-9999999,-9999999999999,-99999999999.99,-7483646,-766,-26,-1.797693231E+108,-3.402866E+18,'1997-01-01','1997-01-01 00:00:00','a','aa','aaa','aaaa','aaaaa','aaaaaa','aaaaaaa','aaaaaaaa','aaaaaaaaa','aaaaaaaaaa','a','aa','aaa','aaaa','aaaaa','aaaaaa','aaaaaaa','aaaaaaaa','aaaaaaaaaa'), +(2,-72036854775805,-8,-998,-9.98,-998,-999998,-9999.98,-9999998,-9999999999998,-99999999999.98,-7483645,-765,-25,-1.797693230E+108,-3.402865E+18,'1997-01-01','1997-01-01 00:00:01','a','b','c','d','e','f','g','h','i','j','a','b','c','d','e','f','g','h','j'), +(3,-72036854775804,-7,-997,-9.97,-997,-999997,-9999.97,-9999997,-9999999999997,-99999999999.97,-7483644,-764,-24,-1.797693229E+108,-3.402864E+18,'1997-01-02','1997-01-02 00:00:01','a','bb','cc','dd','ee','ff','gg','hh','ii','jj','a','bb','cc','dd','ee','ff','gg','hh','jj'), +(4,-72036854775803,-6,-996,-9.96,-996,-999996,-9999.96,-9999996,-9999999999996,-99999999999.96,-7483643,-763,-23,-1.797693228E+108,-3.402863E+18,'1997-01-03','1997-01-03 00:00:02','a','bb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj','a','bb','ccc','ddd','eee','fff','ggg','hhh','jjj'), +(5,-72036854775802,-5,-995,-9.95,-995,-999995,-9999.95,-9999995,-9999999999995,-99999999999.95,-7483642,-762,-22,-1.797693227E+108,-3.402862E+18,'1997-01-04','1997-01-04 00:00:03','a','bb','ccc','dddd','eeee','ffff','gggg','hhhh','iiii','jjjj','a','bb','ccc','dddd','eeee','ffff','gggg','hhhh','jjjj'), +(6,72036854775803,5,995,9.95,995,999995,9999.95,9999995,9999999999995,99999999999.95,7483643,763,23,1.797693227E+108,3.402862E+18,'2009-12-28','2009-12-31 23:59:56','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','sssssss','rrrrrrr','qqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','sssssss','qqqqqqq'), +(7,72036854775804,6,996,9.96,996,999996,9999.96,9999996,9999999999996,99999999999.96,7483644,764,24,1.797693228E+108,3.402863E+18,'2009-12-29','2009-12-31 23:59:57','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','rrrrrrrr','qqqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','qqqqqqqq'), +(8,72036854775805,7,997,9.97,997,999997,9999.97,9999997,9999999999997,99999999999.97,7483645,765,25,1.797693229E+108,3.402864E+18,'2009-12-30','2009-12-31 23:59:58','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','rrrrrrrrr','qqqqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','qqqqqqqqq'), +(9,72036854775806,8,998,9.98,998,999998,9999.98,9999998,9999999999998,99999999999.98,7483646,766,26,1.797693230E+108,3.402865E+18,'2009-12-31','2009-12-31 23:59:59','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','rrrrrrrrr','qqqqqqqqqq','z','yy','xxx','wwww','vvvvv','uuuuuu','ttttttt','ssssssss','qqqqqqqqqq'), +(10,72036854775807,9,999,9.99,999,999999,9999.99,9999999,9999999999999,99999999999.99,7483647,767,27,1.797693231E+108,3.402866E+18,'2009-12-31','2009-12-31 23:59:59','z','zz','zzz','zzzz','zzzzz','zzzzzz','zzzzzzz','zzzzzzzz','zzzzzzzzz','zzzzzzzzzz','z','zz','zzz','zzzz','zzzzz','zzzzzz','zzzzzzz','zzzzzzzz','zzzzzzzzzz'), +(11,0,0,0,0.00,0,0,0.00,0,0,0.00,0,0,0,0.00,0.00,'2009-12-31','2009-12-31 23:59:59',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); + +ALTER TABLE datatypetestm ADD COLUMN CUTINYINT TINYINT UNSIGNED; +ALTER TABLE datatypetestm ADD COLUMN CUSMALLINT SMALLINT UNSIGNED; +ALTER TABLE datatypetestm ADD COLUMN CUINTEGER INT UNSIGNED; +ALTER TABLE datatypetestm ADD COLUMN CUBIGINT BIGINT UNSIGNED; +UPDATE datatypetestm SET CUTINYINT=CTINYINT + 100; +UPDATE datatypetestm SET CUSMALLINT=CSMALLINT + 20000; +UPDATE datatypetestm SET CUINTEGER=CINTEGER + 1140000000; +UPDATE datatypetestm SET CUBIGINT=CBIGINT + 5223000000000000; + +select cidx, CUBIGINT, GREATEST(CUBIGINT,CBIGINT,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +select cidx, CDECIMAL1, CUSMALLINT, GREATEST(CDECIMAL1,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL1, CUTINYINT, GREATEST(CDECIMAL1,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL1, CUBIGINT, GREATEST(CDECIMAL1,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL4, CUSMALLINT, GREATEST(CDECIMAL4,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL4, CUTINYINT, GREATEST(CDECIMAL4,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL4, CUBIGINT, GREATEST(CDECIMAL4,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL4_2, CUSMALLINT, GREATEST(CDECIMAL4_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL4_2, CUTINYINT, GREATEST(CDECIMAL4_2,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL4_2, CUBIGINT, GREATEST(CDECIMAL4_2,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL9, CUSMALLINT, GREATEST(CDECIMAL9,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL9, CUTINYINT, GREATEST(CDECIMAL9,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL9, CUBIGINT, GREATEST(CDECIMAL9,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL9_2, CUSMALLINT, GREATEST(CDECIMAL9_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL9_2, CUTINYINT, GREATEST(CDECIMAL9_2,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL9_2, CUBIGINT, GREATEST(CDECIMAL9_2,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL18, CUSMALLINT, GREATEST(CDECIMAL18,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL18, CUTINYINT, GREATEST(CDECIMAL18,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL18, CUBIGINT, GREATEST(CDECIMAL18,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL18_2, CUSMALLINT, GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL18_2, CUTINYINT, GREATEST(CDECIMAL18_2,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL18_2, CUBIGINT, GREATEST(CDECIMAL18_2,CUBIGINT) from datatypetestm; +select cidx, CINTEGER, CUINTEGER, GREATEST(CUINTEGER,CINTEGER,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +select cidx, CINTEGER, CUSMALLINT, GREATEST(CINTEGER,CUSMALLINT) from datatypetestm; +select cidx, CINTEGER, CUTINYINT, GREATEST(CINTEGER,CUTINYINT) from datatypetestm; +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT) from datatypetestm; +select cidx, CSMALLINT, CUTINYINT, GREATEST(CSMALLINT,CUTINYINT) from datatypetestm; +select cidx, CUBIGINT from datatypetestm where GREATEST(CUBIGINT,CSMALLINT,CUTINYINT,10) <> CUBIGINT; +select cidx, CUSMALLINT from datatypetestm where GREATEST(CUSMALLINT,CSMALLINT) <> CUSMALLINT; +select cidx, CUBIGINT from datatypetestm where GREATEST(CDECIMAL18,CUBIGINT,CUSMALLINT,CUTINYINT,10) <> CUBIGINT; +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUSMALLINT) <> CDECIMAL18; +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUTINYINT) <> CDECIMAL18; +select cidx, CDECIMAL18_2 from datatypetestm where GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +select cidx, CUSMALLINT from datatypetestm where GREATEST(CINTEGER,CUSMALLINT,CUTINYINT,10) <> CINTEGER; +select cidx, CINTEGER from datatypetestm where GREATEST(CINTEGER,CUTINYINT) <> CINTEGER; +select cidx, CUSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +select cidx, CSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUTINYINT) <> CSMALLINT; +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CSMALLINT,CUTINYINT,10) <> CUTINYINT; +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CUTINYINT) <> CUTINYINT; + +--error ER_WARN_DATA_OUT_OF_RANGE +UPDATE datatypetestm SET CUTINYINT=CTINYINT-1; +UPDATE datatypetestm SET CUTINYINT=CTINYINT-1 WHERE CTINYINT > 0; +--error ER_WARN_DATA_OUT_OF_RANGE +UPDATE datatypetestm SET CUSMALLINT=CSMALLINT-1; +UPDATE datatypetestm SET CUSMALLINT=CSMALLINT-1 WHERE CSMALLINT > 0; +--error ER_WARN_DATA_OUT_OF_RANGE +UPDATE datatypetestm SET CUINTEGER=CINTEGER-1; +UPDATE datatypetestm SET CUINTEGER=CINTEGER-1 WHERE CINTEGER > 0; +--error ER_WARN_DATA_OUT_OF_RANGE +UPDATE datatypetestm SET CUBIGINT=CBIGINT-1; +UPDATE datatypetestm SET CUBIGINT=CBIGINT-1 WHERE CBIGINT > 0; + +select cidx, CUBIGINT, GREATEST(CUBIGINT,CBIGINT,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +select cidx, CDECIMAL1, CUSMALLINT, GREATEST(CDECIMAL1,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL1, CUTINYINT, GREATEST(CDECIMAL1,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL1, CUBIGINT, GREATEST(CDECIMAL1,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL4, CUSMALLINT, GREATEST(CDECIMAL4,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL4, CUTINYINT, GREATEST(CDECIMAL4,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL4, CUBIGINT, GREATEST(CDECIMAL4,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL4_2, CUSMALLINT, GREATEST(CDECIMAL4_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL4_2, CUTINYINT, GREATEST(CDECIMAL4_2,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL4_2, CUBIGINT, GREATEST(CDECIMAL4_2,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL9, CUSMALLINT, GREATEST(CDECIMAL9,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL9, CUTINYINT, GREATEST(CDECIMAL9,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL9, CUBIGINT, GREATEST(CDECIMAL9,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL9_2, CUSMALLINT, GREATEST(CDECIMAL9_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL9_2, CUTINYINT, GREATEST(CDECIMAL9_2,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL9_2, CUBIGINT, GREATEST(CDECIMAL9_2,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL18, CUSMALLINT, GREATEST(CDECIMAL18,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL18, CUTINYINT, GREATEST(CDECIMAL18,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL18, CUBIGINT, GREATEST(CDECIMAL18,CUBIGINT) from datatypetestm; +select cidx, CDECIMAL18_2, CUSMALLINT, GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CDECIMAL18_2, CUTINYINT, GREATEST(CDECIMAL18_2,CUTINYINT) from datatypetestm; +select cidx, CDECIMAL18_2, CUBIGINT, GREATEST(CDECIMAL18_2,CUBIGINT) from datatypetestm; +select cidx, CINTEGER, CUINTEGER, GREATEST(CUINTEGER,CINTEGER,CUSMALLINT,CSMALLINT,CUTINYINT,CTINYINT,10) from datatypetestm; +select cidx, CINTEGER, CUSMALLINT, GREATEST(CINTEGER,CUSMALLINT) from datatypetestm; +select cidx, CINTEGER, CUTINYINT, GREATEST(CINTEGER,CUTINYINT) from datatypetestm; +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) from datatypetestm; +select cidx, CSMALLINT, CUSMALLINT, GREATEST(CSMALLINT,CUSMALLINT) from datatypetestm; +select cidx, CSMALLINT, CUTINYINT, GREATEST(CSMALLINT,CUTINYINT) from datatypetestm; +select cidx, CUBIGINT from datatypetestm where GREATEST(CUBIGINT,CSMALLINT,CUTINYINT,10) <> CUBIGINT; +select cidx, CUSMALLINT from datatypetestm where GREATEST(CUSMALLINT,CSMALLINT) <> CUSMALLINT; +select cidx, CUBIGINT from datatypetestm where GREATEST(CDECIMAL18,CUBIGINT,CUSMALLINT,CUTINYINT,10) <> CUBIGINT; +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUSMALLINT) <> CDECIMAL18; +select cidx, CDECIMAL18 from datatypetestm where GREATEST(CDECIMAL18,CUTINYINT) <> CDECIMAL18; +select cidx, CDECIMAL18_2 from datatypetestm where GREATEST(CDECIMAL18_2,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +select cidx, CUSMALLINT from datatypetestm where GREATEST(CINTEGER,CUSMALLINT,CUTINYINT,10) <> CINTEGER; +select cidx, CINTEGER from datatypetestm where GREATEST(CINTEGER,CUTINYINT) <> CINTEGER; +select cidx, CUSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUSMALLINT,CUTINYINT,10) <> CUSMALLINT; +select cidx, CSMALLINT from datatypetestm where GREATEST(CSMALLINT,CUTINYINT) <> CSMALLINT; +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CSMALLINT,CUTINYINT,10) <> CUTINYINT; +select cidx, CUTINYINT from datatypetestm where GREATEST(CTINYINT,CUTINYINT) <> CUTINYINT; + +ALTER TABLE datatypetestm DROP COLUMN CUTINYINT; +ALTER TABLE datatypetestm DROP COLUMN CUSMALLINT; +ALTER TABLE datatypetestm DROP COLUMN CUINTEGER; +ALTER TABLE datatypetestm DROP COLUMN CUBIGINT; + +# Clean UP +DROP DATABASE unsigned_greatest_test; diff --git a/mysql-test/suite/tianmu/t/unsigned_math.test b/mysql-test/suite/tianmu/t/unsigned_math.test new file mode 100644 index 0000000000..9df58ab406 --- /dev/null +++ b/mysql-test/suite/tianmu/t/unsigned_math.test @@ -0,0 +1,128 @@ +--source include/have_tianmu.inc + +--echo # +--echo # Test unsigned_math +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS unsigned_math_test; +--enable_warnings + +CREATE DATABASE unsigned_math_test; +USE unsigned_math_test; + +create table j1 (j1_key int); +insert into j1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(null); + +ALTER TABLE j1 ADD COLUMN CUTINYINT TINYINT UNSIGNED; +ALTER TABLE j1 ADD COLUMN CUSMALLINT SMALLINT UNSIGNED; +ALTER TABLE j1 ADD COLUMN CUINTEGER INT UNSIGNED; +ALTER TABLE j1 ADD COLUMN CUBIGINT BIGINT UNSIGNED; +UPDATE j1 SET CUTINYINT=127; +UPDATE j1 SET CUSMALLINT=32767; +UPDATE j1 SET CUINTEGER=2147483647; +UPDATE j1 SET CUBIGINT=9223372036854775807; + +SELECT 'ABS1', ABS(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'ABS2', ABS(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'ABS3', ABS(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'ABS4', ABS(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'CEIL1', CEIL(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'CEIL2', CEIL(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'CEIL3', CEIL(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'CEIL4', CEIL(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'FLOOR1', FLOOR(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'FLOOR2', FLOOR(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'FLOOR3', FLOOR(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'FLOOR4', FLOOR(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'DIV1', CUINTEGER DIV CUTINYINT FROM j1 WHERE j1_key=1; +SELECT 'DIV2', CUINTEGER DIV CUSMALLINT FROM j1 WHERE j1_key=1; +SELECT 'DIV3', CUBIGINT DIV CUTINYINT FROM j1 WHERE j1_key=1; +SELECT 'DIV4', CUBIGINT DIV CUSMALLINT FROM j1 WHERE j1_key=1; +SELECT 'DIV5', CUBIGINT DIV CUINTEGER FROM j1 WHERE j1_key=1; +SELECT 'DIV6', CUINTEGER DIV CUBIGINT FROM j1 WHERE j1_key=1; + +SELECT 'EXP1', EXP(CUTINYINT) FROM j1 WHERE j1_key=1; + +SELECT 'LN1', LN(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'LN2', LN(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'LN3', LN(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'LN4', LN(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'LOG1', LOG(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'LOG2', LOG(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'LOG3', LOG(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'LOG4', LOG(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'LOG21', LOG2(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'LOG22', LOG2(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'LOG23', LOG2(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'LOG24', LOG2(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'LOG101', LOG10(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'LOG102', LOG10(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'LOG103', LOG10(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'LOG104', LOG10(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'MD51', MD5(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'MD52', MD5(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'MD53', MD5(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'MD54', MD5(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'MOD1', MOD(CUTINYINT,10) FROM j1 WHERE j1_key=1; +SELECT 'MOD2', MOD(CUSMALLINT,9) FROM j1 WHERE j1_key=1; +SELECT 'MOD3', MOD(CUINTEGER,8) FROM j1 WHERE j1_key=1; +SELECT 'MOD4', MOD(CUBIGINT,16) FROM j1 WHERE j1_key=1; + +SELECT 'NULLIF1', NULLIF(CUTINYINT,127) FROM j1 WHERE j1_key=1; +SELECT 'NULLIF2', NULLIF(CUSMALLINT,32767) FROM j1 WHERE j1_key=1; +SELECT 'NULLIF3', NULLIF(CUINTEGER,2147483647) FROM j1 WHERE j1_key=1; +SELECT 'NULLIF4', NULLIF(CUBIGINT,9223372036854775807) FROM j1 WHERE j1_key=1; + +SELECT 'NULLIF5', NULLIF(CUTINYINT,127) FROM j1 WHERE j1_key=1; +SELECT 'NULLIF6', NULLIF(CUSMALLINT,32767) FROM j1 WHERE j1_key=1; +SELECT 'NULLIF7', NULLIF(CUINTEGER,2147483647) FROM j1 WHERE j1_key=1; +SELECT 'NULLIF8', NULLIF(CUBIGINT,9223372036854775807) FROM j1 WHERE j1_key=1; + +SELECT 'POW1', POW(CUTINYINT,4) FROM j1 WHERE j1_key=1; +SELECT 'POW2', POW(CUSMALLINT,4) FROM j1 WHERE j1_key=1; +SELECT 'POW3', POW(CUINTEGER,4) FROM j1 WHERE j1_key=1; +SELECT 'POW4', POW(CUBIGINT,4) FROM j1 WHERE j1_key=1; + +SELECT 'ROUND1', ROUND(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'ROUND2', ROUND(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'ROUND3', ROUND(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'ROUND4', ROUND(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'SIGN1', SIGN(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'SIGN2', SIGN(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'SIGN3', SIGN(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'SIGN4', SIGN(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'SIN1', SIN(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'SIN2', SIN(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'SIN3', SIN(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'SIN4', SIN(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'SQRT1', SQRT(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'SQRT2', SQRT(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'SQRT3', SQRT(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'SQRT4', SQRT(CUBIGINT) FROM j1 WHERE j1_key=1; + +SELECT 'TAN1', TAN(CUTINYINT) FROM j1 WHERE j1_key=1; +SELECT 'TAN2', TAN(CUSMALLINT) FROM j1 WHERE j1_key=1; +SELECT 'TAN3', TAN(CUINTEGER) FROM j1 WHERE j1_key=1; +SELECT 'TAN4', TAN(CUBIGINT) FROM j1 WHERE j1_key=1; + +ALTER TABLE j1 DROP COLUMN CUTINYINT; +ALTER TABLE j1 DROP COLUMN CUSMALLINT; +ALTER TABLE j1 DROP COLUMN CUINTEGER; +ALTER TABLE j1 DROP COLUMN CUBIGINT; + +# Clean UP +drop table j1; +DROP DATABASE unsigned_math_test; + diff --git a/mysql-test/suite/tianmu/t/zerofill.test b/mysql-test/suite/tianmu/t/zerofill.test new file mode 100644 index 0000000000..b9f95ede0e --- /dev/null +++ b/mysql-test/suite/tianmu/t/zerofill.test @@ -0,0 +1,64 @@ +--source include/have_tianmu.inc + +--echo # +--echo # Test zerofill +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS zerofill_test; +--enable_warnings + +CREATE DATABASE zerofill_test; +USE zerofill_test; + +CREATE TABLE st1 (x INT(8) ZEROFILL NOT NULL, y INT(8) NOT NULL); +INSERT INTO st1 VALUES +(1, 1), +(12, 12), +(123, 123), +(1234567, 1234567), +(123456789, 123456789); +select * from st1; + +CREATE TABLE st2(id int PRIMARY KEY,val TINYINT(10) ZEROFILL); +INSERT INTO st2 VALUES(1,12),(2,7),(4,101); +SELECT * FROM st2; +#bug1095 SELECT LENGTH(val) FROM st2 WHERE id=2; +SELECT val+1 FROM st2 WHERE id=2; + +create table st3 (id1 int,id2 int(5)); +insert into st3 values (1,1); +alter table st3 modify id1 int zerofill; +alter table st3 modify id2 int(5) zerofill; +insert into st3 values (1,1234567); +select * from st3; + +CREATE TABLE st4( +`id` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT, +`col2` varchar(20) NOT NULL, +`year` year(4) DEFAULT NULL, +`month` int(2) unsigned zerofill DEFAULT NULL, +`day` int(2) unsigned zerofill DEFAULT NULL, + PRIMARY KEY (`id`) +); + +insert into st4 values(1,'test',2021,12,12); +alter table st4 MODIFY id int; +select * from st4; + +CREATE TABLE st5( +num1 TINYINT, +num2 TINYINT UNSIGNED, +num3 INT, +num4 INT ZEROFILL, +num5 INT UNSIGNED ZEROFILL +); +--error ER_WARN_DATA_OUT_OF_RANGE +INSERT st5(num1,num2) VALUES(-5,-5); +INSERT st5(num3,num4) VALUES(123,123); +INSERT st5 VALUES(0,0,0,0,0); +INSERT st5(num3,num4,num5) VALUES(123,123,123); +SELECT * FROM st5; + +# Clean UP +DROP DATABASE zerofill_test;