Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
12.3.2
-
None
-
Ubuntu 24.04 (Noble) x86_64
Description
MariaDB 12.3.2 cannot resolve an outer-scope correlated column reference when it is used inside a WHERE clause that sits *three or more derived-table levels* below the outer alias.
Minimal Reproducer:
CREATE TABLE repro (id INT PRIMARY KEY, p INT, os VARCHAR(32)); |
INSERT INTO repro VALUES (1,1,'a'),(2,1,'b'),(3,2,'c'),(4,2,'d'); |
-- FAILS on MariaDB 12.3.2
|
SELECT p, id |
FROM (SELECT id, p, os FROM repro) AS outer_a |
WHERE outer_a.os = ( |
SELECT peer.os FROM ( |
SELECT inner_b.os AS os |
FROM (SELECT id, p, os FROM repro) AS inner_b |
WHERE inner_b.p = outer_a.p -- resolution failure |
ORDER BY inner_b.os LIMIT 1 |
) AS peer |
);
|
The query fails with:
ERROR 1054 (42S22): Unknown column 'outer_a.p' in 'WHERE' |
Control Case (Depth-2 Correlation Works)
SELECT p, id |
FROM (SELECT id, p, os FROM repro) AS a |
WHERE a.os = ( |
SELECT b.os |
FROM (SELECT id, p, os FROM repro) AS b |
WHERE b.p = a.p |
ORDER BY b.os LIMIT 1 |
);
|
This query executes successfully on both MariaDB and MySQL, confirming that correlation works when the nesting depth is limited.
Expected Behavior:
Should correctly resolve the outer reference outer_a.p and return:
p id
|
1 1
|
2 3
|
Attachments
Issue Links
- is part of
-
MDEV-35388 PostgreSQL-compatible syntax
-
- Open
-