Commit 70c7e936 authored by Martin Hansson's avatar Martin Hansson

Backport of Bug#33204 from mysql-pe to

mysql-next-mr-bugfixing.

Bug no 32858 was fixed in two different ways in what was
then called mysql 5.1 and 6.0. The fix in 6.0 was very
different since bugfix no 33204 was present.  Furthermore,
the two fixes were not compatible. Hence in order to
backport Bug#33204 to the 5.1-based mysql-next-mr-bugfixing,
it was necessary to remove the 5.1 fix of 32858 and apply
the 6.0 version of the fix.


mysql-test/r/subselect.result:
  Bug#33204-backport: Test result
mysql-test/r/union.result:
  
  Bug#33204-backport:
  - Reversal of test result: bugfix no 32858 for 5.1
  - Application of test result: bugfix no 32858 for 6.0
mysql-test/t/subselect.test:
  Bug#33204-backport: 
  - Changed tests
  - Test case
mysql-test/t/union.test:
  Bug#33204-backport:
  - Reversal of test: bugfix no 32858 for 5.1
  - Application of test: bugfix no 32858 for 6.0
sql/sql_class.cc:
  Bug#33204-backport: Reversal of bugfix no 32858 for 5.1
sql/sql_class.h:
  Bug#33204-backport: Reversal of bugfix no 32858 for 5.1
sql/sql_yacc.yy:
  Bug#33204-backport:
  - Reversal of bugfix no 32858 for 5.1
  - Application of bugfix no 32858 for 6.0
  - Application of bugfix no 33204
parent 725f93fa
This diff is collapsed.
...@@ -153,48 +153,6 @@ ERROR 42S22: Unknown column 'a' in 'field list' ...@@ -153,48 +153,6 @@ ERROR 42S22: Unknown column 'a' in 'field list'
1 3 1 3
1 3 1 3
2 1 2 1
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
SELECT a INTO @v FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1
) alias;
SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
SELECT a FROM (
SELECT a FROM t1
UNION
SELECT a INTO @v FROM t1
) alias;
SELECT a FROM (
SELECT a FROM t1
UNION
SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
) alias;
SELECT a FROM (
SELECT a FROM t1
UNION
SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
) alias;
SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
SELECT a FROM t1 UNION SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
DROP TABLE t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
`pseudo` char(35) NOT NULL default '', `pseudo` char(35) NOT NULL default '',
`pseudo1` char(35) NOT NULL default '', `pseudo1` char(35) NOT NULL default '',
...@@ -1588,3 +1546,39 @@ Warnings: ...@@ -1588,3 +1546,39 @@ Warnings:
Note 1003 select '0' AS `a` from `test`.`t1` union select '0' AS `a` from `test`.`t1` order by `a` Note 1003 select '0' AS `a` from `test`.`t1` union select '0' AS `a` from `test`.`t1` order by `a`
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
#
# Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
# subselects into account
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
# Tests fix in parser rule select_derived_union.
SELECT a INTO @v FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1
) alias;
SELECT a INTO OUTFILE 'union.out.file' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
SELECT a INTO DUMPFILE 'union.out.file2' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1;
SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1;
SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
# Tests fix in parser rule query_expression_body.
SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1;
SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1;
SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1;
DROP TABLE t1;
...@@ -2513,8 +2513,6 @@ DROP TABLE t1, t2; ...@@ -2513,8 +2513,6 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (i INT); CREATE TABLE t1 (i INT);
(SELECT i FROM t1) UNION (SELECT i FROM t1); (SELECT i FROM t1) UNION (SELECT i FROM t1);
#TODO:not supported
--error ER_PARSE_ERROR
SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
( (
(SELECT i FROM t1) UNION (SELECT i FROM t1) UNION
...@@ -2531,8 +2529,6 @@ WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1))); ...@@ -2531,8 +2529,6 @@ WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12)) explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
from t1; from t1;
#TODO:not supported
--error ER_PARSE_ERROR
explain select * from t1 where not exists explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12)); ((select t11.i from t1 t11) union (select t12.i from t1 t12));
...@@ -3203,8 +3199,6 @@ EXPLAIN EXTENDED ...@@ -3203,8 +3199,6 @@ EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a)); SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
#TODO:not supported
--error ER_PARSE_ERROR
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a)); (SELECT 1 FROM t2 WHERE t1.a = t2.a));
...@@ -3544,4 +3538,231 @@ where v in(select v ...@@ -3544,4 +3538,231 @@ where v in(select v
where t1.g=t2.g) is unknown; where t1.g=t2.g) is unknown;
drop table t1, t2; drop table t1, t2;
-- echo #
-- echo # Bug#33204: INTO is allowed in subselect, causing inconsistent results
-- echo #
CREATE TABLE t1( a INT );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2( a INT, b INT );
--error ER_PARSE_ERROR
SELECT *
FROM (SELECT a INTO @var FROM t1 WHERE a = 2) t1a;
--error ER_PARSE_ERROR
SELECT *
FROM (SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a;
--error ER_PARSE_ERROR
SELECT *
FROM (SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (
SELECT 1 a
UNION
SELECT a INTO @var FROM t1 WHERE a = 2
) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (
SELECT 1 a
UNION
SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2
) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (
SELECT 1 a
UNION
SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2
) t1a;
SELECT * FROM (SELECT a FROM t1 WHERE a = 2) t1a;
SELECT * FROM (
SELECT a FROM t1 WHERE a = 2
UNION
SELECT a FROM t1 WHERE a = 2
) t1a;
SELECT * FROM (
SELECT 1 a
UNION
SELECT a FROM t1 WHERE a = 2
UNION
SELECT a FROM t1 WHERE a = 2
) t1a;
# This was not allowed previously. Possibly, it should be allowed on the future.
# For now, the intent is to keep the fix as non-intrusive as possible.
--error ER_PARSE_ERROR
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
SELECT * FROM (SELECT 1 UNION SELECT 1) t1a;
--error ER_PARSE_ERROR
SELECT * FROM ((SELECT 1 a INTO @a)) t1a;
--error ER_PARSE_ERROR
SELECT * FROM ((SELECT 1 a INTO OUTFILE 'file' )) t1a;
--error ER_PARSE_ERROR
SELECT * FROM ((SELECT 1 a INTO DUMPFILE 'file' )) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO @a)) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO DUMPFILE 'file' )) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO OUTFILE 'file' )) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO @a))) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO DUMPFILE 'file' ))) t1a;
--error ER_PARSE_ERROR
SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO OUTFILE 'file' ))) t1a;
SELECT * FROM (SELECT 1 a ORDER BY a) t1a;
SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a) t1a;
SELECT * FROM (SELECT 1 a UNION SELECT 1 a LIMIT 1) t1a;
SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a LIMIT 1) t1a;
# Test of rule
# table_factor: '(' get_select_lex query_expression_body ')' opt_table_alias
# UNION should not be allowed inside the parentheses, nor should
# aliases after.
#
SELECT * FROM t1 JOIN (SELECT 1 UNION SELECT 1) alias ON 1;
--error ER_PARSE_ERROR
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
--error ER_PARSE_ERROR
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
--error ER_PARSE_ERROR
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
--error ER_PARSE_ERROR
SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
--error ER_PARSE_ERROR
SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
SELECT * FROM t1 JOIN (t1 t1a) ON 1;
SELECT * FROM t1 JOIN ((t1 t1a)) ON 1;
SELECT * FROM (t1 t1a);
SELECT * FROM ((t1 t1a));
SELECT * FROM t1 JOIN (SELECT 1 t1a) alias ON 1;
SELECT * FROM t1 JOIN ((SELECT 1 t1a)) alias ON 1;
SELECT * FROM t1 JOIN (SELECT 1 a) a ON 1;
SELECT * FROM t1 JOIN ((SELECT 1 a)) a ON 1;
# For the join, TABLE_LIST::select_lex == NULL
# Check that we handle this.
--error ER_PARSE_ERROR
SELECT * FROM (t1 JOIN (SELECT 1) t1a1 ON 1) t1a2;
SELECT * FROM t1 WHERE a = ALL ( SELECT 1 );
SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 );
SELECT * FROM t1 WHERE a = ANY ( SELECT 3 UNION SELECT 1 );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO @a);
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
SELECT * FROM t1 WHERE a = ( SELECT 1 );
SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( SELECT 1 INTO @a);
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( SELECT 1 INTO OUTFILE 'file' );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( SELECT 1 INTO DUMPFILE 'file' );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO @a);
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
--error ER_PARSE_ERROR
SELECT ( SELECT 1 INTO @v );
--error ER_PARSE_ERROR
SELECT ( SELECT 1 INTO OUTFILE 'file' );
--error ER_PARSE_ERROR
SELECT ( SELECT 1 INTO DUMPFILE 'file' );
--error ER_PARSE_ERROR
SELECT ( SELECT 1 UNION SELECT 1 INTO @v );
--error ER_PARSE_ERROR
SELECT ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
--error ER_PARSE_ERROR
SELECT ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
# Make sure context is popped when we leave the nested select
SELECT ( SELECT a FROM t1 WHERE a = 1 ), a FROM t1;
SELECT ( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ), a FROM t1;
# Make sure we have feature F561 (see .yy file)
SELECT * FROM t2 WHERE (a, b) IN (SELECT a, b FROM t2);
# Make sure the parser does not allow nested UNIONs anywhere
--error ER_PARSE_ERROR
SELECT 1 UNION ( SELECT 1 UNION SELECT 1 );
--error ER_PARSE_ERROR
( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
--error ER_PARSE_ERROR
SELECT ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
--error ER_PARSE_ERROR
SELECT ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
SELECT ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
--error ER_PARSE_ERROR
SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
--error ER_PARSE_ERROR
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ALL ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a = ANY ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a IN ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE EXISTS ( SELECT 1 UNION SELECT 1 INTO @v );
SELECT EXISTS(SELECT 1+1);
--error ER_PARSE_ERROR
SELECT EXISTS(SELECT 1+1 INTO @test);
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 INTO @v );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE EXISTS ( SELECT 1 INTO @v );
--error ER_PARSE_ERROR
SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
DROP TABLE t1, t2;
--echo End of 5.1 tests. --echo End of 5.1 tests.
...@@ -91,88 +91,6 @@ SELECT @a:=1 UNION SELECT @a:=@a+1; ...@@ -91,88 +91,6 @@ SELECT @a:=1 UNION SELECT @a:=@a+1;
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a); (SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2); (SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
#
# Bug#32858: Erro: "Incorrect usage of UNION and INTO" does not take subselects
# into account
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
SELECT a INTO @v FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1
) alias;
--let $outfile = $MYSQLTEST_VARDIR/tmp/union.out.file
--error 0,1
--remove_file $outfile
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval SELECT a INTO OUTFILE '$outfile' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
--remove_file $outfile
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval SELECT a INTO DUMPFILE '$outfile' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
--remove_file $outfile
#
# INTO will not be allowed in subqueries in version 5.1 and above.
#
SELECT a FROM (
SELECT a FROM t1
UNION
SELECT a INTO @v FROM t1
) alias;
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval SELECT a FROM (
SELECT a FROM t1
UNION
SELECT a INTO OUTFILE '$outfile' FROM t1
) alias;
--remove_file $outfile
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval SELECT a FROM (
SELECT a FROM t1
UNION
SELECT a INTO DUMPFILE '$outfile' FROM t1
) alias;
--remove_file $outfile
SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval SELECT a FROM t1 UNION SELECT a INTO OUTFILE '$outfile' FROM t1;
--remove_file $outfile
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '$outfile' FROM t1;
--remove_file $outfile
--error ER_WRONG_USAGE
SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
--error ER_WRONG_USAGE
eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
--error ER_WRONG_USAGE
eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
DROP TABLE t1;
# #
# Test bug reported by joc@presence-pc.com # Test bug reported by joc@presence-pc.com
# #
...@@ -1102,3 +1020,45 @@ DROP TABLE t1; ...@@ -1102,3 +1020,45 @@ DROP TABLE t1;
--echo End of 5.0 tests --echo End of 5.0 tests
-- echo #
-- echo # Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
-- echo # subselects into account
-- echo #
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
-- echo # Tests fix in parser rule select_derived_union.
SELECT a INTO @v FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1
) alias;
SELECT a INTO OUTFILE 'union.out.file' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
SELECT a INTO DUMPFILE 'union.out.file2' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
) alias;
SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1;
SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1;
--error ER_WRONG_USAGE
SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
--error ER_WRONG_USAGE
SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
--error ER_WRONG_USAGE
SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
-- echo # Tests fix in parser rule query_expression_body.
SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1;
SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1;
SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1;
DROP TABLE t1;
...@@ -1626,7 +1626,6 @@ void THD::rollback_item_tree_changes() ...@@ -1626,7 +1626,6 @@ void THD::rollback_item_tree_changes()
select_result::select_result() select_result::select_result()
{ {
thd=current_thd; thd=current_thd;
nest_level= -1;
} }
void select_result::send_error(uint errcode,const char *err) void select_result::send_error(uint errcode,const char *err)
......
...@@ -2381,7 +2381,6 @@ class select_result :public Sql_alloc { ...@@ -2381,7 +2381,6 @@ class select_result :public Sql_alloc {
protected: protected:
THD *thd; THD *thd;
SELECT_LEX_UNIT *unit; SELECT_LEX_UNIT *unit;
uint nest_level;
public: public:
select_result(); select_result();
virtual ~select_result() {}; virtual ~select_result() {};
...@@ -2418,12 +2417,6 @@ public: ...@@ -2418,12 +2417,6 @@ public:
*/ */
virtual void cleanup(); virtual void cleanup();
void set_thd(THD *thd_arg) { thd= thd_arg; } void set_thd(THD *thd_arg) { thd= thd_arg; }
/**
The nest level, if supported.
@return
-1 if nest level is undefined, otherwise a positive integer.
*/
int get_nest_level() { return nest_level; }
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
virtual void begin_dataset() {} virtual void begin_dataset() {}
#else #else
...@@ -2518,14 +2511,6 @@ class select_export :public select_to_file { ...@@ -2518,14 +2511,6 @@ class select_export :public select_to_file {
CHARSET_INFO *write_cs; // output charset CHARSET_INFO *write_cs; // output charset
public: public:
select_export(sql_exchange *ex) :select_to_file(ex) {} select_export(sql_exchange *ex) :select_to_file(ex) {}
/**
Creates a select_export to represent INTO OUTFILE <filename> with a
defined level of subquery nesting.
*/
select_export(sql_exchange *ex, uint nest_level_arg) :select_to_file(ex)
{
nest_level= nest_level_arg;
}
~select_export(); ~select_export();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items); bool send_data(List<Item> &items);
...@@ -2535,15 +2520,6 @@ public: ...@@ -2535,15 +2520,6 @@ public:
class select_dump :public select_to_file { class select_dump :public select_to_file {
public: public:
select_dump(sql_exchange *ex) :select_to_file(ex) {} select_dump(sql_exchange *ex) :select_to_file(ex) {}
/**
Creates a select_export to represent INTO DUMPFILE <filename> with a
defined level of subquery nesting.
*/
select_dump(sql_exchange *ex, uint nest_level_arg) :
select_to_file(ex)
{
nest_level= nest_level_arg;
}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items); bool send_data(List<Item> &items);
}; };
...@@ -3014,16 +2990,6 @@ class select_dumpvar :public select_result_interceptor { ...@@ -3014,16 +2990,6 @@ class select_dumpvar :public select_result_interceptor {
public: public:
List<my_var> var_list; List<my_var> var_list;
select_dumpvar() { var_list.empty(); row_count= 0;} select_dumpvar() { var_list.empty(); row_count= 0;}
/**
Creates a select_dumpvar to represent INTO <variable> with a defined
level of subquery nesting.
*/
select_dumpvar(uint nest_level_arg)
{
var_list.empty();
row_count= 0;
nest_level= nest_level_arg;
}
~select_dumpvar() {} ~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items); bool send_data(List<Item> &items);
......
This diff is collapsed.
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