diff options
author | Sergei Petrunia <sergey@mariadb.com> | 2020-02-18 11:27:17 +0000 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2020-03-10 11:22:33 +0300 |
commit | 28e2ca38f2637d05167313db6ffd79e689a56e94 (patch) | |
tree | c5882c1612e7f6518e059fd9d5077b9e173aac62 | |
parent | ff60d07c84b84e010f7609a9b0606a6c31ce28a5 (diff) | |
download | mariadb-git-28e2ca38f2637d05167313db6ffd79e689a56e94.tar.gz |
CLX-77: INSERT ... SELECT returns rows to the client instead of inserting
Make Pushdown_select write output rows into select->join->result, instead of
thd->protocol.
This makes
- SELECT ... INTO @var
- SELECT ... INTO OUTFILE
- INSERT INTO myisam_table SELECT ... FROM clustrix_table
work as intended.
Also fixed the federatedx select pushdown handler:
- Do not fail an assert if the backend no resultset. Produce an error.
- For the SELECT .. INTO syntax, refuse to use Select Handler, because
the impelementation doesn't support this.
-rw-r--r-- | mysql-test/suite/xpand/basics.result | 22 | ||||
-rw-r--r-- | mysql-test/suite/xpand/basics.test | 29 | ||||
-rw-r--r-- | storage/federatedx/federatedx_pushdown.cc | 9 |
3 files changed, 60 insertions, 0 deletions
diff --git a/mysql-test/suite/xpand/basics.result b/mysql-test/suite/xpand/basics.result index 07fb56dc072..be50e614274 100644 --- a/mysql-test/suite/xpand/basics.result +++ b/mysql-test/suite/xpand/basics.result @@ -45,5 +45,27 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10000 2 DERIVED intandtext ALL NULL NULL NULL NULL 10000 DROP TABLE intandtext; +set +optimizer_switch=default, +xpand_derived_handler= default, +xpand_select_handler=default; +# +# CLX-77: INSERT ... SELECT returns rows to the client instead of inserting +# +drop table if exists t1,t2; +create table t1 (a int) engine=xpand; +insert into t1 values (1); +select a into @var from t1; +select @var; +@var +1 +# This must not emit output to the client: +select a into outfile 'tmpfile1' from t1; +create table t2 (a int) engine=myisam; +insert into t2 select * from t1; +select * from t2; +a +1 +drop table t1,t2; USE test; DROP DATABASE xpd; diff --git a/mysql-test/suite/xpand/basics.test b/mysql-test/suite/xpand/basics.test index 0284086bfbd..9777ad22e51 100644 --- a/mysql-test/suite/xpand/basics.test +++ b/mysql-test/suite/xpand/basics.test @@ -34,5 +34,34 @@ EXPLAIN SELECT i,t FROM (SELECT i,t FROM intandtext) t; DROP TABLE intandtext; +set + optimizer_switch=default, + xpand_derived_handler= default, + xpand_select_handler=default; + +--echo # +--echo # CLX-77: INSERT ... SELECT returns rows to the client instead of inserting +--echo # +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +create table t1 (a int) engine=xpand; +insert into t1 values (1); + +select a into @var from t1; +select @var; + +--echo # This must not emit output to the client: +select a into outfile 'tmpfile1' from t1; +let $file=`select concat(@@datadir,'/clx/tmpfile1')`; + +--remove_file $file + +create table t2 (a int) engine=myisam; +insert into t2 select * from t1; +select * from t2; + +drop table t1,t2; USE test; DROP DATABASE xpd; diff --git a/storage/federatedx/federatedx_pushdown.cc b/storage/federatedx/federatedx_pushdown.cc index 2701436ccf5..acd90e95b1c 100644 --- a/storage/federatedx/federatedx_pushdown.cc +++ b/storage/federatedx/federatedx_pushdown.cc @@ -181,6 +181,15 @@ create_federatedx_select_handler(THD* thd, SELECT_LEX *sel) else if (ht != tbl->table->file->partition_ht()) return 0; } + + /* + Currently, ha_federatedx_select_handler::init_scan just takes the + thd->query and sends it to the backend. + This obviously won't work if the SELECT has an INTO part. + Refuse to work in this case. + */ + if (thd->lex->result) + return NULL; /* Currently, ha_federatedx_select_handler::init_scan just takes the |