Skip to content

Commit

Permalink
feat(tianmu): unsupported DDL in SQL layer should report error. (ston…
Browse files Browse the repository at this point in the history
…eatom#1185)

[summary]
1 modify the MTR testcase;
  • Loading branch information
lujiashun committed Jan 6, 2023
1 parent 4caaf29 commit 8e043b6
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 218 deletions.
119 changes: 7 additions & 112 deletions mysql-test/suite/tianmu/r/create_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ ERROR 23000: Column 'b' cannot be null
create table if not exists t1 (b char(0) not null)ENGINE=tianmu;
Warnings:
Note 1050 Table 't1' already exists
create table t1 (b char(0) not null, index(b))engine=tianmu;
ERROR 42000: The used storage engine can't index column 'b'
create table t1 (b char(0) not null)engine=tianmu;
ERROR 42S01: Table 't1' already exists
drop table t1;
create table `a/a` (a int)engine=tianmu;
show create table `a/a`;
Expand Down Expand Up @@ -75,8 +75,6 @@ ERROR 42000: Incorrect table name ''
use test;
create table t1 (`` int)engine=tianmu;
ERROR 42000: Incorrect column name ''
create table t1 (i int, index `` (i))engine=tianmu;
ERROR 42000: Incorrect index name ''
create table t1 (i int)engine=tianmu;
drop table t1;
#
Expand All @@ -96,83 +94,6 @@ drop table t1;
#
# Test of primary key with 32 index
#
create table t1 (a int not null, b int, primary key(a),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b))engine=tianmu;
Warnings:
Warning 1831 Duplicate index 'b_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_5' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_6' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_7' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_8' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_9' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_10' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_11' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_12' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_13' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_14' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_15' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_16' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_17' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_18' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_19' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_20' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_21' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_22' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_23' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_24' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_25' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_26' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_27' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_28' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_29' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_30' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_31' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`),
KEY `b_2` (`b`),
KEY `b_3` (`b`),
KEY `b_4` (`b`),
KEY `b_5` (`b`),
KEY `b_6` (`b`),
KEY `b_7` (`b`),
KEY `b_8` (`b`),
KEY `b_9` (`b`),
KEY `b_10` (`b`),
KEY `b_11` (`b`),
KEY `b_12` (`b`),
KEY `b_13` (`b`),
KEY `b_14` (`b`),
KEY `b_15` (`b`),
KEY `b_16` (`b`),
KEY `b_17` (`b`),
KEY `b_18` (`b`),
KEY `b_19` (`b`),
KEY `b_20` (`b`),
KEY `b_21` (`b`),
KEY `b_22` (`b`),
KEY `b_23` (`b`),
KEY `b_24` (`b`),
KEY `b_25` (`b`),
KEY `b_26` (`b`),
KEY `b_27` (`b`),
KEY `b_28` (`b`),
KEY `b_29` (`b`),
KEY `b_30` (`b`),
KEY `b_31` (`b`)
) ENGINE=TIANMU DEFAULT CHARSET=latin1
drop table t1;
#
# Test default table type
#
Expand Down Expand Up @@ -236,9 +157,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
#
# Test create with foreign keys
#
create table t1 (a int, key(a))engine=tianmu;
create table t2 (b int, foreign key(b) references t1(a), key(b))engine=tianmu;
drop table if exists t1,t2;
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
#
# Test for create table .. LIKE ..
#
Expand Down Expand Up @@ -339,36 +260,10 @@ create table t1(name varchar(10), age smallint default -1);
describe t2;
Field Type Null Key Default Extra
id int(11) NO NULL
drop table t1,t2;
#
# 'Naming a key "Primary" causes trouble'
#
create table t1 (a int, index `primary` (a))engine=tianmu;
ERROR 42000: Incorrect index name 'primary'
create table t1 (a int, index `PRIMARY` (a))engine=tianmu;
ERROR 42000: Incorrect index name 'PRIMARY'
drop table t1;
create table t1 (`primary` int, index(`primary`))engine=tianmu;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`primary` int(11) DEFAULT NULL,
KEY `primary_2` (`primary`)
) ENGINE=TIANMU DEFAULT CHARSET=latin1
drop table t2;
create table t2 (`PRIMARY` int, index(`PRIMARY`))engine=tianmu;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`PRIMARY` int(11) DEFAULT NULL,
KEY `PRIMARY_2` (`PRIMARY`)
) ENGINE=TIANMU DEFAULT CHARSET=latin1
create table t3 (a int);
alter table t3 add index `primary` (a);
ERROR 42000: Incorrect index name 'primary'
alter table t3 add index `PRIMARY` (a);
ERROR 42000: Incorrect index name 'PRIMARY'
create table t4 (`primary` int)engine=tianmu;
drop table t1,t2,t3,t4;
#
#Can't use 'DEFAULT FALSE' for column of type bool
#
Expand Down Expand Up @@ -490,7 +385,7 @@ drop tables t1,t2;
#
# Creating a base table in presence of an updatable view.
#
create table t2 (a int unique);
create table t2 (a int primary key);
create view t1 as select a from t2;
insert into t1 (a) values (1);
create table t1 (a int);
Expand Down
7 changes: 3 additions & 4 deletions mysql-test/suite/tianmu/r/insert.result
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ drop table t1;
#
# Test of duplicate key values with packed keys
#
create table t1 (id int not null auto_increment primary key, username varchar(32) not null,
unique (username));
create table t1 (id int not null auto_increment primary key, username varchar(32) not null);
insert into t1 values (0,"mysql");
insert into t1 values (0,"mysql ab");
insert into t1 values (0,"mysql a");
Expand Down Expand Up @@ -248,7 +247,7 @@ drop table t1;
#
create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3));
create table t3(id3 int not null, t char(12));
select count(*) from t2;
count(*)
500
Expand Down Expand Up @@ -308,7 +307,7 @@ drop table t1;
#
# ON DUPLICATE KEY clause allows fields not from the insert table
#
create table t1 (f1 int unique, f2 int);
create table t1 (f1 int primary key, f2 int);
create table t2 (f3 int, f4 int);
create view v1 as select * from t1, t2 where f1= f3;
insert into t1 values (1,11), (2,22);
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/suite/tianmu/r/insert_select.result
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,7 @@ f2 varchar(100) NOT NULL default ''
CREATE TABLE t2 (
f1 varchar(10) NOT NULL default '',
f2 char(3) NOT NULL default '',
PRIMARY KEY (`f1`),
KEY `k1` (`f2`, `f1`)
PRIMARY KEY (`f1`)
);
INSERT INTO t1 values(NULL, '');
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/tianmu/r/issue270.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ USE issue270_test;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c))engine=tianmu;
CREATE TABLE t1(a int, b int, c int)engine=tianmu;
insert into t1 values (1,0,0),(2,0,0);
CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a))engine=tianmu;
insert into t2 values (1,'',''), (2,'','');
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b))engine=tianmu;
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b))engine=tianmu;
insert into t3 values (1,1),(1,2);
explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2
where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and
t2.b like '%%' order by t2.b limit 0,1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL b,c NULL NULL NULL 2 100.00 Using where with pushed condition (`issue270_test`.`t1`.`b` = 556476786)(t0) Pckrows: 1, susp. 0 (1 empty 0 full). Conditions: 1; Using temporary; Using filesort
1 SIMPLE t3 NULL ALL PRIMARY,a,b NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop)
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where with pushed condition (`issue270_test`.`t1`.`b` = 556476786)(t0) Pckrows: 1, susp. 0 (1 empty 0 full). Conditions: 1; Using temporary; Using filesort
1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop)
1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1)
drop table t1,t2,t3;
DROP DATABASE issue270_test;
2 changes: 1 addition & 1 deletion mysql-test/suite/tianmu/r/issue281.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ DROP DATABASE IF EXISTS issue281_test;
CREATE DATABASE issue281_test;
USE issue281_test;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f1 INT UNIQUE) ENGINE=TIANMU;
CREATE TABLE t1 (f1 INT) ENGINE=TIANMU;
INSERT INTO t1 VALUES(1),(2),(NULL),(NULL);
SELECT * FROM t1 WHERE f1 IS NULL;
f1
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/tianmu/r/issue964.result
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ USE issue964_test;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
KEY `idx_n` (`name`)
`name` varchar(20),
PRIMARY KEY `idx_n` (`name`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `t2` (
`id` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
KEY `idx_n` (`name`)
`name` varchar(20),
PRIMARY KEY `idx_n` (`name`)
)DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
insert into t1 values(1,'abc');
insert into t1 values(2,'def');
Expand Down
26 changes: 2 additions & 24 deletions mysql-test/suite/tianmu/r/select.result
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ fld3 char(30) DEFAULT '' NOT NULL,
fld4 char(35) DEFAULT '' NOT NULL,
fld5 char(35) DEFAULT '' NOT NULL,
fld6 char(4) DEFAULT '' NOT NULL,
UNIQUE fld1 (fld1),
KEY fld3 (fld3),
PRIMARY KEY (auto)
)engine=tianmu;
#
Expand Down Expand Up @@ -157,26 +155,10 @@ fld3
select t2.fld3 from t2 where fld3 = 'honeysuckle';
fld3
honeysuckle
select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
fld3
honeysuckle
select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
fld3
honeysuckle
select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
fld3
honeysuckle
select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
fld3
honeysuckle
#
# NOTE NOTE NOTE
# The next should give an error
#
select fld3 from t2 ignore index (fld3,not_used);
ERROR 42000: Key 'not_used' doesn't exist in table 't2'
select fld3 from t2 use index (not_used);
ERROR 42000: Key 'not_used' doesn't exist in table 't2'
#
# Test sorting with a used key (there is no need for sorting)
#
Expand Down Expand Up @@ -485,9 +467,7 @@ period int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
key (period),
key (name)
price2 double(11,0)
)engine=tianmu;
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
Expand All @@ -504,9 +484,7 @@ period int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
key (period),
key (name)
price2 double(11,0)
)engine=tianmu;
#Reverse insert data
insert into t3_1 select * from t3;
Expand Down
Loading

0 comments on commit 8e043b6

Please sign in to comment.