From 6ed3cf56e65027696c24c4a931b9d0a5062b9006 Mon Sep 17 00:00:00 2001 From: David Rowley Date: Mon, 18 Sep 2023 10:19:21 +1200 Subject: [PATCH v1 1/2] Re-allow Boolean constants in GROUP BY 941460fcf added a boolean node type which effectively stopped "GROUP BY true" from working as we only allowed integer constants in the GROUP BY clause. Here we add a special case to allow Boolean constants to be specified again. This may be useful for users who wish to guarantee grouping takes place even when the targetlist has no aggregate functions. It also seems good to be consistent as we allow "JOIN ... ON true". Reported-by: David Micallef Author: John Naylor Discussion: https://postgr.es/m/CAJBCwCS7OuEUmGkrnu5Q8SmBP10njnEiX7vJiaxJURZXcCORyw@mail.gmail.com Backpatch-through: 15, where 941460fcf was added --- src/backend/parser/parse_clause.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 334b9b42bd..9effe6ae7c 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -2112,6 +2112,14 @@ findTargetlistEntrySQL92(ParseState *pstate, Node *node, List **tlist, int targetlist_pos = 0; int target_pos; + /* + * Pre-v15 versions supported boolean constants in the GROUP BY clause. + * Here we make a special case to allow these after boolean types were given + * their own parse node type in v15. + */ + if (IsA(&aconst->val, Boolean)) + return findTargetlistEntrySQL99(pstate, node, tlist, exprKind); + if (!IsA(&aconst->val, Integer)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), -- 2.40.1.windows.1