Skip to content

Commit 6a66479

Browse files
roylysengdahlerlend
authored andcommitted
Bug#35913841: Queries from stored procedures not offloading to secondary engine when we have OUT arguments
Before this patch, RAPID could not handle queries of the type SELECT ... INTO <list of variables>. The reason for this was that these kind of queries were set up with a special Query_result interceptor (Query_dumpvar), whereas regular SELECT queries were set up with Query_result_send, which was substituted on the RAPID side with a special protocol adapter. However, RAPID has also implemented another protocol adapter (an Item wrapper), which is used for INSERT INTO and CREATE TABLE ... SELECT statements. It was noted that this adapter could also be used for SELECT INTO, where the Item wrapper is used as an intermediary for Query_dumpvar. Two new property functions on class Query_result are implemented: use_protocol_adapter() returns true for Query_result_send and use_protocol_wrapper() returns true for Query_dumpvar. An alternative implementation may check these functions for when to use adapters resp. wrappers instead of the original Query result classes. The function is_interceptor() is no longer used and is hence removed. We identify this new requirement in IsSupportedProtocol(), where we explicitly allow Query_dumpvar and Query_result_send query results, and in CreateQEP() where we create the Item wrapper for Query_dumpvar. Notice that this implements SELECT ... INTO both as regular statements, as prepared statements and as procedure statements. Notice also that the syntax variants SELECT ... INTO OUTFILE and SELECT ... INTO DUMPFILE are still not supported. Most of the changes are in the test suite where we have eliminated the earlier ER_SECONDARY_ENGINE_PLUGIN error code. A couple of test lines were removed from the tests rapid.sp and rapid.cp_sp because they gave different results in dict and varlen modes. Change-Id: Icd56cb6fbc32e121a59599a7e5b7d651747804f5
1 parent 3a6acfd commit 6a66479

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

sql/opt_explain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class Query_result_explain : public Query_result_send {
146146
: Query_result_send(), interceptor(interceptor_arg) {
147147
unit = unit_arg;
148148
}
149+
bool use_protocol_adapter() const override { return false; }
149150

150151
protected:
151152
bool prepare(THD *thd, const mem_root_deque<Item *> &list,

sql/query_result.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,16 @@ class Query_result {
150150
*/
151151
virtual void cleanup() { /* do nothing */
152152
}
153-
154153
/**
155-
Checks if this Query_result intercepts and transforms the result set.
156-
157-
@return true if it is an interceptor, false otherwise
154+
@returns true if an alternative implementation may replace this with
155+
a protocol adapter.
156+
*/
157+
virtual bool use_protocol_adapter() const { return false; }
158+
/**
159+
@returns true if an alternative implementation may replace this with
160+
a protocol wrapper.
158161
*/
159-
virtual bool is_interceptor() const { return false; }
162+
virtual bool use_protocol_wrapper() const { return false; }
160163

161164
/// Only overridden (and non-empty) for Query_result_union, q.v.
162165
virtual void set_limit(ha_rows) {}
@@ -182,7 +185,6 @@ class Query_result_interceptor : public Query_result {
182185
uint) override {
183186
return false;
184187
}
185-
bool is_interceptor() const final { return true; }
186188
};
187189

188190
class Query_result_send : public Query_result {
@@ -202,6 +204,11 @@ class Query_result_send : public Query_result {
202204
bool check_supports_cursor() const override { return false; }
203205
void abort_result_set(THD *thd) override;
204206
void cleanup() override { is_result_set_started = false; }
207+
/**
208+
An alternative implementation may provide an optimized protocol adapter
209+
for this object.
210+
*/
211+
bool use_protocol_adapter() const override { return true; }
205212
};
206213

207214
class sql_exchange;
@@ -290,6 +297,11 @@ class Query_dumpvar final : public Query_result_interceptor {
290297
bool send_eof(THD *thd) override;
291298
bool check_supports_cursor() const override;
292299
void cleanup() override { row_count = 0; }
300+
/**
301+
An alternative implementation may provide an optimized protocol wrapper
302+
for this object.
303+
*/
304+
bool use_protocol_wrapper() const override { return true; }
293305
};
294306

295307
/**

sql/sql_prepare.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class Query_fetch_protocol_binary final : public Query_result_send {
220220
uint flags) override;
221221
bool send_data(THD *thd, const mem_root_deque<Item *> &items) override;
222222
bool send_eof(THD *thd) override;
223+
bool use_protocol_adapter() const override { return false; }
223224
};
224225

225226
} // namespace

0 commit comments

Comments
 (0)