summaryrefslogtreecommitdiff
path: root/tests/mysql_client_test.c
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2006-02-10 14:50:29 +0100
committerunknown <msvensson@neptunus.(none)>2006-02-10 14:50:29 +0100
commit101e618f7f46fb0012a4166aea7213730a0b4281 (patch)
tree5e837a488d2d41748e956f76d8fd302a9ff588fa /tests/mysql_client_test.c
parentdb16cfc578e389cd63770aab9fe7bc1f520b2413 (diff)
downloadmariadb-git-101e618f7f46fb0012a4166aea7213730a0b4281.tar.gz
Bug#14013 mysql_stmt_store_result() bombs if a cursor is open
- Add code to 'mysql_stmt_store_result' to allow it to be called on a prepared statement with open server side cursor. - Add tests to mysql_client_test that uses 'mysql_stmt_store_result' client/mysqltest.c: Enable cursor protocol(remove the ifdef BUG14013_FIXED) When running in cursor mode, the warnings from execute needs to be extracted after mysql_stmt_execute, put them in a dynamic string for later use. Untabify some tabs. libmysql/libmysql.c: Allow 'mysql_stmt_store_result' to be called on a statement with an open server side cursor. Detect that a server side cursor is open and send a "fetch" to ask for all rows to be sent to the client. Read all binary rows as normal store. Check that server said last row was sent after all binary rows has been sent. tests/mysql_client_test.c: Update 'fetch_n' function to take parameter indicating if 'mysql_stmt_store_result' should be used on the statement. Call fetch_n with parameter set to use 'mysql_stmt_store_result'
Diffstat (limited to 'tests/mysql_client_test.c')
-rw-r--r--tests/mysql_client_test.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 216961b3a80..25729e9f47c 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -1049,7 +1049,10 @@ void stmt_fetch_close(Stmt_fetch *fetch)
reading from the rest.
*/
-my_bool fetch_n(const char **query_list, unsigned query_count)
+enum fetch_type { USE_ROW_BY_ROW_FETCH= 0, USE_STORE_RESULT= 1 };
+
+my_bool fetch_n(const char **query_list, unsigned query_count,
+ enum fetch_type fetch_type)
{
unsigned open_statements= query_count;
int rc, error_count= 0;
@@ -1065,6 +1068,15 @@ my_bool fetch_n(const char **query_list, unsigned query_count)
query_list[fetch - fetch_array]);
}
+ if (fetch_type == USE_STORE_RESULT)
+ {
+ for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch)
+ {
+ rc= mysql_stmt_store_result(fetch->handle);
+ check_execute(fetch->handle, rc);
+ }
+ }
+
while (open_statements)
{
for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch)
@@ -11867,7 +11879,8 @@ static void test_basic_cursors()
fill_tables(basic_tables, sizeof(basic_tables)/sizeof(*basic_tables));
- fetch_n(queries, sizeof(queries)/sizeof(*queries));
+ fetch_n(queries, sizeof(queries)/sizeof(*queries), USE_ROW_BY_ROW_FETCH);
+ fetch_n(queries, sizeof(queries)/sizeof(*queries), USE_STORE_RESULT);
DBUG_VOID_RETURN;
}
@@ -11880,7 +11893,8 @@ static void test_cursors_with_union()
"SELECT t1.id FROM t1 WHERE t1.id < 5"
};
myheader("test_cursors_with_union");
- fetch_n(queries, sizeof(queries)/sizeof(*queries));
+ fetch_n(queries, sizeof(queries)/sizeof(*queries), USE_ROW_BY_ROW_FETCH);
+ fetch_n(queries, sizeof(queries)/sizeof(*queries), USE_STORE_RESULT);
}
/*