diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fork_big2.pl | 284 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 99 |
2 files changed, 213 insertions, 170 deletions
diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index 0d4aee7c774..77b6f305ef5 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -32,21 +32,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 +64,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 +116,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 +188,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 +230,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 +379,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/mysql_client_test.c b/tests/mysql_client_test.c index 5401e360f33..f3943814cb2 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -33,6 +33,7 @@ #include <my_getopt.h> #include <m_string.h> #include <mysqld_error.h> +#include <my_handler.h> #include <sql_common.h> #include <mysql/client_plugin.h> @@ -42,7 +43,9 @@ #define MAX_SERVER_ARGS 64 /* set default options */ +#ifdef NOT_USED static int opt_testcase = 0; +#endif static char *opt_db= 0; static char *opt_user= 0; static char *opt_password= 0; @@ -862,8 +865,10 @@ static void do_verify_prepare_field(MYSQL_RES *result, */ 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) @@ -2532,7 +2537,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; @@ -2571,7 +2576,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); @@ -3307,6 +3312,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). */ @@ -3350,6 +3383,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); @@ -3937,7 +3976,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; @@ -4191,7 +4230,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++) @@ -4506,7 +4545,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; @@ -4535,7 +4574,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; @@ -5104,7 +5143,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); } @@ -5697,7 +5736,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); } @@ -8497,8 +8536,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); @@ -13296,7 +13336,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"); @@ -13319,7 +13359,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; @@ -13344,7 +13384,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); @@ -16589,11 +16629,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 */ @@ -17010,6 +17049,8 @@ static void test_bug27876() rc= mysql_query(mysql, "set names default"); myquery(rc); + + DBUG_VOID_RETURN; } @@ -18168,7 +18209,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; @@ -18191,7 +18232,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; @@ -18813,8 +18854,6 @@ static void test_bug43560(void) Bug#36326: nested transaction and select */ -#ifdef HAVE_QUERY_CACHE - static void test_bug36326() { int rc; @@ -18822,6 +18861,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"); @@ -18861,8 +18906,6 @@ static void test_bug36326() DBUG_VOID_RETURN; } -#endif - /** Bug#41078: With CURSOR_TYPE_READ_ONLY mysql_stmt_fetch() returns short string value. @@ -19673,14 +19716,14 @@ static char **defaults_argv; static struct my_option client_test_long_options[] = { - {"basedir", 'b', "Basedir for tests.", &opt_basedir, - &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"basedir", 'b', "Basedir for tests.", (char**) &opt_basedir, + (char**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"count", 't', "Number of times test to be executed", &opt_count, &opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, {"database", 'D', "Database to use", &opt_db, &opt_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log", &default_dbug_option, - &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (char**) &default_dbug_option, + (char**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host", &opt_host, &opt_host, @@ -19716,8 +19759,8 @@ static struct my_option client_test_long_options[] = {"user", 'u', "User for login if not current user", &opt_user, &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"vardir", 'v', "Data dir for tests.", &opt_vardir, - &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"vardir", 'v', "Data dir for tests.", (char**) &opt_vardir, + (char**) &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"getopt-ll-test", 'g', "Option for testing bug in getopt library", &opt_getopt_ll_test, &opt_getopt_ll_test, 0, GET_LL, REQUIRED_ARG, 0, 0, LONGLONG_MAX, 0, 0, 0}, @@ -19995,9 +20038,7 @@ static struct my_tests_st my_tests[]= { { "test_bug33831", test_bug33831 }, { "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_bug49972", test_bug49972 }, @@ -20022,7 +20063,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), DBUG_PUSH(argument ? argument : default_dbug_option); break; case 'c': +#ifdef NOT_USED opt_testcase = 1; +#endif break; case 'p': if (argument) |