mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-23 06:47:14 +08:00
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
This commit is contained in:
@ -319,6 +319,15 @@ ALTER TABLE tmp1 RENAME TO tx1;
|
||||
\d+ aliased_view_3
|
||||
\d+ aliased_view_4
|
||||
|
||||
-- Test aliasing of joins
|
||||
|
||||
create view view_of_joins as
|
||||
select * from
|
||||
(select * from (tbl1 cross join tbl2) same) ss,
|
||||
(tbl3 cross join tbl4) same;
|
||||
|
||||
\d+ view_of_joins
|
||||
|
||||
-- Test view decompilation in the face of column addition/deletion/renaming
|
||||
|
||||
create table tt2 (a int, b int, c int);
|
||||
|
||||
Reference in New Issue
Block a user