summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2005-08-08 19:24:56 +0400
committerunknown <konstantin@mysql.com>2005-08-08 19:24:56 +0400
commit76a280f1805f3c21a7980fe9d04e97d2b100043f (patch)
tree44893bedfeef9d5c2293f49a03f5dda20400322a /sql/sql_prepare.cc
parentcfb8abd6cc384febda21607a6aafcb23700084a0 (diff)
downloadmariadb-git-76a280f1805f3c21a7980fe9d04e97d2b100043f.tar.gz
A fix and a test case for Bug#11909 "mysql_stmt_attr_set
CURSOR_TYPE_READ_ONLY nested queries corrupt result" sql/sql_prepare.cc: If there is a cursor, use its protocol for fetch: Protocol instances have a state and thd->protocol_prep can't be used for multiple cursors. sql/sql_select.cc: - init Cursor::protocol sql/sql_select.h: - add Cursor::protocol tests/mysql_client_test.c: A test case for Bug#11909 "mysql_stmt_attr_set CURSOR_TYPE_READ_ONLY nested queries corrupt result"
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 18707cc6c87..0861bd1b0b2 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -88,6 +88,7 @@ class Prepared_statement: public Statement
{
public:
THD *thd;
+ Protocol *protocol;
Item_param **param_array;
uint param_count;
uint last_errno;
@@ -2021,6 +2022,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
DBUG_VOID_RETURN;
/* If lex->result is set, mysql_execute_command will use it */
stmt->lex->result= &cursor->result;
+ stmt->protocol= &cursor->protocol;
thd->lock_id= &cursor->lock_id;
}
}
@@ -2055,7 +2057,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
}
mysql_log.write(thd, thd->command, "[%lu] %s", stmt->id, thd->query);
- thd->protocol= &thd->protocol_prep; // Switch to binary protocol
+ thd->protocol= stmt->protocol; // Switch to binary protocol
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR);
mysql_execute_command(thd);
@@ -2247,7 +2249,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), QUERY_PRIOR);
- thd->protocol= &thd->protocol_prep; // Switch to binary protocol
+ thd->protocol= stmt->protocol; // Switch to binary protocol
cursor->fetch(num_rows);
thd->protocol= &thd->protocol_simple; // Use normal protocol
@@ -2419,6 +2421,7 @@ Prepared_statement::Prepared_statement(THD *thd_arg)
thd_arg->variables.query_alloc_block_size,
thd_arg->variables.query_prealloc_size),
thd(thd_arg),
+ protocol(&thd_arg->protocol_prep),
param_array(0),
param_count(0),
last_errno(0)