From 3b236b1dfd1fdc34548e296dc63e75735becd61d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Mar 2005 15:12:53 +0300 Subject: Fixes and test cases for Bug#8880 "Commands out of sync error with cursors" and Bug#9159 "Server crash during mysql_stmt_close". The patch adds support for single-row result sets in cursors. libmysql/libmysql.c: If we wanted a cursor, and the server wasn't able to create one, buffer all rows on client. Currently this is possible only for single row result sets and some SHOW commands. sql/sql_prepare.cc: Properly free resources if there was a request to open a cursor which wasn't fullfilled. Give error on attempt to open a cursor for a statement not returning a result set. sql/sql_select.h: Initialize Item_arena of Cursor object. A case when a cursor object is created but not used is possible with single-row result sets. tests/mysql_client_test.c: Test cases for Bug#8880 and Bug#9159 --- libmysql/libmysql.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libmysql/libmysql.c') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9746cb222fa..47a15dd3fe3 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2862,6 +2862,17 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt) mysql->status= MYSQL_STATUS_READY; stmt->read_row_func= stmt_read_row_from_cursor; } + else if (stmt->flags & CURSOR_TYPE_READ_ONLY) + { + /* + This is a single-row result set, a result set with no rows, EXPLAIN, + SHOW VARIABLES, or some other command which either a) bypasses the + cursors framework in the server and writes rows directly to the + network or b) is more efficient if all (few) result set rows are + precached on client and server's resources are freed. + */ + DBUG_RETURN(mysql_stmt_store_result(stmt)); + } else { stmt->mysql->unbuffered_fetch_owner= &stmt->unbuffered_fetch_cancelled; -- cgit v1.2.1