Commit 3640843a authored by konstantin@mysql.com's avatar konstantin@mysql.com

A fix and test case for bug#5399 "Wrong statement executed by MySQL

 server" (use my_charset_bin for stmt id hash).
parent dab89186
......@@ -1502,7 +1502,7 @@ Statement_map::Statement_map() :
START_STMT_HASH_SIZE = 16,
START_NAME_HASH_SIZE = 16
};
hash_init(&st_hash, default_charset_info, START_STMT_HASH_SIZE, 0, 0,
hash_init(&st_hash, &my_charset_bin, START_STMT_HASH_SIZE, 0, 0,
get_statement_id_as_hash_key,
delete_statement_as_hash_key, MYF(0));
hash_init(&names_hash, system_charset_info, START_NAME_HASH_SIZE, 0, 0,
......
......@@ -10163,6 +10163,52 @@ static void test_bug4231()
myquery(rc);
}
static void test_bug5399()
{
/*
Ascii 97 is 'a', which gets mapped to Ascii 65 'A' unless internal
statement id hash in the server uses binary collation.
*/
#define NUM_OF_USED_STMT 97
MYSQL_STMT *stmt[NUM_OF_USED_STMT];
MYSQL_BIND bind[1];
char buff[500];
int rc, i;
int32 no;
myheader("test_bug5399");
bzero(bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= &no;
for (i= 0; i < NUM_OF_USED_STMT; ++i)
{
stmt[i]= mysql_stmt_init(mysql);
sprintf(buff, "select %d", i);
rc= mysql_stmt_prepare(stmt[i], buff, strlen(buff));
check_execute(stmt[i], rc);
mysql_stmt_bind_result(stmt[i], bind);
}
printf("%d statements prepared.\n", NUM_OF_USED_STMT);
for (i= 0; i < NUM_OF_USED_STMT; ++i)
{
rc= mysql_stmt_execute(stmt[i]);
check_execute(stmt[i], rc);
rc= mysql_stmt_store_result(stmt[i]);
check_execute(stmt[i], rc);
rc= mysql_stmt_fetch(stmt[i]);
assert(rc == 0);
assert((int32) i == no);
}
for (i= 0; i < NUM_OF_USED_STMT; ++i)
mysql_stmt_close(stmt[i]);
#undef NUM_OF_USED_STMT
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
......@@ -10463,6 +10509,8 @@ int main(int argc, char **argv)
test_bug5126(); /* support for mediumint type in libmysql */
test_bug4231(); /* proper handling of all-zero times and
dates in the server */
test_bug5399(); /* check that statement id uniquely identifies
statement */
/*
XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST
DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH.
......
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