diff options
author | Igor Babaev <igor@askmonty.org> | 2019-02-12 22:56:24 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2019-02-12 22:56:24 -0800 |
commit | 27c3abde3071ad2010cbcda5b07435ad15364a70 (patch) | |
tree | 0d4e4066762076beaba6c8d2e774202be7146e2c /sql/derived_handler.cc | |
parent | 17d00d9a94da2c2b57fc7cf75036d92ee6dc9298 (diff) | |
download | mariadb-git-27c3abde3071ad2010cbcda5b07435ad15364a70.tar.gz |
MDEV-17096 Pushdown of simple derived tables to storage engines
MDEV-17631 select_handler for a full query pushdown
Added comments and file headers for files introduced in these tasks.
Diffstat (limited to 'sql/derived_handler.cc')
-rw-r--r-- | sql/derived_handler.cc | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/sql/derived_handler.cc b/sql/derived_handler.cc index 1fa5e94a1d4..76fd736de2b 100644 --- a/sql/derived_handler.cc +++ b/sql/derived_handler.cc @@ -1,18 +1,41 @@ +/* + Copyright (c) 2018, 2019 MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + #include "mariadb.h" #include "sql_priv.h" #include "sql_select.h" #include "derived_handler.h" -void derived_handler::set_derived(TABLE_LIST *tbl) -{ - derived= tbl; - table= tbl->table; - unit= tbl->derived; - select= unit->first_select(); - tmp_table_param= select->next_select() ? - ((select_unit *)(unit->result))->get_tmp_table_param() : - &select->join->tmp_table_param; -} + +/** + The methods of the Pushdown_derived class. + + The objects of this class are used for pushdown of the derived tables + into engines. The main method of the class is Pushdown_derived::execute() + that initiates execution of the query specifying a derived by a foreign + engine, receives the rows of the result set and put them in a temporary + table on the server side. + + The method uses only the functions of the derived_handle interface to do + this. The constructor of the class gets this interface as a parameter. + + Currently a derived tables pushed into an engine is always materialized. + It could be changed if the cases when the tables is used as driving table. +*/ + Pushdown_derived::Pushdown_derived(TABLE_LIST *tbl, derived_handler *h) : derived(tbl), handler(h) @@ -20,11 +43,13 @@ Pushdown_derived::Pushdown_derived(TABLE_LIST *tbl, derived_handler *h) is_analyze= handler->thd->lex->analyze_stmt; } + Pushdown_derived::~Pushdown_derived() { delete handler; } + int Pushdown_derived::execute() { int err; @@ -82,3 +107,21 @@ error_2: DBUG_RETURN(-1); // Error not sent to client } + +void derived_handler::print_error(int error, myf errflag) +{ + my_error(ER_GET_ERRNO, MYF(0), error, hton_name(ht)->str); +} + + +void derived_handler::set_derived(TABLE_LIST *tbl) +{ + derived= tbl; + table= tbl->table; + unit= tbl->derived; + select= unit->first_select(); + tmp_table_param= select->next_select() ? + ((select_unit *)(unit->result))->get_tmp_table_param() : + &select->join->tmp_table_param; +} + |