1
by brian
clean slate |
1 |
# Initialise |
2 |
--disable_warnings
|
|
3 |
drop table if exists t1; |
|
4 |
--enable_warnings
|
|
5 |
||
6 |
select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)); |
|
7 |
select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)); |
|
8 |
select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); |
|
9 |
select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); |
|
10 |
select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')); |
|
11 |
select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)); |
|
12 |
select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)); |
|
13 |
select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); |
|
14 |
select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); |
|
15 |
select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)); |
|
16 |
select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)); |
|
17 |
select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))); |
|
18 |
-- error 1241
|
|
19 |
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4)); |
|
20 |
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); |
|
21 |
explain extended select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); |
|
22 |
||
23 |
SELECT (1,2,3)=(0,NULL,3); |
|
24 |
SELECT (1,2,3)=(1,NULL,3); |
|
25 |
# here's something for Sanja to fix :) |
|
26 |
SELECT (1,2,3)=(1,NULL,0);
|
|
27 |
||
28 |
SELECT ROW(1,2,3)=ROW(1,2,3);
|
|
29 |
SELECT ROW(2,2,3)=ROW(1+1,2,3);
|
|
30 |
SELECT ROW(1,2,3)=ROW(1+1,2,3);
|
|
31 |
SELECT ROW(1,2,3)<ROW(1+1,2,3);
|
|
32 |
SELECT ROW(1,2,3)>ROW(1+1,2,3);
|
|
33 |
SELECT ROW(1,2,3)<=ROW(1+1,2,3);
|
|
34 |
SELECT ROW(1,2,3)>=ROW(1+1,2,3);
|
|
35 |
SELECT ROW(1,2,3)<>ROW(1+1,2,3);
|
|
36 |
SELECT ROW(NULL,2,3)=ROW(NULL,2,3);
|
|
37 |
SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3);
|
|
38 |
SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5));
|
|
39 |
SELECT ROW('test',2,3.33)=ROW('test',2,3.33); |
|
40 |
-- error 1241
|
|
41 |
SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); |
|
42 |
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)); |
|
43 |
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)); |
|
44 |
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)); |
|
45 |
-- error 1241
|
|
46 |
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4); |
|
47 |
||
48 |
create table t1 ( a int, b int, c int);
|
|
49 |
insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL);
|
|
50 |
select * from t1 where ROW(1,2,3)=ROW(a,b,c);
|
|
51 |
select * from t1 where ROW(0,2,3)=ROW(a,b,c);
|
|
52 |
select * from t1 where ROW(1,2,3)<ROW(a,b,c);
|
|
53 |
select ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) from t1;
|
|
54 |
select ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) from t1;
|
|
55 |
select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1;
|
|
56 |
select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1;
|
|
57 |
drop table t1;
|
|
58 |
||
59 |
-- error 1241
|
|
60 |
select ROW(1,1);
|
|
61 |
||
62 |
create table t1 (i int);
|
|
63 |
-- error 1241
|
|
64 |
select 1 from t1 where ROW(1,1);
|
|
65 |
-- error 1241
|
|
66 |
select count(*) from t1 order by ROW(1,1);
|
|
67 |
-- error 1241
|
|
68 |
select count(*) from t1 having (1,1) order by i;
|
|
69 |
drop table t1;
|
|
70 |
||
71 |
create table t1 (a int, b int);
|
|
72 |
insert into t1 values (1, 4);
|
|
73 |
insert into t1 values (10, 40);
|
|
74 |
insert into t1 values (1, 4);
|
|
75 |
insert into t1 values (10, 43);
|
|
76 |
insert into t1 values (1, 4);
|
|
77 |
insert into t1 values (10, 41);
|
|
78 |
insert into t1 values (1, 4);
|
|
79 |
insert into t1 values (10, 43);
|
|
80 |
insert into t1 values (1, 4);
|
|
81 |
select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a;
|
|
82 |
drop table t1;
|
|
83 |
SELECT ROW(2,10) <=> ROW(3,4);
|
|
84 |
SELECT ROW(NULL,10) <=> ROW(3,NULL);
|
|
85 |
||
86 |
#
|
|
87 |
# Bug #27484: nested row expressions in IN predicate
|
|
88 |
#
|
|
89 |
||
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
90 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
91 |
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1));
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
92 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
93 |
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3)));
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
94 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
95 |
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2)));
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
96 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
97 |
SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2)));
|
98 |
||
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
99 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
100 |
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1));
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
101 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
102 |
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4)));
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
103 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
104 |
SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3)));
|
105 |
||
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
106 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
107 |
SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0));
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
108 |
--error ER_OPERAND_COLUMNS
|
1
by brian
clean slate |
109 |
SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2));
|
110 |
||
111 |
#
|
|
112 |
# Bug#27704: erroneous comparison of rows with NULL components
|
|
113 |
#
|
|
114 |
CREATE TABLE t1(a int, b int, c int);
|
|
115 |
INSERT INTO t1 VALUES (1, 2, 3),
|
|
116 |
(NULL, 2, 3 ), (1, NULL, 3 ), (1, 2, NULL),
|
|
117 |
(NULL, 2, 3+1), (1, NULL, 3+1), (1, 2+1, NULL),
|
|
118 |
(NULL, 2, 3-1), (1, NULL, 3-1), (1, 2-1, NULL);
|
|
119 |
||
120 |
SELECT (1,2,3) = (1, NULL, 3);
|
|
121 |
SELECT (1,2,3) = (1+1, NULL, 3);
|
|
122 |
SELECT (1,2,3) = (1, NULL, 3+1);
|
|
123 |
SELECT * FROM t1 WHERE (a,b,c) = (1,2,3);
|
|
124 |
||
125 |
SELECT (1,2,3) <> (1, NULL, 3);
|
|
126 |
SELECT (1,2,3) <> (1+1, NULL, 3);
|
|
127 |
SELECT (1,2,3) <> (1, NULL, 3+1);
|
|
128 |
SELECT * FROM t1 WHERE (a,b,c) <> (1,2,3);
|
|
129 |
||
130 |
SELECT (1,2,3) < (NULL, 2, 3);
|
|
131 |
SELECT (1,2,3) < (1, NULL, 3);
|
|
132 |
SELECT (1,2,3) < (1-1, NULL, 3);
|
|
133 |
SELECT (1,2,3) < (1+1, NULL, 3);
|
|
134 |
SELECT * FROM t1 WHERE (a,b,c) < (1,2,3);
|
|
135 |
||
136 |
SELECT (1,2,3) <= (NULL, 2, 3);
|
|
137 |
SELECT (1,2,3) <= (1, NULL, 3);
|
|
138 |
SELECT (1,2,3) <= (1-1, NULL, 3);
|
|
139 |
SELECT (1,2,3) <= (1+1, NULL, 3);
|
|
140 |
SELECT * FROM t1 WHERE (a,b,c) <= (1,2,3);
|
|
141 |
||
142 |
SELECT (1,2,3) > (NULL, 2, 3);
|
|
143 |
SELECT (1,2,3) > (1, NULL, 3);
|
|
144 |
SELECT (1,2,3) > (1-1, NULL, 3);
|
|
145 |
SELECT (1,2,3) > (1+1, NULL, 3);
|
|
146 |
SELECT * FROM t1 WHERE (a,b,c) > (1,2,3);
|
|
147 |
||
148 |
SELECT (1,2,3) >= (NULL, 2, 3);
|
|
149 |
SELECT (1,2,3) >= (1, NULL, 3);
|
|
150 |
SELECT (1,2,3) >= (1-1, NULL, 3);
|
|
151 |
SELECT (1,2,3) >= (1+1, NULL, 3);
|
|
152 |
SELECT * FROM t1 WHERE (a,b,c) >= (1,2,3);
|
|
153 |
||
154 |
DROP TABLE t1;
|
|
155 |
||
156 |
# End of 4.1 tests
|
|
157 |
||
158 |
#
|
|
159 |
# Correct NULL handling in row comporison (BUG#12509)
|
|
160 |
#
|
|
161 |
SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ;
|
|
162 |
select row(NULL,1)=(2,0);
|
|
163 |
||
164 |
#
|
|
165 |
# Bug #16081: row equalities are to be used for query optimizations
|
|
166 |
#
|
|
167 |
||
168 |
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b));
|
|
169 |
INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3);
|
|
170 |
||
171 |
EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2;
|
|
172 |
EXPLAIN SELECT * FROM t1 WHERE (a,b)=(3,2);
|
|
173 |
SELECT * FROM t1 WHERE a=3 and b=2;
|
|
174 |
SELECT * FROM t1 WHERE (a,b)=(3,2);
|
|
175 |
||
176 |
CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));
|
|
177 |
INSERT INTO t2 VALUES
|
|
178 |
(1,1,2), (3,1,3), (1,2,2), (4,4,2),
|
|
179 |
(1,1,1), (3,1,1), (1,2,1);
|
|
180 |
||
181 |
EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b;
|
|
182 |
EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
|
|
183 |
SELECT * FROM t1,t2 WHERE t1.a=t2.a and t1.b=t2.b;
|
|
184 |
SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
|
|
185 |
||
186 |
EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=2;
|
|
187 |
EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
|
|
188 |
SELECT * FROM t1,t2 WHERE t1.a=1 and t1.b=t2.b;
|
|
189 |
SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
|
|
190 |
||
191 |
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
|
|
192 |
SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
|
|
193 |
||
194 |
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
|
|
195 |
SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
|
|
196 |
||
197 |
EXPLAIN SELECT * FROM t2 WHERE a=3 AND b=2;
|
|
198 |
EXPLAIN SELECT * FROM t2 WHERE (a,b)=(3,2);
|
|
199 |
SELECT * FROM t2 WHERE a=3 and b=2;
|
|
200 |
SELECT * FROM t2 WHERE (a,b)=(3,2);
|
|
201 |
||
202 |
EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND t2.b=2 AND t2.c=1;
|
|
203 |
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
|
|
204 |
SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
|
|
205 |
||
206 |
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
|
|
207 |
SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
|
|
208 |
||
209 |
DROP TABLE t1,t2;
|
|
210 |
||
211 |
#
|
|
212 |
# Bug #27154: crash (memory corruption) when using row equalities
|
|
213 |
#
|
|
214 |
||
215 |
CREATE TABLE t1(
|
|
216 |
a int, b int, c int, d int, e int, f int, g int, h int,
|
|
217 |
PRIMARY KEY (a,b,c,d,e,f,g)
|
|
218 |
);
|
|
219 |
INSERT INTO t1 VALUES (1,2,3,4,5,6,7,99);
|
|
220 |
||
221 |
SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7);
|
|
222 |
||
223 |
SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7));
|
|
224 |
SELECT @x;
|
|
225 |
||
226 |
DROP TABLE t1;
|
|
227 |
||
228 |
#
|
|
229 |
# Bug #34620: item_row.cc:50: Item_row::illegal_method_call(const char*):
|
|
230 |
# Assertion `0' failed |
|
231 |
#
|
|
232 |
||
233 |
CREATE TABLE t1 (a INT, b INT); |
|
234 |
INSERT INTO t1 VALUES (1,1); |
|
235 |
||
236 |
SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a; |
|
237 |
SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a; |
|
238 |
||
239 |
DROP TABLE t1; |