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: Further fix dumping of views that contain just VALUES(...).
Date: Sun, 17 Nov 2019 01:00:40 +0000
Message-ID: <E1iW8vg-0000ZY-HC@gemulon.postgresql.org> (raw)

Further fix dumping of views that contain just VALUES(...).

It turns out that commit e9f1c01b7 missed a case: we must print a
VALUES clause in long format if get_query_def is given a resultDesc
that would require the query's output column name(s) to be different
from what the bare VALUES clause would produce.

This applies in case an ALTER ... RENAME COLUMN has been done to
a view that formerly could be printed in simple format, as shown
in the added regression test case.  It also explains bug #16119
from Dmitry Telpt, because it turns out that (unlike CREATE VIEW)
CREATE MATERIALIZED VIEW fails to apply any column aliases it's
given to the stored ON SELECT rule.  So to get them to be printed,
we have to account for the resultDesc renaming.  It might be worth
changing the matview code so that it creates the ON SELECT rule
with the correct aliases; but we'd still need these messy checks in
get_simple_values_rte to handle the case of a subsequent column
rename, so any such change would be just neatnik-ism not a bug fix.

Like the previous patch, back-patch to all supported branches.

Discussion: https://postgr.es/m/16119-e64823f30a45a754@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bf2efc55da9a1a33da32fa383db9db2f2c49b2cb

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



view thread (7+ messages)

Message-ID: <E1iW8vg-0000ZY-HC@gemulon.postgresql.org>
Permalink:  ../E1iW8vg-0000ZY-HC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iW8vg-0000ZY-HC@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Further fix dumping of views that contain just VALUES(...).
  In-Reply-To: <E1iW8vg-0000ZY-HC@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