pgsql: Fix yet another corner case in dumping rules/views with USING cl

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix yet another corner case in dumping rules/views with USING cl
Date: 2014-05-02 00:22:51
Message-ID: E1Wg1Fb-00021j-S1@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix yet another corner case in dumping rules/views with USING clauses.

ruleutils.c tries to cope with additions/deletions/renamings of columns in
tables referenced by views, by means of adding machine-generated aliases to
the printed form of a view when needed to preserve the original semantics.
A recent blog post by Marko Tiikkaja pointed out a case I'd missed though:
if one input of a join with USING is itself a join, there is nothing to
stop the user from adding a column of the same name as the USING column to
whichever side of the sub-join didn't provide the USING column. And then
there'll be an error when the view is re-parsed, since now the sub-join
exposes two columns matching the USING specification. We were catching a
lot of related cases, but not this one, so add some logic to cope with it.

Back-patch to 9.3, which is the first release that makes any serious
attempt to cope with such cases (cf commit 2ffa740be and follow-ons).

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/91e16b980612d80de1017e97e9f206239afb9026

Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 49 ++++++++++++++++++++++-------
src/test/regress/expected/create_view.out | 34 ++++++++++++++++++++
src/test/regress/sql/create_view.sql | 18 +++++++++++
3 files changed, 90 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2014-05-02 02:10:34 pgsql: doc: Update pg_basebackup version compatibility claim for 9.4
Previous Message Tom Lane 2014-05-01 20:16:48 pgsql: Fix "quiet inline" configure test for newer clang compilers.