summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2012-08-21 08:46:32 +0300
committerMichael Widenius <monty@askmonty.org>2012-08-21 08:46:32 +0300
commita45c451e4002875187a40ec17e872d3b69a3452a (patch)
tree3b77baea158d3e2c0cc92b0f5b01bb3f7eb9ae37 /tests
parent75e8ce6d7316900e3b9431e9d50889fe00d2928c (diff)
downloadmariadb-git-a45c451e4002875187a40ec17e872d3b69a3452a.tar.gz
Fix for bug lp:1039277 "Crash in sql_cache.cc".
The crash happend when combining query cache, prepared statements and using a read only cursor. sql/sql_cache.cc: Fixed unlikely error when one adjust query cache size in middle of operation sql/sql_cursor.cc: Disable query cache when using cursors. This fixed lp:1039277 tests/mysql_client_test.c: Test case for lp:1039277
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 9c2329e609a..a0b18f1f717 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -357,6 +357,7 @@ static void test_prepare_insert_update()
myquery(rc);
}
+
/* Test simple prepares of all DML statements */
static void test_prepare_simple()
@@ -2308,6 +2309,7 @@ static void test_ps_query_cache()
if (!opt_silent)
fprintf(stdout, "OK");
+ break;
}
strmov(query, "select id1, value1 from t1 where id1= ? or "
@@ -13024,6 +13026,49 @@ static void test_bug8880()
mysql_stmt_close(*stmt);
}
+/*
+ Test executing a query with prepared statements while query cache is active
+*/
+
+static void test_open_cursor_prepared_statement_query_cache()
+{
+ MYSQL_STMT *stmt;
+ int rc;
+ MYSQL_RES *result;
+
+ myheader("test_open_cursor_prepared_statement_query_cache");
+ if (! is_query_cache_available())
+ {
+ fprintf(stdout, "Skipping test_open_cursor_prepared_statement_query_cache: Query cache not available.\n");
+ return;
+ }
+
+ rc= mysql_query(mysql, "set global query_cache_size=1000000");
+ myquery(rc);
+
+ mysql_query(mysql, "drop table if exists t1");
+ mysql_query(mysql, "create table t1 (a int not null primary key, b int)");
+ rc= mysql_query(mysql, "insert into t1 values (1,1)");
+ myquery(rc); /* one check is enough */
+
+ /* Store query in query cache */
+ rc= mysql_query(mysql, "SELECT * FROM t1");
+ myquery(rc);
+ result= mysql_store_result(mysql);
+ mytest(result);
+ (void) my_process_result_set(result);
+ mysql_free_result(result);
+
+ /* Test using a cursor */
+ stmt= open_cursor("select a from t1");
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "set global query_cache_size=1000000");
+ myquery(rc);
+}
+
static void test_bug9159()
{
@@ -18917,6 +18962,8 @@ static struct my_tests_st my_tests[]= {
{ "test_bug8378", test_bug8378 },
{ "test_bug8722", test_bug8722 },
{ "test_bug8880", test_bug8880 },
+ { "test_open_cursor_prepared_statement_query_cache",
+ test_open_cursor_prepared_statement_query_cache },
{ "test_bug9159", test_bug9159 },
{ "test_bug9520", test_bug9520 },
{ "test_bug9478", test_bug9478 },