postgresql/src/backend/rewrite
Tom Lane f819020d40 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
2022-04-23 12:16:12 -04:00
..
Makefile SEARCH and CYCLE clauses 2021-02-01 14:32:51 +01:00
rewriteDefine.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rewriteHandler.c Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00
rewriteManip.c Don't bother to attach column name lists to RowExprs of named types. 2022-03-17 18:25:44 -04:00
rewriteRemove.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rewriteSearchCycle.c Fix incautious CTE matching in rewriteSearchAndCycle(). 2022-04-23 12:16:12 -04:00
rewriteSupport.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rowsecurity.c Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00