Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.4.5, 5.5(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL)
-
MariaDB 10.4.5-bionic in Docker on Ubuntu 19.04
Description
When I execute the following Code, I get the error message "Unknown column 'B.AJ' in 'having clause'". I expect that the column can be found (like in the GROUP BY clause or in the examples below) and the sql query can be executed properly.
CREATE SCHEMA A ; |
|
CREATE TABLE A.B (AJ INTEGER) ; |
|
-- Unknown column 'B.AJ' in 'having clause
|
SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ HAVING B.AJ < C.AJ; |
If I delete the HAVING clause completely, the statement gets executed, so it knows the column name in the group by clause.
-- No Error
|
SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ; |
Additionally, If I use SUM(B.AJ) (and SUM(C.AJ)) instead, everything works fine and the query can be executed.
-- No Error
|
SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ HAVING SUM(B.AJ) < SUM(C.AJ); |
If I use the exact same condition in a WHERE clause, it also works properly:
-- No Error
|
SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C WHERE B.AJ < C.AJ GROUP BY B.AJ, C.AJ ; |
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Description |
When I execute the following Code, I get the error message "Unknown column 'B.AJ' in 'having clause'"
{code:sql} CREATE SCHEMA A ; CREATE TABLE A.B (AJ INTEGER) ; -- Unknown column 'B.AJ' in 'having clause SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ HAVING B.AJ < C.AJ; {code} If I delete the HAVING clause completely, the statement gets executed, so it knows the column name in the group by clause. {code:sql} -- No Error SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ; {code} Additionally, If I use SUM(B.AJ) (and SUM(C.AJ)) instead, everything works fine and the query can be executed. {code:sql} -- No Error SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ HAVING SUM(B.AJ) < SUM(C.AJ); {code} If I use the exact same condition in a WHERE clause, it also works properly: {code:sql} -- No Error SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C WHERE B.AJ < C.AJ GROUP BY B.AJ, C.AJ ; {code} |
When I execute the following Code, I get the error message "Unknown column 'B.AJ' in 'having clause'". I expect that the column can be found (like in the GROUP BY clause or in the examples below) and the sql query can be executed properly.
{code:sql} CREATE SCHEMA A ; CREATE TABLE A.B (AJ INTEGER) ; -- Unknown column 'B.AJ' in 'having clause SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ HAVING B.AJ < C.AJ; {code} If I delete the HAVING clause completely, the statement gets executed, so it knows the column name in the group by clause. {code:sql} -- No Error SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ; {code} Additionally, If I use SUM(B.AJ) (and SUM(C.AJ)) instead, everything works fine and the query can be executed. {code:sql} -- No Error SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C GROUP BY B.AJ, C.AJ HAVING SUM(B.AJ) < SUM(C.AJ); {code} If I use the exact same condition in a WHERE clause, it also works properly: {code:sql} -- No Error SELECT 1 AS A FROM A.B CROSS JOIN A.B AS C WHERE B.AJ < C.AJ GROUP BY B.AJ, C.AJ ; {code} |
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Fix Version/s | 10.4 [ 22408 ] | |
Affects Version/s | 5.5 [ 15800 ] | |
Affects Version/s | 10.1 [ 16100 ] | |
Affects Version/s | 10.2 [ 14601 ] | |
Affects Version/s | 10.3 [ 22126 ] | |
Assignee | Oleksandr Byelkin [ sanja ] | |
Labels | parser sql | parser sql upstream-fixed |
Workflow | MariaDB v3 [ 97298 ] | MariaDB v4 [ 144149 ] |
Affects Version/s | 10.4 [ 22408 ] | |
Affects Version/s | 10.5 [ 23123 ] | |
Affects Version/s | 10.6 [ 24028 ] | |
Affects Version/s | 10.7 [ 24805 ] | |
Affects Version/s | 10.8 [ 26121 ] | |
Affects Version/s | 10.9 [ 26905 ] | |
Affects Version/s | 10.10 [ 27530 ] |
Fix Version/s | 10.5 [ 23123 ] | |
Fix Version/s | 10.6 [ 24028 ] | |
Fix Version/s | 10.11 [ 27614 ] | |
Fix Version/s | 11.4 [ 29301 ] | |
Fix Version/s | 11.7 [ 29815 ] | |
Fix Version/s | 10.4(EOL) [ 22408 ] |
Fix Version/s | 11.7(EOL) [ 29815 ] |