summaryrefslogtreecommitdiff
path: root/sql/select_handler.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2020-03-07 01:14:41 +0300
committerSergei Petrunia <psergey@askmonty.org>2020-03-07 01:14:41 +0300
commitcbbe4971b6b26a5017a7da5ebfd89e3aee9f4387 (patch)
tree1a9ae35e2ac48a9771daaaa5889f2a34a4b7e1ff /sql/select_handler.cc
parent23685378bafa38a74957e8f07e2d56b57e90fa53 (diff)
downloadmariadb-git-cbbe4971b6b26a5017a7da5ebfd89e3aee9f4387.tar.gz
MDEV-21887: federatedx crashes on SELECT ... INTO query in select_handler code
- Don't try to push down SELECTs that have a side effect - In case the storage engine did support pushdown of SELECT with an INTO clause, write the rows we've got from it into select->join->result, and not thd->protocol. This way, SELECT ... INTO ... FROM smart_engine_table will put the result into where instructed, and NOT send it to the client.
Diffstat (limited to 'sql/select_handler.cc')
-rw-r--r--sql/select_handler.cc26
1 files changed, 4 insertions, 22 deletions
diff --git a/sql/select_handler.cc b/sql/select_handler.cc
index c8f92461fd0..4d2cacd1a6e 100644
--- a/sql/select_handler.cc
+++ b/sql/select_handler.cc
@@ -77,18 +77,17 @@ bool Pushdown_select::init()
bool Pushdown_select::send_result_set_metadata()
{
- THD *thd= handler->thd;
- Protocol *protocol= thd->protocol;
DBUG_ENTER("Pushdown_select::send_result_set_metadata");
#ifdef WITH_WSREP
+ THD *thd= handler->thd;
if (WSREP(thd) && thd->wsrep_retry_query)
{
WSREP_DEBUG("skipping select metadata");
DBUG_RETURN(false);
}
#endif /* WITH_WSREP */
- if (protocol->send_result_set_metadata(&result_columns,
+ if (select->join->result->send_result_set_metadata(result_columns,
Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF))
DBUG_RETURN(true);
@@ -99,21 +98,10 @@ bool Pushdown_select::send_result_set_metadata()
bool Pushdown_select::send_data()
{
- THD *thd= handler->thd;
- Protocol *protocol= thd->protocol;
DBUG_ENTER("Pushdown_select::send_data");
- protocol->prepare_for_resend();
- if (protocol->send_result_set_row(&result_columns))
- {
- protocol->remove_last_row();
+ if (select->join->result->send_data(result_columns))
DBUG_RETURN(true);
- }
-
- thd->inc_sent_row_count(1);
-
- if (thd->vio_ok())
- DBUG_RETURN(protocol->write());
DBUG_RETURN(false);
}
@@ -121,16 +109,10 @@ bool Pushdown_select::send_data()
bool Pushdown_select::send_eof()
{
- THD *thd= handler->thd;
DBUG_ENTER("Pushdown_select::send_eof");
- /*
- Don't send EOF if we're in error condition (which implies we've already
- sent or are sending an error)
- */
- if (thd->is_error())
+ if (select->join->result->send_eof())
DBUG_RETURN(true);
- ::my_eof(thd);
DBUG_RETURN(false);
}