diff options
Diffstat (limited to 'tests/mysql_client_test.c')
-rw-r--r-- | tests/mysql_client_test.c | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 0d7cdd01ccc..f8cdc57b4be 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. + Copyright (c) 2011 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 @@ -378,7 +379,7 @@ static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect) have_innodb= check_have_innodb(mysql); if (!opt_silent) - fprintf(stdout, "OK"); + fprintf(stdout, "OK\n"); return mysql; } @@ -9760,7 +9761,7 @@ static void test_ts() char name; char query[MAX_TEST_QUERY_LENGTH]; const char *queries [3]= {"SELECT a, b, c FROM test_ts WHERE %c=?", - "SELECT a, b, c FROM test_ts WHERE %c=?", + "SELECT a, b, c FROM test_ts WHERE %c=CAST(? AS TIME)", "SELECT a, b, c FROM test_ts WHERE %c=CAST(? AS DATE)"}; myheader("test_ts"); @@ -13179,7 +13180,7 @@ static void test_datetime_ranges() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - my_process_warnings(mysql, 12); + my_process_warnings(mysql, 6); verify_col_data("t1", "year", "0000-00-00 00:00:00"); verify_col_data("t1", "month", "0000-00-00 00:00:00"); @@ -13210,7 +13211,7 @@ static void test_datetime_ranges() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - my_process_warnings(mysql, 6); + my_process_warnings(mysql, 3); verify_col_data("t1", "year", "0000-00-00 00:00:00"); verify_col_data("t1", "month", "0000-00-00 00:00:00"); @@ -19371,7 +19372,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); @@ -19571,6 +19573,71 @@ static void test_bug56976() DBUG_VOID_RETURN; } +/* + Test that CLIENT_PROGRESS works. +*/ + +uint progress_stage, progress_max_stage, progress_count; + +static void report_progress(const MYSQL *mysql __attribute__((unused)), + uint stage, uint max_stage, + double progress __attribute__((unused)), + const char *proc_info __attribute__((unused)), + uint proc_info_length __attribute__((unused))) +{ + progress_stage= stage; + progress_max_stage= max_stage; + progress_count++; +} + + +static void test_progress_reporting() +{ + int rc, i; + MYSQL* conn; + + /* Progress reporting doesn't work yet with embedded server */ + if (embedded_server_arg_count) + return; + + myheader("test_progress_reporting"); + + conn= client_connect(CLIENT_PROGRESS, MYSQL_PROTOCOL_TCP, 0); + DIE_UNLESS(conn->client_flag & CLIENT_PROGRESS); + + mysql_options(conn, MYSQL_PROGRESS_CALLBACK, (void*) report_progress); + rc= mysql_query(conn, "set @save=@@global.progress_report_time"); + myquery(rc); + rc= mysql_query(conn, "set @@global.progress_report_time=1"); + myquery(rc); + + rc= mysql_query(conn, "drop table if exists t1,t2"); + myquery(rc); + rc= mysql_query(conn, "create table t1 (f2 varchar(255)) engine=aria"); + myquery(rc); + rc= mysql_query(conn, "create table t2 like t1"); + myquery(rc); + rc= mysql_query(conn, "insert into t1 (f2) values (repeat('a',100)),(repeat('b',200)),(repeat('c',202)),(repeat('d',202)),(repeat('e',202)),(repeat('f',202)),(repeat('g',23))"); + myquery(rc); + for (i= 0 ; i < 5 ; i++) + { + rc= mysql_query(conn, "insert into t2 (f2) select f2 from t1"); + myquery(rc); + rc= mysql_query(conn, "insert into t1 (f2) select f2 from t2"); + myquery(rc); + } + rc= mysql_query(conn, "alter table t1 add f1 int primary key auto_increment, add key (f2), order by f2"); + myquery(rc); + if (!opt_silent) + printf("Got progress_count: %u stage: %u max_stage: %u\n", + progress_count, progress_stage, progress_max_stage); + DIE_UNLESS(progress_count > 0 && progress_stage >=2 && progress_max_stage == 3); + myquery(rc); + rc= mysql_query(conn, "set @@global.progress_report_time=@save"); + myquery(rc); + client_disconnect(conn, 0); +} + /** Bug#57058 SERVER_QUERY_WAS_SLOW not wired up. @@ -19711,7 +19778,8 @@ static void test_bug12337762() Read and parse arguments and MySQL options from my.cnf */ -static const char *client_test_load_default_groups[]= { "client", 0 }; +static const char *client_test_load_default_groups[]= +{ "client", "client-server", "client-mariadb", 0 }; static char **defaults_argv; static struct my_option client_test_long_options[] = @@ -20050,6 +20118,7 @@ static struct my_tests_st my_tests[]= { { "test_bug56976", test_bug56976 }, { "test_bug11766854", test_bug11766854 }, { "test_bug12337762", test_bug12337762 }, + { "test_progress_reporting", test_progress_reporting }, { 0, 0 } }; |