~drizzle-trunk/drizzle/development

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