Cleanup: rename select_send::status to select_send::is_result_set_started.
Add select_send::cleanup. Fix a compilation warning. Issues spotted while working on the fix for Bug#12713. sql-common/client.c: Fix a warning. sql/sql_class.cc: Give a variable a more specific name. Rewrite an incorrect comment. Add a cleanup for select_send. The only case now this cleanup can be necessary is when we have a prepared statement inside a stored procedure, and a continue handler. At first execution, the statement is killed after having executed select_send::send_fields. At the second execution it is killed after having executed select_send::send_fields. sql/sql_class.h: Rename a member. Add comments.
This commit is contained in:
parent
6c76397404
commit
9ad4366b7b
@ -1714,7 +1714,6 @@ static MYSQL_METHODS client_methods=
|
|||||||
C_MODE_START
|
C_MODE_START
|
||||||
int mysql_init_character_set(MYSQL *mysql)
|
int mysql_init_character_set(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
NET *net= &mysql->net;
|
|
||||||
const char *default_collation_name;
|
const char *default_collation_name;
|
||||||
|
|
||||||
/* Set character set */
|
/* Set character set */
|
||||||
|
@ -1305,23 +1305,26 @@ bool select_send::send_fields(List<Item> &list, uint flags)
|
|||||||
{
|
{
|
||||||
bool res;
|
bool res;
|
||||||
if (!(res= thd->protocol->send_fields(&list, flags)))
|
if (!(res= thd->protocol->send_fields(&list, flags)))
|
||||||
status= 1;
|
is_result_set_started= 1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void select_send::abort()
|
void select_send::abort()
|
||||||
{
|
{
|
||||||
DBUG_ENTER("select_send::abort");
|
DBUG_ENTER("select_send::abort");
|
||||||
if (status && thd->spcont &&
|
if (is_result_set_started && thd->spcont &&
|
||||||
thd->spcont->find_handler(thd, thd->net.last_errno,
|
thd->spcont->find_handler(thd, thd->net.last_errno,
|
||||||
MYSQL_ERROR::WARN_LEVEL_ERROR))
|
MYSQL_ERROR::WARN_LEVEL_ERROR))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Executing stored procedure without a handler.
|
We're executing a stored procedure, have an open result
|
||||||
Here we should actually send an error to the client,
|
set, an SQL exception conditiona and a handler for it.
|
||||||
but as an error will break a multiple result set, the only thing we
|
In this situation we must abort the current statement,
|
||||||
can do for now is to nicely end the current data set and remembering
|
silence the error and start executing the continue/exit
|
||||||
the error so that the calling routine will abort
|
handler.
|
||||||
|
Before aborting the statement, let's end the open result set, as
|
||||||
|
otherwise the client will hang due to the violation of the
|
||||||
|
client/server protocol.
|
||||||
*/
|
*/
|
||||||
thd->net.report_error= 0;
|
thd->net.report_error= 0;
|
||||||
send_eof();
|
send_eof();
|
||||||
@ -1331,6 +1334,17 @@ void select_send::abort()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Cleanup an instance of this class for re-use
|
||||||
|
at next execution of a prepared statement/
|
||||||
|
stored procedure statement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void select_send::cleanup()
|
||||||
|
{
|
||||||
|
is_result_set_started= FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Send data to client. Returns 0 if ok */
|
/* Send data to client. Returns 0 if ok */
|
||||||
|
|
||||||
bool select_send::send_data(List<Item> &items)
|
bool select_send::send_data(List<Item> &items)
|
||||||
@ -1392,7 +1406,7 @@ bool select_send::send_eof()
|
|||||||
if (! thd->is_error())
|
if (! thd->is_error())
|
||||||
{
|
{
|
||||||
::send_eof(thd);
|
::send_eof(thd);
|
||||||
status= 0;
|
is_result_set_started= 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2051,14 +2051,20 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
class select_send :public select_result {
|
class select_send :public select_result {
|
||||||
int status;
|
/**
|
||||||
|
True if we have sent result set metadata to the client.
|
||||||
|
In this case the client always expects us to end the result
|
||||||
|
set with an eof or error packet
|
||||||
|
*/
|
||||||
|
bool is_result_set_started;
|
||||||
public:
|
public:
|
||||||
select_send() :status(0) {}
|
select_send() :is_result_set_started(FALSE) {}
|
||||||
bool send_fields(List<Item> &list, uint flags);
|
bool send_fields(List<Item> &list, uint flags);
|
||||||
bool send_data(List<Item> &items);
|
bool send_data(List<Item> &items);
|
||||||
bool send_eof();
|
bool send_eof();
|
||||||
virtual bool check_simple_select() const { return FALSE; }
|
virtual bool check_simple_select() const { return FALSE; }
|
||||||
void abort();
|
void abort();
|
||||||
|
virtual void cleanup();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user