Skip site navigation (1) Skip section navigation (2)

pgsql: Fix printing of whole-row Vars at top level of a SELECTtargetli

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix printing of whole-row Vars at top level of a SELECTtargetli
Date: 2012-04-27 23:50:25
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
Fix printing of whole-row Vars at top level of a SELECT targetlist.

Normally whole-row Vars are printed as "tabname.*".  However, that does not
work at top level of a targetlist, because per SQL standard the parser will
think that the "*" should result in column-by-column expansion; which is
not at all what a whole-row Var implies.  We used to just print the table
name in such cases, which works most of the time; but it fails if the table
name matches a column name available anywhere in the FROM clause.  This
could lead for instance to a view being interpreted differently after dump
and reload.  Adding parentheses doesn't fix it, but there is a reasonably
simple kluge we can use instead: attach a no-op cast, so that the "*" isn't
syntactically at top level anymore.  This makes the printing of such
whole-row Vars a lot more consistent with other Vars, and may indeed fix
more cases than just the reported one; I'm suspicious that cases involving
schema qualification probably didn't work properly before, either.

Per bug report and fix proposal from Abbas Butt, though this patch is quite
different in detail from his.

Back-patch to all supported versions.



Modified Files
src/backend/utils/adt/ruleutils.c |   45 ++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 13 deletions(-)

pgsql-committers by date

Next:From: Peter EisentrautDate: 2012-04-28 10:34:30
Subject: pgsql: PL/Python: Update list of supported environment variables
Previous:From: Bruce MomjianDate: 2012-04-27 21:15:52
Subject: pgsql: Add options to git_changelog for use in major release notecreat

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group