~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/mysqltest.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

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