~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/parser.test

pandora-build v0.100 - Fixes several bugs found by cb1kenobi. Add several thoughts from folks at LCA.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
# LEXICAL PARSER (lex)
7
7
#=============================================================================
8
8
 
9
 
SET @save_sql_mode=@@sql_mode;
10
 
 
11
9
#
12
10
# Documenting the current behavior, to detect incompatible changes.
13
11
# In each cases:
15
13
# - an error is the expected result with the current implementation,
16
14
#   and is a limitation.
17
15
 
18
 
set SQL_MODE='';
19
 
 
20
16
create table ADDDATE(a int);
21
17
drop table ADDDATE;
22
18
create table ADDDATE (a int);
23
19
drop table ADDDATE;
24
20
 
25
21
--error ER_PARSE_ERROR
26
 
create table BIT_AND(a int);
27
 
create table BIT_AND (a int);
28
 
drop table BIT_AND;
29
 
 
30
 
--error ER_PARSE_ERROR
31
 
create table BIT_OR(a int);
32
 
create table BIT_OR (a int);
33
 
drop table BIT_OR;
34
 
 
35
 
--error ER_PARSE_ERROR
36
 
create table BIT_XOR(a int);
37
 
create table BIT_XOR (a int);
38
 
drop table BIT_XOR;
39
 
 
40
 
--error ER_PARSE_ERROR
41
22
create table CAST(a int);
 
23
--error ER_PARSE_ERROR
42
24
create table CAST (a int);
43
 
drop table CAST;
44
25
 
45
26
--error ER_PARSE_ERROR
46
27
create table COUNT(a int);
 
28
--error ER_PARSE_ERROR
47
29
create table COUNT (a int);
48
 
drop table COUNT;
49
30
 
50
31
--error ER_PARSE_ERROR
51
32
create table CURDATE(a int);
 
33
--error ER_PARSE_ERROR
52
34
create table CURDATE (a int);
53
 
drop table CURDATE;
54
 
 
55
 
--error ER_PARSE_ERROR
56
 
create table CURTIME(a int);
57
 
create table CURTIME (a int);
58
 
drop table CURTIME;
59
35
 
60
36
--error ER_PARSE_ERROR
61
37
create table DATE_ADD(a int);
 
38
--error ER_PARSE_ERROR
62
39
create table DATE_ADD (a int);
63
 
drop table DATE_ADD;
64
40
 
65
41
--error ER_PARSE_ERROR
66
42
create table DATE_SUB(a int);
 
43
--error ER_PARSE_ERROR
67
44
create table DATE_SUB (a int);
68
 
drop table DATE_SUB;
69
45
 
70
46
--error ER_PARSE_ERROR
71
47
create table EXTRACT(a int);
 
48
--error ER_PARSE_ERROR
72
49
create table EXTRACT (a int);
73
 
drop table EXTRACT;
74
50
 
75
51
--error ER_PARSE_ERROR
76
52
create table GROUP_CONCAT(a int);
 
53
--error ER_PARSE_ERROR
77
54
create table GROUP_CONCAT (a int);
78
 
drop table GROUP_CONCAT;
79
55
 
80
56
# Limitation removed in 5.1
81
57
create table GROUP_UNIQUE_USERS(a int);
85
61
 
86
62
--error ER_PARSE_ERROR
87
63
create table MAX(a int);
 
64
--error ER_PARSE_ERROR
88
65
create table MAX (a int);
89
 
drop table MAX;
90
66
 
91
67
--error ER_PARSE_ERROR
92
68
create table MID(a int);
 
69
--error ER_PARSE_ERROR
93
70
create table MID (a int);
94
 
drop table MID;
95
71
 
96
72
--error ER_PARSE_ERROR
97
73
create table MIN(a int);
 
74
--error ER_PARSE_ERROR
98
75
create table MIN (a int);
99
 
drop table MIN;
100
76
 
101
77
--error ER_PARSE_ERROR
102
78
create table NOW(a int);
 
79
--error ER_PARSE_ERROR
103
80
create table NOW (a int);
104
 
drop table NOW;
105
81
 
106
82
--error ER_PARSE_ERROR
107
83
create table POSITION(a int);
 
84
--error ER_PARSE_ERROR
108
85
create table POSITION (a int);
109
 
drop table POSITION;
110
86
 
111
87
create table SESSION_USER(a int);
112
88
drop table SESSION_USER;
115
91
 
116
92
--error ER_PARSE_ERROR
117
93
create table STD(a int);
 
94
--error ER_PARSE_ERROR
118
95
create table STD (a int);
119
 
drop table STD;
120
96
 
121
97
--error ER_PARSE_ERROR
122
98
create table STDDEV(a int);
 
99
--error ER_PARSE_ERROR
123
100
create table STDDEV (a int);
124
 
drop table STDDEV;
125
101
 
126
102
--error ER_PARSE_ERROR
127
103
create table STDDEV_POP(a int);
 
104
--error ER_PARSE_ERROR
128
105
create table STDDEV_POP (a int);
129
 
drop table STDDEV_POP;
130
106
 
131
107
--error ER_PARSE_ERROR
132
108
create table STDDEV_SAMP(a int);
 
109
--error ER_PARSE_ERROR
133
110
create table STDDEV_SAMP (a int);
134
 
drop table STDDEV_SAMP;
135
111
 
136
112
create table SUBDATE(a int);
137
113
drop table SUBDATE;
140
116
 
141
117
--error ER_PARSE_ERROR
142
118
create table SUBSTR(a int);
 
119
--error ER_PARSE_ERROR
143
120
create table SUBSTR (a int);
144
 
drop table SUBSTR;
145
 
 
146
 
--error ER_PARSE_ERROR
147
 
create table SUBSTRING(a int);
148
 
create table SUBSTRING (a int);
149
 
drop table SUBSTRING;
150
121
 
151
122
--error ER_PARSE_ERROR
152
123
create table SUM(a int);
 
124
--error ER_PARSE_ERROR
153
125
create table SUM (a int);
154
 
drop table SUM;
155
126
 
156
127
--error ER_PARSE_ERROR
157
128
create table SYSDATE(a int);
 
129
--error ER_PARSE_ERROR
158
130
create table SYSDATE (a int);
159
 
drop table SYSDATE;
160
131
 
161
132
create table SYSTEM_USER(a int);
162
133
drop table SYSTEM_USER;
165
136
 
166
137
--error ER_PARSE_ERROR
167
138
create table TRIM(a int);
 
139
--error ER_PARSE_ERROR
168
140
create table TRIM (a int);
169
 
drop table TRIM;
170
141
 
171
142
# Limitation removed in 5.1
172
143
create table UNIQUE_USERS(a int);
176
147
 
177
148
--error ER_PARSE_ERROR
178
149
create table VARIANCE(a int);
 
150
--error ER_PARSE_ERROR
179
151
create table VARIANCE (a int);
180
 
drop table VARIANCE;
181
152
 
182
153
--error ER_PARSE_ERROR
183
154
create table VAR_POP(a int);
 
155
--error ER_PARSE_ERROR
184
156
create table VAR_POP (a int);
185
 
drop table VAR_POP;
186
157
 
187
158
--error ER_PARSE_ERROR
188
159
create table VAR_SAMP(a int);
 
160
--error ER_PARSE_ERROR
189
161
create table VAR_SAMP (a int);
190
 
drop table VAR_SAMP;
191
 
 
192
 
set SQL_MODE='IGNORE_SPACE';
193
162
 
194
163
create table ADDDATE(a int);
195
164
drop table ADDDATE;
197
166
drop table ADDDATE;
198
167
 
199
168
--error ER_PARSE_ERROR
200
 
create table BIT_AND(a int);
201
 
--error ER_PARSE_ERROR
202
 
create table BIT_AND (a int);
203
 
 
204
 
--error ER_PARSE_ERROR
205
 
create table BIT_OR(a int);
206
 
--error ER_PARSE_ERROR
207
 
create table BIT_OR (a int);
208
 
 
209
 
--error ER_PARSE_ERROR
210
 
create table BIT_XOR(a int);
211
 
--error ER_PARSE_ERROR
212
 
create table BIT_XOR (a int);
213
 
 
214
 
--error ER_PARSE_ERROR
215
169
create table CAST(a int);
216
170
--error ER_PARSE_ERROR
217
171
create table CAST (a int);
225
179
create table CURDATE(a int);
226
180
--error ER_PARSE_ERROR
227
181
create table CURDATE (a int);
228
 
 
229
 
--error ER_PARSE_ERROR
230
 
create table CURTIME(a int);
231
 
--error ER_PARSE_ERROR
232
 
create table CURTIME (a int);
233
182
 
234
183
--error ER_PARSE_ERROR
235
184
create table DATE_ADD(a int);
373
322
DROP TABLE IF EXISTS table_25930_b;
374
323
--enable_warnings
375
324
 
376
 
SET SQL_MODE = 'ANSI_QUOTES';
 
325
--error ER_PARSE_ERROR
377
326
CREATE TABLE table_25930_a ( "blah" INT );
 
327
CREATE TABLE table_25930_a ( blah INT );
378
328
CREATE TABLE table_25930_b SELECT "blah" - 1 FROM table_25930_a;
379
329
 
380
330
# The lexer used to chop the first <">,
385
335
DROP TABLE table_25930_b;
386
336
 
387
337
 
388
 
SET @@sql_mode=@save_sql_mode;
389
 
 
390
338
#=============================================================================
391
339
# SYNTACTIC PARSER (bison)
392
340
#=============================================================================
398
346
 
399
347
# Test coverage with edge conditions
400
348
 
 
349
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
401
350
select pi(3.14);
402
351
 
 
352
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
403
353
select tan();
 
354
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
404
355
select tan(1, 2);
405
356
 
 
357
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
406
358
select makedate(1);
 
359
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
407
360
select makedate(1, 2, 3);
408
361
 
409
 
select maketime();
410
 
select maketime(1);
411
 
select maketime(1, 2);
412
 
select maketime(1, 2, 3, 4);
413
 
 
 
362
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
414
363
select atan();
 
364
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
415
365
select atan2(1, 2, 3);
416
366
 
 
367
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
417
368
select concat();
418
369
select concat("foo");
419
370
 
 
371
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
420
372
select concat_ws();
 
373
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
421
374
select concat_ws("foo");
422
375
 
423
 
select encrypt();
424
 
select encrypt(1, 2, 3);
425
 
 
426
 
select des_encrypt("p1", "p2", "not expected");
427
 
select des_decrypt("p1", "p2", "not expected");
428
 
 
 
376
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
429
377
select elt();
 
378
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
430
379
select elt(1);
431
380
 
 
381
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
432
382
select export_set();
 
383
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
433
384
select export_set("p1");
 
385
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
434
386
select export_set("p1", "p2");
 
387
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
435
388
select export_set("p1", "p2", "p3", "p4", "p5", "p6");
436
389
 
 
390
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
437
391
select field();
 
392
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
438
393
select field("p1");
439
394
 
 
395
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
440
396
select from_unixtime();
 
397
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
441
398
select from_unixtime(1, 2, 3);
442
399
 
 
400
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
443
401
select unix_timestamp(1, 2);
444
402
 
 
403
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
445
404
select greatest();
 
405
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
446
406
select greatest(12);
447
407
 
 
408
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
448
409
select last_insert_id(1, 2);
449
410
 
 
411
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
450
412
select least();
 
413
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
451
414
select least(12);
452
415
 
 
416
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
453
417
select locate();
 
418
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
454
419
select locate(1);
 
420
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
455
421
select locate(1, 2, 3, 4);
456
422
 
 
423
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
457
424
select log();
 
425
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
458
426
select log(1, 2, 3);
459
427
 
 
428
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
460
429
select make_set();
 
430
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
461
431
select make_set(1);
462
432
 
463
 
select master_pos_wait();
464
 
select master_pos_wait(1);
465
 
select master_pos_wait(1, 2, 3, 4);
466
 
 
 
433
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
467
434
select rand(1, 2, 3);
468
435
 
 
436
-- error ER_WRONG_PARAMCOUNT_TO_FUNCTION
469
437
select round(1, 2, 3);
470
438
 
471
 
select yearweek();
472
 
select yearweek(1, 2, 3);
473
 
 
474
439
#
475
440
# Bug#24736: UDF functions parsed as Stored Functions
476
441
#
641
558
DROP TABLE IF EXISTS t1;
642
559
--enable_warnings
643
560
 
644
 
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
645
 
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE;
646
561
SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
647
562
SELECT 1 + INTERVAL(1,0,1,2) + 1;
648
 
SELECT INTERVAL(1^1,0,1,2) + 1;
 
563
SELECT INTERVAL(1,0,1,2) + 1;
649
564
SELECT INTERVAL(1,0+1,2,3) * 5.5;
650
565
SELECT INTERVAL(3,3,1+3,4+4) / 0.5;
651
566
SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2;
652
567
SELECT INTERVAL(1,0,1,2) + 1, 5 * INTERVAL(1,0,1,2);
653
568
SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3);
654
569
 
655
 
--disable_warnings
656
 
SELECT 1^1 + INTERVAL 1+1 SECOND & 1 + INTERVAL 1+1 SECOND;
657
 
SELECT 1%2 - INTERVAL 1^1 SECOND | 1%2 - INTERVAL 1^1 SECOND;
658
 
--enable_warnings
659
 
 
660
570
CREATE TABLE t1 (a INT, b DATETIME);
661
571
INSERT INTO t1 VALUES (INTERVAL(3,2,1) + 1, "1997-12-31 23:59:59" + INTERVAL 1 SECOND);
662
572
SELECT * FROM t1 WHERE a = INTERVAL(3,2,1) + 1;