]> granicus.if.org Git - postgresql/commit
Fix incorrect printing of queries with duplicated join names.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Jun 2019 23:42:39 +0000 (19:42 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Jun 2019 23:42:39 +0000 (19:42 -0400)
commitad3e61b2809e5fc0133ca5bc6dde7450f85a00c1
tree6fb167896c12a79a8ff57d96a1d14f051b00b6ba
parent77d45b790e12c654962957ea43f430a59eff4e7e
Fix incorrect printing of queries with duplicated join names.

Given a query in which multiple JOIN nodes used the same alias
(which'd necessarily be in different sub-SELECTs), ruleutils.c
would assign the JOIN nodes distinct aliases for clarity ...
but then it forgot to print the modified aliases when dumping
the JOIN nodes themselves.  This results in a dump/reload hazard
for views, because the emitted query is flat-out incorrect:
Vars will be printed with table names that have no referent.

This has been wrong for a long time, so back-patch to all supported
branches.

Philip DubĂ©

Discussion: https://postgr.es/m/CY4PR2101MB080246F2955FF58A6ED1FEAC98140@CY4PR2101MB0802.namprd21.prod.outlook.com
src/backend/utils/adt/ruleutils.c
src/test/regress/expected/create_view.out
src/test/regress/sql/create_view.sql