summaryrefslogtreecommitdiff
path: root/mysql-test/r/union.result
diff options
context:
space:
mode:
authormhansson/martin@linux-st28.site <>2007-12-13 11:19:05 +0100
committermhansson/martin@linux-st28.site <>2007-12-13 11:19:05 +0100
commit33c4431d39e19fce24c5d3df43fc474439bff115 (patch)
treecaf3c9929e1fdb44793e28bfacf2fa1ea9dc22a6 /mysql-test/r/union.result
parent7f67efccef94449ef6c797583a2695b27a9b7376 (diff)
downloadmariadb-git-33c4431d39e19fce24c5d3df43fc474439bff115.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.
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