diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-07-27 15:24:43 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-07-27 15:24:43 -0300 |
commit | c721cef54fcaaeb2a26aeede0deaeeb177a0f063 (patch) | |
tree | e2bc5a6d5c23e05f7063ed7d3b39a5a7575d8325 /tests | |
parent | 3912c2177de53a41e3f4d10381efa9e7c04fc887 (diff) | |
parent | d5e84db34c3e6c5a66deb236b78f91f18edeb23a (diff) | |
download | mariadb-git-c721cef54fcaaeb2a26aeede0deaeeb177a0f063.tar.gz |
Merge from mysql-5.0-bugteam.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index c51e3984fc9..75789c1beb2 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16951,9 +16951,10 @@ static void bug20023_change_user(MYSQL *con) opt_db ? opt_db : "test")); } -static my_bool query_int_variable(MYSQL *con, +static my_bool query_str_variable(MYSQL *con, const char *var_name, - int *var_value) + char *str, + size_t len) { MYSQL_RES *rs; MYSQL_ROW row; @@ -16962,10 +16963,8 @@ static my_bool query_int_variable(MYSQL *con, my_bool is_null; - my_snprintf(query_buffer, - sizeof (query_buffer), - "SELECT %s", - (const char *) var_name); + my_snprintf(query_buffer, sizeof (query_buffer), + "SELECT %s", var_name); DIE_IF(mysql_query(con, query_buffer)); DIE_UNLESS(rs= mysql_store_result(con)); @@ -16974,28 +16973,44 @@ static my_bool query_int_variable(MYSQL *con, is_null= row[0] == NULL; if (!is_null) - *var_value= atoi(row[0]); + my_snprintf(str, len, "%s", row[0]); mysql_free_result(rs); return is_null; } +static my_bool query_int_variable(MYSQL *con, + const char *var_name, + int *var_value) +{ + char str[32]; + my_bool is_null= query_str_variable(con, var_name, str, sizeof(str)); + + if (!is_null) + *var_value= atoi(str); + + return is_null; +} + static void test_bug20023() { MYSQL con; int sql_big_selects_orig; - int max_join_size_orig; + /* + Type of max_join_size is ha_rows, which might be ulong or off_t + depending on the platform or configure options. Preserve the string + to avoid type overflow pitfalls. + */ + char max_join_size_orig[32]; int sql_big_selects_2; int sql_big_selects_3; int sql_big_selects_4; int sql_big_selects_5; -#if NOT_USED char query_buffer[MAX_TEST_QUERY_LENGTH]; -#endif /* Create a new connection. */ @@ -17018,9 +17033,10 @@ static void test_bug20023() "@@session.sql_big_selects", &sql_big_selects_orig); - query_int_variable(&con, + query_str_variable(&con, "@@global.max_join_size", - &max_join_size_orig); + max_join_size_orig, + sizeof(max_join_size_orig)); /*********************************************************************** Test that COM_CHANGE_USER resets the SQL_BIG_SELECTS to the initial value. @@ -17093,25 +17109,16 @@ static void test_bug20023() Check that SQL_BIG_SELECTS will be the original one. ***********************************************************************/ -#if NOT_USED - /* - max_join_size is a ulong or better. - my_snprintf() only goes up to ul. - */ - /* Restore MAX_JOIN_SIZE. */ my_snprintf(query_buffer, sizeof (query_buffer), - "SET @@global.max_join_size = %d", - (int) max_join_size_orig); + "SET @@global.max_join_size = %s", + max_join_size_orig); DIE_IF(mysql_query(&con, query_buffer)); -#else DIE_IF(mysql_query(&con, "SET @@global.max_join_size = -1")); -#endif - DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default")); /* Issue COM_CHANGE_USER. */ |