~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/mysqltest.test

  • Committer: Brian Aker
  • Date: 2009-12-29 01:38:38 UTC
  • mfrom: (1251.1.1 drizzle)
  • Revision ID: brian@gaz-20091229013838-03kb2z5xbqw03ddt
Merge of Diego fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
# This test uses chmod, can't be run with root permissions
3
 
 
4
 
# ============================================================================
5
 
#
6
 
# Test of mysqltest itself
7
 
#
8
 
# There are three rules that determines what belong to each command
9
 
# 1. A normal command is delimited by the <delimiter> which by default is
10
 
#    set to ';'
11
 
#
12
 
#   ex: | select *
13
 
#       |   from t1;
14
 
#       |
15
 
#   Command: "select * from t1"
16
 
#
17
 
# 2. Special case is a line that starts with "--", this is a comment
18
 
#    ended when the new line character is reached. But the first word
19
 
#    in the comment may contain a valid command, which then will be
20
 
#    executed. This can be useful when sending commands that
21
 
#    contains <delimiter>
22
 
#
23
 
# 3. Special case is also a line that starts with '#' which is treated
24
 
#     as a comment and will be ended by new line character
25
 
#
26
 
# ============================================================================
27
 
 
28
 
# ----------------------------------------------------------------------------
29
 
# $mysql_errno contains the return code of the last command
30
 
# sent to the server.
31
 
# ----------------------------------------------------------------------------
32
 
# get $mysql_errno before the first statement
33
 
#     $mysql_errno should be -1
34
 
eval select $mysql_errno as "before_use_test" ;
35
 
 
36
 
 
37
 
# ----------------------------------------------------------------------------
38
 
# Positive case(statement)
39
 
# ----------------------------------------------------------------------------
40
 
 
41
 
select otto from (select 1 as otto) as t1;
42
 
# expectation = response
43
 
--error 0
44
 
select otto from (select 1 as otto) as t1;
45
 
 
46
 
# ----------------------------------------------------------------------------
47
 
# Negative case(statement):
48
 
# The derived table t1 does not contain a column named 'friedrich' . 
49
 
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
50
 
# --> 1054: Unknown column 'friedrich' in 'field list'
51
 
# ----------------------------------------------------------------------------
52
 
 
53
 
# expectation <> response
54
 
#--error 0
55
 
#select friedrich from (select 1 as otto) as t1
56
 
--error 1
57
 
--exec echo "select friedrich from (select 1 as otto) as t1;" | $DRIZZLE_TEST  2>&1
58
 
 
59
 
# expectation = response
60
 
--error 1054
61
 
select friedrich from (select 1 as otto) as t1;
62
 
 
63
 
# The following unmasked unsuccessful statement must give
64
 
# 1. mysqltest gives a 'failed'
65
 
# 2. does not produce a r/<test case>.reject file !!!
66
 
# PLEASE uncomment it and check its effect
67
 
#select friedrich from (select 1 as otto) as t1;
68
 
 
69
 
 
70
 
# ----------------------------------------------------------------------------
71
 
# Tests for the new feature - SQLSTATE error code matching
72
 
# Positive case(statement)
73
 
# ----------------------------------------------------------------------------
74
 
 
75
 
# This syntax not allowed anymore, use --error S00000, see below
76
 
# expectation = response
77
 
#!S00000 select otto from (select 1 as otto) as t1;
78
 
 
79
 
--error S00000
80
 
select otto from (select 1 as otto) as t1;
81
 
 
82
 
# expectation <> response
83
 
#!S42S22 select otto from (select 1 as otto) as t1;
84
 
#--error S42S22
85
 
#select otto from (select 1 as otto) as t1;
86
 
--error 1
87
 
--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $DRIZZLE_TEST  2>&1
88
 
 
89
 
 
90
 
 
91
 
# ----------------------------------------------------------------------------
92
 
# Negative case(statement)
93
 
# ----------------------------------------------------------------------------
94
 
 
95
 
# This syntax not allowed anymore, use --error S42S22, see below
96
 
# expectation = response
97
 
#!S42S22 select friedrich from (select 1 as otto) as t1;
98
 
--error S42S22
99
 
select friedrich from (select 1 as otto) as t1;
100
 
 
101
 
# expectation !=response
102
 
#!S00000 select friedrich from (select 1 as otto) as t1;
103
 
#--error S00000
104
 
#select friedrich from (select 1 as otto) as t1;
105
 
--error 1
106
 
--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $DRIZZLE_TEST  2>&1
107
 
 
108
 
# ----------------------------------------------------------------------------
109
 
# test cases for $mysql_errno
110
 
#
111
 
# $mysql_errno is a builtin variable of mysqltest and contains the return code
112
 
# of the last command sent to the server.
113
 
#
114
 
#      The following test cases often initialize $mysql_errno to 1064 by 
115
 
#      a command with wrong syntax.
116
 
#      Example: --error 1064      To prevent the abort after the error.
117
 
#               garbage ;
118
 
# ----------------------------------------------------------------------------
119
 
 
120
 
# ----------------------------------------------------------------------------
121
 
# check mysql_errno = 0 after successful statement
122
 
# ----------------------------------------------------------------------------
123
 
select otto from (select 1 as otto) as t1;
124
 
eval select $mysql_errno as "after_successful_stmt_errno" ;
125
 
 
126
 
#----------------------------------------------------------------------------
127
 
# check mysql_errno = 1064 after statement with wrong syntax
128
 
# ----------------------------------------------------------------------------
129
 
--error 1064
130
 
garbage ;
131
 
eval select $mysql_errno as "after_wrong_syntax_errno" ;
132
 
 
133
 
# ----------------------------------------------------------------------------
134
 
# check if let $my_var= 'abc' ; affects $mysql_errno
135
 
# ----------------------------------------------------------------------------
136
 
--error 1064
137
 
garbage ;
138
 
let $my_var= 'abc' ;
139
 
eval select $mysql_errno as "after_let_var_equal_value" ;
140
 
 
141
 
# ----------------------------------------------------------------------------
142
 
# check if set @my_var= 'abc' ; affects $mysql_errno
143
 
# ----------------------------------------------------------------------------
144
 
--error 1064
145
 
garbage ;
146
 
set @my_var= 'abc' ;
147
 
eval select $mysql_errno as "after_set_var_equal_value" ;
148
 
 
149
 
# ----------------------------------------------------------------------------
150
 
#  check if the setting of --disable-warnings itself affects $mysql_errno
151
 
#  (May be --<whatever> modifies $mysql_errno.)
152
 
# ----------------------------------------------------------------------------
153
 
--error 1064
154
 
garbage ;
155
 
--disable_warnings
156
 
eval select $mysql_errno as "after_disable_warnings_command" ;
157
 
 
158
 
# ----------------------------------------------------------------------------
159
 
# check if --disable-warnings + command with warning affects the errno
160
 
# stored within $mysql_errno
161
 
# (May be disabled warnings affect $mysql_errno.)
162
 
# ----------------------------------------------------------------------------
163
 
drop table if exists t1 ;
164
 
--error 1064
165
 
garbage ;
166
 
drop table if exists t1 ;
167
 
eval select $mysql_errno as "after_disable_warnings" ;
168
 
--enable_warnings
169
 
 
170
 
# ----------------------------------------------------------------------------
171
 
# check if masked errors affect $mysql_errno
172
 
# ----------------------------------------------------------------------------
173
 
--error 1064
174
 
garbage ;
175
 
--error 1146
176
 
select 3 from t1 ;
177
 
eval select $mysql_errno as "after_minus_masked" ;
178
 
--error 1064
179
 
garbage ;
180
 
--error 1146
181
 
select 3 from t1 ;
182
 
eval select $mysql_errno as "after_!_masked" ;
183
 
 
184
 
# ----------------------------------------------------------------------------
185
 
# Will manipulations of $mysql_errno be possible and visible ?
186
 
# ----------------------------------------------------------------------------
187
 
--error 1064
188
 
garbage ;
189
 
let $mysql_errno= -1;
190
 
eval select $mysql_errno as "after_let_errno_equal_value" ;
191
 
 
192
 
# ----------------------------------------------------------------------------
193
 
# How affect actions on prepared statements $mysql_errno ?
194
 
# ----------------------------------------------------------------------------
195
 
# failing prepare
196
 
--error 1064
197
 
garbage ;
198
 
--error 1146
199
 
prepare stmt from "select 3 from t1" ;
200
 
eval select $mysql_errno as "after_failing_prepare" ;
201
 
create table t1 ( f1 char(10));
202
 
 
203
 
# successful prepare
204
 
--error 1064
205
 
garbage ;
206
 
prepare stmt from "select 3 from t1" ;
207
 
eval select $mysql_errno as "after_successful_prepare" ;
208
 
 
209
 
# successful execute
210
 
--error 1064
211
 
garbage ;
212
 
execute stmt;
213
 
eval select $mysql_errno as "after_successful_execute" ;
214
 
 
215
 
# failing execute (table has been dropped)
216
 
drop table t1;
217
 
--error 1064
218
 
garbage ;
219
 
--error 1146
220
 
execute stmt;
221
 
eval select $mysql_errno as "after_failing_execute" ;
222
 
 
223
 
# failing execute (unknown statement)
224
 
--error 1064
225
 
garbage ;
226
 
--error 1243
227
 
execute __stmt_;
228
 
eval select $mysql_errno as "after_failing_execute" ;
229
 
 
230
 
# successful deallocate
231
 
--error 1064
232
 
garbage ;
233
 
deallocate prepare stmt;
234
 
eval select $mysql_errno as "after_successful_deallocate" ;
235
 
 
236
 
# failing deallocate ( statement handle does not exist )
237
 
--error 1064
238
 
garbage ;
239
 
--error 1243
240
 
deallocate prepare __stmt_;
241
 
eval select $mysql_errno as "after_failing_deallocate" ;
242
 
 
243
 
 
244
 
# ----------------------------------------------------------------------------
245
 
# test cases for "--disable_abort_on_error"
246
 
#
247
 
# "--disable_abort_on_error" switches off the abort of mysqltest
248
 
# after "unmasked" failing statements.
249
 
#
250
 
# The default is "--enable_abort_on_error".
251
 
#
252
 
# "Maskings" are
253
 
#   --error <error number>  and  --error <error number>
254
 
# in the line before the failing statement.
255
 
#
256
 
# There are some additional test cases for $mysql_errno
257
 
# because "--disable_abort_on_error" enables a new situation.
258
 
# Example: "unmasked" statement fails + analysis of $mysql_errno
259
 
# ----------------------------------------------------------------------------
260
 
 
261
 
# ----------------------------------------------------------------------------
262
 
# Switch off the abort on error and check the effect on $mysql_errno
263
 
# ----------------------------------------------------------------------------
264
 
--error 1064
265
 
garbage ;
266
 
--disable_abort_on_error
267
 
eval select $mysql_errno as "after_--disable_abort_on_error" ;
268
 
 
269
 
# ----------------------------------------------------------------------------
270
 
# "unmasked" failing statement should not cause an abort
271
 
# ----------------------------------------------------------------------------
272
 
select 3 from t1 ;
273
 
 
274
 
# ----------------------------------------------------------------------------
275
 
# masked failing statements
276
 
# ----------------------------------------------------------------------------
277
 
# expected error = response
278
 
--error 1146
279
 
select 3 from t1 ;
280
 
--error 1146
281
 
select 3 from t1 ;
282
 
eval select $mysql_errno as "after_!errno_masked_error" ;
283
 
# expected error <> response
284
 
# --error 1000
285
 
# select 3 from t1 ;
286
 
# --error 1000
287
 
# select 3 from t1 ;
288
 
--error 1
289
 
--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $DRIZZLE_TEST  2>&1
290
 
 
291
 
# ----------------------------------------------------------------------------
292
 
# Switch the abort on error on and check the effect on $mysql_errno
293
 
# ----------------------------------------------------------------------------
294
 
--error 1064
295
 
garbage ;
296
 
--enable_abort_on_error
297
 
eval select $mysql_errno as "after_--enable_abort_on_error" ;
298
 
 
299
 
# ----------------------------------------------------------------------------
300
 
# masked failing statements
301
 
# ----------------------------------------------------------------------------
302
 
# expected error = response
303
 
--error 1146
304
 
select 3 from t1 ;
305
 
 
306
 
# ----------------------------------------------------------------------------
307
 
# check that the old default behaviour is not changed
308
 
# Please remove the '#' to get the abort on error
309
 
# ----------------------------------------------------------------------------
310
 
#--error 1064
311
 
#select 3 from t1 ;
312
 
#
313
 
#select 3 from t1 ;
314
 
 
315
 
--error 1
316
 
--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $DRIZZLE_TEST  2>&1
317
 
 
318
 
 
319
 
# ----------------------------------------------------------------------------
320
 
# Test comments
321
 
# ----------------------------------------------------------------------------
322
 
 
323
 
# This is a comment
324
 
# This is a ;  comment
325
 
# This is a -- comment
326
 
# -- This is also a comment
327
 
# -- # This is also a comment
328
 
# -- This is also a ; comment
329
 
 
330
 
# ----------------------------------------------------------------------------
331
 
# Test comments with embedded command
332
 
# ----------------------------------------------------------------------------
333
 
 
334
 
--echo hello
335
 
 
336
 
--echo # MySQL: -- The
337
 
 
338
 
# ----------------------------------------------------------------------------
339
 
# Test detect end of line "junk"
340
 
# Most likely caused by a missing delimiter
341
 
# ----------------------------------------------------------------------------
342
 
 
343
 
# Too many parameters to function
344
 
--error 1
345
 
--exec echo "sleep 5 6;" | $DRIZZLE_TEST 2>&1
346
 
 
347
 
# Too many parameters to function
348
 
--error 1
349
 
--exec echo "--sleep 5 6" | $DRIZZLE_TEST 2>&1
350
 
 
351
 
#
352
 
# Missing delimiter
353
 
# The comment will be "sucked into" the sleep command since
354
 
# delimiter is missing until after "show status"
355
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
356
 
sleep 4
357
 
# A comment
358
 
show status;
359
 
EOF
360
 
--error 1
361
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
362
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
363
 
 
364
 
#
365
 
# Missing delimiter until eof
366
 
# The comment will be "sucked into" the sleep command since
367
 
# delimiter is missing
368
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
369
 
sleep 7
370
 
# Another comment
371
 
EOF
372
 
--error 1
373
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
374
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
375
 
 
376
 
#
377
 
# Missing delimiter until "disable_query_log"
378
 
#
379
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
380
 
disconnect default
381
 
 
382
 
#
383
 
# comment
384
 
# comment 3
385
 
disable_query_log;
386
 
EOF
387
 
--error 1
388
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
389
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
390
 
 
391
 
#
392
 
# Missing delimiter until "disable_query_log"
393
 
#
394
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
395
 
disconnect default
396
 
 
397
 
#
398
 
# comment
399
 
 
400
 
# comment 3
401
 
disable_query_log;
402
 
EOF
403
 
--error 1
404
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
405
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
406
 
 
407
 
#
408
 
# Missing delimiter until eof
409
 
#
410
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
411
 
disconnect default
412
 
 
413
 
#
414
 
# comment
415
 
# comment2
416
 
 
417
 
# comment 3
418
 
--disable_query_log
419
 
EOF
420
 
--error 1
421
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
422
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
423
 
 
424
 
#
425
 
# Missing delimiter until eof
426
 
#
427
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
428
 
disconnect default # comment
429
 
# comment part2
430
 
 
431
 
# comment 3
432
 
--disable_query_log
433
 
EOF
434
 
--error 1
435
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
436
 
 
437
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
438
 
 
439
 
#
440
 
# Extra delimiter
441
 
#
442
 
--error 1
443
 
--exec echo "--sleep 4;" | $DRIZZLE_TEST 2>&1
444
 
--error 1
445
 
--exec echo "--disable_query_log;" | $DRIZZLE_TEST 2>&1
446
 
 
447
 
 
448
 
# Allow trailing # comment
449
 
--sleep 1 # Wait for insert delayed to be executed.
450
 
--sleep 1        # Wait for insert delayed to be executed.
451
 
 
452
 
# ----------------------------------------------------------------------------
453
 
# Test error
454
 
# ----------------------------------------------------------------------------
455
 
 
456
 
# Missing argument
457
 
--error 1
458
 
--exec echo "error;" | $DRIZZLE_TEST 2>&1
459
 
--error 1
460
 
--exec echo "--error" | $DRIZZLE_TEST 2>&1
461
 
 
462
 
# First char must be uppercase 'S' or 'E' or [0-9]
463
 
--error 1
464
 
--exec echo "--error s99999" | $DRIZZLE_TEST 2>&1
465
 
--error 1
466
 
--exec echo "--error e99999" | $DRIZZLE_TEST 2>&1
467
 
--error 1
468
 
--exec echo "--error 9eeeee" | $DRIZZLE_TEST 2>&1
469
 
--error 1
470
 
--exec echo "--error 1sssss" | $DRIZZLE_TEST 2>&1
471
 
 
472
 
# First char 'S' but too long
473
 
--error 1
474
 
--exec echo "--error S999999" | $DRIZZLE_TEST 2>&1
475
 
 
476
 
# First char 'S' but lowercase char found
477
 
--error 1
478
 
--exec echo "--error S99a99" | $DRIZZLE_TEST 2>&1
479
 
 
480
 
# First char 'S' but too short
481
 
--error 1
482
 
--exec echo "--error S9999" | $DRIZZLE_TEST 2>&1
483
 
 
484
 
# First char 'E' but not found in error array
485
 
--error 1
486
 
--exec echo "--error E9999" | $DRIZZLE_TEST 2>&1
487
 
 
488
 
# First char [0-9] but contains chars
489
 
--error 1
490
 
--exec echo "--error 999e9" | $DRIZZLE_TEST 2>&1
491
 
--error 1
492
 
--exec echo "--error 9b" | $DRIZZLE_TEST 2>&1
493
 
 
494
 
# Multiple errorcodes separated by ','
495
 
--error 1,1,1,1
496
 
#--error 9,ER_PARSE_ERROR
497
 
#--error ER_PARSE_ERROR
498
 
#--error 9,ER_PARSE_ERROR,9,ER_PARSE_ERROR
499
 
#--error 9, ER_PARSE_ERROR,  9,   ER_PARSE_ERROR
500
 
#--error 9,S00000,9,ER_PARSE_ERROR
501
 
#--error 9,S00000,9,ER_PARSE_ERROR,ER_PARSE_ERROR,ER_PARSE_ERROR,9,10,11,12
502
 
--error 9,S00000,9
503
 
--error 9,S00000,9,9,10,11,12
504
 
--error 9 ,10
505
 
--error 9 , 10
506
 
--error    9   ,   10
507
 
--error    9   ,   10
508
 
 
509
 
# Too many errorcodes specified
510
 
--error 1
511
 
--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $DRIZZLE_TEST 2>&1
512
 
 
513
 
 
514
 
# ----------------------------------------------------------------------------
515
 
# Test echo command
516
 
# ----------------------------------------------------------------------------
517
 
 
518
 
echo MySQL;
519
 
echo "MySQL";
520
 
echo MySQL: The world''s most popular open source database;
521
 
echo "MySQL: The world's most popular open source database";
522
 
 
523
 
echo MySQL: The world''s
524
 
     most popular open
525
 
     source database;
526
 
 
527
 
echo # MySQL: The world''s
528
 
# most popular open
529
 
# source database;
530
 
 
531
 
echo - MySQL: The world''s
532
 
- most popular open
533
 
- source database;
534
 
 
535
 
echo - MySQL: The world''s
536
 
 
537
 
echo # MySQL: The
538
 
--world''s
539
 
# most popular
540
 
- source database;
541
 
 
542
 
echo "MySQL: The world's most popular; open source database";
543
 
echo "MySQL: The world's most popular ; open source database";
544
 
echo "MySQL: The world's most popular ;open source database";
545
 
echo echo message echo message;
546
 
 
547
 
 
548
 
echo ;
549
 
 
550
 
# Illegal use of echo
551
 
 
552
 
#--error 1
553
 
#--exec echo "echo \$;" | $DRIZZLE_TEST 2>&1
554
 
 
555
 
 
556
 
# ----------------------------------------------------------------------------
557
 
# Test exec command
558
 
# ----------------------------------------------------------------------------
559
 
 
560
 
# Illegal use of exec
561
 
--error 1
562
 
--exec echo "--exec false" | $DRIZZLE_TEST 2>&1
563
 
 
564
 
--error 1
565
 
--exec echo "--exec " | $DRIZZLE_TEST 2>&1
566
 
 
567
 
# ----------------------------------------------------------------------------
568
 
# Test let command
569
 
# ----------------------------------------------------------------------------
570
 
 
571
 
let $message=MySQL;
572
 
echo $message;
573
 
 
574
 
let $message="MySQL";
575
 
echo $message;
576
 
 
577
 
let $message= MySQL: The
578
 
 world''s most
579
 
 popular open
580
 
 source database;
581
 
echo $message;
582
 
 
583
 
let $message= # MySQL: The
584
 
# world''s most
585
 
# popular open
586
 
# source database;
587
 
echo $message;
588
 
 
589
 
let $message=  -- MySQL: The
590
 
echo $message;
591
 
 
592
 
let $message=  # MySQL: The
593
 
- world''s most
594
 
# source database;
595
 
echo $message;
596
 
 
597
 
echo '$message';
598
 
echo "$message";
599
 
 
600
 
let $1=hej;
601
 
echo $1;
602
 
 
603
 
let   $1   =hej ;
604
 
echo $1;
605
 
 
606
 
let $1 = hej;
607
 
echo $1;
608
 
 
609
 
let $1=1;
610
 
let $2=$1;
611
 
echo $2;
612
 
let $5=$6;
613
 
echo $5;
614
 
echo $6;
615
 
 
616
 
let $where=a long variable content;
617
 
echo $where;
618
 
 
619
 
let $where2= $where;
620
 
echo $where2;
621
 
 
622
 
let $where3=a long $where variable content;
623
 
echo $where3;
624
 
 
625
 
let $where3=a long \\\$where variable content;
626
 
echo $where3;
627
 
 
628
 
let $novar1= $novar2;
629
 
echo $novar1;
630
 
 
631
 
let $cat=na;
632
 
let $cat=ba$cat$cat;
633
 
echo banana = $cat;
634
 
 
635
 
# ba\$cat\$cat should have been sufficient.
636
 
# ba\\\$cat\\\$cat -> ba\$cat\$cat -> ba$cat$cat -> banana
637
 
# Magnus' upcoming patch will fix the missing second interpretation.
638
 
let $cat=ba\\\$cat\\\$cat;
639
 
echo Not a banana: $cat;
640
 
 
641
 
 
642
 
# Test illegal uses of let
643
 
 
644
 
--error 1
645
 
--exec echo "let ;" | $DRIZZLE_TEST 2>&1
646
 
 
647
 
--error 1
648
 
--exec echo "let \$=hi;" | $DRIZZLE_TEST  2>&1
649
 
 
650
 
--error 1
651
 
--exec echo "let \$1 hi;" | $DRIZZLE_TEST  2>&1
652
 
 
653
 
--error 1
654
 
--exec echo "let \$m hi;" | $DRIZZLE_TEST  2>&1
655
 
 
656
 
--error 1
657
 
--exec echo "let \$hi;" | $DRIZZLE_TEST  2>&1
658
 
 
659
 
--error 1
660
 
--exec echo "let \$ hi;" | $DRIZZLE_TEST  2>&1
661
 
 
662
 
--error 1
663
 
--exec echo "let =hi;" | $DRIZZLE_TEST  2>&1
664
 
 
665
 
--error 1
666
 
--exec echo "let hi;" | $DRIZZLE_TEST  2>&1
667
 
 
668
 
# More advanced test for bug#17280
669
 
let $success= 1;
670
 
--echo # Execute: --echo # <whatever> success: \$success
671
 
--echo # <whatever> success: $success
672
 
--echo # Execute: echo # <whatever> success: \$success ;
673
 
echo # <whatever> success: $success ;
674
 
 
675
 
--echo # The next two variants work fine and expand the content of \$success
676
 
--echo # Execute: --echo \$success
677
 
--echo $success
678
 
--echo # Execute: echo \$success ;
679
 
echo $success ;
680
 
 
681
 
 
682
 
# ----------------------------------------------------------------------------
683
 
# Test to assign let from variable
684
 
# let $<var_name>=$<var_name>;
685
 
# ----------------------------------------------------------------------------
686
 
 
687
 
--echo # Check if let \$B = \$A is an assignment per value.
688
 
 
689
 
# Basic preparations:
690
 
--echo let \$A = initial value of A;
691
 
let $A = initial value of A;
692
 
# --echo # Content of \$A is: $A
693
 
--echo let \$B = initial value of B;
694
 
let $B = initial value of B;
695
 
# --echo # Content of \$B is: $B
696
 
 
697
 
# Assign $B to $A:
698
 
--echo let \$B = \$A
699
 
let $A = $B;
700
 
--echo # Content of \$A is: $A
701
 
 
702
 
# Changes of $B must NOT affect $A and Changes of $A must NOT affect $B !
703
 
--echo let \$A = changed value of A;
704
 
let $A = changed value of A;
705
 
--echo # Content of \$B is: $B
706
 
 
707
 
--echo let \$B = changed value of B;
708
 
let $B = changed value of B;
709
 
--echo # Content of \$A is: $A
710
 
 
711
 
# ----------------------------------------------------------------------------
712
 
# Test let from query with $variable
713
 
# let $<var_name>=`<query with $variable>`;
714
 
# ----------------------------------------------------------------------------
715
 
 
716
 
let $var1=content of variable 1;
717
 
let $var2= `select "$var1"`;
718
 
let $var3= `select concat("$var1", " ", "$var2")`;
719
 
echo var2: $var2;
720
 
echo var3: $var3;
721
 
if (`select length("$var3") > 0`)
722
 
{
723
 
  echo length of var3 is longer than 0;
724
 
}
725
 
 
726
 
# ----------------------------------------------------------------------------
727
 
# Test to assign let from query
728
 
# let $<var_name>=`<query>`;
729
 
# ----------------------------------------------------------------------------
730
 
echo var1;
731
 
let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`;
732
 
echo $var1;
733
 
 
734
 
echo var2;
735
 
let $var2= `select 2 as "Column num 2"`;
736
 
echo $var2;
737
 
 
738
 
echo var2 again;
739
 
let $var2= `select 2 as "Column num 2"`;
740
 
echo $var2;
741
 
 
742
 
echo var3 two columns with same name;
743
 
let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`;
744
 
echo $var3;
745
 
 
746
 
echo var4 from query that returns NULL;
747
 
let $var4= `select NULL`;
748
 
 
749
 
echo var5 from query that returns no row;
750
 
let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`;
751
 
 
752
 
echo failing query in let;
753
 
--write_file $MYSQLTEST_VARDIR/tmp/let.sql
754
 
let $var2= `failing query`;
755
 
echo $var2;
756
 
EOF
757
 
 
758
 
--error 1
759
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
760
 
 
761
 
remove_file $MYSQLTEST_VARDIR/tmp/let.sql;
762
 
 
763
 
 
764
 
# ----------------------------------------------------------------------------
765
 
# Test source command
766
 
# ----------------------------------------------------------------------------
767
 
 
768
 
# Test illegal uses of source
769
 
 
770
 
--error 1
771
 
--exec echo "source ;" | $DRIZZLE_TEST 2>&1
772
 
 
773
 
# Fix win paths
774
 
--replace_result \\ /
775
 
# Source a nonexisting file
776
 
--error 1
777
 
--exec echo "source non_existingFile;" | $DRIZZLE_TEST 2>&1
778
 
 
779
 
# Too many source
780
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql
781
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
782
 
--error 1
783
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $DRIZZLE_TEST 2>&1
784
 
remove_file $MYSQLTEST_VARDIR/tmp/recursive.sql;
785
 
 
786
 
# Source a file with error
787
 
--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql
788
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
789
 
--error 1
790
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $DRIZZLE_TEST 2>&1
791
 
 
792
 
remove_file $MYSQLTEST_VARDIR/tmp/error.sql;
793
 
 
794
 
# Test execution of source in a while loop
795
 
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
796
 
echo here is the sourced script;
797
 
EOF
798
 
--disable_query_log
799
 
let $outer= 2; # Number of outer loops
800
 
while ($outer)
801
 
{
802
 
  eval SELECT '$outer = outer loop variable after while' AS "";
803
 
 
804
 
  --source $MYSQLTEST_VARDIR/tmp/sourced.inc
805
 
 
806
 
  eval SELECT '$outer = outer loop variable before dec' AS "";
807
 
  dec $outer;
808
 
  eval SELECT '$outer = outer loop variable after dec' AS "";
809
 
}
810
 
 
811
 
let $outer= 2; # Number of outer loops
812
 
while ($outer)
813
 
{
814
 
  eval SELECT '$outer = outer loop variable after while' AS "";
815
 
 
816
 
  echo here is the sourced script;
817
 
 
818
 
  eval SELECT '$outer = outer loop variable before dec' AS "";
819
 
  dec $outer;
820
 
  eval SELECT '$outer = outer loop variable after dec' AS "";
821
 
}
822
 
 
823
 
 
824
 
# Test execution of source in a while loop
825
 
--disable_abort_on_error
826
 
# Sourcing of a file within while loop, sourced file will
827
 
# source other file
828
 
let $num= 9;
829
 
while ($num)
830
 
{
831
 
   SELECT 'In loop' AS "";
832
 
   --source $MYSQLTEST_VARDIR/tmp/sourced.inc
833
 
   dec $num;
834
 
}
835
 
--enable_abort_on_error
836
 
--enable_query_log
837
 
 
838
 
# Test source $variable/<filename>
839
 
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
840
 
 
841
 
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
842
 
 
843
 
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
844
 
echo "hello";
845
 
EOF
846
 
 
847
 
let $x= sourced;
848
 
source $MYSQLTEST_VARDIR/tmp/$x.inc;
849
 
 
850
 
let $x= $MYSQLTEST_VARDIR;
851
 
source $x/tmp/sourced.inc;
852
 
 
853
 
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
854
 
 
855
 
 
856
 
# ----------------------------------------------------------------------------
857
 
# Test sleep command
858
 
# ----------------------------------------------------------------------------
859
 
 
860
 
sleep 0.5;
861
 
sleep 1;
862
 
real_sleep 1;
863
 
 
864
 
# Missing parameter
865
 
--error 1
866
 
--exec echo "sleep ;" | $DRIZZLE_TEST 2>&1
867
 
--error 1
868
 
--exec echo "real_sleep ;" | $DRIZZLE_TEST 2>&1
869
 
 
870
 
# Illegal parameter
871
 
--error 1
872
 
--exec echo "sleep abc;" | $DRIZZLE_TEST 2>&1
873
 
--error 1
874
 
--exec echo "real_sleep abc;" | $DRIZZLE_TEST 2>&1
875
 
 
876
 
# ----------------------------------------------------------------------------
877
 
# Test inc
878
 
# ----------------------------------------------------------------------------
879
 
inc $i;
880
 
echo $i;
881
 
inc $i;
882
 
echo $i;
883
 
let $i=100;
884
 
inc $i;
885
 
echo $i;
886
 
 
887
 
let $i=hej;
888
 
echo $i;
889
 
inc $i;
890
 
echo $i;
891
 
 
892
 
--error 1
893
 
--exec echo "inc;" | $DRIZZLE_TEST 2>&1
894
 
--error 1
895
 
--exec echo "inc i;" | $DRIZZLE_TEST 2>&1
896
 
--error 1
897
 
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $DRIZZLE_TEST 2>&1
898
 
 
899
 
inc $i; inc $i; inc $i; --echo $i
900
 
echo $i;
901
 
 
902
 
 
903
 
# ----------------------------------------------------------------------------
904
 
# Test dec
905
 
# ----------------------------------------------------------------------------
906
 
 
907
 
dec $d;
908
 
echo $d;
909
 
dec $d;
910
 
echo $d;
911
 
let $d=100;
912
 
dec $d;
913
 
echo $d;
914
 
 
915
 
let $d=hej;
916
 
echo $d;
917
 
dec $d;
918
 
echo $d;
919
 
 
920
 
--error 1
921
 
--exec echo "dec;" | $DRIZZLE_TEST 2>&1
922
 
--error 1
923
 
--exec echo "dec i;" | $DRIZZLE_TEST 2>&1
924
 
--error 1
925
 
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $DRIZZLE_TEST 2>&1
926
 
 
927
 
 
928
 
# ----------------------------------------------------------------------------
929
 
# Test system
930
 
# ----------------------------------------------------------------------------
931
 
#system ls > /dev/null;
932
 
system echo "hej" > /dev/null;
933
 
#--system ls > /dev/null
934
 
--system echo "hej" > /dev/null;
935
 
 
936
 
--error 1
937
 
--exec echo "system;" | $DRIZZLE_TEST 2>&1
938
 
--error 1
939
 
--exec echo "system $NONEXISTSINFVAREABLI;" | $DRIZZLE_TEST 2>&1
940
 
--error 1
941
 
--exec echo "system false;" | $DRIZZLE_TEST 2>&1
942
 
 
943
 
--disable_abort_on_error
944
 
system NonExistsinfComamdn 2> /dev/null;
945
 
--enable_abort_on_error
946
 
 
947
 
 
948
 
# ----------------------------------------------------------------------------
949
 
# Test delimiter
950
 
# ----------------------------------------------------------------------------
951
 
 
952
 
delimiter stop;
953
 
echo teststop
954
 
delimiter ;stop
955
 
echo test2;
956
 
--delimiter stop
957
 
echo test3stop
958
 
--delimiter ;
959
 
echo test4;
960
 
 
961
 
 
962
 
# ----------------------------------------------------------------------------
963
 
# Test if
964
 
# ----------------------------------------------------------------------------
965
 
 
966
 
let $counter=10;
967
 
if ($counter)
968
 
{
969
 
  echo Counter is greater than 0, (counter=10);
970
 
}
971
 
if (!$counter)
972
 
{
973
 
  echo Counter is not 0, (counter=10);
974
 
}
975
 
let $counter=0;
976
 
if($counter)
977
 
{
978
 
  echo Counter is greater than 0, (counter=0);
979
 
}
980
 
if (!$counter)
981
 
{
982
 
  echo Counter is not 0, (counter=0);
983
 
}
984
 
 
985
 
# ----------------------------------------------------------------------------
986
 
# Test while, { and }
987
 
# ----------------------------------------------------------------------------
988
 
 
989
 
let $i=1;
990
 
while ($i)
991
 
{
992
 
  echo $i;
993
 
  dec $i;
994
 
}
995
 
# One liner
996
 
#let $i=1;while ($i){echo $i;dec $i;}
997
 
 
998
 
let $i=0;
999
 
while (!$i)
1000
 
{
1001
 
  echo Testing while with not;
1002
 
  inc $i;
1003
 
}
1004
 
 
1005
 
# Exceed max nesting level
1006
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1007
 
let $1 = 10;
1008
 
while ($1)
1009
 
{
1010
 
while ($1)
1011
 
{
1012
 
while ($1)
1013
 
{
1014
 
 while ($1)
1015
 
{
1016
 
 while ($1)
1017
 
{
1018
 
 while ($1)
1019
 
{
1020
 
 while ($1)
1021
 
{
1022
 
 while ($1)
1023
 
{
1024
 
 while ($1)
1025
 
{
1026
 
 while ($1)
1027
 
{
1028
 
 while ($1)
1029
 
{
1030
 
 while ($1)
1031
 
{
1032
 
 while ($1)
1033
 
{
1034
 
 while ($1)
1035
 
{
1036
 
 while ($1)
1037
 
{
1038
 
 while ($1)
1039
 
{
1040
 
 while ($1)
1041
 
{
1042
 
 while ($1)
1043
 
{
1044
 
 while ($1)
1045
 
{
1046
 
 while ($1)
1047
 
{
1048
 
 while ($1)
1049
 
{
1050
 
 while ($1)
1051
 
{
1052
 
 while ($1)
1053
 
{
1054
 
 while ($1)
1055
 
{
1056
 
 while ($1)
1057
 
{
1058
 
 while ($1)
1059
 
{
1060
 
 while ($1)
1061
 
{
1062
 
 while ($1)
1063
 
{
1064
 
 while ($1)
1065
 
{
1066
 
 while ($1)
1067
 
{
1068
 
 while ($1)
1069
 
{
1070
 
 while ($1)
1071
 
{
1072
 
 while ($1)
1073
 
{
1074
 
 while ($1)
1075
 
{
1076
 
 while ($1)
1077
 
{
1078
 
 while ($1)
1079
 
{
1080
 
 while ($1)
1081
 
{
1082
 
 while ($1)
1083
 
{
1084
 
 while ($1)
1085
 
{
1086
 
 while ($1)
1087
 
{
1088
 
 while ($1)
1089
 
{
1090
 
 while ($1)
1091
 
{
1092
 
 while ($1)
1093
 
{
1094
 
 while ($1)
1095
 
{
1096
 
 while ($1)
1097
 
{
1098
 
 while ($1)
1099
 
{
1100
 
 while ($1)
1101
 
{
1102
 
 while ($1)
1103
 
{
1104
 
 while ($1)
1105
 
{
1106
 
  echo $1;
1107
 
  dec $1;
1108
 
}
1109
 
}
1110
 
}
1111
 
}
1112
 
}
1113
 
}
1114
 
}
1115
 
}
1116
 
}
1117
 
}
1118
 
}
1119
 
}
1120
 
}
1121
 
}
1122
 
}
1123
 
}
1124
 
}
1125
 
}
1126
 
}
1127
 
}
1128
 
}
1129
 
}
1130
 
}
1131
 
}
1132
 
}
1133
 
}
1134
 
}
1135
 
}
1136
 
}
1137
 
}
1138
 
}
1139
 
}
1140
 
}
1141
 
}
1142
 
}
1143
 
}
1144
 
EOF
1145
 
# Fix win path
1146
 
--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1147
 
--error 1
1148
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $DRIZZLE_TEST 2>&1
1149
 
--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1150
 
--error 1
1151
 
--exec echo "while \$i;" | $DRIZZLE_TEST 2>&1
1152
 
--error 1
1153
 
--exec echo "while (\$i;" | $DRIZZLE_TEST 2>&1
1154
 
--error 1
1155
 
--exec echo "let \$i=1; while (\$i) dec \$i;" | $DRIZZLE_TEST 2>&1
1156
 
--error 1
1157
 
--exec echo "};" | $DRIZZLE_TEST 2>&1
1158
 
--error 1
1159
 
--exec echo "end;" | $DRIZZLE_TEST 2>&1
1160
 
--error 1
1161
 
--exec echo "{;" | $DRIZZLE_TEST 2>&1
1162
 
 
1163
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1164
 
while (0)
1165
 
echo hej;
1166
 
EOF
1167
 
--error 1
1168
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1169
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1170
 
 
1171
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1172
 
while (0)
1173
 
{echo hej;
1174
 
EOF
1175
 
--error 1
1176
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1177
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1178
 
 
1179
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1180
 
while (0){
1181
 
 echo hej;
1182
 
EOF
1183
 
--error 1
1184
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1185
 
 
1186
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1187
 
 
1188
 
# ----------------------------------------------------------------------------
1189
 
# Test error messages returned from comments starting with a command
1190
 
# ----------------------------------------------------------------------------
1191
 
--error 1
1192
 
--exec echo "--if the other server is down" | $DRIZZLE_TEST 2>&1
1193
 
 
1194
 
--error 1
1195
 
--exec echo "-- end when ..." | $DRIZZLE_TEST 2>&1
1196
 
 
1197
 
# ----------------------------------------------------------------------------
1198
 
# Test replace
1199
 
# ----------------------------------------------------------------------------
1200
 
--replace_result a b
1201
 
select "a" as col1, "c" as col2;
1202
 
 
1203
 
--replace_result a b c d
1204
 
select "a" as col1, "c" as col2;
1205
 
 
1206
 
--error 1
1207
 
--exec echo "--replace_result a" | $DRIZZLE_TEST 2>&1
1208
 
--error 1
1209
 
--exec echo "--replace_result a;" | $DRIZZLE_TEST 2>&1
1210
 
--error 1
1211
 
--exec echo "replace_result a;" | $DRIZZLE_TEST 2>&1
1212
 
--error 1
1213
 
--exec echo "replace_result a ;" | $DRIZZLE_TEST 2>&1
1214
 
--exec echo "replace_result a b; echo OK;" | $DRIZZLE_TEST 2>&1
1215
 
--error 1
1216
 
--exec echo "--replace_result a b c" | $DRIZZLE_TEST 2>&1
1217
 
--error 1
1218
 
--exec echo "replace_result a b c ;" | $DRIZZLE_TEST 2>&1
1219
 
 
1220
 
 
1221
 
--replace_column 1 b
1222
 
select "a" as col1, "c" as col2;
1223
 
 
1224
 
--replace_column 1 b 2 d
1225
 
select "a" as col1, "c" as col2;
1226
 
 
1227
 
--error 1
1228
 
--exec echo "--replace_column a" | $DRIZZLE_TEST 2>&1
1229
 
 
1230
 
--error 1
1231
 
--exec echo "--replace_column 1" | $DRIZZLE_TEST 2>&1
1232
 
 
1233
 
--error 1
1234
 
--exec echo "--replace_column a b" | $DRIZZLE_TEST 2>&1
1235
 
--error 1
1236
 
--exec echo "--replace_column a 1" | $DRIZZLE_TEST 2>&1
1237
 
--error 1
1238
 
--exec echo "--replace_column 1 b c " | $DRIZZLE_TEST 2>&1
1239
 
 
1240
 
 
1241
 
# ----------------------------------------------------------------------------
1242
 
# Test sync_with_master
1243
 
# ----------------------------------------------------------------------------
1244
 
--error 1
1245
 
--exec echo "sync_with_master 10!;" | $DRIZZLE_TEST 2>&1
1246
 
--error 1
1247
 
--exec echo "sync_with_master a;" | $DRIZZLE_TEST 2>&1
1248
 
 
1249
 
# ----------------------------------------------------------------------------
1250
 
# Test connect
1251
 
# ----------------------------------------------------------------------------
1252
 
 
1253
 
--error 1
1254
 
--exec echo "connect;" | $DRIZZLE_TEST 2>&1
1255
 
--error 1
1256
 
--exec echo "connect ();" | $DRIZZLE_TEST 2>&1
1257
 
--error 1
1258
 
--exec echo "connect (con2);" | $DRIZZLE_TEST 2>&1
1259
 
--error 1
1260
 
--exec echo "connect (con2,);" | $DRIZZLE_TEST 2>&1
1261
 
--error 1
1262
 
--exec echo "connect (con2,localhost,root,,illegal_db);" | $DRIZZLE_TEST 2>&1
1263
 
--error 1
1264
 
--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $DRIZZLE_TEST 2>&1
1265
 
--error 1
1266
 
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $DRIZZLE_TEST 2>&1
1267
 
 
1268
 
# Repeat connect/disconnect
1269
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1270
 
let $i=100;
1271
 
while ($i)
1272
 
{
1273
 
  connect (test_con1,localhost,root,,);
1274
 
  disconnect test_con1;
1275
 
  dec $i;
1276
 
}
1277
 
EOF
1278
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $DRIZZLE_TEST 2>&1
1279
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1280
 
 
1281
 
# Repeat connect/disconnect
1282
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1283
 
let $i=200;
1284
 
while ($i)
1285
 
{
1286
 
 connect (test_con1,localhost,root,,);
1287
 
 disconnect test_con1;
1288
 
 dec $i;
1289
 
}
1290
 
EOF
1291
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1292
 
--error 1
1293
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1294
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1295
 
 
1296
 
# Select disconnected connection
1297
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1298
 
connect (test_con1,localhost,root,,);
1299
 
disconnect test_con1;
1300
 
connection test_con1;
1301
 
EOF
1302
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1303
 
--error 1
1304
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1305
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1306
 
 
1307
 
# Connection name already used
1308
 
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1309
 
connect (test_con1,localhost,root,,);
1310
 
connect (test_con1,localhost,root,,);
1311
 
EOF
1312
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1313
 
--error 1
1314
 
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1315
 
 
1316
 
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1317
 
 
1318
 
# connect when "disable_abort_on_error" caused "connection not found"
1319
 
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
1320
 
--disable_abort_on_error
1321
 
connect (con1,localhost,root,,);
1322
 
connection default;
1323
 
connection con1;
1324
 
disconnect con1;
1325
 
--enable_abort_on_error
1326
 
 
1327
 
# Test connect without a database
1328
 
connect (con2,localhost,root,,*NO-ONE*);
1329
 
--error ER_NO_DB_ERROR
1330
 
show tables;
1331
 
disconnect con2;
1332
 
connection default;
1333
 
 
1334
 
# ----------------------------------------------------------------------------
1335
 
# Test mysqltest arguments
1336
 
# ----------------------------------------------------------------------------
1337
 
 
1338
 
# -x <file_name>, use the file specified after -x as the test file
1339
 
--exec $DRIZZLE_TEST < $DRIZZLE_TEST_DIR/include/mysqltest-x.inc
1340
 
--exec $DRIZZLE_TEST -x $DRIZZLE_TEST_DIR/include/mysqltest-x.inc
1341
 
--exec $DRIZZLE_TEST --test_file=$DRIZZLE_TEST_DIR/include/mysqltest-x.inc
1342
 
# Fix Win paths
1343
 
--replace_result \\ /
1344
 
--error 1
1345
 
--exec $DRIZZLE_TEST -x non_existing_file.inc 2>&1
1346
 
 
1347
 
 
1348
 
# ----------------------------------------------------------------------------
1349
 
# TODO Test queries, especially their errormessages... so it's easy to debug 
1350
 
# new scripts and diagnose errors
1351
 
# ----------------------------------------------------------------------------
1352
 
 
1353
 
# ----------------------------------------------------------------------------
1354
 
# Test bug#12386
1355
 
# ----------------------------------------------------------------------------
1356
 
let $num= 2;
1357
 
while ($num)
1358
 
{
1359
 
   --error 1064
1360
 
   failing_statement;
1361
 
 
1362
 
   dec $num;
1363
 
}
1364
 
 
1365
 
SELECT 1 as a;
1366
 
 
1367
 
 
1368
 
#
1369
 
# Bug #10251: Identifiers containing quotes not handled correctly
1370
 
#
1371
 
select 1 as `a'b`, 2 as `a"b`;
1372
 
 
1373
 
# Test escaping of quotes
1374
 
select 'aaa\\','aa''a',"aa""a";
1375
 
 
1376
 
#
1377
 
# Check of include/show_msg.inc and include/show_msg80.inc
1378
 
#
1379
 
 
1380
 
# The message contains in most cases a string with the default character set
1381
 
let $message= Here comes a message;
1382
 
--source include/show_msg.inc
1383
 
 
1384
 
# The message could also contain a string with character set utf8
1385
 
let $message= `SELECT USER()`;
1386
 
--source include/show_msg.inc
1387
 
 
1388
 
# The message contains more then 80 characters on multiple lines
1389
 
# and is kept between double quotes.
1390
 
let $message= 
1391
 
"Here comes a very very long message that
1392
 
    - is longer then 80 characters    and
1393
 
    - consists of several lines";
1394
 
--source include/show_msg80.inc
1395
 
 
1396
 
# The message contains more then 80 characters on multiple lines
1397
 
# and uses the auxiliary character "." at the beginning of the message lines.
1398
 
let $message= . Here comes a very very long message that
1399
 
              .      - is longer then 80 characters    and
1400
 
              .      - consists of several lines;
1401
 
--source include/show_msg80.inc
1402
 
 
1403
 
#
1404
 
# Test --enable_parsing / disable_parsing
1405
 
#
1406
 
--disable_query_log
1407
 
--disable_parsing
1408
 
# The following will not enable query logging
1409
 
--enable_query_log
1410
 
select "this will not be executed";
1411
 
--enable_parsing
1412
 
select "this will be executed";
1413
 
--enable_query_log
1414
 
 
1415
 
#
1416
 
# Test zero length result file. Should not pass
1417
 
#
1418
 
--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result
1419
 
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
1420
 
--error 1
1421
 
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result  > /dev/null 2>&1
1422
 
 
1423
 
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
1424
 
--error 0,1
1425
 
remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject;
1426
 
--error 0,1
1427
 
remove_file $DRIZZLE_TEST_DIR/r/zero_length_file.reject;
1428
 
 
1429
 
#
1430
 
# Test that a test file that does not generate any output fails.
1431
 
#
1432
 
--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
1433
 
--error 1
1434
 
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql  2>&1
1435
 
 
1436
 
remove_file $MYSQLTEST_VARDIR/tmp/query.sql;
1437
 
 
1438
 
#
1439
 
# Test that mysqltest fails when there are no queries executed
1440
 
# but a result file exists
1441
 
# NOTE! This will never happen as long as it's not allowed to have
1442
 
# test files that produce no output
1443
 
#--exec echo "something" > $MYSQLTEST_VARDIR/tmp/result_file.result
1444
 
#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
1445
 
#--error 1
1446
 
#--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1
1447
 
 
1448
 
#
1449
 
# Bug #11731 mysqltest in multi-statement queries ignores errors in
1450
 
#            non-1st queries
1451
 
#
1452
 
 
1453
 
echo Failing multi statement query;
1454
 
# PS does not support multi statement
1455
 
--exec echo "--disable_ps_protocol"                    > $MYSQLTEST_VARDIR/tmp/bug11731.sql
1456
 
--exec echo "delimiter ||||;"                         >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1457
 
--exec echo "create table t1 (a int primary key);"    >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1458
 
--exec echo "insert into t1 values (1);"              >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1459
 
--exec echo "select 'select-me';"                     >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1460
 
--exec echo "insertz 'error query'||||"               >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1461
 
--exec echo "delimiter ;||||"                         >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1462
 
 
1463
 
--error 1
1464
 
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
1465
 
drop table t1;
1466
 
 
1467
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1468
 
--error 1
1469
 
--exec $DRIZZLE_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
1470
 
# The .out file should be non existent
1471
 
--exec test ! -s $MYSQLTEST_VARDIR/tmp/bug11731.out
1472
 
drop table t1;
1473
 
 
1474
 
 
1475
 
echo Multi statement using expected error;
1476
 
# PS does not support multi statement
1477
 
--exec echo "--disable_ps_protocol"                    > $MYSQLTEST_VARDIR/tmp/bug11731.sql
1478
 
--exec echo "delimiter ||||;"                         >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1479
 
--exec echo "--error 1064"                            >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1480
 
--exec echo "create table t1 (a int primary key);"    >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1481
 
--exec echo "insert into t1 values (1);"              >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1482
 
--exec echo "select 'select-me';"                     >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1483
 
--exec echo "insertz "error query"||||"               >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1484
 
--exec echo "delimiter ;||||"                         >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1485
 
 
1486
 
# These two should work since the error is expected
1487
 
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql  2>&1
1488
 
drop table t1;
1489
 
 
1490
 
--exec $DRIZZLE_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
1491
 
# The .out file should exist
1492
 
--exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out
1493
 
drop table t1;
1494
 
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
1495
 
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
1496
 
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
1497
 
 
1498
 
#
1499
 
# Bug#19890     mysqltest: "query" command is broken
1500
 
#
1501
 
 
1502
 
# It should be possible to use the command "query" to force mysqltest to
1503
 
# send the command to the server although it's a builtin mysqltest command.
1504
 
--error 1064
1505
 
query sleep;
1506
 
 
1507
 
--error 1064
1508
 
--query sleep
1509
 
 
1510
 
# Just an empty query command
1511
 
--error 1065
1512
 
query ;
1513
 
 
1514
 
# test for replace_regex
1515
 
--replace_regex /at/b/
1516
 
select "at" as col1, "c" as col2;
1517
 
 
1518
 
--replace_regex /at/b/i
1519
 
select "at" as col1, "AT" as col2, "c" as col3;
1520
 
 
1521
 
--replace_regex /a/b/ /ct/d/
1522
 
select "a" as col1, "ct" as col2; 
1523
 
 
1524
 
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
1525
 
select "strawberry","blueberry","potato";
1526
 
 
1527
 
--error 1
1528
 
--exec echo "--replace_regex a" | $DRIZZLE_TEST 2>&1
1529
 
--error 1
1530
 
--exec echo "--replace_regex a;" | $DRIZZLE_TEST 2>&1
1531
 
--error 1
1532
 
--exec echo "replace_regex a;" | $DRIZZLE_TEST 2>&1
1533
 
--error 1
1534
 
--exec echo "replace_regex a ;" | $DRIZZLE_TEST 2>&1
1535
 
--error 1
1536
 
--exec echo "replace_regex a b; echo OK;" | $DRIZZLE_TEST 2>&1
1537
 
--error 1
1538
 
--exec echo "--replace_regex /a b c" | $DRIZZLE_TEST 2>&1
1539
 
--error 1
1540
 
--exec echo "replace_regex /a /b c ;" | $DRIZZLE_TEST 2>&1 
1541
 
 
1542
 
# REQUIREMENT
1543
 
#   replace_regex should replace substitutions from left to right in output
1544
 
 
1545
 
create table t1 (a int, b int);
1546
 
insert into t1 values (1,3);
1547
 
insert into t1 values (2,4);
1548
 
--replace_regex /A/C/ /B/D/i /3/2/ /2/1/
1549
 
select * from t1;
1550
 
drop table t1;
1551
 
 
1552
 
# ----------------------------------------------------------------------------
1553
 
# test for remove_file
1554
 
# ----------------------------------------------------------------------------
1555
 
 
1556
 
--error 1
1557
 
--exec echo "remove_file ;" | $DRIZZLE_TEST 2>&1
1558
 
 
1559
 
--error 1
1560
 
remove_file non_existing_file;
1561
 
 
1562
 
# ----------------------------------------------------------------------------
1563
 
# test for write_file
1564
 
# ----------------------------------------------------------------------------
1565
 
--error 1
1566
 
--exec echo "write_file ;" | $DRIZZLE_TEST 2>&1
1567
 
 
1568
 
--error 1
1569
 
--exec echo "write_file filename ;" | $DRIZZLE_TEST 2>&1
1570
 
 
1571
 
# Comment out this test as it confuses cmd.exe with unmatched "
1572
 
#--error 1
1573
 
#--exec echo "write_file filename \";" | $DRIZZLE_TEST 2>&1
1574
 
 
1575
 
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1576
 
Content for test_file1
1577
 
EOF
1578
 
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1579
 
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1580
 
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1581
 
 
1582
 
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER;
1583
 
Content for test_file1 contains EOF
1584
 
END_DELIMITER
1585
 
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1586
 
 
1587
 
# write to already exisiting file
1588
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1589
 
--error 1
1590
 
--exec echo "write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;" | $DRIZZLE_TEST 2>&1
1591
 
 
1592
 
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1593
 
 
1594
 
# ----------------------------------------------------------------------------
1595
 
# test for append_file
1596
 
# ----------------------------------------------------------------------------
1597
 
 
1598
 
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1599
 
Content for test_file1
1600
 
EOF
1601
 
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1602
 
 
1603
 
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1604
 
Appended text
1605
 
EOF
1606
 
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1607
 
 
1608
 
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1609
 
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1610
 
Appended text on nonexisting file
1611
 
EOF
1612
 
 
1613
 
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1614
 
 
1615
 
# ----------------------------------------------------------------------------
1616
 
# test for cat_file
1617
 
# ----------------------------------------------------------------------------
1618
 
 
1619
 
--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp
1620
 
Some data
1621
 
for cat_file command
1622
 
of mysqltest
1623
 
EOF
1624
 
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1625
 
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1626
 
 
1627
 
--error 1
1628
 
--exec echo "cat_file non_existing_file;" | $DRIZZLE_TEST 2>&1
1629
 
 
1630
 
# ----------------------------------------------------------------------------
1631
 
# test for diff_files
1632
 
# ----------------------------------------------------------------------------
1633
 
 
1634
 
--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
1635
 
Some data
1636
 
for diff_file command
1637
 
of mysqltest
1638
 
EOF
1639
 
 
1640
 
--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
1641
 
Some data
1642
 
for diff_file command
1643
 
of mysqltest
1644
 
EOF
1645
 
 
1646
 
--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
1647
 
Some other data
1648
 
for diff_file command
1649
 
of mysqltest
1650
 
EOF
1651
 
 
1652
 
--write_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
1653
 
Some data
1654
 
for diff_file command
1655
 
of musqltest
1656
 
EOF
1657
 
 
1658
 
# Compare equal files
1659
 
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
1660
 
--diff_files $MYSQLTEST_VARDIR/tmp/diff2.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1661
 
 
1662
 
# Write the below commands to a intermediary file and execute them with
1663
 
# mysqltest in --exec, since the output will vary depending on what "diff"
1664
 
# is available it is sent to /dev/null
1665
 
--write_file $MYSQLTEST_VARDIR/tmp/diff.test
1666
 
# Compare files that differ in size
1667
 
--error 2
1668
 
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp
1669
 
--error 2
1670
 
--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1671
 
 
1672
 
# Compare files that differ only in content
1673
 
--error 1
1674
 
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp
1675
 
--error 1
1676
 
--diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1677
 
EOF
1678
 
 
1679
 
# Execute the above diffs, and send their output to /dev/null - only
1680
 
# interesting to see that it returns correct error codes
1681
 
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/diff.test > /dev/null 2>&1
1682
 
 
1683
 
 
1684
 
# Compare equal files, again...
1685
 
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
1686
 
 
1687
 
--remove_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
1688
 
--remove_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
1689
 
--remove_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
1690
 
--remove_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
1691
 
--remove_file $MYSQLTEST_VARDIR/tmp/diff.test
1692
 
 
1693
 
 
1694
 
# ----------------------------------------------------------------------------
1695
 
# test for file_exist
1696
 
# ----------------------------------------------------------------------------
1697
 
--error 1
1698
 
--exec echo "file_exists ;" | $DRIZZLE_TEST 2>&1
1699
 
 
1700
 
--error 0,1
1701
 
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1702
 
--error 1
1703
 
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1704
 
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1705
 
Content for test_file1
1706
 
EOF
1707
 
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1708
 
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1709
 
--error 1
1710
 
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1711
 
 
1712
 
 
1713
 
# ----------------------------------------------------------------------------
1714
 
# test for copy_file
1715
 
# ----------------------------------------------------------------------------
1716
 
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1717
 
file1
1718
 
EOF
1719
 
 
1720
 
copy_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
1721
 
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
1722
 
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1723
 
remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp;
1724
 
 
1725
 
--error 1
1726
 
--exec echo "copy_file ;" | $DRIZZLE_TEST 2>&1
1727
 
 
1728
 
--error 1
1729
 
--exec echo "copy_file from_file;" | $DRIZZLE_TEST 2>&1
1730
 
 
1731
 
# ----------------------------------------------------------------------------
1732
 
# test for chmod
1733
 
# ----------------------------------------------------------------------------
1734
 
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1735
 
file1
1736
 
EOF
1737
 
 
1738
 
chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1739
 
# The below write fails, but --error is not implemented
1740
 
# for write_file
1741
 
#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1742
 
#test should fail
1743
 
#EOF
1744
 
 
1745
 
chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1746
 
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1747
 
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1748
 
test2
1749
 
EOF
1750
 
 
1751
 
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1752
 
 
1753
 
--error 1
1754
 
--exec echo "chmod ;" | $DRIZZLE_TEST 2>&1
1755
 
 
1756
 
--error 1
1757
 
--exec echo "chmod 0 from_file;" | $DRIZZLE_TEST 2>&1
1758
 
 
1759
 
--error 1
1760
 
--exec echo "chmod 08 from_file;" | $DRIZZLE_TEST 2>&1
1761
 
 
1762
 
--error 1
1763
 
--exec echo "chmod from_file;" | $DRIZZLE_TEST 2>&1
1764
 
 
1765
 
--error 1
1766
 
--exec echo "chmod ABZD from_file;" | $DRIZZLE_TEST 2>&1
1767
 
 
1768
 
--error 1
1769
 
--exec echo "chmod 06789 from_file;" | $DRIZZLE_TEST 2>&1
1770
 
 
1771
 
 
1772
 
# ----------------------------------------------------------------------------
1773
 
# test for perl
1774
 
# ----------------------------------------------------------------------------
1775
 
--perl
1776
 
print "hello\n";
1777
 
EOF
1778
 
 
1779
 
--perl EOF
1780
 
print "hello\n";
1781
 
EOF
1782
 
 
1783
 
--perl DELIMITER
1784
 
print "hello\n";
1785
 
DELIMITER
1786
 
 
1787
 
--error 1
1788
 
--exec echo "perl TOO_LONG_DELIMITER ;" | $DRIZZLE_TEST 2>&1
1789
 
 
1790
 
perl;
1791
 
print "hello\n";
1792
 
EOF
1793
 
 
1794
 
perl;
1795
 
  # Print "hello"
1796
 
  print "hello\n";
1797
 
EOF
1798
 
 
1799
 
# ----------------------------------------------------------------------------
1800
 
# test for die
1801
 
# ----------------------------------------------------------------------------
1802
 
 
1803
 
--error 1
1804
 
--exec echo "die test of die;" | $DRIZZLE_TEST 2>&1
1805
 
 
1806
 
 
1807
 
# ----------------------------------------------------------------------------
1808
 
# test for exit
1809
 
# ----------------------------------------------------------------------------
1810
 
 
1811
 
--exec echo "echo Some output; exit; echo Not this;" | $DRIZZLE_TEST 2>&1
1812
 
 
1813
 
# ----------------------------------------------------------------------------
1814
 
# test for sorted_result
1815
 
# ----------------------------------------------------------------------------
1816
 
 
1817
 
create table t1( a int, b char(255), c timestamp);
1818
 
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05');
1819
 
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05');
1820
 
select * from t1;
1821
 
--sorted_result
1822
 
select * from t1;
1823
 
# Should not be sorted
1824
 
select * from t1;
1825
 
disable_result_log;
1826
 
sorted_result;
1827
 
select * from t1;
1828
 
enable_result_log;
1829
 
--sorted_result
1830
 
select '';
1831
 
sorted_result;
1832
 
select "h";
1833
 
--sorted_result
1834
 
select "he";
1835
 
--sorted_result
1836
 
select "hep";
1837
 
--sorted_result
1838
 
select "hepp";
1839
 
 
1840
 
drop table t1;
1841
 
 
1842
 
# 1. Assignment of result set sorting
1843
 
sorted_result;
1844
 
 SELECT 2 as "my_col"
1845
 
UNION
1846
 
SELECT 1;
1847
 
#
1848
 
--sorted_result
1849
 
SELECT 2 as "my_col" UNION SELECT 1;
1850
 
--sorted_result
1851
 
SELECT 2 as "my_col"
1852
 
UNION
1853
 
SELECT 1;
1854
 
 
1855
 
# 2. Ensure that the table header will be not sorted into the result
1856
 
--sorted_result
1857
 
SELECT '2' as "3"
1858
 
UNION
1859
 
SELECT '1';
1860
 
 
1861
 
# 3. Ensure that an empty result set does not cause problems
1862
 
CREATE TABLE t1( a CHAR);
1863
 
--sorted_result
1864
 
SELECT * FROM t1;
1865
 
DROP TABLE t1;
1866
 
 
1867
 
# 4. Ensure that NULL values within the result set do not cause problems
1868
 
SELECT NULL as "my_col1",2 AS "my_col2"
1869
 
UNION
1870
 
SELECT NULL,1;
1871
 
--sorted_result
1872
 
SELECT NULL as "my_col1",2 AS "my_col2"
1873
 
UNION
1874
 
SELECT NULL,1;
1875
 
#
1876
 
SELECT 2 as "my_col1",NULL AS "my_col2"
1877
 
UNION
1878
 
SELECT 1,NULL;
1879
 
--sorted_result
1880
 
SELECT 2 as "my_col1",NULL AS "my_col2"
1881
 
UNION
1882
 
SELECT 1,NULL;
1883
 
 
1884
 
# 5. "sorted_result" changes nothing when applied to a non query statement.
1885
 
sorted_result;
1886
 
 SET @a = 17;
1887
 
#
1888
 
# 6. Show that "sorted_result;" before the "SET @a = 17;" above does not affect
1889
 
# the now following query.
1890
 
SELECT 2 as "my_col"
1891
 
UNION
1892
 
SELECT 1;
1893
 
 
1894
 
# 7. Ensure that "sorted_result" in combination with $variables works
1895
 
let $my_stmt=SELECT 2 as "my_col"
1896
 
UNION
1897
 
SELECT 1;
1898
 
--sorted_result
1899
 
eval $my_stmt;
1900
 
 
1901
 
# 8. Ensure that "sorted_result " does not change the semantics of
1902
 
#    "--error ...." or the protocol output after such an expected failure
1903
 
--sorted_result
1904
 
--error 1146
1905
 
SELECT '2' as "my_col1",2 as "my_col2"
1906
 
UNION
1907
 
SELECT '1',1 from t2;
1908
 
 
1909
 
# 9. Ensure that several result formatting options including "sorted_result" 
1910
 
#    - have all an effect
1911
 
#    - "--sorted_result" does not need to be direct before the statement
1912
 
#    - Row sorting is applied after modification of the column content
1913
 
--sorted_result
1914
 
--replace_column 1 #
1915
 
SELECT '1' as "my_col1",2 as "my_col2"
1916
 
UNION
1917
 
SELECT '2',1;
1918
 
 
1919
 
# 10. Ensure that at least 1024 rows within a result set do not cause problems
1920
 
#
1921
 
CREATE TABLE t1 (f1 INT);
1922
 
INSERT INTO t1 SET f1 = 1024;
1923
 
INSERT INTO t1 SELECT f1 - 1 FROM t1;
1924
 
INSERT INTO t1 SELECT f1 - 2 FROM t1;
1925
 
INSERT INTO t1 SELECT f1 - 4 FROM t1;
1926
 
INSERT INTO t1 SELECT f1 - 8 FROM t1;
1927
 
INSERT INTO t1 SELECT f1 - 16 FROM t1;
1928
 
INSERT INTO t1 SELECT f1 - 32 FROM t1;
1929
 
INSERT INTO t1 SELECT f1 - 64 FROM t1;
1930
 
INSERT INTO t1 SELECT f1 - 128 FROM t1;
1931
 
INSERT INTO t1 SELECT f1 - 256 FROM t1;
1932
 
INSERT INTO t1 SELECT f1 - 512 FROM t1;
1933
 
--disable_result_log
1934
 
--sorted_result
1935
 
SELECT * FROM t1;
1936
 
--enable_result_log
1937
 
DROP TABLE t1;
1938
 
# ----------------------------------------------------------------------------
1939
 
# Some coverage tests
1940
 
# ----------------------------------------------------------------------------
1941
 
 
1942
 
--disable_query_log
1943
 
--exec $DRIZZLE_TEST --help 2>&1 > /dev/null
1944
 
--exec $DRIZZLE_TEST --version 2>&1 > /dev/null
1945
 
--enable_query_log
1946
 
--disable_abort_on_error
1947
 
--error 1
1948
 
--exec $DRIZZLE_TEST a b c 2>&1 > /dev/null
1949
 
--enable_abort_on_error
1950
 
--enable_query_log
1951
 
 
1952
 
# ----------------------------------------------------------------------------
1953
 
# test for query_get_value
1954
 
# ----------------------------------------------------------------------------
1955
 
 
1956
 
CREATE TABLE t1(
1957
 
 a int, b varchar(255), c datetime
1958
 
);
1959
 
SHOW COLUMNS FROM t1;
1960
 
 
1961
 
#------------ Positive tests ------------
1962
 
# 1. constant parameters
1963
 
#    value is simple string without spaces
1964
 
let $value= query_get_value(SHOW COLUMNS FROM t1, Type, 1);
1965
 
--echo statement=SHOW COLUMNS FROM t1 row_number=1, column_name="Type", Value=$value
1966
 
let $value= query_get_value("SHOW COLUMNS FROM t1", Type, 1);
1967
 
--echo statement="SHOW COLUMNS FROM t1" row_number=1, column_name="Type", Value=$value
1968
 
#
1969
 
# 2. $variables as parameters
1970
 
#    value IS NULL
1971
 
let $my_show= SHOW COLUMNS FROM t1;
1972
 
let $column_name= Default;
1973
 
let $row_number= 1;
1974
 
let $value= query_get_value($my_show, $column_name, $row_number);
1975
 
--echo statement=$my_show row_number=$row_number, column_name=$column_name, Value=$value
1976
 
#
1977
 
# 3. result set of a SELECT (not recommended, because projection and
1978
 
#         selection could be done much better by pure SELECT functionality)
1979
 
#    value is string with space in the middle
1980
 
let $value= query_get_value(SELECT 'A B' AS "MyColumn", MyColumn, 1);
1981
 
--echo value= ->$value<-
1982
 
#
1983
 
# 4. column name with space
1984
 
let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1);
1985
 
--echo value= $value
1986
 
#
1987
 
#------------ Negative tests ------------
1988
 
# 5. Incomplete statement including missing parameters
1989
 
# 5.1 incomplete statement
1990
 
--error 1
1991
 
--exec echo "let \$value= query_get_value(SHOW;" | $DRIZZLE_TEST 2>&1
1992
 
# 5.2 missing query
1993
 
--error 1
1994
 
--exec echo "let \$value= query_get_value;" | $DRIZZLE_TEST 2>&1
1995
 
# 5.3 missing column name
1996
 
--error 1
1997
 
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1);" | $DRIZZLE_TEST 2>&1
1998
 
# 5.4 missing row number
1999
 
--error 1
2000
 
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field);" | $DRIZZLE_TEST 2>&1
2001
 
#
2002
 
# 6. Somehow "wrong" value of parameters
2003
 
# 6.1 row parameter
2004
 
# 6.1.1 non sense number 0
2005
 
let $value= initialized;
2006
 
let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 0);
2007
 
--echo value= $value
2008
 
# 6.1.2 after the last row
2009
 
let $value= initialized;
2010
 
let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 10);
2011
 
--echo value= $value
2012
 
# 6.1.3 invalid row number
2013
 
--error 1
2014
 
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field, notnumber);" | $DRIZZLE_TEST 2>&1
2015
 
# 6.2 column name parameter, name of not existing column
2016
 
--error 1
2017
 
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, column_not_exists, 1);" | $DRIZZLE_TEST 2>&1
2018
 
# 6.3. statement which never gives a result set
2019
 
--error 1
2020
 
--exec echo "let \$value= query_get_value(SET @A = 1, Field, 1);" | $DRIZZLE_TEST 2>&1
2021
 
# 6.4. statement contains a ","
2022
 
#      Note: There is no need to improve this, because we need query_get_value
2023
 
#            for SHOW commands only.
2024
 
--error 1
2025
 
--exec echo "let \$value= query_get_value(SELECT 1 AS "A", 1 AS "B", 1);" | $DRIZZLE_TEST 2>&1
2026
 
#
2027
 
# 7. empty result set
2028
 
let $value= initialized;
2029
 
let $value= query_get_value(SELECT a FROM t1, a, 1);
2030
 
--echo value= $value
2031
 
#
2032
 
# 9. failing statement
2033
 
--error 1
2034
 
--exec echo "let \$value= query_get_value(SHOW COLNS FROM t1, Field, 1);" | $DRIZZLE_TEST 2>&1
2035
 
#
2036
 
# 10. Artificial example how to process a complete SHOW result set:
2037
 
let $show_statement= SHOW COLUMNS FROM t1;
2038
 
let $rowno= 1;
2039
 
let $run=1;
2040
 
let $count= 0;
2041
 
--echo
2042
 
--echo Field Type Null Key Default Extra
2043
 
while ($run)
2044
 
{
2045
 
   let $Field=   query_get_value($show_statement, Field,   $rowno);
2046
 
   if (`SELECT '$Field' = 'No such row'`)
2047
 
   {
2048
 
      let $run= 0;
2049
 
   }
2050
 
   if (`SELECT '$Field' <> 'No such row'`)
2051
 
   {
2052
 
      let $Type=    query_get_value($show_statement, Type,    $rowno);
2053
 
      let $Null=    query_get_value($show_statement, Null,    $rowno);
2054
 
      if (`SELECT '$Null' = 'YES'`)
2055
 
      {
2056
 
         inc $count;
2057
 
      }
2058
 
      let $Key=     query_get_value($show_statement, Key,     $rowno);
2059
 
      let $Default= query_get_value($show_statement, Default, $rowno);
2060
 
      let $Extra=   query_get_value($show_statement, Extra,   $rowno);
2061
 
      --echo $Field $Type $Null ->$Key<- $Default $Extra
2062
 
      inc $rowno;
2063
 
   }
2064
 
}
2065
 
--echo
2066
 
--echo Number of columns with Default NULL: $count
2067
 
--echo
2068
 
eval $show_statement;
2069
 
 
2070
 
drop table t1;
2071
 
 
2072
 
# ----------------------------------------------------------------------------
2073
 
# Test change_user command
2074
 
# ----------------------------------------------------------------------------
2075
 
 
2076
 
--error 1
2077
 
--exec echo "--change_user root,,inexistent" | $DRIZZLE_TEST 2>&1
2078
 
 
2079
 
--error 1
2080
 
--exec echo "--change_user inexistent,,test" | $DRIZZLE_TEST 2>&1
2081
 
 
2082
 
--error 1
2083
 
--exec echo "--change_user root,inexistent,test" | $DRIZZLE_TEST 2>&1
2084
 
 
2085
 
--change_user
2086
 
--change_user root
2087
 
--change_user root,,
2088
 
--change_user root,,test
2089
 
 
2090
 
# ----------------------------------------------------------------------------
2091
 
# Test mkdir and rmdir command
2092
 
# ----------------------------------------------------------------------------
2093
 
 
2094
 
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2095
 
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2096
 
 
2097
 
# Directory already exist
2098
 
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2099
 
--error 1
2100
 
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2101
 
 
2102
 
# Remove dir with file inside
2103
 
write_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
2104
 
hello
2105
 
EOF
2106
 
--error 1
2107
 
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2108
 
 
2109
 
remove_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
2110
 
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2111
 
 
2112
 
 
2113
 
--echo End of tests
2114