Type:
Bug
Priority:
Major
Resolution:
Unresolved
Affects Version/s:
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)
Environment:
MariaDB 10.4.5-bionic in Docker on Ubuntu 19.04
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 ;
-
created issue -
2019-06-03 14:41
-
made changes -
2019-06-03 14:42
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}
Elena Stepanova
made changes -
2019-06-03 15:06
Status
Open
[ 1
]
Confirmed
[ 10101
]
Elena Stepanova
made changes -
2019-06-03 15:07
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
Sergei Golubchik
made changes -
2021-12-06 21:36
Workflow
MariaDB v3
[ 97298
]
MariaDB v4
[ 144149
]
Alice Sherepa
made changes -
2022-11-29 10:32
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
]
Alice Sherepa
made changes -
2024-11-25 16:07
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
]
Julien Fritsch
made changes -
2025-02-14 11:39
Fix Version/s
11.7(EOL)
[ 29815
]
{"report":{"fcp":958.8000000715256,"ttfb":370.8000000715256,"pageVisibility":"visible","entityId":76585,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"ed8566e6-dcd4-4a6e-a490-3f44fe7a252c","navigationType":0,"readyForUser":1035.7000000476837,"redirectCount":0,"resourceLoadedEnd":1055,"resourceLoadedStart":376.5,"resourceTiming":[{"duration":39.300000071525574,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":376.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":376.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":415.8000000715256,"responseStart":0,"secureConnectionStart":0},{"duration":40,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":376.8000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":376.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":416.8000000715256,"responseStart":0,"secureConnectionStart":0},{"duration":93.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":376.90000009536743,"connectEnd":376.90000009536743,"connectStart":376.90000009536743,"domainLookupEnd":376.90000009536743,"domainLookupStart":376.90000009536743,"fetchStart":376.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":376.90000009536743,"responseEnd":470.5,"responseStart":470.5,"secureConnectionStart":376.90000009536743},{"duration":172.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":377.10000002384186,"connectEnd":377.10000002384186,"connectStart":377.10000002384186,"domainLookupEnd":377.10000002384186,"domainLookupStart":377.10000002384186,"fetchStart":377.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":377.10000002384186,"responseEnd":549.7000000476837,"responseStart":549.7000000476837,"secureConnectionStart":377.10000002384186},{"duration":176.39999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":377.3000000715256,"connectEnd":377.3000000715256,"connectStart":377.3000000715256,"domainLookupEnd":377.3000000715256,"domainLookupStart":377.3000000715256,"fetchStart":377.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":377.3000000715256,"responseEnd":553.7000000476837,"responseStart":553.7000000476837,"secureConnectionStart":377.3000000715256},{"duration":176.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":377.5,"connectEnd":377.5,"connectStart":377.5,"domainLookupEnd":377.5,"domainLookupStart":377.5,"fetchStart":377.5,"redirectEnd":0,"redirectStart":0,"requestStart":377.5,"responseEnd":554.2000000476837,"responseStart":554.2000000476837,"secureConnectionStart":377.5},{"duration":177,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":377.60000002384186,"connectEnd":377.60000002384186,"connectStart":377.60000002384186,"domainLookupEnd":377.60000002384186,"domainLookupStart":377.60000002384186,"fetchStart":377.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":377.60000002384186,"responseEnd":554.6000000238419,"responseStart":554.6000000238419,"secureConnectionStart":377.60000002384186},{"duration":233.69999992847443,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":377.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":377.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":611.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":177.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":378,"connectEnd":378,"connectStart":378,"domainLookupEnd":378,"domainLookupStart":378,"fetchStart":378,"redirectEnd":0,"redirectStart":0,"requestStart":378,"responseEnd":555.1000000238419,"responseStart":555.1000000238419,"secureConnectionStart":378},{"duration":233.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":378.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":378.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":611.8000000715256,"responseStart":0,"secureConnectionStart":0},{"duration":177.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":378.2000000476837,"connectEnd":378.2000000476837,"connectStart":378.2000000476837,"domainLookupEnd":378.2000000476837,"domainLookupStart":378.2000000476837,"fetchStart":378.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":378.2000000476837,"responseEnd":555.8000000715256,"responseStart":555.8000000715256,"secureConnectionStart":378.2000000476837},{"duration":364.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":379,"connectEnd":379,"connectStart":379,"domainLookupEnd":379,"domainLookupStart":379,"fetchStart":379,"redirectEnd":0,"redirectStart":0,"requestStart":379,"responseEnd":743.2000000476837,"responseStart":743.2000000476837,"secureConnectionStart":379},{"duration":528,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":383.10000002384186,"connectEnd":383.10000002384186,"connectStart":383.10000002384186,"domainLookupEnd":383.10000002384186,"domainLookupStart":383.10000002384186,"fetchStart":383.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":383.10000002384186,"responseEnd":911.1000000238419,"responseStart":911.1000000238419,"secureConnectionStart":383.10000002384186},{"duration":121,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":622.7000000476837,"connectEnd":622.7000000476837,"connectStart":622.7000000476837,"domainLookupEnd":622.7000000476837,"domainLookupStart":622.7000000476837,"fetchStart":622.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":622.7000000476837,"responseEnd":743.7000000476837,"responseStart":743.6000000238419,"secureConnectionStart":622.7000000476837},{"duration":38.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":878.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":878.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":916.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":170.19999992847443,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":879.4000000953674,"connectEnd":879.4000000953674,"connectStart":879.4000000953674,"domainLookupEnd":879.4000000953674,"domainLookupStart":879.4000000953674,"fetchStart":879.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":879.4000000953674,"responseEnd":1049.6000000238419,"responseStart":1049.6000000238419,"secureConnectionStart":879.4000000953674},{"duration":175.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":879.7000000476837,"connectEnd":879.7000000476837,"connectStart":879.7000000476837,"domainLookupEnd":879.7000000476837,"domainLookupStart":879.7000000476837,"fetchStart":879.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":879.7000000476837,"responseEnd":1055,"responseStart":1055,"secureConnectionStart":879.7000000476837},{"duration":116.79999995231628,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":952.8000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":952.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1069.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":82.29999995231628,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":973.7000000476837,"connectEnd":973.7000000476837,"connectStart":973.7000000476837,"domainLookupEnd":973.7000000476837,"domainLookupStart":973.7000000476837,"fetchStart":973.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":973.7000000476837,"responseEnd":1056,"responseStart":1056,"secureConnectionStart":973.7000000476837}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":175,"responseStart":371,"responseEnd":380,"domLoading":374,"domInteractive":1113,"domContentLoadedEventStart":1113,"domContentLoadedEventEnd":1162,"domComplete":1348,"loadEventStart":1348,"loadEventEnd":1349,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1072.3000000715256},{"name":"bigPipe.sidebar-id.end","time":1073.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.start","time":1073.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":1076.6000000238419},{"name":"activityTabFullyLoaded","time":1186.3000000715256}],"measures":[],"correlationId":"df109a05ac5dfc","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":135,"dbReadsTimeInMs":21,"dbConnsTimeInMs":30,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Reproducible on all of MariaDB 5.5-10.4 and MySQL 5.6.
Not reproducible on MySQL 5.7.