Commit 28e2ca38 authored by Sergei Petrunia's avatar Sergei Petrunia Committed by Sergei Petrunia

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.
parent ff60d07c
......@@ -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;
......@@ -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;
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment