~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
326
326
--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $MYSQL_TEST  2>&1
327
327
 
328
328
# ----------------------------------------------------------------------------
 
329
# Check some non-query statements that would fail
 
330
# ----------------------------------------------------------------------------
 
331
--exec illegal_command
 
332
--cat_file does_not_exist
 
333
--perl
 
334
  exit(2);
 
335
EOF
 
336
 
 
337
# ----------------------------------------------------------------------------
 
338
# Check backtick and query_get_value, result should be empty
 
339
# ----------------------------------------------------------------------------
 
340
let $empty= `garbage`;
 
341
echo $empty is empty;
 
342
let $empty= query_get_value(nonsense, blabla, 1);
 
343
echo $empty is empty;
 
344
 
 
345
# ----------------------------------------------------------------------------
329
346
# Switch the abort on error on and check the effect on $mysql_errno
330
347
# ----------------------------------------------------------------------------
331
348
--error ER_PARSE_ERROR
356
373
 
357
374
 
358
375
# ----------------------------------------------------------------------------
 
376
# Test --error with backtick operator or query_get_value
 
377
# ----------------------------------------------------------------------------
 
378
 
 
379
--error 0,ER_NO_SUCH_TABLE
 
380
let $empty= `SELECT foo from bar`;
 
381
echo $empty is empty;
 
382
 
 
383
--error 0,ER_BAD_FIELD_ERROR
 
384
let $empty= query_get_value(SELECT bar as foo, baz, 1);
 
385
echo $empty is empty;
 
386
 
 
387
--error 0,ER_NO_SUCH_TABLE
 
388
if (!`SELECT foo from bar`) {
 
389
  echo "Yes it's empty";
 
390
}
 
391
 
 
392
# ----------------------------------------------------------------------------
359
393
# Test comments
360
394
# ----------------------------------------------------------------------------
361
395
 
485
519
--error 1
486
520
--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
487
521
 
 
522
#
 
523
# Extra text after ``
 
524
#
 
525
# Cannot use exec echo here as ` may or may not need to be escaped
 
526
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
 
527
let $x= `select 1` BOO ;
 
528
EOF
 
529
--error 1
 
530
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
 
531
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
 
532
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
 
533
--let $x= `select 1`;
 
534
EOF
 
535
--error 1
 
536
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
 
537
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
 
538
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
 
539
# Missing ; in next line should be detected and cause failure
 
540
let $x= `select 1`
 
541
let $x= 2;
 
542
echo $x;
 
543
EOF
 
544
--error 1
 
545
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
 
546
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
 
547
 
488
548
 
489
549
# Allow trailing # comment
490
550
--sleep 1 # Wait for insert delayed to be executed.
692
752
let $cat=ba\\\$cat\\\$cat;
693
753
echo Not a banana: $cat;
694
754
 
 
755
# Bug #55413 would cause this to fail
 
756
let $escape= with\`some\"escaped\'quotes;
 
757
echo $escape;
 
758
 
 
759
--let $escape= with\`some\"escaped\'quotes
 
760
echo $escape;
 
761
 
 
762
# This only works with "--let" syntax
 
763
--let $tick= single'tick`backtick
 
764
echo $tick;
695
765
 
696
766
# Test illegal uses of let
697
767
 
809
879
echo $var2;
810
880
EOF
811
881
 
 
882
create table t1 (a varchar(100));
 
883
insert into t1 values ('`select 42`');
 
884
let $a= `select * from t1`;
 
885
# This should output `select 42`, not evaluate it again to 42
 
886
echo $a;
 
887
insert into t1 values ('$dollar');
 
888
# These should also output the string without evaluating it.
 
889
let $a= query_get_value(select * from t1 order by a, a, 1);
 
890
echo $a;
 
891
let $a= query_get_value(select * from t1 order by a, a, 2);
 
892
echo $a;
 
893
drop table t1;
 
894
 
812
895
--error 1
813
896
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
814
897
 
863
946
}
864
947
 
865
948
# Test source in an if in a while which is false on 1st iteration
866
 
# Also test --error in same context
 
949
# Also test --error and --disable_abort_on_error in same context
867
950
let $outer= 2; # Number of outer loops
868
951
let $ifval= 0; # false 1st time
869
952
while ($outer)
874
957
    --source $MYSQLTEST_VARDIR/tmp/sourced.inc
875
958
    --error ER_NO_SUCH_TABLE
876
959
    SELECT * from nowhere;
 
960
    --disable_abort_on_error
 
961
# Statement giving a different error, to make sure we don't mask it
 
962
    SELECT * FROM nowhere else;
 
963
    --enable_abort_on_error
877
964
  }
878
965
  dec $outer;
879
966
  inc $ifval;
1082
1169
{
1083
1170
  echo Counter is not 0, (counter=10);
1084
1171
}
 
1172
if (! $counter)
 
1173
{
 
1174
  let $counter=5;
 
1175
}
 
1176
echo Counter should still be 10, is $counter;
1085
1177
let $counter=0;
1086
1178
if($counter)
1087
1179
{
1091
1183
{
1092
1184
  echo Counter is not 0, (counter=0);
1093
1185
}
 
1186
if (! $counter)
 
1187
{
 
1188
  echo Not space var works;
 
1189
}
 
1190
 
 
1191
# ----------------------------------------------------------------------------
 
1192
# Test if with some non-numerics
 
1193
# ----------------------------------------------------------------------------
 
1194
 
 
1195
let $counter=alpha;
 
1196
if ($counter)
 
1197
{
 
1198
  echo Counter is true, (counter=alpha);
 
1199
}
 
1200
let $counter=   ;
 
1201
if ($counter)
 
1202
{
 
1203
  echo oops, space is true;
 
1204
}
 
1205
let $counter=-0;
 
1206
if ($counter)
 
1207
{
 
1208
  echo oops, -0 is true;
 
1209
}
 
1210
if (beta)
 
1211
{
 
1212
  echo Beta is true;
 
1213
}
 
1214
let $counter=gamma;
 
1215
while ($counter)
 
1216
{
 
1217
  echo while with string, only once;
 
1218
  let $counter=000;
 
1219
}
1094
1220
 
1095
1221
# ----------------------------------------------------------------------------
1096
1222
# Test while, { and }
1388
1514
 
1389
1515
# Repeat connect/disconnect
1390
1516
--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
1517
let $i=200;
1405
1518
while ($i)
1406
1519
{
1408
1521
 disconnect test_con1;
1409
1522
 dec $i;
1410
1523
}
 
1524
echo 200 connects succeeded;
1411
1525
EOF
1412
 
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1413
 
--error 1
1414
1526
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
1415
1527
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1416
1528
 
1437
1549
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1438
1550
 
1439
1551
# connect when "disable_abort_on_error" caused "connection not found"
1440
 
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
1441
1552
--disable_abort_on_error
1442
1553
connect (con1,localhost,root,,);
1443
1554
connection default;
1452
1563
disconnect con2;
1453
1564
connection default;
1454
1565
 
 
1566
# Test enable_connect_log
 
1567
--enable_connect_log
 
1568
connect (con1,localhost,root,,);
 
1569
connection default;
 
1570
connection con1;
 
1571
--disable_query_log
 
1572
# These should not be logged
 
1573
connect (con2,localhost,root,,*NO-ONE*);
 
1574
connection con2;
 
1575
disconnect con2;
 
1576
connection con1;
 
1577
--enable_query_log
 
1578
disconnect con1;
 
1579
connection default;
 
1580
--disable_connect_log
 
1581
 
1455
1582
# ----------------------------------------------------------------------------
1456
1583
# Test mysqltest arguments
1457
1584
# ----------------------------------------------------------------------------
1724
1851
--reap
1725
1852
EOF
1726
1853
--error 1
1727
 
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.in 2>&1
 
1854
# Must filter unpredictable extra warning from output
 
1855
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.in > $MYSQL_TMP_DIR/mysqltest.out 2>&1
 
1856
--perl
 
1857
  my $dir= $ENV{'MYSQL_TMP_DIR'};
 
1858
  open (FILE, "$dir/mysqltest.out");
 
1859
  while (<FILE>) {
 
1860
    print unless /Note: net_clear/; # This shows up on rare occations
 
1861
  }
 
1862
EOF
 
1863
remove_file $MYSQL_TMP_DIR/mysqltest.out;
1728
1864
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.in;
1729
1865
 
1730
1866
drop table t1;
1831
1967
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1832
1968
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1833
1969
 
 
1970
--replace_regex /my_errno=[0-9]*/(my_errno)/
1834
1971
--error 1
1835
1972
--exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1
1836
1973
 
2407
2544
hello
2408
2545
EOF
2409
2546
 
 
2547
# Verify that --replace_result also work on list_files
 
2548
--replace_result file REPLACED_FILE
2410
2549
list_files $MYSQLTEST_VARDIR/tmp/testdir;
2411
2550
# list_files gets the directory list before creating the new file
2412
2551
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *;