oceanbase
207 строк · 5.9 Кб
1--disable_query_log
2set @@session.explicit_defaults_for_timestamp=off;
3--enable_query_log
4#owner: link.zt
5#owner group: sql1
6
7#
8## Bug
9#
10# partition by key()
11--disable_warnings
12drop database if exists db1;
13drop database if exists db2;
14create database db1;
15create database db2;
16use db1;
17drop table if exists t1;
18create table t1(c1 int key) partition by key() partitions 2;
19--enable_warnings
20use db2;
21--disable_warnings
22drop table if exists t1;
23--enable_warnings
24create table t1(c1 int key) partition by key() partitions 2;
25select * from db1.t1,db2.t1;
26# partition by key(expr)
27use db1;
28--disable_warnings
29drop table if exists t1;
30create table t1(c1 int key) partition by key(c1) partitions 2;
31create database if not exists db2;
32use db2;
33--enable_warnings
34--disable_warnings
35drop table if exists t1;
36--enable_warnings
37create table t1(c1 int key) partition by key(c1) partitions 2;
38select * from db1.t1,db2.t1;
39# partition by hash(expr)
40use db1;
41--disable_warnings
42drop table if exists t1;
43create table t1(c1 int key) partition by hash(c1) partitions 2;
44create database if not exists db2;
45--enable_warnings
46use db2;
47--disable_warnings
48drop table if exists t1;
49--enable_warnings
50create table t1(c1 int key) partition by hash(c1) partitions 2;
51select * from db1.t1,db2.t1;
52
53#
54--disable_warnings
55drop table if exists t1;
56--enable_warnings
57create table t1 (c1 int primary key, c2 int);
58insert into t1 values(1,8), (2,7), (3,6), (4,5);
59--error 1054
60select c1 from t1 group by t2.c1;
61--error 1052
62select c1, c2 as c1 from t1 group by c1;
63--sorted_result
64select c1, c2 as c1 from t1 group by t1.c1;
65--error 1052
66select c1 as c1, c2 as c1 from t1 group by c1;
67--sorted_result
68select c1 as c1, c2 as c1 from t1 group by t1.c1;
69--sorted_result
70select t1.c1 as cc from t1 group by t1.c1;
71--sorted_result
72select c1, c1 from t1 group by c1;
73select 1 as c1, 2 as c2 from t1 group by c1;
74--error 1052
75select 1 as c1, c1 from t1 group by c1;
76--disable_warnings
77select c1 as c2, c2 as c1 from t1 group by c1;
78--error 1052
79select c2+1 as c1, c1 from t1 group by c1;
80--enable_warnings
81select c1, c2 as c1 from t1 having t1.c1 > 2;
82select c1, c2 + 1 as c1 from t1 having t1.c1 > 2;
83--error 1052
84select c1, c2 + 1 as c1 from t1 having c1 > 2;
85--error 1052
86select c1, c2 + 1 as c1 from t1 order by c1;
87select c1, c2 + 1 as c1 from t1 order by t1.c1;
88--disable_warnings
89--error 1052
90select c1, c2 + 1 as c1 from t1 group by c1;
91--sorted_result
92select c1, c2 + 1 as c1 from t1 group by t1.c1;
93--enable_warnings
94select t1.c1 as c1 from t1 order by t1.c1;
95select t1.c1 as c2 from t1 order by t1.c1;
96drop table t1;
97
98#
99--disable_warnings
100drop table if exists t1, t2;
101--enable_warnings
102create table t1 (a int(11), b char(10), key (a));
103insert into t1 (a) values (1),(2),(3),(4);
104create table t2 (a int);
105select * from t1 left join t2 on t1.a=t2.a order by t1.a;
106select * from t1 left join t2 on t1.a=t2.a having not (t2.a <=> t1.a) order by t1.a;
107select exists(( select 1));
108select exists( select 1);
109drop table t1,t2;
110
111create table t1(c1 int, c2 int);
112insert into t1 values(1, 1), (2, 2);
113select * from t1 where c1<'2';
114select * from t1 where c1>'1';
115select * from t1 where c1='2';
116select * from t1 where c1!='2';
117select * from t1 where c1<='2';
118select * from t1 where c1>='2';
119select * from t1 where c1+'1'<=3;
120select * from t1 where c1+'1'>=2;
121drop table t1;
122
123create table t1(c1 int primary key, c2 int);
124insert into t1 values(1, 1), (2, 2);
125select * from t1 where c1<'2';
126select * from t1 where c1>'1';
127select * from t1 where c1='2';
128select * from t1 where c1!='2';
129select * from t1 where c1<='2';
130select * from t1 where c1>='2';
131select * from t1 where c1+'1'<=3;
132select * from t1 where c1+'1'>=2;
133drop table t1;
134
135##like syntax
136SELECT 'a' = 'a ', 'a' LIKE 'a ';
137SELECT 'David!' LIKE 'David_';
138SELECT 'David!' LIKE '%D%v%';
139SELECT 'David!' LIKE 'David\_';
140SELECT 'David_' LIKE 'David\_';
141SELECT 'David_' LIKE 'David|_' ESCAPE '|';
142SELECT 'abc' LIKE 'ABC';
143SELECT 'abc' LIKE BINARY 'ABC';
144SELECT 10 LIKE '1%';
145SELECT 'David_' LIKE 'David|_' ESCAPE null;
146SELECT 'David_' LIKE 'David|_' ESCAPE 1;
147--error 1210
148SELECT 'David_' LIKE 'David|_' ESCAPE 12;
149--error 1210
150SELECT 'David_' LIKE 'David|_' ESCAPE '12';
151## alias
152--disable_warnings
153drop table if exists a1,a2;
154--enable_warnings
155create table a2(rowkey_suffix2 int primary key, price2 int);
156create table a1(rowkey_suffix int primary key, price int);
157--error 1064
158select (select price from a2 where 1000 > price) as 'x', a1.* as 'with_alias' from a1;
159--error 1064
160select (select price from a2 where 1000 > price) as 'x', a1.* as with_alias from a1;
161--error 1241
162select 1 from dual where @a:=1 and (1, 2);
163--error 1241
164select 1 from dual where @a:=1 and (1, (select 2));
165--error 1241
166select 1 from dual where @a:=1 and (1, exists(select 2));
167
168create table t1(c1 int);
169select 1 from t1 where c1 in (select c1 from t1 where exists( (select 1) union (select 1)));
170select (1 and 100) or 100;
171
172drop table t1;
173create table t1(c1 bigint, c2 varchar(64), c3 datetime);
174insert into t1 values(20101010000000, '020101010000000', '2010-10-10 00:00:00');
175select * from t1 where c1=c2 and c1=cast('2010-10-10 00:00:00' as datetime);
176
177--disable_warnings
178drop table if exists bug;
179--enable_warnings
180create table bug (col_float float);
181insert into bug values(100);
182select ((col_float and 100) or col_float) from bug;
183
184drop table t1;
185create table test1 (id int,dt datetime(6), primary key(id, dt));
186insert into test1 values (0, '2017-01-01'), (0, '2017-01-02'), (0, '2017-01-03'), (1, '2017-01-01'), (1, '2017-01-02'), (1, '2017-01-03');
187select * from test1 where (id, dt) > (0, '2017-01-02') and (id, dt) <= (1, '2017-01-03');
188select * from test1 where (id, dt) > (0, '2017-01-02') and (id, dt) <= (1, '2017-01-03') and dt < '2017-01-02';
189
190
191#fix a bug :
192--result_format 4
193--error 1054
194select cast '';
195--error 1054
196select length '';
197--error 1054
198select yearweek '';
199--error 1054
200select lala '';
201select 1 '';
202select 2 '';
203select 2 as '';
204select 1 as '';
205
206drop database if exists db1;
207drop database if exists db2;
208