BUG #17479: "plan should not reference subplan's variable" when calling `grouping` on result of subquery
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: sully@msully.net
Date: 2022-05-10T01:02:35Z
Lists: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 17479
Logged by: Michael J. Sullivan
Email address: sully@msully.net
PostgreSQL version: 14.2
Operating system: Linux
Description:
The following query produces "plan should not reference subplan's
variable"
create table Card (id uuid);
SELECT
-- This line causes "variable not found in subplan target list"
-- grouping(res.cnt)
-- This line causes "plan should not reference subplan's variable"
(SELECT grouping(res.cnt))
FROM Card
CROSS JOIN LATERAL
(SELECT
(SELECT Card.id) AS cnt
) AS res
GROUP BY
res.cnt
As the comment says, a slight change instead errors with "variable not found
in subplan target list".
Commits
-
Make pull_var_clause() handle GroupingFuncs exactly like Aggrefs.
- b7579b25c815 13.8 landed
- b53442f6fe0f 10.22 landed
- ac51c9fba5a7 14.4 landed
- 7f7f1750d4ca 11.17 landed
- 79b58c6f6843 15.0 landed
- 301b91c56556 12.12 landed