pgsql: Show 'AS "?column?"' explicitly when it's important.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Show 'AS "?column?"' explicitly when it's important.
Дата
Msg-id E1nsU7C-000TmA-1y@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Show 'AS "?column?"' explicitly when it's important.

ruleutils.c was coded to suppress the AS label for a SELECT output
expression if the column name is "?column?", which is the parser's
fallback if it can't think of something better.  This is fine, and
avoids ugly clutter, so long as (1) nothing further up in the parse
tree relies on that column name or (2) the same fallback would be
assigned when the rule or view definition is reloaded.  Unfortunately
(2) is far from certain, both because ruleutils.c might print the
expression in a different form from how it was originally written
and because FigureColname's rules might change in future releases.
So we shouldn't rely on that.

Detecting exactly whether there is any outer-level use of a SELECT
column name would be rather expensive.  This patch takes the simpler
approach of just passing down a flag indicating whether there *could*
be any outer use; for example, the output column names of a SubLink
are not referenceable, and we also do not care about the names exposed
by the right-hand side of a setop.  This is sufficient to suppress
unwanted clutter in all but one case in the regression tests.  That
seems like reasonable evidence that it won't be too much in users'
faces, while still fixing the cases we need to fix.

Per bug #17486 from Nicolas Lutic.  This issue is ancient, so
back-patch to all supported branches.

Discussion: https://postgr.es/m/17486-1ad6fd786728b8af@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7686403b43ca6ad8ae8e5c76273ec4826e2f2dce

Modified Files
--------------
src/backend/utils/adt/ruleutils.c     | 100 ++++++++++++++++++++++------------
src/test/regress/expected/matview.out |   4 +-
2 files changed, 66 insertions(+), 38 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Remove unused-and-misspelled function extern declaration.
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: pgstat: fix stats.spec instability on slow machines.