diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/big_record.pl | 15 | ||||
-rwxr-xr-x | tests/drop_test.pl | 16 | ||||
-rwxr-xr-x | tests/export.pl | 15 | ||||
-rwxr-xr-x | tests/fork2_test.pl | 15 | ||||
-rwxr-xr-x | tests/fork_big.pl | 16 | ||||
-rw-r--r-- | tests/fork_big2.pl | 300 | ||||
-rwxr-xr-x | tests/grant.pl | 1 | ||||
-rwxr-xr-x | tests/index_corrupt.pl | 16 | ||||
-rwxr-xr-x | tests/insert_and_repair.pl | 16 | ||||
-rwxr-xr-x | tests/lock_test.pl | 15 | ||||
-rw-r--r-- | tests/mysql_client_fw.c | 5 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 86 | ||||
-rwxr-xr-x | tests/pmail.pl | 16 | ||||
-rwxr-xr-x | tests/rename_test.pl | 16 | ||||
-rwxr-xr-x | tests/table_types.pl | 16 | ||||
-rwxr-xr-x | tests/test_delayed_insert.pl | 15 | ||||
-rwxr-xr-x | tests/truncate.pl | 16 |
19 files changed, 211 insertions, 390 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2093fc0da36..30afebb46bd 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,7 +15,6 @@ # About "mysqlclient_notls", see note in "client/CMakeLists.txt" -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") ADD_DEFINITIONS("-DMYSQL_CLIENT") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) @@ -25,3 +24,5 @@ TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient_notls wsock32) ADD_EXECUTABLE(bug25714 bug25714.c) TARGET_LINK_LIBRARIES(bug25714 mysqlclient_notls wsock32) + +INSTALL(TARGETS mysql_client_test bug25714 DESTINATION bin COMPONENT runtime) diff --git a/tests/Makefile.am b/tests/Makefile.am index 3da18683f85..48ac873fcd0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -63,6 +63,3 @@ DEFS = -DMYSQL_CLIENT_NO_THREADS thread_test.o: thread_test.c $(COMPILE) -c $(INCLUDES) $< - -# Don't update the files from bitkeeper -%::SCCS/s.% diff --git a/tests/big_record.pl b/tests/big_record.pl index 77d1e613193..fbe94e3540f 100755 --- a/tests/big_record.pl +++ b/tests/big_record.pl @@ -1,20 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2000, 2003 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # This is a test with stores big records in a blob. # Note that for the default test the mysql server should have been # started with at least 'mysqld -O max_allowed_packet=30M' and you should have diff --git a/tests/drop_test.pl b/tests/drop_test.pl index 272c4029e0f..9dcadf45c2e 100755 --- a/tests/drop_test.pl +++ b/tests/drop_test.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2000 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # This is a test with uses processes to insert, select and drop tables. # diff --git a/tests/export.pl b/tests/export.pl index d543ede8697..29f0d1af8ff 100755 --- a/tests/export.pl +++ b/tests/export.pl @@ -1,20 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2000, 2001 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # This is a test with uses two processes to a database. # The other inserts records in two tables, the other does a lot of joins # on these. diff --git a/tests/fork2_test.pl b/tests/fork2_test.pl index 64e3e060b09..19fab5a67d6 100755 --- a/tests/fork2_test.pl +++ b/tests/fork2_test.pl @@ -1,20 +1,5 @@ #!/usr/bin/perl -w -# Copyright (C) 2000, 2001 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # This is a test with uses 5 processes to insert, update and select from # two tables. # One inserts records in the tables, one updates some record in it and diff --git a/tests/fork_big.pl b/tests/fork_big.pl index a674f7f7164..5c4f11b00e2 100755 --- a/tests/fork_big.pl +++ b/tests/fork_big.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2001 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # This is a test with uses many processes to test a MySQL server. # diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index 0d4aee7c774..f22aeaa6713 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2002, 2005 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # This is a test with uses many processes to test a MySQL server. # @@ -32,21 +16,21 @@ package main; $opt_skip_create=$opt_skip_in=$opt_verbose=$opt_fast_insert= $opt_lock_tables=$opt_debug=$opt_skip_drop=$opt_fast=$opt_force=0; -$opt_thread_factor=1;
-$opt_insert=1;
-$opt_select=6;$opt_join=4;
-$opt_select_count=$opt_join_count=0;
-$opt_update=1;$opt_delete=0;
-$opt_flush=$opt_check=$opt_repair=$opt_alter=0;
-$opt_join_range=100;
+$opt_thread_factor=1; +$opt_insert=1; +$opt_select=6;$opt_join=4; +$opt_select_count=$opt_join_count=0; +$opt_update=1;$opt_delete=0; +$opt_flush=$opt_check=$opt_repair=$opt_alter=0; +$opt_join_range=100; $opt_resize_interval=0; $opt_time=0; $opt_host=$opt_user=$opt_password=""; $opt_db="test"; $opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these -GetOptions("host=s","db=s","user=s","password=s","loop-count=i","skip-create","skip-in","skip-drop",
- "verbose","fast-insert","lock-tables","debug","fast","force","thread-factor=i",
- "insert=i", "select=i", "join=i", "select-count=i", "join-count=i", "update=i", "delete=i",
+GetOptions("host=s","db=s","user=s","password=s","loop-count=i","skip-create","skip-in","skip-drop", + "verbose","fast-insert","lock-tables","debug","fast","force","thread-factor=i", + "insert=i", "select=i", "join=i", "select-count=i", "join-count=i", "update=i", "delete=i", "flush=i", "check=i", "repair=i", "alter=i", "resize-interval=i", "max-join_range=i", "time=i") || die "Aborted"; print "Test of multiple connections that test the following things:\n"; @@ -64,20 +48,20 @@ srand 100; # Make random numbers repeatable #### #### Start timeing and start test -####
-
+#### + $opt_insert*=$opt_thread_factor; -$opt_select*=$opt_thread_factor;
-$opt_join*=$opt_thread_factor;
-$opt_select_count*=$opt_thread_factor;
-$opt_join_count*=$opt_thread_factor;
-$opt_update*=$opt_thread_factor;
-$opt_delete*=$opt_thread_factor;
-
-if ($opt_time == 0 && $opt_insert == 0)
-{
- $opt_insert=1;
-}
+$opt_select*=$opt_thread_factor; +$opt_join*=$opt_thread_factor; +$opt_select_count*=$opt_thread_factor; +$opt_join_count*=$opt_thread_factor; +$opt_update*=$opt_thread_factor; +$opt_delete*=$opt_thread_factor; + +if ($opt_time == 0 && $opt_insert == 0) +{ + $opt_insert=1; +} $start_time=new Benchmark; $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", @@ -116,71 +100,71 @@ $|= 1; # Autoflush #### #### Start the tests #### -if ($opt_time != 0)
-{
- test_abort() if (($pid=fork()) == 0); $work{$pid}="abort";
+if ($opt_time != 0) +{ + test_abort() if (($pid=fork()) == 0); $work{$pid}="abort"; } for ($i=0 ; $i < $opt_insert ; $i ++) { test_insert() if (($pid=fork()) == 0); $work{$pid}="insert"; -}
+} $threads=$i; -for ($i=0 ; $i < $opt_select ; $i ++)
-{
- test_select() if (($pid=fork()) == 0); $work{$pid}="select";
-}
-$threads+=$i;
-for ($i=0 ; $i < $opt_join ; $i ++)
-{
- test_join() if (($pid=fork()) == 0); $work{$pid}="join";
-}
-$threads+=$i;
+for ($i=0 ; $i < $opt_select ; $i ++) +{ + test_select() if (($pid=fork()) == 0); $work{$pid}="select"; +} +$threads+=$i; +for ($i=0 ; $i < $opt_join ; $i ++) +{ + test_join() if (($pid=fork()) == 0); $work{$pid}="join"; +} +$threads+=$i; for ($i=0 ; $i < $opt_select_count ; $i ++) { test_select_count() if (($pid=fork()) == 0); $work{$pid}="select_count"; } -$threads+=$i;
-for ($i=0 ; $i < $opt_join_count ; $i ++)
-{
- test_join_count() if (($pid=fork()) == 0); $work{$pid}="join_count";
-}
-$threads+=$i;
-for ($i=0 ; $i < $opt_update ; $i ++)
-{
- test_update() if (($pid=fork()) == 0); $work{$pid}="update";
-}
-$threads+=$i;
-for ($i=0 ; $i < $opt_delete ; $i ++)
-{
- test_delete() if (($pid=fork()) == 0); $work{$pid}="delete";
-}
-$threads+=$i;
-for ($i=0 ; $i < $opt_flush ; $i ++)
-{
- test_flush() if (($pid=fork()) == 0); $work{$pid}="flush";
-}
-$threads+=$i;
-for ($i=0 ; $i < $opt_check ; $i ++)
-{
- test_check() if (($pid=fork()) == 0); $work{$pid}="check";
-}
-$threads+=$i;
-for ($i=0 ; $i < $opt_repair ; $i ++)
-{
- test_repair() if (($pid=fork()) == 0); $work{$pid}="repair";
-}
-$threads+=$i;
-for ($i=0 ; $i < $opt_alter ; $i ++)
-{
- test_alter() if (($pid=fork()) == 0); $work{$pid}="alter";
-}
-$threads+=$i;
+$threads+=$i; +for ($i=0 ; $i < $opt_join_count ; $i ++) +{ + test_join_count() if (($pid=fork()) == 0); $work{$pid}="join_count"; +} +$threads+=$i; +for ($i=0 ; $i < $opt_update ; $i ++) +{ + test_update() if (($pid=fork()) == 0); $work{$pid}="update"; +} +$threads+=$i; +for ($i=0 ; $i < $opt_delete ; $i ++) +{ + test_delete() if (($pid=fork()) == 0); $work{$pid}="delete"; +} +$threads+=$i; +for ($i=0 ; $i < $opt_flush ; $i ++) +{ + test_flush() if (($pid=fork()) == 0); $work{$pid}="flush"; +} +$threads+=$i; +for ($i=0 ; $i < $opt_check ; $i ++) +{ + test_check() if (($pid=fork()) == 0); $work{$pid}="check"; +} +$threads+=$i; +for ($i=0 ; $i < $opt_repair ; $i ++) +{ + test_repair() if (($pid=fork()) == 0); $work{$pid}="repair"; +} +$threads+=$i; +for ($i=0 ; $i < $opt_alter ; $i ++) +{ + test_alter() if (($pid=fork()) == 0); $work{$pid}="alter"; +} +$threads+=$i; if ($opt_resize_interval != 0) { test_resize() if (($pid=fork()) == 0); $work{$pid}="resize"; $threads+=1; } -
+ print "Started $threads threads\n"; $errors=0; @@ -188,17 +172,17 @@ $running_insert_threads=$opt_insert; while (($pid=wait()) != -1) { $ret=$?/256; - print "thread '" . $work{$pid} . "' finished with exit code $ret\n";
- if ($opt_time == 0)
+ print "thread '" . $work{$pid} . "' finished with exit code $ret\n"; + if ($opt_time == 0) { if ($work{$pid} =~ /^insert/) { if (!--$running_insert_threads) - {
-
+ { + # Time to stop other threads signal_abort(); - }
+ } } } $errors++ if ($ret != 0); @@ -230,17 +214,17 @@ print "Total time: " . exit(0); -#
-# Sleep and then abort other threads
-#
-
-sub test_abort
-{
- sleep($opt_time);
- signal_abort();
- exit(0);
-}
-
+# +# Sleep and then abort other threads +# + +sub test_abort +{ + sleep($opt_time); + signal_abort(); + exit(0); +} + # # Insert records in the table @@ -379,58 +363,58 @@ sub test_join $dbh->disconnect; $dbh=0; print "Test_join: Executed $count joins\n"; exit(0); -}
-
-#
-# select records
-# Do continously joins between the first and second for range and count selected rows
-#
-
-sub test_join_count
-{
- my ($dbh, $i, $j, $count, $loop);
-
- $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host",
- $opt_user, $opt_password,
- { PrintError => 0}) || die $DBI::errstr;
-
- $count_query=make_count_query($numtables);
- $count=0;
- $loop=9999;
- $sum=0;
-
- srand();
-
- $i=0;
- while (($i++ % 10) || !test_if_abort($dbh))
- {
- if ($loop++ >= 10)
- {
- $loop=0;
- $row_counts=simple_query($dbh, $count_query);
- }
- for ($j=0 ; $j < $numtables-1 ; $j++)
- {
- my ($id1)= int rand $row_counts->[$j];
- my ($id2)= int rand $row_counts->[$j];
- if ($id1 > $id2)
- {
- my $id0=$id1; $id1=$id2; $id2=$id0;
- if ($id2-$id1 > $opt_join_range)
- {
- $id2=$id1+$opt_join_range;
- }
- }
- my ($t1,$t2)= ($testtables[$j]->[0],$testtables[$j+1]->[0]);
- $row=simple_query($dbh, "select count(*) from $t1, $t2 where $t1.id=$t2.id and $t1.id between $id1 and $id2");
- $sum+=$row->[0];
- $count++;
- }
- }
- $dbh->disconnect; $dbh=0;
- print "Test_join_count: Executed $count joins: total $sum rows\n";
- exit(0);
-}
+} + +# +# select records +# Do continously joins between the first and second for range and count selected rows +# + +sub test_join_count +{ + my ($dbh, $i, $j, $count, $loop); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $count_query=make_count_query($numtables); + $count=0; + $loop=9999; + $sum=0; + + srand(); + + $i=0; + while (($i++ % 10) || !test_if_abort($dbh)) + { + if ($loop++ >= 10) + { + $loop=0; + $row_counts=simple_query($dbh, $count_query); + } + for ($j=0 ; $j < $numtables-1 ; $j++) + { + my ($id1)= int rand $row_counts->[$j]; + my ($id2)= int rand $row_counts->[$j]; + if ($id1 > $id2) + { + my $id0=$id1; $id1=$id2; $id2=$id0; + if ($id2-$id1 > $opt_join_range) + { + $id2=$id1+$opt_join_range; + } + } + my ($t1,$t2)= ($testtables[$j]->[0],$testtables[$j+1]->[0]); + $row=simple_query($dbh, "select count(*) from $t1, $t2 where $t1.id=$t2.id and $t1.id between $id1 and $id2"); + $sum+=$row->[0]; + $count++; + } + } + $dbh->disconnect; $dbh=0; + print "Test_join_count: Executed $count joins: total $sum rows\n"; + exit(0); +} # diff --git a/tests/grant.pl b/tests/grant.pl index 23a7d2110fb..a2465d19bb1 100755 --- a/tests/grant.pl +++ b/tests/grant.pl @@ -1,5 +1,4 @@ #!/usr/bin/perl - # Copyright (c) 2000, 2005 MySQL AB, 2009 Sun Microsystems, Inc. # Use is subject to license terms. # diff --git a/tests/index_corrupt.pl b/tests/index_corrupt.pl index fa4c8151277..19bf54f5d11 100755 --- a/tests/index_corrupt.pl +++ b/tests/index_corrupt.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2005 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # This is a test for a key cache bug (bug #10167) # To expose the bug mysqld should be started with --key-buffer-size=64K diff --git a/tests/insert_and_repair.pl b/tests/insert_and_repair.pl index 00ab20f051b..1c7186bb651 100755 --- a/tests/insert_and_repair.pl +++ b/tests/insert_and_repair.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2000, 2001 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # This is a test of insert and repair/check. # diff --git a/tests/lock_test.pl b/tests/lock_test.pl index a40bec681f6..5daeeddad8e 100755 --- a/tests/lock_test.pl +++ b/tests/lock_test.pl @@ -1,20 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2000 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # This is a test with uses two processes to a database. # The other inserts records in two tables, the other does a lot of joins # on these. diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index 34a4c05215b..ec909c91079 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -20,6 +20,7 @@ #include <my_getopt.h> #include <m_string.h> #include <mysqld_error.h> +#include <my_handler.h> #define VER "2.1" #define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */ @@ -27,7 +28,7 @@ #define MAX_SERVER_ARGS 64 /* set default options */ -static int opt_testcase = 0; +static int opt_testcase __attribute__((unused)) = 0; static char *opt_db= 0; static char *opt_user= 0; static char *opt_password= 0; @@ -768,8 +769,10 @@ const char *file, int line) */ if (length && (field->length != expected_field_length)) { + fflush(stdout); fprintf(stderr, "Expected field length: %llu, got length: %lu\n", expected_field_length, field->length); + fflush(stderr); DIE_UNLESS(field->length == expected_field_length); } if (def) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index c38695db1b1..5f9d7bc76c8 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. + Copyright (c) 2008, 2012, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -593,7 +594,7 @@ static void test_prepare() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 100; tiny_data++) { - length[1]= sprintf(str_data, "MySQL%d", int_data); + length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -632,7 +633,7 @@ static void test_prepare() /* now, execute the prepared statement to insert 10 records.. */ for (o_tiny_data= 0; o_tiny_data < 100; o_tiny_data++) { - len= sprintf(data, "MySQL%d", o_int_data); + len= my_sprintf(data, (data, "MySQL%d", o_int_data)); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); @@ -1368,6 +1369,34 @@ static uint query_cache_hits(MYSQL *conn) /* + Check that query cache is available in server. +*/ +static my_bool is_query_cache_available() +{ + int rc; + MYSQL_RES *result; + MYSQL_ROW row; + int res= -1; + + rc= mysql_query(mysql, "SHOW VARIABLES LIKE 'have_query_cache'"); + myquery(rc); + + result= mysql_store_result(mysql); + DIE_UNLESS(result); + + row= mysql_fetch_row(result); + DIE_UNLESS(row != NULL); + if (strcmp(row[1], "YES") == 0) + res= 1; + else if (strcmp(row[1], "NO") == 0) + res= 0; + mysql_free_result(result); + + DIE_UNLESS(res == 0 || res == 1); + return res; +} + +/* Test that prepared statements make use of the query cache just as normal statements (BUG#735). */ @@ -1411,6 +1440,12 @@ static void test_ps_query_cache() myheader("test_ps_query_cache"); + if (! is_query_cache_available()) + { + fprintf(stdout, "Skipping test_ps_query_cache: Query cache not available.\n"); + return; + } + rc= mysql_query(mysql, "SET SQL_MODE=''"); myquery(rc); @@ -1998,7 +2033,7 @@ static void test_simple_update() my_bind[0].buffer= szData; /* string data */ my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= sprintf(szData, "updated-data"); + length[0]= my_sprintf(szData, (szData, "updated-data")); my_bind[1].buffer= (void *) &nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -2252,7 +2287,7 @@ static void test_long_data_str1() rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); - length= sprintf(data, "MySQL AB"); + length= my_sprintf(data, (data, "MySQL AB")); /* supply data in pieces */ for (i= 0; i < 3; i++) @@ -2567,7 +2602,7 @@ static void test_update() my_bind[0].buffer= szData; my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= sprintf(szData, "inserted-data"); + length[0]= my_sprintf(szData, (szData, "inserted-data")); my_bind[1].buffer= (void *)&nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -2596,7 +2631,7 @@ static void test_update() my_bind[0].buffer= szData; my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= sprintf(szData, "updated-data"); + length[0]= my_sprintf(szData, (szData, "updated-data")); my_bind[1].buffer= (void *)&nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -3165,7 +3200,7 @@ static void bind_fetch(int row_count) /* CHAR */ { char buff[20]; - long len= sprintf(buff, "%d", rc); + long len= my_sprintf(buff, (buff, "%d", rc)); DIE_UNLESS(strcmp(s_data, buff) == 0); DIE_UNLESS(length[6] == (ulong) len); } @@ -3758,7 +3793,7 @@ static void test_insert() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 3; tiny_data++) { - length= sprintf(str_data, "MySQL%d", tiny_data); + length= my_sprintf(str_data, (str_data, "MySQL%d", tiny_data)); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } @@ -6767,8 +6802,9 @@ static void test_explain_bug() "", "", NAME_CHAR_LEN*MAX_KEY, 0); } + /* The length of this may verify between MariaDB versions (1024 / 2048) */ verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, - "", "", "", NAME_CHAR_LEN*16, 0); + "", "", "", NAME_CHAR_LEN * HA_MAX_KEY_SEG, 0); verify_prepare_field(result, 8, "rows", "", MYSQL_TYPE_LONGLONG, "", "", "", 10, 0); @@ -11566,7 +11602,7 @@ static void test_conversion() const char *stmt_text; int rc; MYSQL_BIND my_bind[1]; - char buff[4]; + uchar buff[4]; ulong length; myheader("test_conversion"); @@ -11589,7 +11625,7 @@ static void test_conversion() check_execute(stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); - my_bind[0].buffer= buff; + my_bind[0].buffer= (char*) buff; my_bind[0].length= &length; my_bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -11614,7 +11650,7 @@ static void test_conversion() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); DIE_UNLESS(length == 1); - DIE_UNLESS((uchar) buff[0] == 0xE0); + DIE_UNLESS(buff[0] == 0xE0); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); @@ -14857,11 +14893,10 @@ static void test_bug21206() static void test_status() { - const char *status; DBUG_ENTER("test_status"); myheader("test_status"); - if (!(status= mysql_stat(mysql))) + if (!mysql_stat(mysql)) { myerror("mysql_stat failed"); /* purecov: inspected */ die(__FILE__, __LINE__, "mysql_stat failed"); /* purecov: inspected */ @@ -15278,6 +15313,8 @@ static void test_bug27876() rc= mysql_query(mysql, "set names default"); myquery(rc); + + DBUG_VOID_RETURN; } @@ -16435,7 +16472,7 @@ static void test_wl4166_1() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 10; tiny_data++) { - length[1]= sprintf(str_data, "MySQL%d", int_data); + length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -16458,7 +16495,7 @@ static void test_wl4166_1() for (tiny_data= 50; tiny_data < 60; tiny_data++) { - length[1]= sprintf(str_data, "MySQL%d", int_data); + length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -16779,8 +16816,6 @@ static void test_bug43560(void) Bug#36326: nested transaction and select */ -#ifdef HAVE_QUERY_CACHE - static void test_bug36326() { int rc; @@ -16788,6 +16823,12 @@ static void test_bug36326() DBUG_ENTER("test_bug36326"); myheader("test_bug36326"); + if (! is_query_cache_available()) + { + fprintf(stdout, "Skipping test_bug36326: Query cache not available.\n"); + DBUG_VOID_RETURN; + } + rc= mysql_autocommit(mysql, TRUE); myquery(rc); rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); @@ -16827,8 +16868,6 @@ static void test_bug36326() DBUG_VOID_RETURN; } -#endif - /** Bug#41078: With CURSOR_TYPE_READ_ONLY mysql_stmt_fetch() returns short string value. @@ -17331,7 +17370,8 @@ static void test_bug58036() if (!opt_silent) printf("Got mysql_real_connect() error (expected): %s (%d)\n", mysql_error(conn), mysql_errno(conn)); - DIE_UNLESS(mysql_errno(conn) == ER_WRONG_VALUE_FOR_VAR); + DIE_UNLESS(mysql_errno(conn) == ER_WRONG_VALUE_FOR_VAR || + mysql_errno(conn)== CR_CANT_READ_CHARSET); mysql_close(conn); @@ -17740,9 +17780,7 @@ static struct my_tests_st my_tests[]= { { "test_bug38486", test_bug38486 }, { "test_bug40365", test_bug40365 }, { "test_bug43560", test_bug43560 }, -#ifdef HAVE_QUERY_CACHE { "test_bug36326", test_bug36326 }, -#endif { "test_bug41078", test_bug41078 }, { "test_bug44495", test_bug44495 }, { "test_bug42373", test_bug42373 }, diff --git a/tests/pmail.pl b/tests/pmail.pl index 38905832069..02d5d60ac0f 100755 --- a/tests/pmail.pl +++ b/tests/pmail.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2000, 2005 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # Prints mails to standard output # diff --git a/tests/rename_test.pl b/tests/rename_test.pl index 23fc33c9095..edf3216a62f 100755 --- a/tests/rename_test.pl +++ b/tests/rename_test.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2000, 2001 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # This is a test with uses processes to insert, select and drop tables. # diff --git a/tests/table_types.pl b/tests/table_types.pl index 23d26215abe..4dbcdcb975c 100755 --- a/tests/table_types.pl +++ b/tests/table_types.pl @@ -1,19 +1,5 @@ #!/usr/bin/perl - -# Copyright (C) 2000, 2003 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# use DBI; use Benchmark; diff --git a/tests/test_delayed_insert.pl b/tests/test_delayed_insert.pl index 5046c4fb580..c7a8f0ca4b7 100755 --- a/tests/test_delayed_insert.pl +++ b/tests/test_delayed_insert.pl @@ -1,20 +1,5 @@ #!/usr/bin/perl -w -# Copyright (C) 2000, 2001 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # This is a test for INSERT DELAYED # diff --git a/tests/truncate.pl b/tests/truncate.pl index 85e826fd4cd..57b50cf96b6 100755 --- a/tests/truncate.pl +++ b/tests/truncate.pl @@ -1,20 +1,4 @@ #!/usr/bin/perl -w - -# Copyright (C) 2002 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # # This is a test with uses many processes to test a MySQL server. # |