summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2006-02-15 12:06:20 -0800
committerunknown <jimw@mysql.com>2006-02-15 12:06:20 -0800
commit2d8e733dd34b02007182cf485e1490066c3fbff5 (patch)
tree8cd64b5f2e36ee7a8a46c176905eeaa0c4c9d709 /libmysql
parent90717a3b1d84a4abf9d19d43910649d4a908c142 (diff)
parent2974245c2170c49362d2bde51386f8c4a393ea40 (diff)
downloadmariadb-git-2d8e733dd34b02007182cf485e1490066c3fbff5.tar.gz
Merge mysql.com:/home/jimw/my/mysql-5.0-clean
into mysql.com:/home/jimw/my/mysql-5.1-clean client/mysqltest.c: Auto merged libmysql/libmysql.c: Auto merged mysql-test/r/mysqltest.result: Auto merged mysql-test/t/mysqltest.test: Auto merged tests/mysql_client_test.c: Auto merged BitKeeper/deleted/.del-ndb_load.result: Auto merged BitKeeper/deleted/.del-ndb_load.test: Auto merged mysql-test/t/disabled.def: Resolve conflict
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/libmysql.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 0bf3b76bf45..4b7aace549a 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -4752,12 +4752,39 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
if (!stmt->field_count)
DBUG_RETURN(0);
- if ((int) stmt->state < (int) MYSQL_STMT_EXECUTE_DONE ||
- mysql->status != MYSQL_STATUS_GET_RESULT)
+
+ if ((int) stmt->state < (int) MYSQL_STMT_EXECUTE_DONE)
+ {
+ set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
+ DBUG_RETURN(1);
+ }
+
+ if (mysql->status == MYSQL_STATUS_READY &&
+ stmt->server_status & SERVER_STATUS_CURSOR_EXISTS)
+ {
+ /*
+ Server side cursor exist, tell server to start sending the rows
+ */
+ NET *net= &mysql->net;
+ char buff[4 /* statement id */ +
+ 4 /* number of rows to fetch */];
+
+ /* Send row request to the server */
+ int4store(buff, stmt->stmt_id);
+ int4store(buff + 4, (int)~0); /* number of rows to fetch */
+ if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
+ NullS, 0, 1))
+ {
+ set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
+ DBUG_RETURN(1);
+ }
+ }
+ else if (mysql->status != MYSQL_STATUS_GET_RESULT)
{
set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
DBUG_RETURN(1);
}
+
if (result->data)
{
free_root(&result->alloc, MYF(MY_KEEP_PREALLOC));
@@ -4798,6 +4825,10 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
DBUG_RETURN(1);
}
+ /* Assert that if there was a cursor, all rows have been fetched */
+ DBUG_ASSERT(mysql->status != MYSQL_STATUS_READY ||
+ (mysql->server_status & SERVER_STATUS_LAST_ROW_SENT));
+
if (stmt->update_max_length)
{
MYSQL_ROWS *cur= result->data;