1
-- source include/have_log_bin.inc
3
# This test uses chmod, can't be run with root permissions
4
-- source include/not_as_root.inc
6
# ============================================================================
8
# Test of mysqltest itself
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
17
# Command: "select * from t1"
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>
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
28
# ============================================================================
30
# ----------------------------------------------------------------------------
31
# $mysql_errno contains the return code of the last command
33
# ----------------------------------------------------------------------------
34
# get $mysql_errno before the first statement
35
# $mysql_errno should be -1
36
eval select $mysql_errno as "before_use_test" ;
39
# ----------------------------------------------------------------------------
40
# Positive case(statement)
41
# ----------------------------------------------------------------------------
43
select otto from (select 1 as otto) as t1;
44
# expectation = response
46
select otto from (select 1 as otto) as t1;
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
# ----------------------------------------------------------------------------
55
# expectation <> response
57
#select friedrich from (select 1 as otto) as t1
59
--exec echo "select friedrich from (select 1 as otto) as t1;" | $DRIZZLE_TEST 2>&1
61
# expectation = response
63
select friedrich from (select 1 as otto) as t1;
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;
72
# ----------------------------------------------------------------------------
73
# Tests for the new feature - SQLSTATE error code matching
74
# Positive case(statement)
75
# ----------------------------------------------------------------------------
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;
82
select otto from (select 1 as otto) as t1;
84
# expectation <> response
85
#!S42S22 select otto from (select 1 as otto) as t1;
87
#select otto from (select 1 as otto) as t1;
89
--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $DRIZZLE_TEST 2>&1
93
# ----------------------------------------------------------------------------
94
# Negative case(statement)
95
# ----------------------------------------------------------------------------
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;
101
select friedrich from (select 1 as otto) as t1;
103
# expectation !=response
104
#!S00000 select friedrich from (select 1 as otto) as t1;
106
#select friedrich from (select 1 as otto) as t1;
108
--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $DRIZZLE_TEST 2>&1
110
# ----------------------------------------------------------------------------
111
# test cases for $mysql_errno
113
# $mysql_errno is a builtin variable of mysqltest and contains the return code
114
# of the last command sent to the server.
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.
120
# ----------------------------------------------------------------------------
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" ;
128
#----------------------------------------------------------------------------
129
# check mysql_errno = 1064 after statement with wrong syntax
130
# ----------------------------------------------------------------------------
133
eval select $mysql_errno as "after_wrong_syntax_errno" ;
135
# ----------------------------------------------------------------------------
136
# check if let $my_var= 'abc' ; affects $mysql_errno
137
# ----------------------------------------------------------------------------
141
eval select $mysql_errno as "after_let_var_equal_value" ;
143
# ----------------------------------------------------------------------------
144
# check if set @my_var= 'abc' ; affects $mysql_errno
145
# ----------------------------------------------------------------------------
149
eval select $mysql_errno as "after_set_var_equal_value" ;
151
# ----------------------------------------------------------------------------
152
# check if the setting of --disable-warnings itself affects $mysql_errno
153
# (May be --<whatever> modifies $mysql_errno.)
154
# ----------------------------------------------------------------------------
158
eval select $mysql_errno as "after_disable_warnings_command" ;
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 ;
168
drop table if exists t1 ;
169
eval select $mysql_errno as "after_disable_warnings" ;
172
# ----------------------------------------------------------------------------
173
# check if masked errors affect $mysql_errno
174
# ----------------------------------------------------------------------------
179
eval select $mysql_errno as "after_minus_masked" ;
184
eval select $mysql_errno as "after_!_masked" ;
186
# ----------------------------------------------------------------------------
187
# Will manipulations of $mysql_errno be possible and visible ?
188
# ----------------------------------------------------------------------------
191
let $mysql_errno= -1;
192
eval select $mysql_errno as "after_let_errno_equal_value" ;
194
# ----------------------------------------------------------------------------
195
# How affect actions on prepared statements $mysql_errno ?
196
# ----------------------------------------------------------------------------
201
prepare stmt from "select 3 from t1" ;
202
eval select $mysql_errno as "after_failing_prepare" ;
203
create table t1 ( f1 char(10));
208
prepare stmt from "select 3 from t1" ;
209
eval select $mysql_errno as "after_successful_prepare" ;
215
eval select $mysql_errno as "after_successful_execute" ;
217
# failing execute (table has been dropped)
223
eval select $mysql_errno as "after_failing_execute" ;
225
# failing execute (unknown statement)
230
eval select $mysql_errno as "after_failing_execute" ;
232
# successful deallocate
235
deallocate prepare stmt;
236
eval select $mysql_errno as "after_successful_deallocate" ;
238
# failing deallocate ( statement handle does not exist )
242
deallocate prepare __stmt_;
243
eval select $mysql_errno as "after_failing_deallocate" ;
246
# ----------------------------------------------------------------------------
247
# test cases for "--disable_abort_on_error"
249
# "--disable_abort_on_error" switches off the abort of mysqltest
250
# after "unmasked" failing statements.
252
# The default is "--enable_abort_on_error".
255
# --error <error number> and --error <error number>
256
# in the line before the failing statement.
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
# ----------------------------------------------------------------------------
263
# ----------------------------------------------------------------------------
264
# Switch off the abort on error and check the effect on $mysql_errno
265
# ----------------------------------------------------------------------------
268
--disable_abort_on_error
269
eval select $mysql_errno as "after_--disable_abort_on_error" ;
271
# ----------------------------------------------------------------------------
272
# "unmasked" failing statement should not cause an abort
273
# ----------------------------------------------------------------------------
276
# ----------------------------------------------------------------------------
277
# masked failing statements
278
# ----------------------------------------------------------------------------
279
# expected error = response
284
eval select $mysql_errno as "after_!errno_masked_error" ;
285
# expected error <> response
291
--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $DRIZZLE_TEST 2>&1
293
# ----------------------------------------------------------------------------
294
# Switch the abort on error on and check the effect on $mysql_errno
295
# ----------------------------------------------------------------------------
298
--enable_abort_on_error
299
eval select $mysql_errno as "after_--enable_abort_on_error" ;
301
# ----------------------------------------------------------------------------
302
# masked failing statements
303
# ----------------------------------------------------------------------------
304
# expected error = response
308
# ----------------------------------------------------------------------------
309
# check that the old default behaviour is not changed
310
# Please remove the '#' to get the abort on error
311
# ----------------------------------------------------------------------------
318
--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $DRIZZLE_TEST 2>&1
321
# ----------------------------------------------------------------------------
323
# ----------------------------------------------------------------------------
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
332
# ----------------------------------------------------------------------------
333
# Test comments with embedded command
334
# ----------------------------------------------------------------------------
340
--echo # MySQL: -- The
342
# ----------------------------------------------------------------------------
343
# Test detect end of line "junk"
344
# Most likely caused by a missing delimiter
345
# ----------------------------------------------------------------------------
347
# Too many parameters to function
349
--exec echo "sleep 5 6;" | $DRIZZLE_TEST 2>&1
351
# Too many parameters to function
353
--exec echo "--sleep 5 6" | $DRIZZLE_TEST 2>&1
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
365
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
366
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
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
377
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
378
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
381
# Missing delimiter until "disable_query_log"
383
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
392
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
393
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
396
# Missing delimiter until "disable_query_log"
398
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
408
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
409
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
412
# Missing delimiter until eof
414
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
425
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
426
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
429
# Missing delimiter until eof
431
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
432
disconnect default # comment
439
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
441
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
447
--exec echo "--sleep 4;" | $DRIZZLE_TEST 2>&1
449
--exec echo "--disable_query_log;" | $DRIZZLE_TEST 2>&1
452
# Allow trailing # comment
453
--sleep 1 # Wait for insert delayed to be executed.
454
--sleep 1 # Wait for insert delayed to be executed.
456
# ----------------------------------------------------------------------------
458
# ----------------------------------------------------------------------------
462
--exec echo "error;" | $DRIZZLE_TEST 2>&1
464
--exec echo "--error" | $DRIZZLE_TEST 2>&1
466
# First char must be uppercase 'S' or 'E' or [0-9]
468
--exec echo "--error s99999" | $DRIZZLE_TEST 2>&1
470
--exec echo "--error e99999" | $DRIZZLE_TEST 2>&1
472
--exec echo "--error 9eeeee" | $DRIZZLE_TEST 2>&1
474
--exec echo "--error 1sssss" | $DRIZZLE_TEST 2>&1
476
# First char 'S' but too long
478
--exec echo "--error S999999" | $DRIZZLE_TEST 2>&1
480
# First char 'S' but lowercase char found
482
--exec echo "--error S99a99" | $DRIZZLE_TEST 2>&1
484
# First char 'S' but too short
486
--exec echo "--error S9999" | $DRIZZLE_TEST 2>&1
488
# First char 'E' but not found in error array
490
--exec echo "--error E9999" | $DRIZZLE_TEST 2>&1
492
# First char [0-9] but contains chars
494
--exec echo "--error 999e9" | $DRIZZLE_TEST 2>&1
496
--exec echo "--error 9b" | $DRIZZLE_TEST 2>&1
498
# Multiple errorcodes separated by ','
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
507
--error 9,S00000,9,9,10,11,12
513
# Too many errorcodes specified
515
--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $DRIZZLE_TEST 2>&1
518
# ----------------------------------------------------------------------------
520
# ----------------------------------------------------------------------------
524
echo MySQL: The world''s most popular open source database;
525
echo "MySQL: The world's most popular open source database";
527
echo MySQL: The world''s
531
echo # MySQL: The world''s
535
echo - MySQL: The world''s
539
echo - MySQL: The world''s
541
-- open source database;
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;
557
# Illegal use of echo
560
#--exec echo "echo \$;" | $DRIZZLE_TEST 2>&1
563
# ----------------------------------------------------------------------------
565
# ----------------------------------------------------------------------------
567
# Illegal use of exec
569
--exec echo "--exec false" | $DRIZZLE_TEST 2>&1
572
--exec echo "--exec " | $DRIZZLE_TEST 2>&1
574
# ----------------------------------------------------------------------------
576
# ----------------------------------------------------------------------------
581
let $message="MySQL";
584
let $message= MySQL: The
590
let $message= # MySQL: The
596
let $message= -- MySQL: The
599
-- open source database;
602
let $message= # MySQL: The
627
let $where=a long variable content;
633
let $where3=a long $where variable content;
636
let $where3=a long \\\$where variable content;
639
let $novar1= $novar2;
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;
653
# Test illegal uses of let
656
--exec echo "let ;" | $DRIZZLE_TEST 2>&1
659
--exec echo "let \$=hi;" | $DRIZZLE_TEST 2>&1
662
--exec echo "let \$1 hi;" | $DRIZZLE_TEST 2>&1
665
--exec echo "let \$m hi;" | $DRIZZLE_TEST 2>&1
668
--exec echo "let \$hi;" | $DRIZZLE_TEST 2>&1
671
--exec echo "let \$ hi;" | $DRIZZLE_TEST 2>&1
674
--exec echo "let =hi;" | $DRIZZLE_TEST 2>&1
677
--exec echo "let hi;" | $DRIZZLE_TEST 2>&1
679
# More advanced test for bug#17280
681
--echo # Execute: --echo # <whatever> success: \$success
682
--echo # <whatever> success: $success
683
--echo # Execute: echo # <whatever> success: \$success ;
684
echo # <whatever> success: $success ;
686
--echo # The next two variants work fine and expand the content of \$success
687
--echo # Execute: --echo \$success
689
--echo # Execute: echo \$success ;
693
# ----------------------------------------------------------------------------
694
# Test to assign let from variable
695
# let $<var_name>=$<var_name>;
696
# ----------------------------------------------------------------------------
698
--echo # Check if let \$B = \$A is an assignment per value.
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
711
--echo # Content of \$A is: $A
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
718
--echo let \$B = changed value of B;
719
let $B = changed value of B;
720
--echo # Content of \$A is: $A
722
# ----------------------------------------------------------------------------
723
# Test let from query with $variable
724
# let $<var_name>=`<query with $variable>`;
725
# ----------------------------------------------------------------------------
727
let $var1=content of variable 1;
728
let $var2= `select "$var1"`;
729
let $var3= `select concat("$var1", " ", "$var2")`;
732
if (`select length("$var3") > 0`)
734
echo length of var3 is longer than 0;
737
# ----------------------------------------------------------------------------
738
# Test to assign let from query
739
# let $<var_name>=`<query>`;
740
# ----------------------------------------------------------------------------
742
let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`;
746
let $var2= `select 2 as "Column num 2"`;
750
let $var2= `select 2 as "Column num 2"`;
753
echo var3 two columns with same name;
754
let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`;
757
echo var4 from query that returns NULL;
758
let $var4= `select NULL`;
760
echo var5 from query that returns no row;
761
let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`;
763
echo failing query in let;
764
--write_file $MYSQLTEST_VARDIR/tmp/let.sql
765
let $var2= `failing query`;
770
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
772
remove_file $MYSQLTEST_VARDIR/tmp/let.sql;
775
# ----------------------------------------------------------------------------
776
# Test source command
777
# ----------------------------------------------------------------------------
779
# Test illegal uses of source
782
--exec echo "source ;" | $DRIZZLE_TEST 2>&1
785
--replace_result \\ /
786
# Source a nonexisting file
788
--exec echo "source non_existingFile;" | $DRIZZLE_TEST 2>&1
791
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql
792
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
794
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $DRIZZLE_TEST 2>&1
795
remove_file $MYSQLTEST_VARDIR/tmp/recursive.sql;
797
# Source a file with error
798
--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql
799
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
801
--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $DRIZZLE_TEST 2>&1
803
remove_file $MYSQLTEST_VARDIR/tmp/error.sql;
805
# Test execution of source in a while loop
806
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
807
echo here is the sourced script;
810
let $outer= 2; # Number of outer loops
813
eval SELECT '$outer = outer loop variable after while' AS "";
815
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
817
eval SELECT '$outer = outer loop variable before dec' AS "";
819
eval SELECT '$outer = outer loop variable after dec' AS "";
822
let $outer= 2; # Number of outer loops
825
eval SELECT '$outer = outer loop variable after while' AS "";
827
echo here is the sourced script;
829
eval SELECT '$outer = outer loop variable before dec' AS "";
831
eval SELECT '$outer = outer loop variable after dec' AS "";
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
842
SELECT 'In loop' AS "";
843
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
846
--enable_abort_on_error
849
# Test source $variable/<filename>
850
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
852
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
854
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
859
source $MYSQLTEST_VARDIR/tmp/$x.inc;
861
let $x= $MYSQLTEST_VARDIR;
862
source $x/tmp/sourced.inc;
864
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
867
# ----------------------------------------------------------------------------
869
# ----------------------------------------------------------------------------
877
--exec echo "sleep ;" | $DRIZZLE_TEST 2>&1
879
--exec echo "real_sleep ;" | $DRIZZLE_TEST 2>&1
883
--exec echo "sleep abc;" | $DRIZZLE_TEST 2>&1
885
--exec echo "real_sleep abc;" | $DRIZZLE_TEST 2>&1
887
# ----------------------------------------------------------------------------
889
# ----------------------------------------------------------------------------
904
--exec echo "inc;" | $DRIZZLE_TEST 2>&1
906
--exec echo "inc i;" | $DRIZZLE_TEST 2>&1
908
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $DRIZZLE_TEST 2>&1
910
inc $i; inc $i; inc $i; --echo $i
914
# ----------------------------------------------------------------------------
916
# ----------------------------------------------------------------------------
932
--exec echo "dec;" | $DRIZZLE_TEST 2>&1
934
--exec echo "dec i;" | $DRIZZLE_TEST 2>&1
936
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $DRIZZLE_TEST 2>&1
939
# ----------------------------------------------------------------------------
941
# ----------------------------------------------------------------------------
942
#system ls > /dev/null;
943
system echo "hej" > /dev/null;
944
#--system ls > /dev/null
945
--system echo "hej" > /dev/null;
948
--exec echo "system;" | $DRIZZLE_TEST 2>&1
950
--exec echo "system $NONEXISTSINFVAREABLI;" | $DRIZZLE_TEST 2>&1
952
--exec echo "system false;" | $DRIZZLE_TEST 2>&1
954
--disable_abort_on_error
955
system NonExistsinfComamdn 2> /dev/null;
956
--enable_abort_on_error
959
# ----------------------------------------------------------------------------
961
# ----------------------------------------------------------------------------
973
# ----------------------------------------------------------------------------
975
# ----------------------------------------------------------------------------
980
echo Counter is greater than 0, (counter=10);
984
echo Counter is not 0, (counter=10);
989
echo Counter is greater than 0, (counter=0);
993
echo Counter is not 0, (counter=0);
996
# ----------------------------------------------------------------------------
997
# Test while, { and }
998
# ----------------------------------------------------------------------------
1007
#let $i=1;while ($i){echo $i;dec $i;}
1012
echo Testing while with not;
1016
# Exceed max nesting level
1017
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1157
--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1159
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $DRIZZLE_TEST 2>&1
1160
--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1162
--exec echo "while \$i;" | $DRIZZLE_TEST 2>&1
1164
--exec echo "while (\$i;" | $DRIZZLE_TEST 2>&1
1166
--exec echo "let \$i=1; while (\$i) dec \$i;" | $DRIZZLE_TEST 2>&1
1168
--exec echo "};" | $DRIZZLE_TEST 2>&1
1170
--exec echo "end;" | $DRIZZLE_TEST 2>&1
1172
--exec echo "{;" | $DRIZZLE_TEST 2>&1
1174
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1179
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1180
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1182
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1187
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1188
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1190
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1195
--exec $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1197
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1199
# ----------------------------------------------------------------------------
1200
# Test error messages returned from comments starting with a command
1201
# ----------------------------------------------------------------------------
1203
--exec echo "--if the other server is down" | $DRIZZLE_TEST 2>&1
1206
--exec echo "-- end when ..." | $DRIZZLE_TEST 2>&1
1208
# ----------------------------------------------------------------------------
1210
# ----------------------------------------------------------------------------
1211
--replace_result a b
1212
select "a" as col1, "c" as col2;
1214
--replace_result a b c d
1215
select "a" as col1, "c" as col2;
1218
--exec echo "--replace_result a" | $DRIZZLE_TEST 2>&1
1220
--exec echo "--replace_result a;" | $DRIZZLE_TEST 2>&1
1222
--exec echo "replace_result a;" | $DRIZZLE_TEST 2>&1
1224
--exec echo "replace_result a ;" | $DRIZZLE_TEST 2>&1
1225
--exec echo "replace_result a b; echo OK;" | $DRIZZLE_TEST 2>&1
1227
--exec echo "--replace_result a b c" | $DRIZZLE_TEST 2>&1
1229
--exec echo "replace_result a b c ;" | $DRIZZLE_TEST 2>&1
1232
--replace_column 1 b
1233
select "a" as col1, "c" as col2;
1235
--replace_column 1 b 2 d
1236
select "a" as col1, "c" as col2;
1239
--exec echo "--replace_column a" | $DRIZZLE_TEST 2>&1
1242
--exec echo "--replace_column 1" | $DRIZZLE_TEST 2>&1
1245
--exec echo "--replace_column a b" | $DRIZZLE_TEST 2>&1
1247
--exec echo "--replace_column a 1" | $DRIZZLE_TEST 2>&1
1249
--exec echo "--replace_column 1 b c " | $DRIZZLE_TEST 2>&1
1252
# ----------------------------------------------------------------------------
1253
# Test sync_with_master
1254
# ----------------------------------------------------------------------------
1256
--exec echo "sync_with_master 10!;" | $DRIZZLE_TEST 2>&1
1258
--exec echo "sync_with_master a;" | $DRIZZLE_TEST 2>&1
1260
# ----------------------------------------------------------------------------
1262
# ----------------------------------------------------------------------------
1265
--exec echo "connect;" | $DRIZZLE_TEST 2>&1
1267
--exec echo "connect ();" | $DRIZZLE_TEST 2>&1
1269
--exec echo "connect (con2);" | $DRIZZLE_TEST 2>&1
1271
--exec echo "connect (con2,);" | $DRIZZLE_TEST 2>&1
1273
--exec echo "connect (con2,localhost,root,,illegal_db);" | $DRIZZLE_TEST 2>&1
1275
--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $DRIZZLE_TEST 2>&1
1277
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $DRIZZLE_TEST 2>&1
1279
# Repeat connect/disconnect
1280
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1284
connect (test_con1,localhost,root,,);
1285
disconnect test_con1;
1289
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $DRIZZLE_TEST 2>&1
1290
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1292
# Repeat connect/disconnect
1293
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1297
connect (test_con1,localhost,root,,);
1298
disconnect 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
# 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;
1313
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1315
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1316
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
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,,);
1323
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1325
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $DRIZZLE_TEST 2>&1
1327
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
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,,);
1336
--enable_abort_on_error
1338
# Test connect without a database
1339
connect (con2,localhost,root,,*NO-ONE*);
1340
--error ER_NO_DB_ERROR
1345
# ----------------------------------------------------------------------------
1346
# Test mysqltest arguments
1347
# ----------------------------------------------------------------------------
1349
# -x <file_name>, use the file specified after -x as the test file
1350
--exec $DRIZZLE_TEST < $DRIZZLE_TEST_DIR/include/mysqltest-x.inc
1351
--exec $DRIZZLE_TEST -x $DRIZZLE_TEST_DIR/include/mysqltest-x.inc
1352
--exec $DRIZZLE_TEST --test_file=$DRIZZLE_TEST_DIR/include/mysqltest-x.inc
1354
--replace_result \\ /
1356
--exec $DRIZZLE_TEST -x non_existing_file.inc 2>&1
1359
# ----------------------------------------------------------------------------
1360
# TODO Test queries, especially their errormessages... so it's easy to debug
1361
# new scripts and diagnose errors
1362
# ----------------------------------------------------------------------------
1364
# ----------------------------------------------------------------------------
1366
# ----------------------------------------------------------------------------
1380
# Bug #10251: Identifiers containing quotes not handled correctly
1382
select 1 as `a'b`, 2 as `a"b`;
1384
# Test escaping of quotes
1385
select 'aaa\\','aa''a',"aa""a";
1388
# Check of include/show_msg.inc and include/show_msg80.inc
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
1395
# The message could also contain a string with character set utf8
1396
let $message= `SELECT USER()`;
1397
--source include/show_msg.inc
1399
# The message contains more then 80 characters on multiple lines
1400
# and is kept between double quotes.
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
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
1415
# Test --enable_parsing / disable_parsing
1419
# The following will not enable query logging
1421
select "this will not be executed";
1423
select "this will be executed";
1427
# Test zero length result file. Should not pass
1429
--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result
1430
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
1432
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
1434
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
1436
remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject;
1438
remove_file $DRIZZLE_TEST_DIR/r/zero_length_file.reject;
1441
# Test that a test file that does not generate any output fails.
1443
--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
1445
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1
1447
remove_file $MYSQLTEST_VARDIR/tmp/query.sql;
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
1457
#--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1
1460
# Bug #11731 mysqltest in multi-statement queries ignores errors in
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
1475
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
1478
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1480
--exec $DRIZZLE_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
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
1497
# These two should work since the error is expected
1498
--exec $DRIZZLE_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
1501
--exec $DRIZZLE_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
1505
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
1506
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
1507
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
1510
# Bug#19890 mysqltest: "query" command is broken
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.
1521
# Just an empty query command
1525
# test for replace_regex
1526
--replace_regex /at/b/
1527
select "at" as col1, "c" as col2;
1529
--replace_regex /at/b/i
1530
select "at" as col1, "AT" as col2, "c" as col3;
1532
--replace_regex /a/b/ /ct/d/
1533
select "a" as col1, "ct" as col2;
1535
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
1536
select "strawberry","blueberry","potato";
1539
--exec echo "--replace_regex a" | $DRIZZLE_TEST 2>&1
1541
--exec echo "--replace_regex a;" | $DRIZZLE_TEST 2>&1
1543
--exec echo "replace_regex a;" | $DRIZZLE_TEST 2>&1
1545
--exec echo "replace_regex a ;" | $DRIZZLE_TEST 2>&1
1547
--exec echo "replace_regex a b; echo OK;" | $DRIZZLE_TEST 2>&1
1549
--exec echo "--replace_regex /a b c" | $DRIZZLE_TEST 2>&1
1551
--exec echo "replace_regex /a /b c ;" | $DRIZZLE_TEST 2>&1
1554
# replace_regex should replace substitutions from left to right in output
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/
1563
# ----------------------------------------------------------------------------
1564
# test for remove_file
1565
# ----------------------------------------------------------------------------
1568
--exec echo "remove_file ;" | $DRIZZLE_TEST 2>&1
1571
remove_file non_existing_file;
1573
# ----------------------------------------------------------------------------
1574
# test for write_file
1575
# ----------------------------------------------------------------------------
1577
--exec echo "write_file ;" | $DRIZZLE_TEST 2>&1
1580
--exec echo "write_file filename ;" | $DRIZZLE_TEST 2>&1
1582
# Comment out this test as it confuses cmd.exe with unmatched "
1584
#--exec echo "write_file filename \";" | $DRIZZLE_TEST 2>&1
1586
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1587
Content for test_file1
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;
1593
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER;
1594
Content for test_file1 contains EOF
1596
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1598
# write to already exisiting file
1599
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1601
--exec echo "write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;" | $DRIZZLE_TEST 2>&1
1603
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1605
# ----------------------------------------------------------------------------
1606
# test for append_file
1607
# ----------------------------------------------------------------------------
1609
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1610
Content for test_file1
1612
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1614
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1617
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1619
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1620
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1621
Appended text on nonexisting file
1624
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1626
# ----------------------------------------------------------------------------
1628
# ----------------------------------------------------------------------------
1630
--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp
1632
for cat_file command
1635
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1636
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1639
--exec echo "cat_file non_existing_file;" | $DRIZZLE_TEST 2>&1
1641
# ----------------------------------------------------------------------------
1642
# test for diff_files
1643
# ----------------------------------------------------------------------------
1645
--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
1647
for diff_file command
1651
--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
1653
for diff_file command
1657
--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
1659
for diff_file command
1663
--write_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
1665
for diff_file command
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
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
1679
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp
1681
--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1683
# Compare files that differ only in content
1685
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp
1687
--diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
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 $DRIZZLE_TEST < $MYSQLTEST_VARDIR/tmp/diff.test > /dev/null 2>&1
1695
# Compare equal files, again...
1696
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
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
1705
# ----------------------------------------------------------------------------
1706
# test for file_exist
1707
# ----------------------------------------------------------------------------
1709
--exec echo "file_exists ;" | $DRIZZLE_TEST 2>&1
1712
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1714
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1715
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1716
Content for test_file1
1718
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1719
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1721
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1724
# ----------------------------------------------------------------------------
1725
# test for copy_file
1726
# ----------------------------------------------------------------------------
1727
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
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;
1737
--exec echo "copy_file ;" | $DRIZZLE_TEST 2>&1
1740
--exec echo "copy_file from_file;" | $DRIZZLE_TEST 2>&1
1742
# ----------------------------------------------------------------------------
1744
# ----------------------------------------------------------------------------
1745
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1749
chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1750
# The below write fails, but --error is not implemented
1752
#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1756
chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1757
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1758
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1762
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1765
--exec echo "chmod ;" | $DRIZZLE_TEST 2>&1
1768
--exec echo "chmod 0 from_file;" | $DRIZZLE_TEST 2>&1
1771
--exec echo "chmod 08 from_file;" | $DRIZZLE_TEST 2>&1
1774
--exec echo "chmod from_file;" | $DRIZZLE_TEST 2>&1
1777
--exec echo "chmod ABZD from_file;" | $DRIZZLE_TEST 2>&1
1780
--exec echo "chmod 06789 from_file;" | $DRIZZLE_TEST 2>&1
1783
# ----------------------------------------------------------------------------
1785
# ----------------------------------------------------------------------------
1799
--exec echo "perl TOO_LONG_DELIMITER ;" | $DRIZZLE_TEST 2>&1
1810
# ----------------------------------------------------------------------------
1812
# ----------------------------------------------------------------------------
1815
--exec echo "die test of die;" | $DRIZZLE_TEST 2>&1
1818
# ----------------------------------------------------------------------------
1820
# ----------------------------------------------------------------------------
1822
--exec echo "echo Some output; exit; echo Not this;" | $DRIZZLE_TEST 2>&1
1824
# ----------------------------------------------------------------------------
1825
# test for sorted_result
1826
# ----------------------------------------------------------------------------
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');
1834
# Should not be sorted
1853
# 1. Assignment of result set sorting
1855
SELECT 2 as "my_col"
1860
SELECT 2 as "my_col" UNION SELECT 1;
1862
SELECT 2 as "my_col"
1866
# 2. Ensure that the table header will be not sorted into the result
1872
# 3. Ensure that an empty result set does not cause problems
1873
CREATE TABLE t1( a CHAR);
1878
# 4. Ensure that NULL values within the result set do not cause problems
1879
SELECT NULL as "my_col1",2 AS "my_col2"
1883
SELECT NULL as "my_col1",2 AS "my_col2"
1887
SELECT 2 as "my_col1",NULL AS "my_col2"
1891
SELECT 2 as "my_col1",NULL AS "my_col2"
1895
# 5. "sorted_result" changes nothing when applied to a non query statement.
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"
1905
# 7. Ensure that "sorted_result" in combination with $variables works
1906
let $my_stmt=SELECT 2 as "my_col"
1912
# 8. Ensure that "sorted_result " does not change the semantics of
1913
# "--error ...." or the protocol output after such an expected failure
1916
SELECT '2' as "my_col1",2 as "my_col2"
1918
SELECT '1',1 from t2;
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
1925
--replace_column 1 #
1926
SELECT '1' as "my_col1",2 as "my_col2"
1930
# 10. Ensure that at least 1024 rows within a result set do not cause problems
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
1949
# ----------------------------------------------------------------------------
1950
# Some coverage tests
1951
# ----------------------------------------------------------------------------
1954
--exec $DRIZZLE_TEST --help 2>&1 > /dev/null
1955
--exec $DRIZZLE_TEST --version 2>&1 > /dev/null
1957
--disable_abort_on_error
1959
--exec $DRIZZLE_TEST a b c 2>&1 > /dev/null
1960
--enable_abort_on_error
1963
# ----------------------------------------------------------------------------
1964
# test for query_get_value
1965
# ----------------------------------------------------------------------------
1968
a int, b varchar(255), c datetime
1970
SHOW COLUMNS FROM t1;
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
1980
# 2. $variables as parameters
1982
let $my_show= SHOW COLUMNS FROM t1;
1983
let $column_name= Default;
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
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<-
1994
# 4. column name with space
1995
let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1);
1996
--echo value= $value
1998
#------------ Negative tests ------------
1999
# 5. Incomplete statement including missing parameters
2000
# 5.1 incomplete statement
2002
--exec echo "let \$value= query_get_value(SHOW;" | $DRIZZLE_TEST 2>&1
2005
--exec echo "let \$value= query_get_value;" | $DRIZZLE_TEST 2>&1
2006
# 5.3 missing column name
2008
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1);" | $DRIZZLE_TEST 2>&1
2009
# 5.4 missing row number
2011
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field);" | $DRIZZLE_TEST 2>&1
2013
# 6. Somehow "wrong" value of parameters
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
2025
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field, notnumber);" | $DRIZZLE_TEST 2>&1
2026
# 6.2 column name parameter, name of not existing column
2028
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, column_not_exists, 1);" | $DRIZZLE_TEST 2>&1
2029
# 6.3. statement which never gives a result set
2031
--exec echo "let \$value= query_get_value(SET @A = 1, Field, 1);" | $DRIZZLE_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.
2036
--exec echo "let \$value= query_get_value(SELECT 1 AS "A", 1 AS "B", 1);" | $DRIZZLE_TEST 2>&1
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
2043
# 9. failing statement
2045
--exec echo "let \$value= query_get_value(SHOW COLNS FROM t1, Field, 1);" | $DRIZZLE_TEST 2>&1
2047
# 10. Artificial example how to process a complete SHOW result set:
2048
let $show_statement= SHOW COLUMNS FROM t1;
2053
--echo Field Type Null Key Default Extra
2056
let $Field= query_get_value($show_statement, Field, $rowno);
2057
if (`SELECT '$Field' = 'No such row'`)
2061
if (`SELECT '$Field' <> 'No such row'`)
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'`)
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
2077
--echo Number of columns with Default NULL: $count
2079
eval $show_statement;
2083
# ----------------------------------------------------------------------------
2084
# Test change_user command
2085
# ----------------------------------------------------------------------------
2088
--exec echo "--change_user root,,inexistent" | $DRIZZLE_TEST 2>&1
2091
--exec echo "--change_user inexistent,,test" | $DRIZZLE_TEST 2>&1
2094
--exec echo "--change_user root,inexistent,test" | $DRIZZLE_TEST 2>&1
2098
--change_user root,,
2099
--change_user root,,test
2101
# ----------------------------------------------------------------------------
2102
# Test mkdir and rmdir command
2103
# ----------------------------------------------------------------------------
2105
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2106
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2108
# Directory already exist
2109
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2111
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2113
# Remove dir with file inside
2114
write_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
2118
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2120
remove_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
2121
rmdir $MYSQLTEST_VARDIR/tmp/testdir;