]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Further fix dumping of views that contain just VALUES(...).
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Nov 2019 01:00:19 +0000 (20:00 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Nov 2019 01:00:19 +0000 (20:00 -0500)
commitfcaf29d87a6ca08188fa9fe1ebba90c9654df006
treeda0f8126c237357f060d0ed3749a1f53ea8545a9
parentbbaa38e824236ac106fffbf5f61e5da9b3dc1ec9
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
src/backend/utils/adt/ruleutils.c
src/test/regress/expected/rules.out
src/test/regress/sql/rules.sql