diff options
author | msvensson@neptunus.(none) <> | 2006-02-13 10:56:45 +0100 |
---|---|---|
committer | msvensson@neptunus.(none) <> | 2006-02-13 10:56:45 +0100 |
commit | e486d81a5229647dd3ce8351e5f12925bb8bab6b (patch) | |
tree | df9423e9ea0a29f6defeeb6f015bbe7b40ad2abf /libmysql/libmysql.c | |
parent | e1dabf65e4b2abb698eb75ad5eafdb9e99c66d30 (diff) | |
parent | 5000951ab48b3f995e5eb6e65a50820cc9ebd0c0 (diff) | |
download | mariadb-git-e486d81a5229647dd3ce8351e5f12925bb8bab6b.tar.gz |
Merge neptunus.(none):/home/msvensson/mysql/bug14013/my50-bug14013
into neptunus.(none):/home/msvensson/mysql/mysql-5.0
Diffstat (limited to 'libmysql/libmysql.c')
-rw-r--r-- | libmysql/libmysql.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9825f1ecdfa..7a492e50034 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4757,12 +4757,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)); @@ -4803,6 +4830,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; |