mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug#23345: Wrongly allowed INTO in a non-last select of a UNION.
INTO clause can be specified only for the last select of a UNION and it receives the result of the whole query. But it was wrongly allowed in non-last selects of a UNION which leads to a confusing query result. Now INTO allowed only in the last select of a UNION. mysql-test/t/union.test: Added a test case for the bug#23345: Wrongly allowed INTO in a non-last select of a UNION. mysql-test/r/union.result: Added a test case for the bug#23345: Wrongly allowed INTO in a non-last select of a UNION. sql/sql_yacc.yy: Bug#23345: Wrongly allowed INTO in a non-last select of a UNION. Now INTO allowed only in the last select of a UNION.
This commit is contained in:
@ -1381,4 +1381,12 @@ a
|
||||
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
|
||||
ERROR 42S22: Unknown column 'c' in 'order clause'
|
||||
DROP TABLE t1;
|
||||
(select 1 into @var) union (select 1);
|
||||
ERROR HY000: Incorrect usage of UNION and INTO
|
||||
(select 1) union (select 1 into @var);
|
||||
select @var;
|
||||
@var
|
||||
1
|
||||
(select 2) union (select 1 into @var);
|
||||
ERROR 42000: Result consisted of more than one row
|
||||
End of 5.0 tests
|
||||
|
@ -868,4 +868,13 @@ SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#23345: Wrongly allowed INTO in a non-last select of a UNION.
|
||||
#
|
||||
--error 1221
|
||||
(select 1 into @var) union (select 1);
|
||||
(select 1) union (select 1 into @var);
|
||||
select @var;
|
||||
--error 1172
|
||||
(select 2) union (select 1 into @var);
|
||||
--echo End of 5.0 tests
|
||||
|
Reference in New Issue
Block a user