summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Nozdrin <roman.nozdrin@mariadb.com>2019-05-10 18:07:36 +0300
committerRoman Nozdrin <roman.nozdrin@mariadb.com>2019-05-10 18:11:15 +0300
commit98c66f50fc7dd4076f76336d12284198b86a3bb9 (patch)
tree5f8cec26cbb1850cfcdbb344b66aad66d5320e72
parent44b8b002f56d5d0c5da3d600276965c41d9ab7bf (diff)
downloadmariadb-git-10.4-drrtuy-MCOL-2178.tar.gz
MDEV-XXX find_select_handler now tries its best to find a handlerton that10.4-drrtuy-MCOL-2178
processes the whole query. find_select_handler traverses all tables in all SELECT_LEX_UNITs for the purpose.
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_select.cc33
2 files changed, 22 insertions, 13 deletions
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 58c1dd3dfae..2abf4b2248a 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1514,7 +1514,7 @@ public:
uchar *arg);
Item *pushdown_from_having_into_where(THD *thd, Item *having);
- select_handler *find_select_handler(THD *thd);
+ select_handler *find_select_handler(THD *thd, SELECT_LEX *top_select);
private:
bool m_non_agg_field_used;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9e5e4bf4ee5..720cb214e33 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4572,7 +4572,7 @@ mysql_select(THD *thd,
}
/* Look for a table owned by an engine with the select_handler interface */
- select_lex->select_h= select_lex->find_select_handler(thd);
+ select_lex->select_h= select_lex->find_select_handler(thd, NULL);
if (select_lex->select_h)
{
/* Create a Pushdown_select object for later execution of the query */
@@ -28371,11 +28371,10 @@ Item *remove_pushed_top_conjuncts(THD *thd, Item *cond)
@param thd The thread handler
@details
- The function checks that this is an upper level select and if so looks
- through its tables searching for one whose handlerton owns a
- create_select call-back function. If the call of this function returns
- a select_handler interface object then the server will push the select
- query into this engine.
+ The function traverses through all tables involved searching for one
+ whose handlerton owns a create_select call-back function. If the call
+ of this function returns a select_handler interface object then the
+ server will push the whole select query into this engine.
This is a responsibility of the create_select call-back function to
check whether the engine can execute the query.
@@ -28383,20 +28382,30 @@ Item *remove_pushed_top_conjuncts(THD *thd, Item *cond)
0 otherwise
*/
-select_handler *SELECT_LEX::find_select_handler(THD *thd)
+select_handler *SELECT_LEX::find_select_handler(THD *thd, SELECT_LEX *top_select)
{
- if (next_select())
- return 0;
- if (master_unit()->outer_select())
- return 0;
+ select_handler *sh = NULL;
+
for (TABLE_LIST *tbl= join->tables_list; tbl; tbl= tbl->next_local)
{
if (!tbl->table)
continue;
+ if (tbl->derived)
+ {
+ SELECT_LEX *d_lex= tbl->derived->first_select();
+ while( d_lex )
+ {
+ sh= d_lex->find_select_handler(thd, (top_select) ? top_select : this);
+ d_lex= (tbl->derived->next_unit())
+ ? tbl->derived->next_unit()->first_select() : NULL;
+ }
+ if (sh)
+ return sh;
+ }
handlerton *ht= tbl->table->file->partition_ht();
if (!ht->create_select)
continue;
- select_handler *sh= ht->create_select(thd, this);
+ select_handler *sh= ht->create_select(thd, (top_select) ? top_select : this);
return sh;
}
return 0;