mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -16270,33 +16270,46 @@ static void bug20023_change_user(MYSQL *con)
|
|||||||
opt_db ? opt_db : "test"));
|
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,
|
const char *var_name,
|
||||||
int *var_value)
|
char *str,
|
||||||
|
size_t len)
|
||||||
{
|
{
|
||||||
MYSQL_RES *rs;
|
MYSQL_RES *rs;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
char query_buffer[MAX_TEST_QUERY_LENGTH];
|
char query_buffer[MAX_TEST_QUERY_LENGTH];
|
||||||
|
|
||||||
my_snprintf(query_buffer,
|
my_snprintf(query_buffer, sizeof (query_buffer),
|
||||||
sizeof (query_buffer),
|
"SELECT @@%s", var_name);
|
||||||
"SELECT @@%s",
|
|
||||||
(const char *) var_name);
|
|
||||||
|
|
||||||
DIE_IF(mysql_query(con, query_buffer));
|
DIE_IF(mysql_query(con, query_buffer));
|
||||||
DIE_UNLESS(rs= mysql_store_result(con));
|
DIE_UNLESS(rs= mysql_store_result(con));
|
||||||
DIE_UNLESS(row= mysql_fetch_row(rs));
|
DIE_UNLESS(row= mysql_fetch_row(rs));
|
||||||
*var_value= atoi(row[0]);
|
my_snprintf(str, len, "%s", row[0]);
|
||||||
mysql_free_result(rs);
|
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()
|
static void test_bug20023()
|
||||||
{
|
{
|
||||||
MYSQL con;
|
MYSQL con;
|
||||||
|
|
||||||
int sql_big_selects_orig;
|
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_2;
|
||||||
int sql_big_selects_3;
|
int sql_big_selects_3;
|
||||||
@ -16326,9 +16339,10 @@ static void test_bug20023()
|
|||||||
"session.sql_big_selects",
|
"session.sql_big_selects",
|
||||||
&sql_big_selects_orig);
|
&sql_big_selects_orig);
|
||||||
|
|
||||||
bug20023_query_int_variable(&con,
|
bug20023_query_str_variable(&con,
|
||||||
"global.max_join_size",
|
"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.
|
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,
|
my_snprintf(query_buffer,
|
||||||
sizeof (query_buffer),
|
sizeof (query_buffer),
|
||||||
"SET @@global.max_join_size = %d",
|
"SET @@global.max_join_size = %s",
|
||||||
(int) max_join_size_orig);
|
max_join_size_orig);
|
||||||
|
|
||||||
DIE_IF(mysql_query(&con, query_buffer));
|
DIE_IF(mysql_query(&con, query_buffer));
|
||||||
DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default"));
|
DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default"));
|
||||||
|
Reference in New Issue
Block a user