~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/parser.test

Cleanup around SAFEMALLOC

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# This file contains tests covering the parser
3
 
#
4
 
 
5
 
#=============================================================================
6
 
# LEXICAL PARSER (lex)
7
 
#=============================================================================
8
 
 
9
 
#
10
 
# Documenting the current behavior, to detect incompatible changes.
11
 
# In each cases:
12
 
# - no error is the correct result
13
 
# - an error is the expected result with the current implementation,
14
 
#   and is a limitation.
15
 
 
16
 
create table ADDDATE(a int);
17
 
drop table ADDDATE;
18
 
create table ADDDATE (a int);
19
 
drop table ADDDATE;
20
 
 
21
 
--error ER_PARSE_ERROR
22
 
create table CAST(a int);
23
 
--error ER_PARSE_ERROR
24
 
create table CAST (a int);
25
 
 
26
 
--error ER_PARSE_ERROR
27
 
create table COUNT(a int);
28
 
--error ER_PARSE_ERROR
29
 
create table COUNT (a int);
30
 
 
31
 
--error ER_PARSE_ERROR
32
 
create table CURDATE(a int);
33
 
--error ER_PARSE_ERROR
34
 
create table CURDATE (a int);
35
 
 
36
 
--error ER_PARSE_ERROR
37
 
create table DATE_ADD(a int);
38
 
--error ER_PARSE_ERROR
39
 
create table DATE_ADD (a int);
40
 
 
41
 
--error ER_PARSE_ERROR
42
 
create table DATE_SUB(a int);
43
 
--error ER_PARSE_ERROR
44
 
create table DATE_SUB (a int);
45
 
 
46
 
--error ER_PARSE_ERROR
47
 
create table EXTRACT(a int);
48
 
--error ER_PARSE_ERROR
49
 
create table EXTRACT (a int);
50
 
 
51
 
--error ER_PARSE_ERROR
52
 
create table GROUP_CONCAT(a int);
53
 
--error ER_PARSE_ERROR
54
 
create table GROUP_CONCAT (a int);
55
 
 
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;
61
 
 
62
 
--error ER_PARSE_ERROR
63
 
create table MAX(a int);
64
 
--error ER_PARSE_ERROR
65
 
create table MAX (a int);
66
 
 
67
 
--error ER_PARSE_ERROR
68
 
create table MID(a int);
69
 
--error ER_PARSE_ERROR
70
 
create table MID (a int);
71
 
 
72
 
--error ER_PARSE_ERROR
73
 
create table MIN(a int);
74
 
--error ER_PARSE_ERROR
75
 
create table MIN (a int);
76
 
 
77
 
--error ER_PARSE_ERROR
78
 
create table NOW(a int);
79
 
--error ER_PARSE_ERROR
80
 
create table NOW (a int);
81
 
 
82
 
--error ER_PARSE_ERROR
83
 
create table POSITION(a int);
84
 
--error ER_PARSE_ERROR
85
 
create table POSITION (a int);
86
 
 
87
 
create table SESSION_USER(a int);
88
 
drop table SESSION_USER;
89
 
create table SESSION_USER (a int);
90
 
drop table SESSION_USER;
91
 
 
92
 
--error ER_PARSE_ERROR
93
 
create table STD(a int);
94
 
--error ER_PARSE_ERROR
95
 
create table STD (a int);
96
 
 
97
 
--error ER_PARSE_ERROR
98
 
create table STDDEV(a int);
99
 
--error ER_PARSE_ERROR
100
 
create table STDDEV (a int);
101
 
 
102
 
--error ER_PARSE_ERROR
103
 
create table STDDEV_POP(a int);
104
 
--error ER_PARSE_ERROR
105
 
create table STDDEV_POP (a int);
106
 
 
107
 
--error ER_PARSE_ERROR
108
 
create table STDDEV_SAMP(a int);
109
 
--error ER_PARSE_ERROR
110
 
create table STDDEV_SAMP (a int);
111
 
 
112
 
create table SUBDATE(a int);
113
 
drop table SUBDATE;
114
 
create table SUBDATE (a int);
115
 
drop table SUBDATE;
116
 
 
117
 
--error ER_PARSE_ERROR
118
 
create table SUBSTR(a int);
119
 
--error ER_PARSE_ERROR
120
 
create table SUBSTR (a int);
121
 
 
122
 
--error ER_PARSE_ERROR
123
 
create table SUM(a int);
124
 
--error ER_PARSE_ERROR
125
 
create table SUM (a int);
126
 
 
127
 
--error ER_PARSE_ERROR
128
 
create table SYSDATE(a int);
129
 
--error ER_PARSE_ERROR
130
 
create table SYSDATE (a int);
131
 
 
132
 
create table SYSTEM_USER(a int);
133
 
drop table SYSTEM_USER;
134
 
create table SYSTEM_USER (a int);
135
 
drop table SYSTEM_USER;
136
 
 
137
 
--error ER_PARSE_ERROR
138
 
create table TRIM(a int);
139
 
--error ER_PARSE_ERROR
140
 
create table TRIM (a int);
141
 
 
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;
147
 
 
148
 
--error ER_PARSE_ERROR
149
 
create table VARIANCE(a int);
150
 
--error ER_PARSE_ERROR
151
 
create table VARIANCE (a int);
152
 
 
153
 
--error ER_PARSE_ERROR
154
 
create table VAR_POP(a int);
155
 
--error ER_PARSE_ERROR
156
 
create table VAR_POP (a int);
157
 
 
158
 
--error ER_PARSE_ERROR
159
 
create table VAR_SAMP(a int);
160
 
--error ER_PARSE_ERROR
161
 
create table VAR_SAMP (a int);
162
 
 
163
 
create table ADDDATE(a int);
164
 
drop table ADDDATE;
165
 
create table ADDDATE (a int);
166
 
drop table ADDDATE;
167
 
 
168
 
--error ER_PARSE_ERROR
169
 
create table CAST(a int);
170
 
--error ER_PARSE_ERROR
171
 
create table CAST (a int);
172
 
 
173
 
--error ER_PARSE_ERROR
174
 
create table COUNT(a int);
175
 
--error ER_PARSE_ERROR
176
 
create table COUNT (a int);
177
 
 
178
 
--error ER_PARSE_ERROR
179
 
create table CURDATE(a int);
180
 
--error ER_PARSE_ERROR
181
 
create table CURDATE (a int);
182
 
 
183
 
--error ER_PARSE_ERROR
184
 
create table DATE_ADD(a int);
185
 
--error ER_PARSE_ERROR
186
 
create table DATE_ADD (a int);
187
 
 
188
 
--error ER_PARSE_ERROR
189
 
create table DATE_SUB(a int);
190
 
--error ER_PARSE_ERROR
191
 
create table DATE_SUB (a int);
192
 
 
193
 
--error ER_PARSE_ERROR
194
 
create table EXTRACT(a int);
195
 
--error ER_PARSE_ERROR
196
 
create table EXTRACT (a int);
197
 
 
198
 
--error ER_PARSE_ERROR
199
 
create table GROUP_CONCAT(a int);
200
 
--error ER_PARSE_ERROR
201
 
create table GROUP_CONCAT (a int);
202
 
 
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;
208
 
 
209
 
--error ER_PARSE_ERROR
210
 
create table MAX(a int);
211
 
--error ER_PARSE_ERROR
212
 
create table MAX (a int);
213
 
 
214
 
--error ER_PARSE_ERROR
215
 
create table MID(a int);
216
 
--error ER_PARSE_ERROR
217
 
create table MID (a int);
218
 
 
219
 
--error ER_PARSE_ERROR
220
 
create table MIN(a int);
221
 
--error ER_PARSE_ERROR
222
 
create table MIN (a int);
223
 
 
224
 
--error ER_PARSE_ERROR
225
 
create table NOW(a int);
226
 
--error ER_PARSE_ERROR
227
 
create table NOW (a int);
228
 
 
229
 
--error ER_PARSE_ERROR
230
 
create table POSITION(a int);
231
 
--error ER_PARSE_ERROR
232
 
create table POSITION (a int);
233
 
 
234
 
create table SESSION_USER(a int);
235
 
drop table SESSION_USER;
236
 
create table SESSION_USER (a int);
237
 
drop table SESSION_USER;
238
 
 
239
 
--error ER_PARSE_ERROR
240
 
create table STD(a int);
241
 
--error ER_PARSE_ERROR
242
 
create table STD (a int);
243
 
 
244
 
--error ER_PARSE_ERROR
245
 
create table STDDEV(a int);
246
 
--error ER_PARSE_ERROR
247
 
create table STDDEV (a int);
248
 
 
249
 
--error ER_PARSE_ERROR
250
 
create table STDDEV_POP(a int);
251
 
--error ER_PARSE_ERROR
252
 
create table STDDEV_POP (a int);
253
 
 
254
 
--error ER_PARSE_ERROR
255
 
create table STDDEV_SAMP(a int);
256
 
--error ER_PARSE_ERROR
257
 
create table STDDEV_SAMP (a int);
258
 
 
259
 
create table SUBDATE(a int);
260
 
drop table SUBDATE;
261
 
create table SUBDATE (a int);
262
 
drop table SUBDATE;
263
 
 
264
 
--error ER_PARSE_ERROR
265
 
create table SUBSTR(a int);
266
 
--error ER_PARSE_ERROR
267
 
create table SUBSTR (a int);
268
 
 
269
 
--error ER_PARSE_ERROR
270
 
create table SUBSTRING(a int);
271
 
--error ER_PARSE_ERROR
272
 
create table SUBSTRING (a int);
273
 
 
274
 
--error ER_PARSE_ERROR
275
 
create table SUM(a int);
276
 
--error ER_PARSE_ERROR
277
 
create table SUM (a int);
278
 
 
279
 
--error ER_PARSE_ERROR
280
 
create table SYSDATE(a int);
281
 
--error ER_PARSE_ERROR
282
 
create table SYSDATE (a int);
283
 
 
284
 
create table SYSTEM_USER(a int);
285
 
drop table SYSTEM_USER;
286
 
create table SYSTEM_USER (a int);
287
 
drop table SYSTEM_USER;
288
 
 
289
 
--error ER_PARSE_ERROR
290
 
create table TRIM(a int);
291
 
--error ER_PARSE_ERROR
292
 
create table TRIM (a int);
293
 
 
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;
299
 
 
300
 
--error ER_PARSE_ERROR
301
 
create table VARIANCE(a int);
302
 
--error ER_PARSE_ERROR
303
 
create table VARIANCE (a int);
304
 
 
305
 
--error ER_PARSE_ERROR
306
 
create table VAR_POP(a int);
307
 
--error ER_PARSE_ERROR
308
 
create table VAR_POP (a int);
309
 
 
310
 
--error ER_PARSE_ERROR
311
 
create table VAR_SAMP(a int);
312
 
--error ER_PARSE_ERROR
313
 
create table VAR_SAMP (a int);
314
 
 
315
 
#
316
 
# Bug#25930 (CREATE TABLE x SELECT ... parses columns wrong when ran with
317
 
#            ANSI_QUOTES mode)
318
 
#
319
 
 
320
 
--disable_warnings
321
 
DROP TABLE IF EXISTS table_25930_a;
322
 
DROP TABLE IF EXISTS table_25930_b;
323
 
--enable_warnings
324
 
 
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;
329
 
 
330
 
# The lexer used to chop the first <">,
331
 
# not marking the start of the token "blah" correctly.
332
 
desc table_25930_b;
333
 
 
334
 
DROP TABLE table_25930_a;
335
 
DROP TABLE table_25930_b;
336
 
 
337
 
 
338
 
#=============================================================================
339
 
# SYNTACTIC PARSER (bison)
340
 
#=============================================================================
341
 
 
342
 
#
343
 
#
344
 
# Bug#21114 (Foreign key creation fails to table with name format)
345
 
346
 
 
347
 
# Test coverage with edge conditions
348
 
 
349
 
select pi(3.14);
350
 
 
351
 
select tan();
352
 
select tan(1, 2);
353
 
 
354
 
select makedate(1);
355
 
select makedate(1, 2, 3);
356
 
 
357
 
select atan();
358
 
select atan2(1, 2, 3);
359
 
 
360
 
select concat();
361
 
select concat("foo");
362
 
 
363
 
select concat_ws();
364
 
select concat_ws("foo");
365
 
 
366
 
select elt();
367
 
select elt(1);
368
 
 
369
 
select export_set();
370
 
select export_set("p1");
371
 
select export_set("p1", "p2");
372
 
select export_set("p1", "p2", "p3", "p4", "p5", "p6");
373
 
 
374
 
select field();
375
 
select field("p1");
376
 
 
377
 
select from_unixtime();
378
 
select from_unixtime(1, 2, 3);
379
 
 
380
 
select unix_timestamp(1, 2);
381
 
 
382
 
select greatest();
383
 
select greatest(12);
384
 
 
385
 
select last_insert_id(1, 2);
386
 
 
387
 
select least();
388
 
select least(12);
389
 
 
390
 
select locate();
391
 
select locate(1);
392
 
select locate(1, 2, 3, 4);
393
 
 
394
 
select log();
395
 
select log(1, 2, 3);
396
 
 
397
 
select make_set();
398
 
select make_set(1);
399
 
 
400
 
select rand(1, 2, 3);
401
 
 
402
 
select round(1, 2, 3);
403
 
 
404
 
#
405
 
# Bug#24736: UDF functions parsed as Stored Functions
406
 
#
407
 
 
408
 
# Verify that the syntax for calling UDF : foo(expr AS param, ...)
409
 
# can not be used when calling native functions
410
 
 
411
 
# Native function with 1 argument
412
 
 
413
 
select abs(3);
414
 
select abs(3 AS three);
415
 
select abs(3 three);
416
 
select abs(3 AS "three");
417
 
select abs(3 "three");
418
 
 
419
 
# Native function with 2 arguments
420
 
 
421
 
set @bar="bar";
422
 
set @foobar="foobar";
423
 
 
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);
438
 
 
439
 
# Native function with 3 arguments
440
 
 
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);
455
 
 
456
 
# Native function with a variable number of arguments
457
 
 
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
462
 
select atan(10);
463
 
select atan(10 AS p1);
464
 
select atan(10 p1);
465
 
select atan(10 AS "p1");
466
 
select atan(10 "p1");
467
 
 
468
 
select atan(10, 20);
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);
478
 
 
479
 
#
480
 
# Bug#22312 Syntax error in expression with INTERVAL()
481
 
#
482
 
 
483
 
--disable_warnings
484
 
DROP TABLE IF EXISTS t1;
485
 
--enable_warnings
486
 
 
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);
495
 
 
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;
499
 
DROP TABLE t1;
500
 
 
501
 
#
502
 
# Bug#28317 Left Outer Join with {oj outer-join}
503
 
#
504
 
 
505
 
--disable_warnings
506
 
DROP TABLE IF EXISTS t1,t2,t3;
507
 
--enable_warnings
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;
520
 
 
521
 
#
522
 
# Bug#31765 (BACKUP DATABASE broken syntax)
523
 
#
524
 
 
525
 
--error ER_PARSE_ERROR
526
 
BACKUP DATABASE *, test to 'broken.bak';
527
 
 
528
 
--error ER_PARSE_ERROR
529
 
BACKUP DATABASE *, db1, db2, db3 to 'broken.bak';
530