summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorunknown <georg@lmy002.wdf.sap.corp>2005-07-15 14:30:47 +0200
committerunknown <georg@lmy002.wdf.sap.corp>2005-07-15 14:30:47 +0200
commit6fcb9c8e8043a2c8687324aee3cb9b88281ac51d (patch)
tree105f8ecab5c2f4717252c2106add0e090806c17a /libmysql
parentba7d8ad734f84c032d2352ecb05f5937855217b3 (diff)
downloadmariadb-git-6fcb9c8e8043a2c8687324aee3cb9b88281ac51d.tar.gz
Fix for bug #11037.
When all rows are fetched subsequent calls to mysql_stmt_fetch return now MYSQL_NO_DATA instead of errorcode 1. libmysql/libmysql.c: fix for bug#11037 tests/mysql_client_test.c: added new testcase for bug #11037
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/libmysql.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index f622b2d2fb2..097983cbbd3 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1774,6 +1774,7 @@ static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row);
static int stmt_read_row_buffered(MYSQL_STMT *stmt, unsigned char **row);
static int stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row);
static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row);
+static int stmt_read_row_no_result_set(MYSQL_STMT *stmt, unsigned char **row);
/*
This function is used in mysql_stmt_store_result if
@@ -2036,7 +2037,7 @@ mysql_stmt_init(MYSQL *mysql)
stmt->list.data= stmt;
stmt->state= MYSQL_STMT_INIT_DONE;
stmt->mysql= mysql;
- stmt->read_row_func= stmt_read_row_no_data;
+ stmt->read_row_func= stmt_read_row_no_result_set;
stmt->prefetch_rows= DEFAULT_PREFETCH_ROWS;
/* The rest of statement members was bzeroed inside malloc */
@@ -2779,6 +2780,13 @@ static int
stmt_read_row_no_data(MYSQL_STMT *stmt __attribute__((unused)),
unsigned char **row __attribute__((unused)))
{
+ return MYSQL_NO_DATA;
+}
+
+static int
+stmt_read_row_no_result_set(MYSQL_STMT *stmt __attribute__((unused)),
+ unsigned char **row __attribute__((unused)))
+{
set_stmt_error(stmt, CR_NO_RESULT_SET, unknown_sqlstate);
return 1;
}
@@ -4600,7 +4608,8 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt)
((rc= stmt_fetch_row(stmt, row)) && rc != MYSQL_DATA_TRUNCATED))
{
stmt->state= MYSQL_STMT_PREPARE_DONE; /* XXX: this is buggy */
- stmt->read_row_func= stmt_read_row_no_data;
+ stmt->read_row_func= (rc == MYSQL_NO_DATA) ?
+ stmt_read_row_no_data : stmt_read_row_no_result_set;
}
else
{
@@ -4937,7 +4946,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
for (; param < param_end; param++)
param->long_data_used= 0;
}
- stmt->read_row_func= stmt_read_row_no_data;
+ stmt->read_row_func= stmt_read_row_no_result_set;
if (mysql)
{
if ((int) stmt->state > (int) MYSQL_STMT_PREPARE_DONE)