summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_class.cc2
-rw-r--r--tests/client_test.c48
2 files changed, 49 insertions, 1 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index b103ee29095..2d6c778fab4 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -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,
diff --git a/tests/client_test.c b/tests/client_test.c
index b124fba3f59..0f9d1dba4a7 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -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.