Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1, 12.3.3
-
Linux x86_64; MariaDB 12.3.3 binary distribution
Description
A mixed UNION/INTERSECT query rejects equivalent three-column projections with ER 1222 when each operand selects an explicit expression followed by a table wildcard. Explicit-column and single-operator controls return the expected row.
Steps to reproduce
- Save the following as test.sql:
DROP DATABASE IF EXISTS set_test; |
CREATE DATABASE set_test; |
USE set_test; |
CREATE TABLE t1 (a INT, b INT); |
INSERT INTO t1 VALUES (10,20); |
|
|
-- Explicit-column control.
|
SELECT 0 AS x, a, b FROM t1 |
UNION
|
SELECT 0 AS x, a, b FROM t1 |
INTERSECT
|
SELECT 0 AS x, a, b FROM t1; |
|
|
-- UNION-only wildcard control.
|
SELECT 0 AS x, t1.* FROM t1 |
UNION
|
SELECT 0 AS x, t1.* FROM t1; |
|
|
-- INTERSECT-only wildcard control.
|
SELECT 0 AS x, t1.* FROM t1 |
INTERSECT
|
SELECT 0 AS x, t1.* FROM t1; |
|
|
-- Mixed-operator wildcard query.
|
SELECT 0 AS x, t1.* FROM t1 |
UNION
|
SELECT 0 AS x, t1.* FROM t1 |
INTERSECT
|
SELECT 0 AS x, t1.* FROM t1; |
- Run it with the MariaDB client:
mariadb < test.sql |
Actual result
The first three queries each return the same three-column row:
x a b
|
0 10 20
|
x a b
|
0 10 20
|
x a b
|
0 10 20
|
The final mixed-operator query fails:
ERROR 1222 (21000): The used SELECT statements have a different number of columns
|
Expected result
The final query should also return 0,10,20. Every operand resolves to the three columns x, a, and b, just as in the explicit-column control. The set-operation precedence handling must not introduce an additional x column while expanding t1.*.
This occurs when a mixed UNION/INTERSECT chain projects both an explicit expression and a table wildcard.