summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-07-27 12:31:28 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-07-27 12:31:28 -0300
commitd5e84db34c3e6c5a66deb236b78f91f18edeb23a (patch)
tree94e4738ae12f0effabcda413f0b10c15c0d316dd /tests
parente8a97ae267fd38b0898a59e6449c576e01e54d9b (diff)
downloadmariadb-git-d5e84db34c3e6c5a66deb236b78f91f18edeb23a.tar.gz
Bug#20023: mysql_change_user() resets the value of SQL_BIG_SELECTS
Post-merge fix: test case could fail due to a conversion of the max_join_size value to a integer. Fixed by preserving the value as a string for comparison purposes. tests/mysql_client_test.c: Preserve max_join_size value as a string instead of converting it to a integer -- value can be larger then the type used.
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 2896d5dffdc..040ef4d050d 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -16270,33 +16270,46 @@ static void bug20023_change_user(MYSQL *con)
opt_db ? opt_db : "test"));
}
-static void bug20023_query_int_variable(MYSQL *con,
+static void bug20023_query_str_variable(MYSQL *con,
const char *var_name,
- int *var_value)
+ char *str,
+ size_t len)
{
MYSQL_RES *rs;
MYSQL_ROW row;
char query_buffer[MAX_TEST_QUERY_LENGTH];
- 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));
DIE_UNLESS(row= mysql_fetch_row(rs));
- *var_value= atoi(row[0]);
+ my_snprintf(str, len, "%s", row[0]);
mysql_free_result(rs);
}
+static void bug20023_query_int_variable(MYSQL *con,
+ const char *var_name,
+ int *var_value)
+{
+ char str[32];
+ bug20023_query_str_variable(con, var_name, str, sizeof(str));
+ *var_value= atoi(str);
+}
+
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;
@@ -16326,9 +16339,10 @@ static void test_bug20023()
"session.sql_big_selects",
&sql_big_selects_orig);
- bug20023_query_int_variable(&con,
+ bug20023_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.
@@ -16405,8 +16419,8 @@ static void test_bug20023()
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));
DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default"));