]> granicus.if.org Git - postgresql/commit
Fix printing of whole-row Vars at top level of a SELECT targetlist.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 27 Apr 2012 23:49:40 +0000 (19:49 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 27 Apr 2012 23:49:40 +0000 (19:49 -0400)
commita45c63ea0e5fcd3aaf9b707ec6fc059e07cd18a4
tree6bf99628094b0dd3c23b805602ae1c65ec6b0a21
parentaa0c797c901d43a5cd7ce74b0348198792c0646b
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.
src/backend/utils/adt/ruleutils.c