Commit c721cef5 authored by Davi Arnaut's avatar Davi Arnaut

Merge from mysql-5.0-bugteam.

parents 3912c217 d5e84db3
......@@ -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. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment