pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix incautious CTE matching in rewriteSearchAndCycle(). 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix incautious CTE matching in rewriteSearchAndCycle(). @ 2022-04-23 16:16 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2022-04-23 16:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix incautious CTE matching in rewriteSearchAndCycle(). This function looks for a reference to the recursive WITH CTE, but it checked only the CTE name not ctelevelsup, so that it could seize on a lower CTE that happened to have the same name. This would result in planner failures later, either weird errors such as "could not find attribute 2 in subquery targetlist", or crashes or assertion failures. The code also merely Assert'ed that it found a matching entry, which is not guaranteed at all by the parser. Per bugs #17320 and #17318 from Zhiyong Wu. Thanks to Kyotaro Horiguchi for investigation. Discussion: https://postgr.es/m/17320-70e37868182512ab@postgresql.org Discussion: https://postgr.es/m/17318-2eb65a3a611d2368@postgresql.org Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/dff6c77faf0c6bcf1d407dc3ffef9e169166c714 Modified Files -------------- src/backend/rewrite/rewriteSearchCycle.c | 19 ++++++++++++++++--- src/test/regress/expected/with.out | 10 ++++++++++ src/test/regress/sql/with.sql | 10 ++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix incautious CTE matching in rewriteSearchAndCycle(). @ 2022-04-23 16:16 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2022-04-23 16:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix incautious CTE matching in rewriteSearchAndCycle(). This function looks for a reference to the recursive WITH CTE, but it checked only the CTE name not ctelevelsup, so that it could seize on a lower CTE that happened to have the same name. This would result in planner failures later, either weird errors such as "could not find attribute 2 in subquery targetlist", or crashes or assertion failures. The code also merely Assert'ed that it found a matching entry, which is not guaranteed at all by the parser. Per bugs #17320 and #17318 from Zhiyong Wu. Thanks to Kyotaro Horiguchi for investigation. Discussion: https://postgr.es/m/17320-70e37868182512ab@postgresql.org Discussion: https://postgr.es/m/17318-2eb65a3a611d2368@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/f819020d400f1dbd96ee1a9fd44a1f6f44932b4d Modified Files -------------- src/backend/rewrite/rewriteSearchCycle.c | 19 ++++++++++++++++--- src/test/regress/expected/with.out | 10 ++++++++++ src/test/regress/sql/with.sql | 10 ++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-04-23 16:16 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-04-23 16:16 pgsql: Fix incautious CTE matching in rewriteSearchAndCycle(). Tom Lane <tgl@sss.pgh.pa.us> 2022-04-23 16:16 pgsql: Fix incautious CTE matching in rewriteSearchAndCycle(). Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox