pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix incorrect printing of queries with duplicated join names.
Date: Wed, 12 Jun 2019 23:43:28 +0000
Message-ID: <E1hbCts-0002d3-UI@gemulon.postgresql.org> (raw)

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.c...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3d99a81397abb8bb7b95aee794d6644e174e174f

Modified Files
--------------
src/backend/utils/adt/ruleutils.c         | 10 +++++++-
src/test/regress/expected/create_view.out | 38 ++++++++++++++++++++++++++++++-
src/test/regress/sql/create_view.sql      |  9 ++++++++
3 files changed, 55 insertions(+), 2 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1hbCts-0002d3-UI@gemulon.postgresql.org>
Permalink:  ../E1hbCts-0002d3-UI@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hbCts-0002d3-UI@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix incorrect printing of queries with duplicated join names.
  In-Reply-To: <E1hbCts-0002d3-UI@gemulon.postgresql.org>
  References: <E1hbCts-0002d3-UI@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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