Re: JumbleQuery ma treat different GROUP BY expr as the same - Mailing list pgsql-hackers

From jian he
Subject Re: JumbleQuery ma treat different GROUP BY expr as the same
Date
Msg-id CACJufxFb2AjY5CS4iCOompuVjriRxUddkGCTdPRdpEHjG5tD=g@mail.gmail.com
Whole thread Raw
In response to Re: JumbleQuery ma treat different GROUP BY expr as the same  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: JumbleQuery ma treat different GROUP BY expr as the same
List pgsql-hackers
hi.

while working on it, I guess I found another bug,  below JumbleQuery will return
the same result:

SELECT FROM (VALUES (1::INT, 2::INT)) AS t(a, b) ORDER BY a, b;
SELECT a FROM (VALUES (1::INT, 2::INT)) AS t(a, b) ORDER BY a, b;
SELECT a, b FROM (VALUES (1::INT, 2::INT)) AS t(a, b) ORDER BY a, b;

so I think TargetEntry.resjunk should not be marked as query_jumble_ignore.

addRangeTableEntryForGroup
will make RangeTblEntry(RTE_GROUP) have a newly copied original groupexprs.
Query->targetList also has the original groupexprs.

but after parseCheckAggregates->substitute_grouped_columns.
Query->targetList Var node will point to the offset of the RTE_GROUP,
not the RTE_RELATION.
see src/backend/parser/parse_agg.c line 1543.

After parseCheckAggregates, JumbleQuery(Query->targetList) will produce the same
result as long as the grouping columns have the same list of data types.
JumbleQuery(Query->groupClause) will also produce the same result
as long as the grouping columns have the same list of data types.

Since only the RangeTblEntry(RTE_GROUP) have the original grouping expressions,
we can not mark the RangeTblEntry->groupexprs as query_jumble_ignore.

looking at, transformUpdateTargetList->transformTargetList
so i think it's OK to remove query_jumble_ignore from TargetEntry.resjunk for
INSERT/UPDATE/DELETE.


--
jian
https://www.enterprisedb.com/

Attachment

pgsql-hackers by date:

Previous
From: tushar
Date:
Subject: Re: Non-text mode for pg_dumpall
Next
From: Anthonin Bonnefoy
Date:
Subject: Re: Fix possible 'unexpected data beyond EOF' on replica restart