2
# This file contains tests covering the parser
5
#=============================================================================
7
#=============================================================================
10
# Documenting the current behavior, to detect incompatible changes.
12
# - no error is the correct result
13
# - an error is the expected result with the current implementation,
14
# and is a limitation.
16
create table ADDDATE(a int);
18
create table ADDDATE (a int);
21
--error ER_PARSE_ERROR
22
create table CAST(a int);
23
--error ER_PARSE_ERROR
24
create table CAST (a int);
26
--error ER_PARSE_ERROR
27
create table COUNT(a int);
28
--error ER_PARSE_ERROR
29
create table COUNT (a int);
31
--error ER_PARSE_ERROR
32
create table CURDATE(a int);
33
--error ER_PARSE_ERROR
34
create table CURDATE (a int);
36
--error ER_PARSE_ERROR
37
create table DATE_ADD(a int);
38
--error ER_PARSE_ERROR
39
create table DATE_ADD (a int);
41
--error ER_PARSE_ERROR
42
create table DATE_SUB(a int);
43
--error ER_PARSE_ERROR
44
create table DATE_SUB (a int);
46
--error ER_PARSE_ERROR
47
create table EXTRACT(a int);
48
--error ER_PARSE_ERROR
49
create table EXTRACT (a int);
51
--error ER_PARSE_ERROR
52
create table GROUP_CONCAT(a int);
53
--error ER_PARSE_ERROR
54
create table GROUP_CONCAT (a int);
56
# Limitation removed in 5.1
57
create table GROUP_UNIQUE_USERS(a int);
58
drop table GROUP_UNIQUE_USERS;
59
create table GROUP_UNIQUE_USERS (a int);
60
drop table GROUP_UNIQUE_USERS;
62
--error ER_PARSE_ERROR
63
create table MAX(a int);
64
--error ER_PARSE_ERROR
65
create table MAX (a int);
67
--error ER_PARSE_ERROR
68
create table MID(a int);
69
--error ER_PARSE_ERROR
70
create table MID (a int);
72
--error ER_PARSE_ERROR
73
create table MIN(a int);
74
--error ER_PARSE_ERROR
75
create table MIN (a int);
77
--error ER_PARSE_ERROR
78
create table NOW(a int);
79
--error ER_PARSE_ERROR
80
create table NOW (a int);
82
--error ER_PARSE_ERROR
83
create table POSITION(a int);
84
--error ER_PARSE_ERROR
85
create table POSITION (a int);
87
create table SESSION_USER(a int);
88
drop table SESSION_USER;
89
create table SESSION_USER (a int);
90
drop table SESSION_USER;
92
--error ER_PARSE_ERROR
93
create table STD(a int);
94
--error ER_PARSE_ERROR
95
create table STD (a int);
97
--error ER_PARSE_ERROR
98
create table STDDEV(a int);
99
--error ER_PARSE_ERROR
100
create table STDDEV (a int);
102
--error ER_PARSE_ERROR
103
create table STDDEV_POP(a int);
104
--error ER_PARSE_ERROR
105
create table STDDEV_POP (a int);
107
--error ER_PARSE_ERROR
108
create table STDDEV_SAMP(a int);
109
--error ER_PARSE_ERROR
110
create table STDDEV_SAMP (a int);
112
create table SUBDATE(a int);
114
create table SUBDATE (a int);
117
--error ER_PARSE_ERROR
118
create table SUBSTR(a int);
119
--error ER_PARSE_ERROR
120
create table SUBSTR (a int);
122
--error ER_PARSE_ERROR
123
create table SUM(a int);
124
--error ER_PARSE_ERROR
125
create table SUM (a int);
127
--error ER_PARSE_ERROR
128
create table SYSDATE(a int);
129
--error ER_PARSE_ERROR
130
create table SYSDATE (a int);
132
create table SYSTEM_USER(a int);
133
drop table SYSTEM_USER;
134
create table SYSTEM_USER (a int);
135
drop table SYSTEM_USER;
137
--error ER_PARSE_ERROR
138
create table TRIM(a int);
139
--error ER_PARSE_ERROR
140
create table TRIM (a int);
142
# Limitation removed in 5.1
143
create table UNIQUE_USERS(a int);
144
drop table UNIQUE_USERS;
145
create table UNIQUE_USERS (a int);
146
drop table UNIQUE_USERS;
148
--error ER_PARSE_ERROR
149
create table VARIANCE(a int);
150
--error ER_PARSE_ERROR
151
create table VARIANCE (a int);
153
--error ER_PARSE_ERROR
154
create table VAR_POP(a int);
155
--error ER_PARSE_ERROR
156
create table VAR_POP (a int);
158
--error ER_PARSE_ERROR
159
create table VAR_SAMP(a int);
160
--error ER_PARSE_ERROR
161
create table VAR_SAMP (a int);
163
create table ADDDATE(a int);
165
create table ADDDATE (a int);
168
--error ER_PARSE_ERROR
169
create table CAST(a int);
170
--error ER_PARSE_ERROR
171
create table CAST (a int);
173
--error ER_PARSE_ERROR
174
create table COUNT(a int);
175
--error ER_PARSE_ERROR
176
create table COUNT (a int);
178
--error ER_PARSE_ERROR
179
create table CURDATE(a int);
180
--error ER_PARSE_ERROR
181
create table CURDATE (a int);
183
--error ER_PARSE_ERROR
184
create table DATE_ADD(a int);
185
--error ER_PARSE_ERROR
186
create table DATE_ADD (a int);
188
--error ER_PARSE_ERROR
189
create table DATE_SUB(a int);
190
--error ER_PARSE_ERROR
191
create table DATE_SUB (a int);
193
--error ER_PARSE_ERROR
194
create table EXTRACT(a int);
195
--error ER_PARSE_ERROR
196
create table EXTRACT (a int);
198
--error ER_PARSE_ERROR
199
create table GROUP_CONCAT(a int);
200
--error ER_PARSE_ERROR
201
create table GROUP_CONCAT (a int);
203
# Limitation removed in 5.1
204
create table GROUP_UNIQUE_USERS(a int);
205
drop table GROUP_UNIQUE_USERS;
206
create table GROUP_UNIQUE_USERS (a int);
207
drop table GROUP_UNIQUE_USERS;
209
--error ER_PARSE_ERROR
210
create table MAX(a int);
211
--error ER_PARSE_ERROR
212
create table MAX (a int);
214
--error ER_PARSE_ERROR
215
create table MID(a int);
216
--error ER_PARSE_ERROR
217
create table MID (a int);
219
--error ER_PARSE_ERROR
220
create table MIN(a int);
221
--error ER_PARSE_ERROR
222
create table MIN (a int);
224
--error ER_PARSE_ERROR
225
create table NOW(a int);
226
--error ER_PARSE_ERROR
227
create table NOW (a int);
229
--error ER_PARSE_ERROR
230
create table POSITION(a int);
231
--error ER_PARSE_ERROR
232
create table POSITION (a int);
234
create table SESSION_USER(a int);
235
drop table SESSION_USER;
236
create table SESSION_USER (a int);
237
drop table SESSION_USER;
239
--error ER_PARSE_ERROR
240
create table STD(a int);
241
--error ER_PARSE_ERROR
242
create table STD (a int);
244
--error ER_PARSE_ERROR
245
create table STDDEV(a int);
246
--error ER_PARSE_ERROR
247
create table STDDEV (a int);
249
--error ER_PARSE_ERROR
250
create table STDDEV_POP(a int);
251
--error ER_PARSE_ERROR
252
create table STDDEV_POP (a int);
254
--error ER_PARSE_ERROR
255
create table STDDEV_SAMP(a int);
256
--error ER_PARSE_ERROR
257
create table STDDEV_SAMP (a int);
259
create table SUBDATE(a int);
261
create table SUBDATE (a int);
264
--error ER_PARSE_ERROR
265
create table SUBSTR(a int);
266
--error ER_PARSE_ERROR
267
create table SUBSTR (a int);
269
--error ER_PARSE_ERROR
270
create table SUBSTRING(a int);
271
--error ER_PARSE_ERROR
272
create table SUBSTRING (a int);
274
--error ER_PARSE_ERROR
275
create table SUM(a int);
276
--error ER_PARSE_ERROR
277
create table SUM (a int);
279
--error ER_PARSE_ERROR
280
create table SYSDATE(a int);
281
--error ER_PARSE_ERROR
282
create table SYSDATE (a int);
284
create table SYSTEM_USER(a int);
285
drop table SYSTEM_USER;
286
create table SYSTEM_USER (a int);
287
drop table SYSTEM_USER;
289
--error ER_PARSE_ERROR
290
create table TRIM(a int);
291
--error ER_PARSE_ERROR
292
create table TRIM (a int);
294
# Limitation removed in 5.1
295
create table UNIQUE_USERS(a int);
296
drop table UNIQUE_USERS;
297
create table UNIQUE_USERS (a int);
298
drop table UNIQUE_USERS;
300
--error ER_PARSE_ERROR
301
create table VARIANCE(a int);
302
--error ER_PARSE_ERROR
303
create table VARIANCE (a int);
305
--error ER_PARSE_ERROR
306
create table VAR_POP(a int);
307
--error ER_PARSE_ERROR
308
create table VAR_POP (a int);
310
--error ER_PARSE_ERROR
311
create table VAR_SAMP(a int);
312
--error ER_PARSE_ERROR
313
create table VAR_SAMP (a int);
316
# Bug#25930 (CREATE TABLE x SELECT ... parses columns wrong when ran with
321
DROP TABLE IF EXISTS table_25930_a;
322
DROP TABLE IF EXISTS table_25930_b;
325
--error ER_PARSE_ERROR
326
CREATE TABLE table_25930_a ( "blah" INT );
327
CREATE TABLE table_25930_a ( blah INT );
328
CREATE TABLE table_25930_b SELECT "blah" - 1 FROM table_25930_a;
330
# The lexer used to chop the first <">,
331
# not marking the start of the token "blah" correctly.
334
DROP TABLE table_25930_a;
335
DROP TABLE table_25930_b;
338
#=============================================================================
339
# SYNTACTIC PARSER (bison)
340
#=============================================================================
344
# Bug#21114 (Foreign key creation fails to table with name format)
347
# Test coverage with edge conditions
355
select makedate(1, 2, 3);
358
select atan2(1, 2, 3);
361
select concat("foo");
364
select concat_ws("foo");
370
select export_set("p1");
371
select export_set("p1", "p2");
372
select export_set("p1", "p2", "p3", "p4", "p5", "p6");
377
select from_unixtime();
378
select from_unixtime(1, 2, 3);
380
select unix_timestamp(1, 2);
385
select last_insert_id(1, 2);
392
select locate(1, 2, 3, 4);
400
select rand(1, 2, 3);
402
select round(1, 2, 3);
405
# Bug#24736: UDF functions parsed as Stored Functions
408
# Verify that the syntax for calling UDF : foo(expr AS param, ...)
409
# can not be used when calling native functions
411
# Native function with 1 argument
414
select abs(3 AS three);
416
select abs(3 AS "three");
417
select abs(3 "three");
419
# Native function with 2 arguments
422
set @foobar="foobar";
424
select instr("foobar", "bar");
425
select instr("foobar" AS p1, "bar");
426
select instr("foobar" p1, "bar");
427
select instr("foobar" AS "p1", "bar");
428
## String concatenation, valid syntax
429
select instr("foobar" "p1", "bar");
430
select instr(@foobar "p1", "bar");
431
select instr("foobar", "bar" AS p2);
432
select instr("foobar", "bar" p2);
433
select instr("foobar", "bar" AS "p2");
434
## String concatenation, valid syntax
435
select instr("foobar", "bar" "p2");
436
select instr("foobar", @bar "p2");
437
select instr("foobar" AS p1, "bar" AS p2);
439
# Native function with 3 arguments
441
select conv(255, 10, 16);
442
select conv(255 AS p1, 10, 16);
443
select conv(255 p1, 10, 16);
444
select conv(255 AS "p1", 10, 16);
445
select conv(255 "p1", 10, 16);
446
select conv(255, 10 AS p2, 16);
447
select conv(255, 10 p2, 16);
448
select conv(255, 10 AS "p2", 16);
449
select conv(255, 10 "p2", 16);
450
select conv(255, 10, 16 AS p3);
451
select conv(255, 10, 16 p3);
452
select conv(255, 10, 16 AS "p3");
453
select conv(255, 10, 16 "p3");
454
select conv(255 AS p1, 10 AS p2, 16 AS p3);
456
# Native function with a variable number of arguments
458
# Bug in libm.so on Solaris:
459
# atan(10) from 32-bit version returns 1.4711276743037347
460
# atan(10) from 64-bit version returns 1.4711276743037345
461
--replace_result 1.4711276743037345 1.4711276743037347
463
select atan(10 AS p1);
465
select atan(10 AS "p1");
466
select atan(10 "p1");
469
select atan(10 AS p1, 20);
470
select atan(10 p1, 20);
471
select atan(10 AS "p1", 20);
472
select atan(10 "p1", 20);
473
select atan(10, 20 AS p2);
474
select atan(10, 20 p2);
475
select atan(10, 20 AS "p2");
476
select atan(10, 20 "p2");
477
select atan(10 AS p1, 20 AS p2);
480
# Bug#22312 Syntax error in expression with INTERVAL()
484
DROP TABLE IF EXISTS t1;
487
SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
488
SELECT 1 + INTERVAL(1,0,1,2) + 1;
489
SELECT INTERVAL(1,0,1,2) + 1;
490
SELECT INTERVAL(1,0+1,2,3) * 5.5;
491
SELECT INTERVAL(3,3,1+3,4+4) / 0.5;
492
SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2;
493
SELECT INTERVAL(1,0,1,2) + 1, 5 * INTERVAL(1,0,1,2);
494
SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3);
496
CREATE TABLE t1 (a INT, b DATETIME);
497
INSERT INTO t1 VALUES (INTERVAL(3,2,1) + 1, "1997-12-31 23:59:59" + INTERVAL 1 SECOND);
498
SELECT * FROM t1 WHERE a = INTERVAL(3,2,1) + 1;
502
# Bug#28317 Left Outer Join with {oj outer-join}
506
DROP TABLE IF EXISTS t1,t2,t3;
508
CREATE TABLE t1 (a1 INT, a2 INT, a3 INT, a4 DATETIME);
509
CREATE TABLE t2 LIKE t1;
510
CREATE TABLE t3 LIKE t1;
511
SELECT t1.* FROM t1 AS t0, { OJ t2 INNER JOIN t1 ON (t1.a1=t2.a1) } WHERE t0.a3=2;
512
SELECT t1.*,t2.* FROM { OJ ((t1 INNER JOIN t2 ON (t1.a1=t2.a2)) LEFT OUTER JOIN t3 ON t3.a3=t2.a1)};
513
SELECT t1.*,t2.* FROM { OJ ((t1 LEFT OUTER JOIN t2 ON t1.a3=t2.a2) INNER JOIN t3 ON (t3.a1=t2.a2))};
514
SELECT t1.*,t2.* FROM { OJ (t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a2) CROSS JOIN t3 ON (t3.a2=t2.a3)};
515
SELECT * FROM {oj t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a3} WHERE t1.a2 > 10;
516
SELECT {fn CONCAT(a1,a2)} FROM t1;
517
UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0;
518
SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')};
519
DROP TABLE t1, t2, t3;
522
# Bug#31765 (BACKUP DATABASE broken syntax)
525
--error ER_PARSE_ERROR
526
BACKUP DATABASE *, test to 'broken.bak';
528
--error ER_PARSE_ERROR
529
BACKUP DATABASE *, db1, db2, db3 to 'broken.bak';