2
# This test uses chmod, can't be run with root permissions
4
# ============================================================================
6
# Test of mysqltest itself
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
15
# Command: "select * from t1"
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>
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
26
# ============================================================================
28
# ----------------------------------------------------------------------------
29
# $mysql_errno contains the return code of the last command
31
# ----------------------------------------------------------------------------
32
# get $mysql_errno before the first statement
33
# $mysql_errno should be -1
34
eval select $mysql_errno as "before_use_test" ;
37
# ----------------------------------------------------------------------------
38
# Positive case(statement)
39
# ----------------------------------------------------------------------------
41
select otto from (select 1 as otto) as t1;
42
# expectation = response
44
select otto from (select 1 as otto) as t1;
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
# ----------------------------------------------------------------------------
53
# expectation <> response
55
#select friedrich from (select 1 as otto) as t1
57
--exec echo "select friedrich from (select 1 as otto) as t1;" | $DRIZZLE_TEST 2>&1
59
# expectation = response
61
select friedrich from (select 1 as otto) as t1;
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;
70
# ----------------------------------------------------------------------------
71
# Tests for the new feature - SQLSTATE error code matching
72
# Positive case(statement)
73
# ----------------------------------------------------------------------------
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;
80
select otto from (select 1 as otto) as t1;
82
# expectation <> response
83
#!S42S22 select otto from (select 1 as otto) as t1;
85
#select otto from (select 1 as otto) as t1;
87
--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $DRIZZLE_TEST 2>&1
91
# ----------------------------------------------------------------------------
92
# Negative case(statement)
93
# ----------------------------------------------------------------------------
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;
99
select friedrich from (select 1 as otto) as t1;
101
# expectation !=response
102
#!S00000 select friedrich from (select 1 as otto) as t1;
104
#select friedrich from (select 1 as otto) as t1;
106
--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $DRIZZLE_TEST 2>&1
108
# ----------------------------------------------------------------------------
109
# test cases for $mysql_errno
111
# $mysql_errno is a builtin variable of mysqltest and contains the return code
112
# of the last command sent to the server.
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.
118
# ----------------------------------------------------------------------------
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" ;
126
#----------------------------------------------------------------------------
127
# check mysql_errno = 1064 after statement with wrong syntax
128
# ----------------------------------------------------------------------------
131
eval select $mysql_errno as "after_wrong_syntax_errno" ;
133
# ----------------------------------------------------------------------------
134
# check if let $my_var= 'abc' ; affects $mysql_errno
135
# ----------------------------------------------------------------------------
139
eval select $mysql_errno as "after_let_var_equal_value" ;
141
# ----------------------------------------------------------------------------
142
# check if set @my_var= 'abc' ; affects $mysql_errno
143
# ----------------------------------------------------------------------------
147
eval select $mysql_errno as "after_set_var_equal_value" ;
149
# ----------------------------------------------------------------------------
150
# check if the setting of --disable-warnings itself affects $mysql_errno
151
# (May be --<whatever> modifies $mysql_errno.)
152
# ----------------------------------------------------------------------------
156
eval select $mysql_errno as "after_disable_warnings_command" ;
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 ;
166
drop table if exists t1 ;
167
eval select $mysql_errno as "after_disable_warnings" ;
170
# ----------------------------------------------------------------------------
171
# check if masked errors affect $mysql_errno
172
# ----------------------------------------------------------------------------
177
eval select $mysql_errno as "after_minus_masked" ;
182
eval select $mysql_errno as "after_!_masked" ;
184
# ----------------------------------------------------------------------------
185
# Will manipulations of $mysql_errno be possible and visible ?
186
# ----------------------------------------------------------------------------
189
let $mysql_errno= -1;
190
eval select $mysql_errno as "after_let_errno_equal_value" ;
192
# ----------------------------------------------------------------------------
193
# How affect actions on prepared statements $mysql_errno ?
194
# ----------------------------------------------------------------------------
199
prepare stmt from "select 3 from t1" ;
200
eval select $mysql_errno as "after_failing_prepare" ;
201
create table t1 ( f1 char(10));
206
prepare stmt from "select 3 from t1" ;
207
eval select $mysql_errno as "after_successful_prepare" ;
213
eval select $mysql_errno as "after_successful_execute" ;
215
# failing execute (table has been dropped)
221
eval select $mysql_errno as "after_failing_execute" ;
223
# failing execute (unknown statement)
228
eval select $mysql_errno as "after_failing_execute" ;
230
# successful deallocate
233
deallocate prepare stmt;
234
eval select $mysql_errno as "after_successful_deallocate" ;
236
# failing deallocate ( statement handle does not exist )
240
deallocate prepare __stmt_;
241
eval select $mysql_errno as "after_failing_deallocate" ;
244
# ----------------------------------------------------------------------------
245
# test cases for "--disable_abort_on_error"
247
# "--disable_abort_on_error" switches off the abort of mysqltest
248
# after "unmasked" failing statements.
250
# The default is "--enable_abort_on_error".
253
# --error <error number> and --error <error number>
254
# in the line before the failing statement.
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
# ----------------------------------------------------------------------------
261
# ----------------------------------------------------------------------------
262
# Switch off the abort on error and check the effect on $mysql_errno
263
# ----------------------------------------------------------------------------
266
--disable_abort_on_error
267
eval select $mysql_errno as "after_--disable_abort_on_error" ;
269
# ----------------------------------------------------------------------------
270
# "unmasked" failing statement should not cause an abort
271
# ----------------------------------------------------------------------------
274
# ----------------------------------------------------------------------------
275
# masked failing statements
276
# ----------------------------------------------------------------------------
277
# expected error = response
282
eval select $mysql_errno as "after_!errno_masked_error" ;
283
# expected error <> response
289
--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $DRIZZLE_TEST 2>&1
291
# ----------------------------------------------------------------------------
292
# Switch the abort on error on and check the effect on $mysql_errno
293
# ----------------------------------------------------------------------------
296
--enable_abort_on_error
297
eval select $mysql_errno as "after_--enable_abort_on_error" ;
299
# ----------------------------------------------------------------------------
300
# masked failing statements
301
# ----------------------------------------------------------------------------
302
# expected error = response
306
# ----------------------------------------------------------------------------
307
# check that the old default behaviour is not changed
308
# Please remove the '#' to get the abort on error
309
# ----------------------------------------------------------------------------
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
319
# ----------------------------------------------------------------------------
321
# ----------------------------------------------------------------------------
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
330
# ----------------------------------------------------------------------------
331
# Test comments with embedded command
332
# ----------------------------------------------------------------------------
336
--echo # MySQL: -- The
338
# ----------------------------------------------------------------------------
339
# Test detect end of line "junk"
340
# Most likely caused by a missing delimiter
341
# ----------------------------------------------------------------------------
343
# Too many parameters to function
345
--exec echo "sleep 5 6;" | $DRIZZLE_TEST 2>&1
347
# Too many parameters to function
349
--exec echo "--sleep 5 6" | $DRIZZLE_TEST 2>&1
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
361
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
362
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
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
373
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
374
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
377
# Missing delimiter until "disable_query_log"
379
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
388
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
389
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
392
# Missing delimiter until "disable_query_log"
394
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
404
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
405
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
408
# Missing delimiter until eof
410
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
421
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
422
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
425
# Missing delimiter until eof
427
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
428
disconnect default # comment
435
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
437
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
443
--exec echo "--sleep 4;" | $DRIZZLE_TEST 2>&1
445
--exec echo "--disable_query_log;" | $DRIZZLE_TEST 2>&1
448
# Allow trailing # comment
449
--sleep 1 # Wait for insert delayed to be executed.
450
--sleep 1 # Wait for insert delayed to be executed.
452
# ----------------------------------------------------------------------------
454
# ----------------------------------------------------------------------------
458
--exec echo "error;" | $DRIZZLE_TEST 2>&1
460
--exec echo "--error" | $DRIZZLE_TEST 2>&1
462
# First char must be uppercase 'S' or 'E' or [0-9]
464
--exec echo "--error s99999" | $DRIZZLE_TEST 2>&1
466
--exec echo "--error e99999" | $DRIZZLE_TEST 2>&1
468
--exec echo "--error 9eeeee" | $DRIZZLE_TEST 2>&1
470
--exec echo "--error 1sssss" | $DRIZZLE_TEST 2>&1
472
# First char 'S' but too long
474
--exec echo "--error S999999" | $DRIZZLE_TEST 2>&1
476
# First char 'S' but lowercase char found
478
--exec echo "--error S99a99" | $DRIZZLE_TEST 2>&1
480
# First char 'S' but too short
482
--exec echo "--error S9999" | $DRIZZLE_TEST 2>&1
484
# First char 'E' but not found in error array
486
--exec echo "--error E9999" | $DRIZZLE_TEST 2>&1
488
# First char [0-9] but contains chars
490
--exec echo "--error 999e9" | $DRIZZLE_TEST 2>&1
492
--exec echo "--error 9b" | $DRIZZLE_TEST 2>&1
494
# Multiple errorcodes separated by ','
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
503
--error 9,S00000,9,9,10,11,12
509
# Too many errorcodes specified
511
--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $DRIZZLE_TEST 2>&1
514
# ----------------------------------------------------------------------------
516
# ----------------------------------------------------------------------------
520
echo MySQL: The world''s most popular open source database;
521
echo "MySQL: The world's most popular open source database";
523
echo MySQL: The world''s
527
echo # MySQL: The world''s
531
echo - MySQL: The world''s
535
echo - MySQL: The world''s
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;
550
# Illegal use of echo
553
#--exec echo "echo \$;" | $DRIZZLE_TEST 2>&1
556
# ----------------------------------------------------------------------------
558
# ----------------------------------------------------------------------------
560
# Illegal use of exec
562
--exec echo "--exec false" | $DRIZZLE_TEST 2>&1
565
--exec echo "--exec " | $DRIZZLE_TEST 2>&1
567
# ----------------------------------------------------------------------------
569
# ----------------------------------------------------------------------------
574
let $message="MySQL";
577
let $message= MySQL: The
583
let $message= # MySQL: The
589
let $message= -- MySQL: The
592
let $message= # MySQL: The
616
let $where=a long variable content;
622
let $where3=a long $where variable content;
625
let $where3=a long \\\$where variable content;
628
let $novar1= $novar2;
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;
642
# Test illegal uses of let
645
--exec echo "let ;" | $DRIZZLE_TEST 2>&1
648
--exec echo "let \$=hi;" | $DRIZZLE_TEST 2>&1
651
--exec echo "let \$1 hi;" | $DRIZZLE_TEST 2>&1
654
--exec echo "let \$m hi;" | $DRIZZLE_TEST 2>&1
657
--exec echo "let \$hi;" | $DRIZZLE_TEST 2>&1
660
--exec echo "let \$ hi;" | $DRIZZLE_TEST 2>&1
663
--exec echo "let =hi;" | $DRIZZLE_TEST 2>&1
666
--exec echo "let hi;" | $DRIZZLE_TEST 2>&1
668
# More advanced test for bug#17280
670
--echo # Execute: --echo # <whatever> success: \$success
671
--echo # <whatever> success: $success
672
--echo # Execute: echo # <whatever> success: \$success ;
673
echo # <whatever> success: $success ;
675
--echo # The next two variants work fine and expand the content of \$success
676
--echo # Execute: --echo \$success
678
--echo # Execute: echo \$success ;
682
# ----------------------------------------------------------------------------
683
# Test to assign let from variable
684
# let $<var_name>=$<var_name>;
685
# ----------------------------------------------------------------------------
687
--echo # Check if let \$B = \$A is an assignment per value.
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
700
--echo # Content of \$A is: $A
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
707
--echo let \$B = changed value of B;
708
let $B = changed value of B;
709
--echo # Content of \$A is: $A
711
# ----------------------------------------------------------------------------
712
# Test let from query with $variable
713
# let $<var_name>=`<query with $variable>`;
714
# ----------------------------------------------------------------------------
716
let $var1=content of variable 1;
717
let $var2= `select "$var1"`;
718
let $var3= `select concat("$var1", " ", "$var2")`;
721
if (`select length("$var3") > 0`)
723
echo length of var3 is longer than 0;
726
# ----------------------------------------------------------------------------
727
# Test to assign let from query
728
# let $<var_name>=`<query>`;
729
# ----------------------------------------------------------------------------
731
let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`;
735
let $var2= `select 2 as "Column num 2"`;
739
let $var2= `select 2 as "Column num 2"`;
742
echo var3 two columns with same name;
743
let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`;
746
echo var4 from query that returns NULL;
747
let $var4= `select NULL`;
749
echo var5 from query that returns no row;
750
let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`;
752
echo failing query in let;
753
--write_file $MYSQLTEST_VARDIR/tmp/let.sql
754
let $var2= `failing query`;
759
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
761
remove_file $MYSQLTEST_VARDIR/tmp/let.sql;
764
# ----------------------------------------------------------------------------
765
# Test source command
766
# ----------------------------------------------------------------------------
768
# Test illegal uses of source
771
--exec echo "source ;" | $DRIZZLE_TEST 2>&1
774
--replace_result \\ /
775
# Source a nonexisting file
777
--exec echo "source non_existingFile;" | $DRIZZLE_TEST 2>&1
780
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql
781
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
783
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $DRIZZLE_TEST 2>&1
784
remove_file $MYSQLTEST_VARDIR/tmp/recursive.sql;
786
# Source a file with error
787
--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql
788
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
790
--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $DRIZZLE_TEST 2>&1
792
remove_file $MYSQLTEST_VARDIR/tmp/error.sql;
794
# Test execution of source in a while loop
795
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
796
echo here is the sourced script;
799
let $outer= 2; # Number of outer loops
802
eval SELECT '$outer = outer loop variable after while' AS "";
804
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
806
eval SELECT '$outer = outer loop variable before dec' AS "";
808
eval SELECT '$outer = outer loop variable after dec' AS "";
811
let $outer= 2; # Number of outer loops
814
eval SELECT '$outer = outer loop variable after while' AS "";
816
echo here is the sourced script;
818
eval SELECT '$outer = outer loop variable before dec' AS "";
820
eval SELECT '$outer = outer loop variable after dec' AS "";
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
831
SELECT 'In loop' AS "";
832
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
835
--enable_abort_on_error
838
# Test source $variable/<filename>
839
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
841
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
843
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
848
source $MYSQLTEST_VARDIR/tmp/$x.inc;
850
let $x= $MYSQLTEST_VARDIR;
851
source $x/tmp/sourced.inc;
853
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
856
# ----------------------------------------------------------------------------
858
# ----------------------------------------------------------------------------
866
--exec echo "sleep ;" | $DRIZZLE_TEST 2>&1
868
--exec echo "real_sleep ;" | $DRIZZLE_TEST 2>&1
872
--exec echo "sleep abc;" | $DRIZZLE_TEST 2>&1
874
--exec echo "real_sleep abc;" | $DRIZZLE_TEST 2>&1
876
# ----------------------------------------------------------------------------
878
# ----------------------------------------------------------------------------
893
--exec echo "inc;" | $DRIZZLE_TEST 2>&1
895
--exec echo "inc i;" | $DRIZZLE_TEST 2>&1
897
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $DRIZZLE_TEST 2>&1
899
inc $i; inc $i; inc $i; --echo $i
903
# ----------------------------------------------------------------------------
905
# ----------------------------------------------------------------------------
921
--exec echo "dec;" | $DRIZZLE_TEST 2>&1
923
--exec echo "dec i;" | $DRIZZLE_TEST 2>&1
925
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $DRIZZLE_TEST 2>&1
928
# ----------------------------------------------------------------------------
930
# ----------------------------------------------------------------------------
931
#system ls > /dev/null;
932
system echo "hej" > /dev/null;
933
#--system ls > /dev/null
934
--system echo "hej" > /dev/null;
937
--exec echo "system;" | $DRIZZLE_TEST 2>&1
939
--exec echo "system $NONEXISTSINFVAREABLI;" | $DRIZZLE_TEST 2>&1
941
--exec echo "system false;" | $DRIZZLE_TEST 2>&1
943
--disable_abort_on_error
944
system NonExistsinfComamdn 2> /dev/null;
945
--enable_abort_on_error
948
# ----------------------------------------------------------------------------
950
# ----------------------------------------------------------------------------
962
# ----------------------------------------------------------------------------
964
# ----------------------------------------------------------------------------
969
echo Counter is greater than 0, (counter=10);
973
echo Counter is not 0, (counter=10);
978
echo Counter is greater than 0, (counter=0);
982
echo Counter is not 0, (counter=0);
985
# ----------------------------------------------------------------------------
986
# Test while, { and }
987
# ----------------------------------------------------------------------------
996
#let $i=1;while ($i){echo $i;dec $i;}
1001
echo Testing while with not;
1005
# Exceed max nesting level
1006
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1146
--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1148
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $DRIZZLE_TEST 2>&1
1149
--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1151
--exec echo "while \$i;" | $DRIZZLE_TEST 2>&1
1153
--exec echo "while (\$i;" | $DRIZZLE_TEST 2>&1
1155
--exec echo "let \$i=1; while (\$i) dec \$i;" | $DRIZZLE_TEST 2>&1
1157
--exec echo "};" | $DRIZZLE_TEST 2>&1
1159
--exec echo "end;" | $DRIZZLE_TEST 2>&1
1161
--exec echo "{;" | $DRIZZLE_TEST 2>&1
1163
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1168
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1169
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1171
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1176
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1177
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1179
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1184
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1186
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1188
# ----------------------------------------------------------------------------
1189
# Test error messages returned from comments starting with a command
1190
# ----------------------------------------------------------------------------
1192
--exec echo "--if the other server is down" | $DRIZZLE_TEST 2>&1
1195
--exec echo "-- end when ..." | $DRIZZLE_TEST 2>&1
1197
# ----------------------------------------------------------------------------
1199
# ----------------------------------------------------------------------------
1200
--replace_result a b
1201
select "a" as col1, "c" as col2;
1203
--replace_result a b c d
1204
select "a" as col1, "c" as col2;
1207
--exec echo "--replace_result a" | $DRIZZLE_TEST 2>&1
1209
--exec echo "--replace_result a;" | $DRIZZLE_TEST 2>&1
1211
--exec echo "replace_result a;" | $DRIZZLE_TEST 2>&1
1213
--exec echo "replace_result a ;" | $DRIZZLE_TEST 2>&1
1214
--exec echo "replace_result a b; echo OK;" | $DRIZZLE_TEST 2>&1
1216
--exec echo "--replace_result a b c" | $DRIZZLE_TEST 2>&1
1218
--exec echo "replace_result a b c ;" | $DRIZZLE_TEST 2>&1
1221
--replace_column 1 b
1222
select "a" as col1, "c" as col2;
1224
--replace_column 1 b 2 d
1225
select "a" as col1, "c" as col2;
1228
--exec echo "--replace_column a" | $DRIZZLE_TEST 2>&1
1231
--exec echo "--replace_column 1" | $DRIZZLE_TEST 2>&1
1234
--exec echo "--replace_column a b" | $DRIZZLE_TEST 2>&1
1236
--exec echo "--replace_column a 1" | $DRIZZLE_TEST 2>&1
1238
--exec echo "--replace_column 1 b c " | $DRIZZLE_TEST 2>&1
1241
# ----------------------------------------------------------------------------
1242
# Test sync_with_master
1243
# ----------------------------------------------------------------------------
1245
--exec echo "sync_with_master 10!;" | $DRIZZLE_TEST 2>&1
1247
--exec echo "sync_with_master a;" | $DRIZZLE_TEST 2>&1
1249
# ----------------------------------------------------------------------------
1251
# ----------------------------------------------------------------------------
1254
--exec echo "connect;" | $DRIZZLE_TEST 2>&1
1256
--exec echo "connect ();" | $DRIZZLE_TEST 2>&1
1258
--exec echo "connect (con2);" | $DRIZZLE_TEST 2>&1
1260
--exec echo "connect (con2,);" | $DRIZZLE_TEST 2>&1
1262
--exec echo "connect (con2,localhost,root,,illegal_db);" | $DRIZZLE_TEST 2>&1
1264
--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $DRIZZLE_TEST 2>&1
1266
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $DRIZZLE_TEST 2>&1
1268
# Repeat connect/disconnect
1269
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1273
connect (test_con1,localhost,root,,);
1274
disconnect test_con1;
1278
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $DRIZZLE_TEST 2>&1
1279
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1281
# Repeat connect/disconnect
1282
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1286
connect (test_con1,localhost,root,,);
1287
disconnect test_con1;
1291
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1293
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1294
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
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;
1302
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1304
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1305
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
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,,);
1312
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1314
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1316
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
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,,);
1325
--enable_abort_on_error
1327
# Test connect without a database
1328
connect (con2,localhost,root,,*NO-ONE*);
1329
--error ER_NO_DB_ERROR
1334
# ----------------------------------------------------------------------------
1335
# Test mysqltest arguments
1336
# ----------------------------------------------------------------------------
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
1343
--replace_result \\ /
1345
--exec $DRIZZLE_TEST -x non_existing_file.inc 2>&1
1348
# ----------------------------------------------------------------------------
1349
# TODO Test queries, especially their errormessages... so it's easy to debug
1350
# new scripts and diagnose errors
1351
# ----------------------------------------------------------------------------
1353
# ----------------------------------------------------------------------------
1355
# ----------------------------------------------------------------------------
1369
# Bug #10251: Identifiers containing quotes not handled correctly
1371
select 1 as `a'b`, 2 as `a"b`;
1373
# Test escaping of quotes
1374
select 'aaa\\','aa''a',"aa""a";
1377
# Check of include/show_msg.inc and include/show_msg80.inc
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
1384
# The message could also contain a string with character set utf8
1385
let $message= `SELECT USER()`;
1386
--source include/show_msg.inc
1388
# The message contains more then 80 characters on multiple lines
1389
# and is kept between double quotes.
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
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
1404
# Test --enable_parsing / disable_parsing
1408
# The following will not enable query logging
1410
select "this will not be executed";
1412
select "this will be executed";
1416
# Test zero length result file. Should not pass
1418
--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result
1419
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
1421
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
1423
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
1425
remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject;
1427
remove_file $DRIZZLE_TEST_DIR/r/zero_length_file.reject;
1430
# Test that a test file that does not generate any output fails.
1432
--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
1434
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1
1436
remove_file $MYSQLTEST_VARDIR/tmp/query.sql;
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
1446
#--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1
1449
# Bug #11731 mysqltest in multi-statement queries ignores errors in
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
1464
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
1467
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
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
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
1486
# These two should work since the error is expected
1487
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
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
1494
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
1495
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
1496
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
1499
# Bug#19890 mysqltest: "query" command is broken
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.
1510
# Just an empty query command
1514
# test for replace_regex
1515
--replace_regex /at/b/
1516
select "at" as col1, "c" as col2;
1518
--replace_regex /at/b/i
1519
select "at" as col1, "AT" as col2, "c" as col3;
1521
--replace_regex /a/b/ /ct/d/
1522
select "a" as col1, "ct" as col2;
1524
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
1525
select "strawberry","blueberry","potato";
1528
--exec echo "--replace_regex a" | $DRIZZLE_TEST 2>&1
1530
--exec echo "--replace_regex a;" | $DRIZZLE_TEST 2>&1
1532
--exec echo "replace_regex a;" | $DRIZZLE_TEST 2>&1
1534
--exec echo "replace_regex a ;" | $DRIZZLE_TEST 2>&1
1536
--exec echo "replace_regex a b; echo OK;" | $DRIZZLE_TEST 2>&1
1538
--exec echo "--replace_regex /a b c" | $DRIZZLE_TEST 2>&1
1540
--exec echo "replace_regex /a /b c ;" | $DRIZZLE_TEST 2>&1
1543
# replace_regex should replace substitutions from left to right in output
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/
1552
# ----------------------------------------------------------------------------
1553
# test for remove_file
1554
# ----------------------------------------------------------------------------
1557
--exec echo "remove_file ;" | $DRIZZLE_TEST 2>&1
1560
remove_file non_existing_file;
1562
# ----------------------------------------------------------------------------
1563
# test for write_file
1564
# ----------------------------------------------------------------------------
1566
--exec echo "write_file ;" | $DRIZZLE_TEST 2>&1
1569
--exec echo "write_file filename ;" | $DRIZZLE_TEST 2>&1
1571
# Comment out this test as it confuses cmd.exe with unmatched "
1573
#--exec echo "write_file filename \";" | $DRIZZLE_TEST 2>&1
1575
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1576
Content for test_file1
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;
1582
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER;
1583
Content for test_file1 contains EOF
1585
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1587
# write to already exisiting file
1588
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1590
--exec echo "write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;" | $DRIZZLE_TEST 2>&1
1592
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1594
# ----------------------------------------------------------------------------
1595
# test for append_file
1596
# ----------------------------------------------------------------------------
1598
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1599
Content for test_file1
1601
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1603
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1606
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1608
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1609
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1610
Appended text on nonexisting file
1613
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1615
# ----------------------------------------------------------------------------
1617
# ----------------------------------------------------------------------------
1619
--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp
1621
for cat_file command
1624
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1625
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1628
--exec echo "cat_file non_existing_file;" | $DRIZZLE_TEST 2>&1
1630
# ----------------------------------------------------------------------------
1631
# test for diff_files
1632
# ----------------------------------------------------------------------------
1634
--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
1636
for diff_file command
1640
--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
1642
for diff_file command
1646
--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
1648
for diff_file command
1652
--write_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
1654
for diff_file command
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
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
1668
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp
1670
--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1672
# Compare files that differ only in content
1674
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp
1676
--diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
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
1684
# Compare equal files, again...
1685
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
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
1694
# ----------------------------------------------------------------------------
1695
# test for file_exist
1696
# ----------------------------------------------------------------------------
1698
--exec echo "file_exists ;" | $DRIZZLE_TEST 2>&1
1701
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1703
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1704
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1705
Content for test_file1
1707
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1708
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1710
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1713
# ----------------------------------------------------------------------------
1714
# test for copy_file
1715
# ----------------------------------------------------------------------------
1716
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
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;
1726
--exec echo "copy_file ;" | $DRIZZLE_TEST 2>&1
1729
--exec echo "copy_file from_file;" | $DRIZZLE_TEST 2>&1
1731
# ----------------------------------------------------------------------------
1733
# ----------------------------------------------------------------------------
1734
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1738
chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1739
# The below write fails, but --error is not implemented
1741
#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1745
chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1746
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1747
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1751
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1754
--exec echo "chmod ;" | $DRIZZLE_TEST 2>&1
1757
--exec echo "chmod 0 from_file;" | $DRIZZLE_TEST 2>&1
1760
--exec echo "chmod 08 from_file;" | $DRIZZLE_TEST 2>&1
1763
--exec echo "chmod from_file;" | $DRIZZLE_TEST 2>&1
1766
--exec echo "chmod ABZD from_file;" | $DRIZZLE_TEST 2>&1
1769
--exec echo "chmod 06789 from_file;" | $DRIZZLE_TEST 2>&1
1772
# ----------------------------------------------------------------------------
1774
# ----------------------------------------------------------------------------
1788
--exec echo "perl TOO_LONG_DELIMITER ;" | $DRIZZLE_TEST 2>&1
1799
# ----------------------------------------------------------------------------
1801
# ----------------------------------------------------------------------------
1804
--exec echo "die test of die;" | $DRIZZLE_TEST 2>&1
1807
# ----------------------------------------------------------------------------
1809
# ----------------------------------------------------------------------------
1811
--exec echo "echo Some output; exit; echo Not this;" | $DRIZZLE_TEST 2>&1
1813
# ----------------------------------------------------------------------------
1814
# test for sorted_result
1815
# ----------------------------------------------------------------------------
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');
1823
# Should not be sorted
1842
# 1. Assignment of result set sorting
1844
SELECT 2 as "my_col"
1849
SELECT 2 as "my_col" UNION SELECT 1;
1851
SELECT 2 as "my_col"
1855
# 2. Ensure that the table header will be not sorted into the result
1861
# 3. Ensure that an empty result set does not cause problems
1862
CREATE TABLE t1( a CHAR);
1867
# 4. Ensure that NULL values within the result set do not cause problems
1868
SELECT NULL as "my_col1",2 AS "my_col2"
1872
SELECT NULL as "my_col1",2 AS "my_col2"
1876
SELECT 2 as "my_col1",NULL AS "my_col2"
1880
SELECT 2 as "my_col1",NULL AS "my_col2"
1884
# 5. "sorted_result" changes nothing when applied to a non query statement.
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"
1894
# 7. Ensure that "sorted_result" in combination with $variables works
1895
let $my_stmt=SELECT 2 as "my_col"
1901
# 8. Ensure that "sorted_result " does not change the semantics of
1902
# "--error ...." or the protocol output after such an expected failure
1905
SELECT '2' as "my_col1",2 as "my_col2"
1907
SELECT '1',1 from t2;
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
1914
--replace_column 1 #
1915
SELECT '1' as "my_col1",2 as "my_col2"
1919
# 10. Ensure that at least 1024 rows within a result set do not cause problems
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
1938
# ----------------------------------------------------------------------------
1939
# Some coverage tests
1940
# ----------------------------------------------------------------------------
1943
--exec $DRIZZLE_TEST --help 2>&1 > /dev/null
1944
--exec $DRIZZLE_TEST --version 2>&1 > /dev/null
1946
--disable_abort_on_error
1948
--exec $DRIZZLE_TEST a b c 2>&1 > /dev/null
1949
--enable_abort_on_error
1952
# ----------------------------------------------------------------------------
1953
# test for query_get_value
1954
# ----------------------------------------------------------------------------
1957
a int, b varchar(255), c datetime
1959
SHOW COLUMNS FROM t1;
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
1969
# 2. $variables as parameters
1971
let $my_show= SHOW COLUMNS FROM t1;
1972
let $column_name= Default;
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
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<-
1983
# 4. column name with space
1984
let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1);
1985
--echo value= $value
1987
#------------ Negative tests ------------
1988
# 5. Incomplete statement including missing parameters
1989
# 5.1 incomplete statement
1991
--exec echo "let \$value= query_get_value(SHOW;" | $DRIZZLE_TEST 2>&1
1994
--exec echo "let \$value= query_get_value;" | $DRIZZLE_TEST 2>&1
1995
# 5.3 missing column name
1997
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1);" | $DRIZZLE_TEST 2>&1
1998
# 5.4 missing row number
2000
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field);" | $DRIZZLE_TEST 2>&1
2002
# 6. Somehow "wrong" value of parameters
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
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
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
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.
2025
--exec echo "let \$value= query_get_value(SELECT 1 AS "A", 1 AS "B", 1);" | $DRIZZLE_TEST 2>&1
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
2032
# 9. failing statement
2034
--exec echo "let \$value= query_get_value(SHOW COLNS FROM t1, Field, 1);" | $DRIZZLE_TEST 2>&1
2036
# 10. Artificial example how to process a complete SHOW result set:
2037
let $show_statement= SHOW COLUMNS FROM t1;
2042
--echo Field Type Null Key Default Extra
2045
let $Field= query_get_value($show_statement, Field, $rowno);
2046
if (`SELECT '$Field' = 'No such row'`)
2050
if (`SELECT '$Field' <> 'No such row'`)
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'`)
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
2066
--echo Number of columns with Default NULL: $count
2068
eval $show_statement;
2072
# ----------------------------------------------------------------------------
2073
# Test change_user command
2074
# ----------------------------------------------------------------------------
2077
--exec echo "--change_user root,,inexistent" | $DRIZZLE_TEST 2>&1
2080
--exec echo "--change_user inexistent,,test" | $DRIZZLE_TEST 2>&1
2083
--exec echo "--change_user root,inexistent,test" | $DRIZZLE_TEST 2>&1
2087
--change_user root,,
2088
--change_user root,,test
2090
# ----------------------------------------------------------------------------
2091
# Test mkdir and rmdir command
2092
# ----------------------------------------------------------------------------
2094
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2095
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2097
# Directory already exist
2098
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2100
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2102
# Remove dir with file inside
2103
write_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
2107
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2109
remove_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
2110
rmdir $MYSQLTEST_VARDIR/tmp/testdir;