Skip to content

Commit

Permalink
test(mtr): add and update some testcases(stoneatom#497)
Browse files Browse the repository at this point in the history
[summary]
add    ctas.test
add    different_charsets_b.test
update insert_select.test
update left_join.test
  • Loading branch information
davidshiz committed Dec 15, 2022
1 parent ad960cb commit 9a8438e
Show file tree
Hide file tree
Showing 8 changed files with 1,414 additions and 176 deletions.
212 changes: 137 additions & 75 deletions mysql-test/suite/tianmu/r/ctas.result
Original file line number Diff line number Diff line change
@@ -1,75 +1,137 @@
CREATE DATABASE ctastest;
USE ctastest;
CREATE TABLE `ctas_test` (
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint',
`c_smallint` smallint NOT NULL COMMENT 'smallint',
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint',
`c_int` int DEFAULT NULL COMMENT 'int',
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint',
`c_float` float DEFAULT NULL COMMENT 'float',
`c_double` double DEFAULT NULL COMMENT 'double',
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal',
`c_date` date DEFAULT NULL COMMENT 'date',
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime',
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp',
`c_time` time DEFAULT NULL COMMENT 'time',
`c_char` char(10) DEFAULT NULL COMMENT 'char',
`c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar',
`c_blob` blob COMMENT 'blob',
`c_text` text COMMENT 'text',
`c_longblob` longblob COMMENT 'longblob'
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO ctas_test(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text)
VALUES(1,2,3,4,5,5.2,10.88,105.083,'2016-02-25','2016-02-25 10:20:01','2016-02-25 05:20:01','10:20:01','stoneatom1','hello1','bcdefghijklmn'),
(2,3,4,5,6,5.3,10.89,105.084,'2016-02-26','2016-02-26 10:20:02','2016-02-25 05:20:02','10:20:02','stoneatom2','hello2','qweqeqweqweqw'),
(3,4,5,6,7,5.4,10.90,105.085,'2016-02-27','2016-02-27 10:20:03','2016-02-25 05:20:03','10:20:03','stoneatom3','hello3','asdfasdfsadfa');
SHOW CREATE TABLE ctas_test;
Table Create Table
ctas_test CREATE TABLE `ctas_test` (
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint',
`c_smallint` smallint(6) NOT NULL COMMENT 'smallint',
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint',
`c_int` int(11) DEFAULT NULL COMMENT 'int',
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint',
`c_float` float DEFAULT NULL COMMENT 'float',
`c_double` double DEFAULT NULL COMMENT 'double',
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal',
`c_date` date DEFAULT NULL COMMENT 'date',
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime',
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp',
`c_time` time DEFAULT NULL COMMENT 'time',
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char',
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar',
`c_blob` blob COMMENT 'blob',
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text',
`c_longblob` longblob COMMENT 'longblob'
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
CREATE TABLE ctas_test1 AS SELECT * FROM ctas_test;
SHOW CREATE TABLE ctas_test1;
Table Create Table
ctas_test1 CREATE TABLE `ctas_test1` (
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint',
`c_smallint` smallint(6) NOT NULL COMMENT 'smallint',
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint',
`c_int` int(11) DEFAULT NULL COMMENT 'int',
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint',
`c_float` float DEFAULT NULL COMMENT 'float',
`c_double` double DEFAULT NULL COMMENT 'double',
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal',
`c_date` date DEFAULT NULL COMMENT 'date',
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime',
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp',
`c_time` time DEFAULT NULL COMMENT 'time',
`c_char` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char',
`c_varchar` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar',
`c_blob` blob COMMENT 'blob',
`c_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'text',
`c_longblob` longblob COMMENT 'longblob'
) ENGINE=TIANMU DEFAULT CHARSET=latin1
SELECT * FROM ctas_test1;
c_tinyint c_smallint c_mediumint c_int c_bigint c_float c_double c_decimal c_date c_datetime c_timestamp c_time c_char c_varchar c_blob c_text c_longblob
1 2 3 4 5 5.2 10.88 105.08300 2016-02-25 2016-02-25 10:20:01 2016-02-25 05:20:01 10:20:01 stoneatom1 hello1 NULL bcdefghijklmn NULL
2 3 4 5 6 5.3 10.89 105.08400 2016-02-26 2016-02-26 10:20:02 2016-02-25 05:20:02 10:20:02 stoneatom2 hello2 NULL qweqeqweqweqw NULL
3 4 5 6 7 5.4 10.9 105.08500 2016-02-27 2016-02-27 10:20:03 2016-02-25 05:20:03 10:20:03 stoneatom3 hello3 NULL asdfasdfsadfa NULL
DROP TABLE ctas_test, ctas_test1;
DROP DATABASE ctastest;
#
# 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;
Loading

0 comments on commit 9a8438e

Please sign in to comment.