summaryrefslogtreecommitdiff
path: root/mysql-test/r/union.result
diff options
context:
space:
mode:
authorunknown <mhansson/martin@linux-st28.site>2007-12-13 11:19:05 +0100
committerunknown <mhansson/martin@linux-st28.site>2007-12-13 11:19:05 +0100
commit93e3057ba574672c2f0bb1b0958221c0d7efc553 (patch)
treecaf3c9929e1fdb44793e28bfacf2fa1ea9dc22a6 /mysql-test/r/union.result
parent62a7e160bc0e960ec1374a546dde4a7f26120ceb (diff)
downloadmariadb-git-93e3057ba574672c2f0bb1b0958221c0d7efc553.tar.gz
Bug #32858: Erro: "Incorrect usage of UNION and INTO" does not take
subselects into account It is forbidden to use the SELECT INTO construction inside UNION statements unless on the last SELECT of the union. The parser records whether it has seen INTO or not when parsing a UNION statement. But if the INTO was legally used in an outer query, an error is thrown if UNION is seen in a subquery. Fixed in 5.0 by remembering the nesting level of INTO tokens and mitigate the error unless it collides with the UNION. mysql-test/r/union.result: Bug#32858: Test result mysql-test/t/union.test: Bug#32858: Test case sql/sql_class.cc: Bug#32858: Initializing new member sql/sql_class.h: Bug#32858: Added property nest_level to select_result class. sql/sql_yacc.yy: Bug#32858: The fix.
Diffstat (limited to 'mysql-test/r/union.result')
-rw-r--r--mysql-test/r/union.result42
1 files changed, 42 insertions, 0 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index efdd8195fb5..dadc6bb3558 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1389,4 +1389,46 @@ select @var;
1
(select 2) union (select 1 into @var);
ERROR 42000: Result consisted of more than one row
+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 '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 (
+SELECT a FROM t1
+UNION
+SELECT a INTO @v FROM t1
+) alias;
+SELECT a FROM (
+SELECT a FROM t1
+UNION
+SELECT a INTO OUTFILE 'union.out.file3' FROM t1
+) alias;
+SELECT a FROM (
+SELECT a FROM t1
+UNION
+SELECT a INTO DUMPFILE 'union.out.file4' FROM t1
+) 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
+DROP TABLE t1;
End of 5.0 tests