diff --git a/mysql-test/suite/tianmu/r/ctas1.result b/mysql-test/suite/tianmu/r/ctas1.result new file mode 100644 index 000000000..0f4c299a6 --- /dev/null +++ b/mysql-test/suite/tianmu/r/ctas1.result @@ -0,0 +1,137 @@ +# +# Test CREATE TABLE AS SELECT +# +DROP DATABASE IF EXISTS ctas_test; +CREATE DATABASE ctas_test; +USE ctas_test; +CREATE TABLE `user` ( +`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', +`user_name` varchar(200) DEFAULT '', +`phone` varchar(200) DEFAULT '', +`b_code` varchar(255) DEFAULT NULL, +PRIMARY KEY (`id`) +)DEFAULT CHARSET=utf8; +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('李明', '101', '2021001'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('赵慧', '456', '2020001'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('李凯', '123', '2021002'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('张三1', '123', '2022001'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('张三2', '123', '2021003'); +create table user1 as select * from user; +select * from user1; +id user_name phone b_code +1 李明 101 2021001 +2 赵慧 456 2020001 +3 李凯 123 2021002 +4 张三1 123 2022001 +5 张三2 123 2021003 +desc user1; +Field Type Null Key Default Extra +id bigint(20) NO 0 +user_name varchar(200) YES +phone varchar(200) YES +b_code varchar(255) YES NULL +create table user2 as select user_name, phone from user; +select * from user2; +user_name phone +李明 101 +赵慧 456 +李凯 123 +张三1 123 +张三2 123 +create table user3 as select user_name, phone from user limit 2; +select * from user3; +user_name phone +李明 101 +赵慧 456 +create table user4 select user_name, phone from user limit 4; +select * from user4; +user_name phone +李明 101 +赵慧 456 +李凯 123 +张三1 123 +create table user5 as select * from user where b_code like '2021%'; +select * from user5; +id user_name phone b_code +1 李明 101 2021001 +3 李凯 123 2021002 +5 张三2 123 2021003 +desc user5; +Field Type Null Key Default Extra +id bigint(20) NO 0 +user_name varchar(200) YES +phone varchar(200) YES +b_code varchar(255) YES NULL +create table user6 like user; +select * from user6; +id user_name phone b_code +desc user6; +Field Type Null Key Default Extra +id bigint(20) NO PRI NULL auto_increment +user_name varchar(200) YES +phone varchar(200) YES +b_code varchar(255) YES NULL +create table user7 like user; +insert into user7 select * from user; +CREATE TABLE user_bk4( id INT NOT NULL) ENGINE=InnoDB SELECT id,user_name FROM user; +select * from user_bk4; +id user_name +1 李明 +2 赵慧 +3 李凯 +4 张三1 +5 张三2 +CREATE TABLE user_bk5( id INT NOT NULL primary key)ENGINE=TIANMU SELECT id,user_name FROM user; +select * from user_bk5; +id user_name +1 李明 +2 赵慧 +3 李凯 +4 张三1 +5 张三2 +create table user_bk6 select id+1 as id1 from user; +select * from user_bk6; +id1 +2 +3 +4 +5 +6 +desc user_bk6; +Field Type Null Key Default Extra +id1 bigint(21) NO 0 +DROP TABLE IF EXISTS `test_tbl`; +Warnings: +Note 1051 Unknown table 'ctas_test.test_tbl' +CREATE TABLE `test_tbl` ( +`test_id` int(11) NOT NULL AUTO_INCREMENT, +`test_title` varchar(100) NOT NULL, +`test_author` varchar(40) NOT NULL, +`submission_date` date DEFAULT NULL, +PRIMARY KEY (`test_id`) +) DEFAULT CHARSET=utf8; +INSERT INTO `test_tbl` +VALUES +('1', 'c++', 'test', '2017-04-12'), +('2', 'MySQL', 'test', '2017-04-12'), +('3', 'Java', 'test.COM', '2015-05-01'), +('4', 'Python', 'test.COM', '2016-03-06'), +('5', 'C', 'FK', '2017-04-05'); +DROP TABLE IF EXISTS `tcount_tbl`; +Warnings: +Note 1051 Unknown table 'ctas_test.tcount_tbl' +CREATE TABLE `tcount_tbl` ( +`test_author` varchar(255) NOT NULL DEFAULT '', +`test_count` int(11) NOT NULL DEFAULT '0' +) DEFAULT CHARSET=utf8; +INSERT INTO `tcount_tbl` +VALUES +('test','10'), +('test.COM','20'), +('Google', '22'); +create table test_tbl1 SELECT test_id, submission_date FROM test_tbl a left JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl2 SELECT a.test_id, a.test_author FROM test_tbl a right JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl3 SELECT a.test_id, a.test_author, b.test_count FROM test_tbl a INNER JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl4 as SELECT a.test_id, a.test_author, b.test_count FROM test_tbl a INNER JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl5 select * from test_tbl natural join tcount_tbl; +drop database ctas_test; diff --git a/mysql-test/suite/tianmu/r/different_charsets_b.result b/mysql-test/suite/tianmu/r/different_charsets_b.result new file mode 100644 index 000000000..459fbd486 --- /dev/null +++ b/mysql-test/suite/tianmu/r/different_charsets_b.result @@ -0,0 +1,626 @@ +# +# Test column length with different charsets 2 +# +drop database if exists different_charsets_test; +set character_set_client = utf8; +set character_set_connection = utf8; +set character_set_database = utf8mb4; +set character_set_results = utf8; +set character_set_server = utf8mb4; +create database different_charsets_test; +use different_charsets_test; +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +create table st1 (a char(1) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, +c char(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, +e char(240) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, +g char(255) CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL +); +create table st2 (a char(1) CHARACTER SET utf8, b datetime NOT NULL, +c char(10) CHARACTER SET utf8mb4, d datetime NOT NULL, +e char(240) CHARACTER SET utf8, f datetime NOT NULL, +g char(255) CHARACTER SET utf8mb4, h datetime NOT NULL +); +create table i1 (a char(1) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, +c char(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, +e char(240) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, +g char(255) CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL +); +create table i2 (a char(1) CHARACTER SET utf8, b datetime NOT NULL, +c char(10) CHARACTER SET utf8mb4, d datetime NOT NULL, +e char(240) CHARACTER SET utf8, f datetime NOT NULL, +g char(255) CHARACTER SET utf8mb4, h datetime NOT NULL +); +insert into i1 values ('a', '2020-10-25 01:02:03', +'bcd', '2020-10-25 01:02:04', +'cde', '2020-10-25 01:02:05', +'def', '2020-10-25 01:02:06' + ); +insert into i2(b, d, f, h) values ('2020-10-25 01:02:03', +'2020-10-25 01:02:04', +'2020-10-25 01:02:05', +'2020-10-25 01:02:06' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +a b c d e f g h +a 2020-10-25 01:02:03 bcd 2020-10-25 01:02:04 cde 2020-10-25 01:02:05 def 2020-10-25 01:02:06 +select * from st2; +a b c d e f g h +NULL 2020-10-25 01:02:03 NULL 2020-10-25 01:02:04 NULL 2020-10-25 01:02:05 NULL 2020-10-25 01:02:06 +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', +'abc', '2020-10-25 01:02:06', +'cde', '2020-10-25 01:02:07'); +insert into st3 values ('1', '2020-10-25 01:02:05', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', +'abc', '2020-10-25 01:02:07', +'cde', '2020-10-25 01:02:08'); +ERROR 22001: Data too long for column 'c' at row 1 +insert ignore into st3 values ('12', '2020-10-25 01:02:06', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:07', +'abc', '2020-10-25 01:02:08', +'cde', '2020-10-25 01:02:09'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', +'1234567890', '2020-10-25 01:02:08', +'abc', '2020-10-25 01:02:09', +'cde', '2020-10-25 01:02:10'); +ERROR HY000: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1 +select * from st3; +a b c d e f g h +1 2020-10-25 01:02:04 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:05 abc 2020-10-25 01:02:06 cde 2020-10-25 01:02:07 +1 2020-10-25 01:02:06 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:07 abc 2020-10-25 01:02:08 cde 2020-10-25 01:02:09 +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; +column_name data_type character_maximum_length character_octet_length +a char 1 3 +b datetime NULL NULL +c char 10 40 +d datetime NULL NULL +e char 240 720 +f datetime NULL NULL +g char 255 1020 +h datetime NULL NULL +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +create table st1 (a char(1) NOT NULL, b datetime NOT NULL, +c char(10) NOT NULL, d datetime NOT NULL, +e char(240) NOT NULL, f datetime NOT NULL, +g char(255) NOT NULL, h datetime NOT NULL +) default character set utf8; +create table st2 (a char(1), b datetime NOT NULL, +c char(10), d datetime NOT NULL, +e char(240), f datetime NOT NULL, +g char(255), h datetime NOT NULL +) default character set utf8; +create table i1 (a char(1) NOT NULL, b datetime NOT NULL, +c char(10) NOT NULL, d datetime NOT NULL, +e char(240) NOT NULL, f datetime NOT NULL, +g char(255) NOT NULL, h datetime NOT NULL +) default character set utf8; +create table i2 (a char(1), b datetime NOT NULL, +c char(10), d datetime NOT NULL, +e char(240), f datetime NOT NULL, +g char(255), h datetime NOT NULL +) default character set utf8; +insert into i1 values ('a', '2020-10-25 01:02:03', +'bcd', '2020-10-25 01:02:04', +'cde', '2020-10-25 01:02:05', +'def', '2020-10-25 01:02:06' + ); +insert into i2(b, d, f, h) values ('2020-10-25 01:02:03', +'2020-10-25 01:02:04', +'2020-10-25 01:02:05', +'2020-10-25 01:02:06' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +a b c d e f g h +a 2020-10-25 01:02:03 bcd 2020-10-25 01:02:04 cde 2020-10-25 01:02:05 def 2020-10-25 01:02:06 +select * from st2; +a b c d e f g h +NULL 2020-10-25 01:02:03 NULL 2020-10-25 01:02:04 NULL 2020-10-25 01:02:05 NULL 2020-10-25 01:02:06 +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', +'abc', '2020-10-25 01:02:06', +'cde', '2020-10-25 01:02:07'); +insert into st3 values ('1', '2020-10-25 01:02:05', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', +'abc', '2020-10-25 01:02:07', +'cde', '2020-10-25 01:02:08'); +ERROR 22001: Data too long for column 'c' at row 1 +insert ignore into st3 values ('12', '2020-10-25 01:02:06', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:07', +'abc', '2020-10-25 01:02:08', +'cde', '2020-10-25 01:02:09'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', +'1234567890', '2020-10-25 01:02:08', +'abc', '2020-10-25 01:02:09', +'cde', '2020-10-25 01:02:10'); +ERROR HY000: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1 +select * from st3; +a b c d e f g h +1 2020-10-25 01:02:04 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:05 abc 2020-10-25 01:02:06 cde 2020-10-25 01:02:07 +1 2020-10-25 01:02:06 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:07 abc 2020-10-25 01:02:08 cde 2020-10-25 01:02:09 +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; +column_name data_type character_maximum_length character_octet_length +a char 1 3 +b datetime NULL NULL +c char 10 30 +d datetime NULL NULL +e char 240 720 +f datetime NULL NULL +g char 255 765 +h datetime NULL NULL +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +create table st1 (a char(1) NOT NULL, b datetime NOT NULL, +c char(10) NOT NULL, d datetime NOT NULL, +e char(240) NOT NULL, f datetime NOT NULL, +g char(255) NOT NULL, h datetime NOT NULL +) default character set utf8mb4; +create table st2 (a char(1), b datetime NOT NULL, +c char(10), d datetime NOT NULL, +e char(240), f datetime NOT NULL, +g char(255), h datetime NOT NULL +) default character set utf8mb4; +create table i1 (a char(1) NOT NULL, b datetime NOT NULL, +c char(10) NOT NULL, d datetime NOT NULL, +e char(240) NOT NULL, f datetime NOT NULL, +g char(255) NOT NULL, h datetime NOT NULL +) default character set utf8mb4; +create table i2 (a char(1), b datetime NOT NULL, +c char(10), d datetime NOT NULL, +e char(240), f datetime NOT NULL, +g char(255), h datetime NOT NULL +) default character set utf8mb4; +insert into i1 values ('a', '2020-10-25 01:02:03', +'bcd', '2020-10-25 01:02:04', +'cde', '2020-10-25 01:02:05', +'def', '2020-10-25 01:02:06' + ); +insert into i2(b, d, f, h) values ('2020-10-25 01:02:03', +'2020-10-25 01:02:04', +'2020-10-25 01:02:05', +'2020-10-25 01:02:06' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +a b c d e f g h +a 2020-10-25 01:02:03 bcd 2020-10-25 01:02:04 cde 2020-10-25 01:02:05 def 2020-10-25 01:02:06 +select * from st2; +a b c d e f g h +NULL 2020-10-25 01:02:03 NULL 2020-10-25 01:02:04 NULL 2020-10-25 01:02:05 NULL 2020-10-25 01:02:06 +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', +'abc', '2020-10-25 01:02:06', +'cde', '2020-10-25 01:02:07'); +insert into st3 values ('1', '2020-10-25 01:02:05', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', +'abc', '2020-10-25 01:02:07', +'cde', '2020-10-25 01:02:08'); +ERROR 22001: Data too long for column 'c' at row 1 +insert ignore into st3 values ('12', '2020-10-25 01:02:06', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:07', +'abc', '2020-10-25 01:02:08', +'cde', '2020-10-25 01:02:09'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', +'1234567890', '2020-10-25 01:02:08', +'abc', '2020-10-25 01:02:09', +'cde', '2020-10-25 01:02:10'); +select * from st3; +a b c d e f g h +1 2020-10-25 01:02:04 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:05 abc 2020-10-25 01:02:06 cde 2020-10-25 01:02:07 +1 2020-10-25 01:02:06 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:07 abc 2020-10-25 01:02:08 cde 2020-10-25 01:02:09 +? 2020-10-25 01:02:07 1234567890 2020-10-25 01:02:08 abc 2020-10-25 01:02:09 cde 2020-10-25 01:02:10 +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; +column_name data_type character_maximum_length character_octet_length +a char 1 4 +b datetime NULL NULL +c char 10 40 +d datetime NULL NULL +e char 240 960 +f datetime NULL NULL +g char 255 1020 +h datetime NULL NULL +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +create table st1 (a text(8) NOT NULL, b datetime NOT NULL, +c text(10) NOT NULL, d datetime NOT NULL, +e text(255) NOT NULL, f datetime NOT NULL, +g text NOT NULL, h datetime NOT NULL, +i text(65535) NOT NULL, j datetime NOT NULL, +k text(16777215) NOT NULL, l datetime NOT NULL +); +create table st2 (a text(8), b datetime NOT NULL, +c text(10), d datetime NOT NULL, +e text(255), f datetime NOT NULL, +g text, h datetime NOT NULL, +i text(65535), j datetime NOT NULL, +k text(16777215), l datetime NOT NULL +); +create table i1 (a text(8) NOT NULL, b datetime NOT NULL, +c text(10) NOT NULL, d datetime NOT NULL, +e text(255) NOT NULL, f datetime NOT NULL, +g text NOT NULL, h datetime NOT NULL, +i text(65535) NOT NULL, j datetime NOT NULL, +k text(16777215) NOT NULL, l datetime NOT NULL +); +create table i2 (a text(8), b datetime NOT NULL, +c text(10), d datetime NOT NULL, +e text(255), f datetime NOT NULL, +g text, h datetime NOT NULL, +i text(65535), j datetime NOT NULL, +k text(16777215), l datetime NOT NULL +); +insert into i1 values ('a', '2020-10-25 01:02:03', +'bcd', '2020-10-25 01:02:04', +'cde', '2020-10-25 01:02:05', +'def', '2020-10-25 01:02:06', +'efg', '2020-10-25 01:02:07', +'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', +'2020-10-25 01:02:04', +'2020-10-25 01:02:05', +'2020-10-25 01:02:06', +'2020-10-25 01:02:07', +'2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +a b c d e f g h i j k l +a 2020-10-25 01:02:03 bcd 2020-10-25 01:02:04 cde 2020-10-25 01:02:05 def 2020-10-25 01:02:06 efg 2020-10-25 01:02:07 fgh 2020-10-25 01:02:08 +select * from st2; +a b c d e f g h i j k l +NULL 2020-10-25 01:02:03 NULL 2020-10-25 01:02:04 NULL 2020-10-25 01:02:05 NULL 2020-10-25 01:02:06 NULL 2020-10-25 01:02:07 NULL 2020-10-25 01:02:08 +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', +'1234567890', '2020-10-25 01:02:05', +'cde', '2020-10-25 01:02:07', +'def', '2020-10-25 01:02:08', +'efg', '2020-10-25 01:02:09', +'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', +'12345678901', '2020-10-25 01:02:06', +'cde', '2020-10-25 01:02:08', +'def', '2020-10-25 01:02:09', +'efg', '2020-10-25 01:02:10', +'fgh', '2020-10-25 01:02:11'); +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', +'1234567890', '2020-10-25 01:02:08', +'cde', '2020-10-25 01:02:10', +'def', '2020-10-25 01:02:11', +'efg', '2020-10-25 01:02:12', +'fgh', '2020-10-25 01:02:13'); +select * from st3; +a b c d e f g h i j k l +1 2020-10-25 01:02:04 1234567890 2020-10-25 01:02:05 cde 2020-10-25 01:02:07 def 2020-10-25 01:02:08 efg 2020-10-25 01:02:09 fgh 2020-10-25 01:02:10 +1 2020-10-25 01:02:05 12345678901 2020-10-25 01:02:06 cde 2020-10-25 01:02:08 def 2020-10-25 01:02:09 efg 2020-10-25 01:02:10 fgh 2020-10-25 01:02:11 +? 2020-10-25 01:02:07 1234567890 2020-10-25 01:02:08 cde 2020-10-25 01:02:10 def 2020-10-25 01:02:11 efg 2020-10-25 01:02:12 fgh 2020-10-25 01:02:13 +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; +column_name data_type character_maximum_length character_octet_length +a tinytext 255 255 +b datetime NULL NULL +c tinytext 255 255 +d datetime NULL NULL +e text 65535 65535 +f datetime NULL NULL +g text 65535 65535 +h datetime NULL NULL +i mediumtext 16777215 16777215 +j datetime NULL NULL +k longtext 4294967295 4294967295 +l datetime NULL NULL +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +create table st1 (a text(8) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, +c text(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, +e text(255) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, +g text CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL, +i text(65535) CHARACTER SET utf8 NOT NULL, j datetime NOT NULL, +k text(16777215) CHARACTER SET utf8mb4 NOT NULL, l datetime NOT NULL +); +create table st2 (a text(8) CHARACTER SET utf8, b datetime NOT NULL, +c text(10) CHARACTER SET utf8mb4, d datetime NOT NULL, +e text(255) CHARACTER SET utf8, f datetime NOT NULL, +g text CHARACTER SET utf8mb4, h datetime NOT NULL, +i text(65535) CHARACTER SET utf8, j datetime NOT NULL, +k text(16777215) CHARACTER SET utf8mb4, l datetime NOT NULL +); +create table i1 (a text(8) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, +c text(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, +e text(255) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, +g text CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL, +i text(65535) CHARACTER SET utf8 NOT NULL, j datetime NOT NULL, +k text(16777215) CHARACTER SET utf8mb4 NOT NULL, l datetime NOT NULL +); +create table i2 (a text(8) CHARACTER SET utf8, b datetime NOT NULL, +c text(10) CHARACTER SET utf8mb4, d datetime NOT NULL, +e text(255) CHARACTER SET utf8, f datetime NOT NULL, +g text CHARACTER SET utf8mb4, h datetime NOT NULL, +i text(65535) CHARACTER SET utf8, j datetime NOT NULL, +k text(16777215) CHARACTER SET utf8mb4, l datetime NOT NULL +); +insert into i1 values ('ab', '2020-10-25 01:02:03', +'bcd', '2020-10-25 01:02:04', +'cde', '2020-10-25 01:02:05', +'def', '2020-10-25 01:02:06', +'efg', '2020-10-25 01:02:07', +'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', +'2020-10-25 01:02:04', +'2020-10-25 01:02:05', +'2020-10-25 01:02:06', +'2020-10-25 01:02:07', +'2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +a b c d e f g h i j k l +ab 2020-10-25 01:02:03 bcd 2020-10-25 01:02:04 cde 2020-10-25 01:02:05 def 2020-10-25 01:02:06 efg 2020-10-25 01:02:07 fgh 2020-10-25 01:02:08 +select * from st2; +a b c d e f g h i j k l +NULL 2020-10-25 01:02:03 NULL 2020-10-25 01:02:04 NULL 2020-10-25 01:02:05 NULL 2020-10-25 01:02:06 NULL 2020-10-25 01:02:07 NULL 2020-10-25 01:02:08 +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', +'cde', '2020-10-25 01:02:07', +'def', '2020-10-25 01:02:08', +'efg', '2020-10-25 01:02:09', +'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', +'cde', '2020-10-25 01:02:08', +'def', '2020-10-25 01:02:09', +'efg', '2020-10-25 01:02:10', +'fgh', '2020-10-25 01:02:11'); +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', +'1234567890', '2020-10-25 01:02:08', +'cde', '2020-10-25 01:02:10', +'def', '2020-10-25 01:02:11', +'efg', '2020-10-25 01:02:12', +'fgh', '2020-10-25 01:02:13'); +ERROR HY000: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1 +select * from st3; +a b c d e f g h i j k l +1 2020-10-25 01:02:04 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:05 cde 2020-10-25 01:02:07 def 2020-10-25 01:02:08 efg 2020-10-25 01:02:09 fgh 2020-10-25 01:02:10 +1 2020-10-25 01:02:05 ¹²³⁴⁵⁶⁷⁸⁹⁰¹ 2020-10-25 01:02:06 cde 2020-10-25 01:02:08 def 2020-10-25 01:02:09 efg 2020-10-25 01:02:10 fgh 2020-10-25 01:02:11 +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; +column_name data_type character_maximum_length character_octet_length +a tinytext 255 255 +b datetime NULL NULL +c tinytext 255 255 +d datetime NULL NULL +e text 65535 65535 +f datetime NULL NULL +g text 65535 65535 +h datetime NULL NULL +i mediumtext 16777215 16777215 +j datetime NULL NULL +k longtext 4294967295 4294967295 +l datetime NULL NULL +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +create table st1 (a text(8) NOT NULL, b datetime NOT NULL, +c text(10) NOT NULL, d datetime NOT NULL, +e text(255) NOT NULL, f datetime NOT NULL, +g text NOT NULL, h datetime NOT NULL, +i text(65535) NOT NULL, j datetime NOT NULL, +k text(16777215) NOT NULL, l datetime NOT NULL +) default character set utf8; +create table st2 (a text(8), b datetime NOT NULL, +c text(10), d datetime NOT NULL, +e text(255), f datetime NOT NULL, +g text, h datetime NOT NULL, +i text(65535), j datetime NOT NULL, +k text(16777215), l datetime NOT NULL +) default character set utf8; +create table i1 (a text(8) NOT NULL, b datetime NOT NULL, +c text(10) NOT NULL, d datetime NOT NULL, +e text(255) NOT NULL, f datetime NOT NULL, +g text NOT NULL, h datetime NOT NULL, +i text(65535) NOT NULL, j datetime NOT NULL, +k text(16777215) NOT NULL, l datetime NOT NULL +) default character set utf8; +create table i2 (a text(8), b datetime NOT NULL, +c text(10), d datetime NOT NULL, +e text(255), f datetime NOT NULL, +g text, h datetime NOT NULL, +i text(65535), j datetime NOT NULL, +k text(16777215), l datetime NOT NULL +) default character set utf8; +insert into i1 values ('ab', '2020-10-25 01:02:03', +'bcd', '2020-10-25 01:02:04', +'cde', '2020-10-25 01:02:05', +'def', '2020-10-25 01:02:06', +'efg', '2020-10-25 01:02:07', +'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', +'2020-10-25 01:02:04', +'2020-10-25 01:02:05', +'2020-10-25 01:02:06', +'2020-10-25 01:02:07', +'2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +a b c d e f g h i j k l +ab 2020-10-25 01:02:03 bcd 2020-10-25 01:02:04 cde 2020-10-25 01:02:05 def 2020-10-25 01:02:06 efg 2020-10-25 01:02:07 fgh 2020-10-25 01:02:08 +select * from st2; +a b c d e f g h i j k l +NULL 2020-10-25 01:02:03 NULL 2020-10-25 01:02:04 NULL 2020-10-25 01:02:05 NULL 2020-10-25 01:02:06 NULL 2020-10-25 01:02:07 NULL 2020-10-25 01:02:08 +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', +'cde', '2020-10-25 01:02:07', +'def', '2020-10-25 01:02:08', +'efg', '2020-10-25 01:02:09', +'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', +'cde', '2020-10-25 01:02:08', +'def', '2020-10-25 01:02:09', +'efg', '2020-10-25 01:02:10', +'fgh', '2020-10-25 01:02:11'); +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', +'1234567890', '2020-10-25 01:02:08', +'cde', '2020-10-25 01:02:10', +'def', '2020-10-25 01:02:11', +'efg', '2020-10-25 01:02:12', +'fgh', '2020-10-25 01:02:13'); +ERROR HY000: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1 +select * from st3; +a b c d e f g h i j k l +1 2020-10-25 01:02:04 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:05 cde 2020-10-25 01:02:07 def 2020-10-25 01:02:08 efg 2020-10-25 01:02:09 fgh 2020-10-25 01:02:10 +1 2020-10-25 01:02:05 ¹²³⁴⁵⁶⁷⁸⁹⁰¹ 2020-10-25 01:02:06 cde 2020-10-25 01:02:08 def 2020-10-25 01:02:09 efg 2020-10-25 01:02:10 fgh 2020-10-25 01:02:11 +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; +column_name data_type character_maximum_length character_octet_length +a tinytext 255 255 +b datetime NULL NULL +c tinytext 255 255 +d datetime NULL NULL +e text 65535 65535 +f datetime NULL NULL +g text 65535 65535 +h datetime NULL NULL +i mediumtext 16777215 16777215 +j datetime NULL NULL +k longtext 4294967295 4294967295 +l datetime NULL NULL +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +create table st1 (a text(8) NOT NULL, b datetime NOT NULL, +c text(10) NOT NULL, d datetime NOT NULL, +e text(255) NOT NULL, f datetime NOT NULL, +g text NOT NULL, h datetime NOT NULL, +i text(65535) NOT NULL, j datetime NOT NULL, +k text(16777215) NOT NULL, l datetime NOT NULL +) default character set utf8mb4; +create table st2 (a text(8), b datetime NOT NULL, +c text(10), d datetime NOT NULL, +e text(255), f datetime NOT NULL, +g text, h datetime NOT NULL, +i text(65535), j datetime NOT NULL, +k text(16777215), l datetime NOT NULL +) default character set utf8mb4; +create table i1 (a text(8) NOT NULL, b datetime NOT NULL, +c text(10) NOT NULL, d datetime NOT NULL, +e text(255) NOT NULL, f datetime NOT NULL, +g text NOT NULL, h datetime NOT NULL, +i text(65535) NOT NULL, j datetime NOT NULL, +k text(16777215) NOT NULL, l datetime NOT NULL +) default character set utf8mb4; +create table i2 (a text(8), b datetime NOT NULL, +c text(10), d datetime NOT NULL, +e text(255), f datetime NOT NULL, +g text, h datetime NOT NULL, +i text(65535), j datetime NOT NULL, +k text(16777215), l datetime NOT NULL +) default character set utf8mb4; +insert into i1 values ('ab', '2020-10-25 01:02:03', +'bcd', '2020-10-25 01:02:04', +'cde', '2020-10-25 01:02:05', +'def', '2020-10-25 01:02:06', +'efg', '2020-10-25 01:02:07', +'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', +'2020-10-25 01:02:04', +'2020-10-25 01:02:05', +'2020-10-25 01:02:06', +'2020-10-25 01:02:07', +'2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +a b c d e f g h i j k l +ab 2020-10-25 01:02:03 bcd 2020-10-25 01:02:04 cde 2020-10-25 01:02:05 def 2020-10-25 01:02:06 efg 2020-10-25 01:02:07 fgh 2020-10-25 01:02:08 +select * from st2; +a b c d e f g h i j k l +NULL 2020-10-25 01:02:03 NULL 2020-10-25 01:02:04 NULL 2020-10-25 01:02:05 NULL 2020-10-25 01:02:06 NULL 2020-10-25 01:02:07 NULL 2020-10-25 01:02:08 +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', +'cde', '2020-10-25 01:02:07', +'def', '2020-10-25 01:02:08', +'efg', '2020-10-25 01:02:09', +'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', +_utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', +'cde', '2020-10-25 01:02:08', +'def', '2020-10-25 01:02:09', +'efg', '2020-10-25 01:02:10', +'fgh', '2020-10-25 01:02:11'); +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', +'1234567890', '2020-10-25 01:02:08', +'cde', '2020-10-25 01:02:10', +'def', '2020-10-25 01:02:11', +'efg', '2020-10-25 01:02:12', +'fgh', '2020-10-25 01:02:13'); +select * from st3; +a b c d e f g h i j k l +1 2020-10-25 01:02:04 ¹²³⁴⁵⁶⁷⁸⁹⁰ 2020-10-25 01:02:05 cde 2020-10-25 01:02:07 def 2020-10-25 01:02:08 efg 2020-10-25 01:02:09 fgh 2020-10-25 01:02:10 +1 2020-10-25 01:02:05 ¹²³⁴⁵⁶⁷⁸⁹⁰¹ 2020-10-25 01:02:06 cde 2020-10-25 01:02:08 def 2020-10-25 01:02:09 efg 2020-10-25 01:02:10 fgh 2020-10-25 01:02:11 +? 2020-10-25 01:02:07 1234567890 2020-10-25 01:02:08 cde 2020-10-25 01:02:10 def 2020-10-25 01:02:11 efg 2020-10-25 01:02:12 fgh 2020-10-25 01:02:13 +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; +column_name data_type character_maximum_length character_octet_length +a tinytext 255 255 +b datetime NULL NULL +c tinytext 255 255 +d datetime NULL NULL +e text 65535 65535 +f datetime NULL NULL +g text 65535 65535 +h datetime NULL NULL +i mediumtext 16777215 16777215 +j datetime NULL NULL +k longtext 4294967295 4294967295 +l datetime NULL NULL +drop table st1; +drop table st2; +drop table st3; +drop table i1; +drop table i2; +drop database different_charsets_test; diff --git a/mysql-test/suite/tianmu/r/insert_select.result b/mysql-test/suite/tianmu/r/insert_select.result index 8b2bbf3ab..72ddd4774 100644 --- a/mysql-test/suite/tianmu/r/insert_select.result +++ b/mysql-test/suite/tianmu/r/insert_select.result @@ -4,32 +4,19 @@ DROP DATABASE IF EXISTS insert_select_db; CREATE DATABASE insert_select_db; USE insert_select_db; -drop table if exists t1,t2,t3; SET sql_mode = 'NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER'; create table t1 (bandID MEDIUMINT NOT NULL PRIMARY KEY, payoutID SMALLINT NOT NULL); insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); create table t2 (payoutID SMALLINT NOT NULL PRIMARY KEY); insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; -insert into t2 (payoutID) SELECT payoutID+10 FROM t1; -ERROR 23000: Duplicate entry '16' for key 'PRIMARY' -insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1; -Warnings: -Warning 1062 Duplicate entry '16' for key 'PRIMARY' -Warning 1062 Duplicate entry '22' for key 'PRIMARY' -select * from t2; +select * from t2 order by payoutID; payoutID -6 +1 4 +6 9 10 -1 12 -16 -14 -19 -20 -11 -22 drop table t1,t2; # # Test of insert ... select from same table @@ -550,23 +537,6 @@ insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x); ERROR 42S22: Unknown column 't2.x' in 'field list' drop table t1,t2; # -# INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big tables -# -CREATE TABLE t1 (a int PRIMARY KEY); -INSERT INTO t1 values (1), (2); -flush status; -INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1; -show status like 'Handler_read%'; -Variable_name Value -Handler_read_first 0 -Handler_read_key 0 -Handler_read_last 0 -Handler_read_next 0 -Handler_read_prev 0 -Handler_read_rnd 0 -Handler_read_rnd_next 1 -DROP TABLE t1; -# # INSERT INTO SELECT inserts values even if # SELECT statement itself returns empty # @@ -615,10 +585,10 @@ use bug21774_1; INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1; DROP DATABASE bug21774_1; DROP DATABASE bug21774_2; -USE test; # # wrong result, when INSERT t1 SELECT ... FROM t1 ON DUPLICATE # +use insert_select_db; CREATE TABLE t1 (f1 INT, f2 INT ); CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT); INSERT INTO t1 VALUES (1,1),(2,2),(10,10); diff --git a/mysql-test/suite/tianmu/r/left_join.result b/mysql-test/suite/tianmu/r/left_join.result index 53cd1ad7a..9f53c48df 100644 --- a/mysql-test/suite/tianmu/r/left_join.result +++ b/mysql-test/suite/tianmu/r/left_join.result @@ -110,6 +110,10 @@ select * from t1 left join t2 left join t3 on t2.a=t3.a on t1.a=t2.a where t3.a a a a 3 3 3 4 4 4 +select * from t1 left join t2 left join t3 on t2.a=t3.a on t1.a=t2.a where t3.a is null order by 1,2,3; +a a a +1 NULL NULL +2 2 NULL select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a order by 1,2,3,4; a a a a 1 NULL NULL NULL @@ -135,6 +139,11 @@ a a a a select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a where t4.a < 100 order by 1,2,3,4; a a a a 4 4 4 4 +select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a where t4.a is null order by 1,2,3,4; +a a a a +1 NULL NULL NULL +2 2 NULL NULL +3 3 3 NULL select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t4.a order by 1,2,3,4; a a a a 1 NULL NULL NULL @@ -190,6 +199,11 @@ a a a a select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a where t4.a < 100 order by 1,2,3,4; a a a a 4 4 4 4 +select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a where t4.a is null order by 1,2,3,4; +a a a a +1 NULL NULL NULL +2 2 NULL NULL +3 3 3 NULL select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t4.a order by 1,2,3,4; a a a a 1 NULL NULL NULL diff --git a/mysql-test/suite/tianmu/t/ctas1.test b/mysql-test/suite/tianmu/t/ctas1.test new file mode 100644 index 000000000..04cbdd68b --- /dev/null +++ b/mysql-test/suite/tianmu/t/ctas1.test @@ -0,0 +1,100 @@ +--source include/have_tianmu.inc + +--echo # +--echo # Test CREATE TABLE AS SELECT +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS ctas_test; +--enable_warnings + +CREATE DATABASE ctas_test; +USE ctas_test; + +CREATE TABLE `user` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `user_name` varchar(200) DEFAULT '', + `phone` varchar(200) DEFAULT '', + `b_code` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +)DEFAULT CHARSET=utf8; + +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('李明', '101', '2021001'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('赵慧', '456', '2020001'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('李凯', '123', '2021002'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('张三1', '123', '2022001'); +INSERT INTO `user`(`user_name`, `phone`, `b_code`) VALUES ('张三2', '123', '2021003'); + +create table user1 as select * from user; +select * from user1; +desc user1; + +create table user2 as select user_name, phone from user; +select * from user2; + +create table user3 as select user_name, phone from user limit 2; +select * from user3; + +create table user4 select user_name, phone from user limit 4; +select * from user4; + +create table user5 as select * from user where b_code like '2021%'; +select * from user5; +desc user5; + +create table user6 like user; +select * from user6; +desc user6; + +create table user7 like user; +insert into user7 select * from user; + +CREATE TABLE user_bk4( id INT NOT NULL) ENGINE=InnoDB SELECT id,user_name FROM user; +select * from user_bk4; + +CREATE TABLE user_bk5( id INT NOT NULL primary key)ENGINE=TIANMU SELECT id,user_name FROM user; +select * from user_bk5; + +create table user_bk6 select id+1 as id1 from user; +select * from user_bk6; +desc user_bk6; + +# create table as select join +DROP TABLE IF EXISTS `test_tbl`; +CREATE TABLE `test_tbl` ( + `test_id` int(11) NOT NULL AUTO_INCREMENT, + `test_title` varchar(100) NOT NULL, + `test_author` varchar(40) NOT NULL, + `submission_date` date DEFAULT NULL, + PRIMARY KEY (`test_id`) +) DEFAULT CHARSET=utf8; + +INSERT INTO `test_tbl` +VALUES +('1', 'c++', 'test', '2017-04-12'), +('2', 'MySQL', 'test', '2017-04-12'), +('3', 'Java', 'test.COM', '2015-05-01'), +('4', 'Python', 'test.COM', '2016-03-06'), +('5', 'C', 'FK', '2017-04-05'); + + +DROP TABLE IF EXISTS `tcount_tbl`; +CREATE TABLE `tcount_tbl` ( + `test_author` varchar(255) NOT NULL DEFAULT '', + `test_count` int(11) NOT NULL DEFAULT '0' +) DEFAULT CHARSET=utf8; + +INSERT INTO `tcount_tbl` +VALUES +('test','10'), +('test.COM','20'), +('Google', '22'); + +create table test_tbl1 SELECT test_id, submission_date FROM test_tbl a left JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl2 SELECT a.test_id, a.test_author FROM test_tbl a right JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl3 SELECT a.test_id, a.test_author, b.test_count FROM test_tbl a INNER JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl4 as SELECT a.test_id, a.test_author, b.test_count FROM test_tbl a INNER JOIN tcount_tbl b ON a.test_author = b.test_author; +create table test_tbl5 select * from test_tbl natural join tcount_tbl; + +# clean up +drop database ctas_test; diff --git a/mysql-test/suite/tianmu/t/different_charsets_b.test b/mysql-test/suite/tianmu/t/different_charsets_b.test new file mode 100644 index 000000000..88d460206 --- /dev/null +++ b/mysql-test/suite/tianmu/t/different_charsets_b.test @@ -0,0 +1,538 @@ +--source include/have_tianmu.inc + +--echo # +--echo # Test column length with different charsets 2 +--echo # + +-- disable_warnings +drop database if exists different_charsets_test; +set character_set_client = utf8; +set character_set_connection = utf8; +set character_set_database = utf8mb4; +set character_set_results = utf8; +set character_set_server = utf8mb4; +-- enable_warnings + +create database different_charsets_test; +use different_charsets_test; + +# CHAR tests +# With mix of utf8 and utf8mb4 character sets at the column level +--disable_warnings +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +--enable_warnings +create table st1 (a char(1) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, + c char(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, + e char(240) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, + g char(255) CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL + ); +create table st2 (a char(1) CHARACTER SET utf8, b datetime NOT NULL, + c char(10) CHARACTER SET utf8mb4, d datetime NOT NULL, + e char(240) CHARACTER SET utf8, f datetime NOT NULL, + g char(255) CHARACTER SET utf8mb4, h datetime NOT NULL + ); +create table i1 (a char(1) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, + c char(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, + e char(240) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, + g char(255) CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL + ); +create table i2 (a char(1) CHARACTER SET utf8, b datetime NOT NULL, + c char(10) CHARACTER SET utf8mb4, d datetime NOT NULL, + e char(240) CHARACTER SET utf8, f datetime NOT NULL, + g char(255) CHARACTER SET utf8mb4, h datetime NOT NULL + ); +insert into i1 values ('a', '2020-10-25 01:02:03', + 'bcd', '2020-10-25 01:02:04', + 'cde', '2020-10-25 01:02:05', + 'def', '2020-10-25 01:02:06' + ); +insert into i2(b, d, f, h) values ('2020-10-25 01:02:03', + '2020-10-25 01:02:04', + '2020-10-25 01:02:05', + '2020-10-25 01:02:06' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +select * from st2; + +# test some corner cases: wrong encoding, truncating, internal structure +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', + 'abc', '2020-10-25 01:02:06', + 'cde', '2020-10-25 01:02:07'); +--error 1406 +insert into st3 values ('1', '2020-10-25 01:02:05', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', + 'abc', '2020-10-25 01:02:07', + 'cde', '2020-10-25 01:02:08'); +insert ignore into st3 values ('12', '2020-10-25 01:02:06', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:07', + 'abc', '2020-10-25 01:02:08', + 'cde', '2020-10-25 01:02:09'); +--error 1366 +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', + '1234567890', '2020-10-25 01:02:08', + 'abc', '2020-10-25 01:02:09', + 'cde', '2020-10-25 01:02:10'); +select * from st3; +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; + +# With utf8 character set at the table level +--disable_warnings +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +--enable_warnings +create table st1 (a char(1) NOT NULL, b datetime NOT NULL, + c char(10) NOT NULL, d datetime NOT NULL, + e char(240) NOT NULL, f datetime NOT NULL, + g char(255) NOT NULL, h datetime NOT NULL + ) default character set utf8; +create table st2 (a char(1), b datetime NOT NULL, + c char(10), d datetime NOT NULL, + e char(240), f datetime NOT NULL, + g char(255), h datetime NOT NULL + ) default character set utf8; +create table i1 (a char(1) NOT NULL, b datetime NOT NULL, + c char(10) NOT NULL, d datetime NOT NULL, + e char(240) NOT NULL, f datetime NOT NULL, + g char(255) NOT NULL, h datetime NOT NULL + ) default character set utf8; +create table i2 (a char(1), b datetime NOT NULL, + c char(10), d datetime NOT NULL, + e char(240), f datetime NOT NULL, + g char(255), h datetime NOT NULL + ) default character set utf8; +insert into i1 values ('a', '2020-10-25 01:02:03', + 'bcd', '2020-10-25 01:02:04', + 'cde', '2020-10-25 01:02:05', + 'def', '2020-10-25 01:02:06' + ); +insert into i2(b, d, f, h) values ('2020-10-25 01:02:03', + '2020-10-25 01:02:04', + '2020-10-25 01:02:05', + '2020-10-25 01:02:06' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +select * from st2; + +# test some corner cases: wrong encoding, truncating, internal structure +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', + 'abc', '2020-10-25 01:02:06', + 'cde', '2020-10-25 01:02:07'); +--error 1406 +insert into st3 values ('1', '2020-10-25 01:02:05', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', + 'abc', '2020-10-25 01:02:07', + 'cde', '2020-10-25 01:02:08'); +insert ignore into st3 values ('12', '2020-10-25 01:02:06', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:07', + 'abc', '2020-10-25 01:02:08', + 'cde', '2020-10-25 01:02:09'); +--error 1366 +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', + '1234567890', '2020-10-25 01:02:08', + 'abc', '2020-10-25 01:02:09', + 'cde', '2020-10-25 01:02:10'); +select * from st3; +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; + +# With utf8mb4 character set at the table level +--disable_warnings +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +--enable_warnings +create table st1 (a char(1) NOT NULL, b datetime NOT NULL, + c char(10) NOT NULL, d datetime NOT NULL, + e char(240) NOT NULL, f datetime NOT NULL, + g char(255) NOT NULL, h datetime NOT NULL + ) default character set utf8mb4; +create table st2 (a char(1), b datetime NOT NULL, + c char(10), d datetime NOT NULL, + e char(240), f datetime NOT NULL, + g char(255), h datetime NOT NULL + ) default character set utf8mb4; +create table i1 (a char(1) NOT NULL, b datetime NOT NULL, + c char(10) NOT NULL, d datetime NOT NULL, + e char(240) NOT NULL, f datetime NOT NULL, + g char(255) NOT NULL, h datetime NOT NULL + ) default character set utf8mb4; +create table i2 (a char(1), b datetime NOT NULL, + c char(10), d datetime NOT NULL, + e char(240), f datetime NOT NULL, + g char(255), h datetime NOT NULL + ) default character set utf8mb4; +insert into i1 values ('a', '2020-10-25 01:02:03', + 'bcd', '2020-10-25 01:02:04', + 'cde', '2020-10-25 01:02:05', + 'def', '2020-10-25 01:02:06' + ); +insert into i2(b, d, f, h) values ('2020-10-25 01:02:03', + '2020-10-25 01:02:04', + '2020-10-25 01:02:05', + '2020-10-25 01:02:06' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +select * from st2; + +# test some corner cases: wrong encoding, truncating, internal structure +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', + 'abc', '2020-10-25 01:02:06', + 'cde', '2020-10-25 01:02:07'); +--error 1406 +insert into st3 values ('1', '2020-10-25 01:02:05', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', + 'abc', '2020-10-25 01:02:07', + 'cde', '2020-10-25 01:02:08'); +insert ignore into st3 values ('12', '2020-10-25 01:02:06', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:07', + 'abc', '2020-10-25 01:02:08', + 'cde', '2020-10-25 01:02:09'); +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', + '1234567890', '2020-10-25 01:02:08', + 'abc', '2020-10-25 01:02:09', + 'cde', '2020-10-25 01:02:10'); +select * from st3; +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; + +# TEXT tests +# Without character set +--disable_warnings +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +--enable_warnings +create table st1 (a text(8) NOT NULL, b datetime NOT NULL, + c text(10) NOT NULL, d datetime NOT NULL, + e text(255) NOT NULL, f datetime NOT NULL, + g text NOT NULL, h datetime NOT NULL, + i text(65535) NOT NULL, j datetime NOT NULL, + k text(16777215) NOT NULL, l datetime NOT NULL + ); +create table st2 (a text(8), b datetime NOT NULL, + c text(10), d datetime NOT NULL, + e text(255), f datetime NOT NULL, + g text, h datetime NOT NULL, + i text(65535), j datetime NOT NULL, + k text(16777215), l datetime NOT NULL + ); +create table i1 (a text(8) NOT NULL, b datetime NOT NULL, + c text(10) NOT NULL, d datetime NOT NULL, + e text(255) NOT NULL, f datetime NOT NULL, + g text NOT NULL, h datetime NOT NULL, + i text(65535) NOT NULL, j datetime NOT NULL, + k text(16777215) NOT NULL, l datetime NOT NULL + ); +create table i2 (a text(8), b datetime NOT NULL, + c text(10), d datetime NOT NULL, + e text(255), f datetime NOT NULL, + g text, h datetime NOT NULL, + i text(65535), j datetime NOT NULL, + k text(16777215), l datetime NOT NULL + ); +insert into i1 values ('a', '2020-10-25 01:02:03', + 'bcd', '2020-10-25 01:02:04', + 'cde', '2020-10-25 01:02:05', + 'def', '2020-10-25 01:02:06', + 'efg', '2020-10-25 01:02:07', + 'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', + '2020-10-25 01:02:04', + '2020-10-25 01:02:05', + '2020-10-25 01:02:06', + '2020-10-25 01:02:07', + '2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +select * from st2; + +# test some corner cases: wrong encoding, truncating, internal structure +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', + '1234567890', '2020-10-25 01:02:05', + 'cde', '2020-10-25 01:02:07', + 'def', '2020-10-25 01:02:08', + 'efg', '2020-10-25 01:02:09', + 'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', + '12345678901', '2020-10-25 01:02:06', + 'cde', '2020-10-25 01:02:08', + 'def', '2020-10-25 01:02:09', + 'efg', '2020-10-25 01:02:10', + 'fgh', '2020-10-25 01:02:11'); +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', + '1234567890', '2020-10-25 01:02:08', + 'cde', '2020-10-25 01:02:10', + 'def', '2020-10-25 01:02:11', + 'efg', '2020-10-25 01:02:12', + 'fgh', '2020-10-25 01:02:13'); +select * from st3; +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; + +# With mix of utf8 and utf8mb4 character sets at the column level +--disable_warnings +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +--enable_warnings +create table st1 (a text(8) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, + c text(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, + e text(255) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, + g text CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL, + i text(65535) CHARACTER SET utf8 NOT NULL, j datetime NOT NULL, + k text(16777215) CHARACTER SET utf8mb4 NOT NULL, l datetime NOT NULL + ); +create table st2 (a text(8) CHARACTER SET utf8, b datetime NOT NULL, + c text(10) CHARACTER SET utf8mb4, d datetime NOT NULL, + e text(255) CHARACTER SET utf8, f datetime NOT NULL, + g text CHARACTER SET utf8mb4, h datetime NOT NULL, + i text(65535) CHARACTER SET utf8, j datetime NOT NULL, + k text(16777215) CHARACTER SET utf8mb4, l datetime NOT NULL + ); +create table i1 (a text(8) CHARACTER SET utf8 NOT NULL, b datetime NOT NULL, + c text(10) CHARACTER SET utf8mb4 NOT NULL, d datetime NOT NULL, + e text(255) CHARACTER SET utf8 NOT NULL, f datetime NOT NULL, + g text CHARACTER SET utf8mb4 NOT NULL, h datetime NOT NULL, + i text(65535) CHARACTER SET utf8 NOT NULL, j datetime NOT NULL, + k text(16777215) CHARACTER SET utf8mb4 NOT NULL, l datetime NOT NULL + ); +create table i2 (a text(8) CHARACTER SET utf8, b datetime NOT NULL, + c text(10) CHARACTER SET utf8mb4, d datetime NOT NULL, + e text(255) CHARACTER SET utf8, f datetime NOT NULL, + g text CHARACTER SET utf8mb4, h datetime NOT NULL, + i text(65535) CHARACTER SET utf8, j datetime NOT NULL, + k text(16777215) CHARACTER SET utf8mb4, l datetime NOT NULL + ); +insert into i1 values ('ab', '2020-10-25 01:02:03', + 'bcd', '2020-10-25 01:02:04', + 'cde', '2020-10-25 01:02:05', + 'def', '2020-10-25 01:02:06', + 'efg', '2020-10-25 01:02:07', + 'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', + '2020-10-25 01:02:04', + '2020-10-25 01:02:05', + '2020-10-25 01:02:06', + '2020-10-25 01:02:07', + '2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +select * from st2; + +# test some corner cases: wrong encoding, truncating, internal structure +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', + 'cde', '2020-10-25 01:02:07', + 'def', '2020-10-25 01:02:08', + 'efg', '2020-10-25 01:02:09', + 'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', + 'cde', '2020-10-25 01:02:08', + 'def', '2020-10-25 01:02:09', + 'efg', '2020-10-25 01:02:10', + 'fgh', '2020-10-25 01:02:11'); +--error 1366 +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', + '1234567890', '2020-10-25 01:02:08', + 'cde', '2020-10-25 01:02:10', + 'def', '2020-10-25 01:02:11', + 'efg', '2020-10-25 01:02:12', + 'fgh', '2020-10-25 01:02:13'); +select * from st3; +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; + +# With utf8 character set at the table level +--disable_warnings +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +--enable_warnings +create table st1 (a text(8) NOT NULL, b datetime NOT NULL, + c text(10) NOT NULL, d datetime NOT NULL, + e text(255) NOT NULL, f datetime NOT NULL, + g text NOT NULL, h datetime NOT NULL, + i text(65535) NOT NULL, j datetime NOT NULL, + k text(16777215) NOT NULL, l datetime NOT NULL + ) default character set utf8; +create table st2 (a text(8), b datetime NOT NULL, + c text(10), d datetime NOT NULL, + e text(255), f datetime NOT NULL, + g text, h datetime NOT NULL, + i text(65535), j datetime NOT NULL, + k text(16777215), l datetime NOT NULL + ) default character set utf8; +create table i1 (a text(8) NOT NULL, b datetime NOT NULL, + c text(10) NOT NULL, d datetime NOT NULL, + e text(255) NOT NULL, f datetime NOT NULL, + g text NOT NULL, h datetime NOT NULL, + i text(65535) NOT NULL, j datetime NOT NULL, + k text(16777215) NOT NULL, l datetime NOT NULL + ) default character set utf8; +create table i2 (a text(8), b datetime NOT NULL, + c text(10), d datetime NOT NULL, + e text(255), f datetime NOT NULL, + g text, h datetime NOT NULL, + i text(65535), j datetime NOT NULL, + k text(16777215), l datetime NOT NULL + ) default character set utf8; +insert into i1 values ('ab', '2020-10-25 01:02:03', + 'bcd', '2020-10-25 01:02:04', + 'cde', '2020-10-25 01:02:05', + 'def', '2020-10-25 01:02:06', + 'efg', '2020-10-25 01:02:07', + 'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', + '2020-10-25 01:02:04', + '2020-10-25 01:02:05', + '2020-10-25 01:02:06', + '2020-10-25 01:02:07', + '2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +select * from st2; + +# test some corner cases: wrong encoding, truncating, internal structure +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', + 'cde', '2020-10-25 01:02:07', + 'def', '2020-10-25 01:02:08', + 'efg', '2020-10-25 01:02:09', + 'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', + 'cde', '2020-10-25 01:02:08', + 'def', '2020-10-25 01:02:09', + 'efg', '2020-10-25 01:02:10', + 'fgh', '2020-10-25 01:02:11'); +--error 1366 +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', + '1234567890', '2020-10-25 01:02:08', + 'cde', '2020-10-25 01:02:10', + 'def', '2020-10-25 01:02:11', + 'efg', '2020-10-25 01:02:12', + 'fgh', '2020-10-25 01:02:13'); +select * from st3; +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; + +# With utf8mb4 character set at the table level +--disable_warnings +drop table if exists st1; +drop table if exists st2; +drop table if exists st3; +drop table if exists i1; +drop table if exists i2; +--enable_warnings +create table st1 (a text(8) NOT NULL, b datetime NOT NULL, + c text(10) NOT NULL, d datetime NOT NULL, + e text(255) NOT NULL, f datetime NOT NULL, + g text NOT NULL, h datetime NOT NULL, + i text(65535) NOT NULL, j datetime NOT NULL, + k text(16777215) NOT NULL, l datetime NOT NULL + ) default character set utf8mb4; +create table st2 (a text(8), b datetime NOT NULL, + c text(10), d datetime NOT NULL, + e text(255), f datetime NOT NULL, + g text, h datetime NOT NULL, + i text(65535), j datetime NOT NULL, + k text(16777215), l datetime NOT NULL + ) default character set utf8mb4; +create table i1 (a text(8) NOT NULL, b datetime NOT NULL, + c text(10) NOT NULL, d datetime NOT NULL, + e text(255) NOT NULL, f datetime NOT NULL, + g text NOT NULL, h datetime NOT NULL, + i text(65535) NOT NULL, j datetime NOT NULL, + k text(16777215) NOT NULL, l datetime NOT NULL + ) default character set utf8mb4; +create table i2 (a text(8), b datetime NOT NULL, + c text(10), d datetime NOT NULL, + e text(255), f datetime NOT NULL, + g text, h datetime NOT NULL, + i text(65535), j datetime NOT NULL, + k text(16777215), l datetime NOT NULL + ) default character set utf8mb4; +insert into i1 values ('ab', '2020-10-25 01:02:03', + 'bcd', '2020-10-25 01:02:04', + 'cde', '2020-10-25 01:02:05', + 'def', '2020-10-25 01:02:06', + 'efg', '2020-10-25 01:02:07', + 'fgh', '2020-10-25 01:02:08' + ); +insert into i2(b, d, f, h, j, l) values ('2020-10-25 01:02:03', + '2020-10-25 01:02:04', + '2020-10-25 01:02:05', + '2020-10-25 01:02:06', + '2020-10-25 01:02:07', + '2020-10-25 01:02:08' + ); +insert into st1 select * from i1; +insert into st2 select * from i2; +select * from st1; +select * from st2; + +# test some corner cases: wrong encoding, truncating, internal structure +create table st3 like st1; +insert into st3 values ('1', '2020-10-25 01:02:04', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0, '2020-10-25 01:02:05', + 'cde', '2020-10-25 01:02:07', + 'def', '2020-10-25 01:02:08', + 'efg', '2020-10-25 01:02:09', + 'fgh', '2020-10-25 01:02:10'); +insert into st3 values ('1', '2020-10-25 01:02:05', + _utf8mb4 0xc2b9c2b2c2b3e281b4e281b5e281b6e281b7e281b8e281b9e281b0c2b9, '2020-10-25 01:02:06', + 'cde', '2020-10-25 01:02:08', + 'def', '2020-10-25 01:02:09', + 'efg', '2020-10-25 01:02:10', + 'fgh', '2020-10-25 01:02:11'); +insert into st3 values (_utf8mb4 0xF09F988E, '2020-10-25 01:02:07', + '1234567890', '2020-10-25 01:02:08', + 'cde', '2020-10-25 01:02:10', + 'def', '2020-10-25 01:02:11', + 'efg', '2020-10-25 01:02:12', + 'fgh', '2020-10-25 01:02:13'); +select * from st3; +select column_name, data_type, character_maximum_length, character_octet_length from information_schema.columns where table_schema='different_charsets_test' and table_name='st3'; + +drop table st1; +drop table st2; +drop table st3; +drop table i1; +drop table i2; + +drop database different_charsets_test; diff --git a/mysql-test/suite/tianmu/t/insert_select.test b/mysql-test/suite/tianmu/t/insert_select.test index 7e1b3f3a5..5e7eae6cc 100644 --- a/mysql-test/suite/tianmu/t/insert_select.test +++ b/mysql-test/suite/tianmu/t/insert_select.test @@ -1,7 +1,9 @@ ---source include/no_valgrind_without_big.inc +--source include/have_tianmu.inc + --echo # --echo # Problem with INSERT ... SELECT --echo # + --disable_warnings DROP DATABASE IF EXISTS insert_select_db; --enable_warnings @@ -9,18 +11,13 @@ DROP DATABASE IF EXISTS insert_select_db; CREATE DATABASE insert_select_db; USE insert_select_db; ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings SET sql_mode = 'NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER'; create table t1 (bandID MEDIUMINT NOT NULL PRIMARY KEY, payoutID SMALLINT NOT NULL); insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); create table t2 (payoutID SMALLINT NOT NULL PRIMARY KEY); insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; ---error ER_DUP_ENTRY -insert into t2 (payoutID) SELECT payoutID+10 FROM t1; -insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1; -select * from t2; + +select * from t2 order by payoutID; drop table t1,t2; --echo # @@ -72,20 +69,6 @@ insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z); insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x); drop table t1,t2; ---echo # ---echo # INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big tables ---echo # - -#Note: not an exsaustive test : just a check of the code path. -CREATE TABLE t1 (a int PRIMARY KEY); -INSERT INTO t1 values (1), (2); - -flush status; -INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1; -show status like 'Handler_read%'; - -DROP TABLE t1; - --echo # --echo # INSERT INTO SELECT inserts values even if --echo # SELECT statement itself returns empty @@ -138,12 +121,11 @@ INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1; DROP DATABASE bug21774_1; DROP DATABASE bug21774_2; -USE test; --echo # --echo # wrong result, when INSERT t1 SELECT ... FROM t1 ON DUPLICATE --echo # - +use insert_select_db; CREATE TABLE t1 (f1 INT, f2 INT ); CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT); INSERT INTO t1 VALUES (1,1),(2,2),(10,10); @@ -205,5 +187,6 @@ SELECT *, HEX(a) FROM t1 WHERE a = 'abc-def'; SELECT *, HEX(a) FROM t1 WHERE a = '\'(),-.'; DROP TABLE t1; + # Clean UP DROP DATABASE insert_select_db; diff --git a/mysql-test/suite/tianmu/t/left_join.test b/mysql-test/suite/tianmu/t/left_join.test index b8db6aba7..9c3d6365b 100644 --- a/mysql-test/suite/tianmu/t/left_join.test +++ b/mysql-test/suite/tianmu/t/left_join.test @@ -46,8 +46,7 @@ select * from t1 left join t2 left join t3 on t2.a=t3.a on t1.a=t2.a where t2.a select * from t1 left join t2 left join t3 on t2.a=t3.a on t1.a=t2.a where t2.a is null order by 1,2,3; select * from t1 left join t2 left join t3 on t2.a=t3.a on t1.a=t2.a where t3.a < 100 order by 1,2,3; -# Below query is disabled until fixed #887 -#select * from t1 left join t2 left join t3 on t2.a=t3.a on t1.a=t2.a where t3.a is null order by 1,2,3; +select * from t1 left join t2 left join t3 on t2.a=t3.a on t1.a=t2.a where t3.a is null order by 1,2,3; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a order by 1,2,3,4; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a where t2.a < 100 order by 1,2,3,4; @@ -56,8 +55,7 @@ select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4. select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a where t3.a is null order by 1,2,3,4; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a where t4.a < 100 order by 1,2,3,4; -# Below query is disabled until fixed #887 -#select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a where t4.a is null order by 1,2,3,4; +select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t3.a where t4.a is null order by 1,2,3,4; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t4.a order by 1,2,3,4; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t1.a=t4.a where t2.a < 100 order by 1,2,3,4; @@ -74,8 +72,7 @@ select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4. select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a where t3.a is null order by 1,2,3,4; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a where t4.a < 100 order by 1,2,3,4; -# Below query is disabled until fixed #887 -#select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a where t4.a is null order by 1,2,3,4; +select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a where t4.a is null order by 1,2,3,4; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t4.a order by 1,2,3,4; select * from t1 left join t2 on t1.a=t2.a left join t3 left join t4 on t3.a=t4.a on t2.a=t4.a where t2.a < 100 order by 1,2,3,4;