Fix printing of whole-row Vars at top level of a SELECT targetlist.
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.

greenplum-db/gpdb,rvs/gpdb,yuanzhao/gpdb,xinzweb/gpdb,kaknikhil/gpdb,CraigHarris/gpdb,edespino/gpdb,Quikling/gpdb,ashwinstar/gpdb,zaksoup/gpdb,cjcjameson/gpdb,chrishajas/gpdb,xuegang/gpdb,kaknikhil/gpdb,rvs/gpdb,Chibin/gpdb,zaksoup/gpdb,greenplum-db/gpdb,kaknikhil/gpdb,xuegang/gpdb,cjcjameson/gpdb,xuegang/gpdb,Chibin/gpdb,CraigHarris/gpdb,rvs/gpdb,xinzweb/gpdb,greenplum-db/gpdb,Quikling/gpdb,adam8157/gpdb,Chibin/gpdb,royc1/gpdb,yuanzhao/gpdb,ahachete/gpdb,lisakowen/gpdb,xinzweb/gpdb,zaksoup/gpdb,Quikling/gpdb,ahachete/gpdb,lisakowen/gpdb,janebeckman/gpdb,janebeckman/gpdb,janebeckman/gpdb,yuanzhao/gpdb,ashwinstar/gpdb,adam8157/gpdb,adam8157/gpdb,edespino/gpdb,50wu/gpdb,kaknikhil/gpdb,chrishajas/gpdb,janebeckman/gpdb,Chibin/gpdb,cjcjameson/gpdb,zaksoup/gpdb,chrishajas/gpdb,CraigHarris/gpdb,lintzc/gpdb,janebeckman/gpdb,greenplum-db/gpdb,yuanzhao/gpdb,xuegang/gpdb,zaksoup/gpdb,yuanzhao/gpdb,cjcjameson/gpdb,jmcatamney/gpdb,0x0FFF/gpdb,chrishajas/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,xinzweb/gpdb,Chibin/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,lintzc/gpdb,xuegang/gpdb,50wu/gpdb,edespino/gpdb,cjcjameson/gpdb,xuegang/gpdb,Quikling/gpdb,greenplum-db/gpdb,CraigHarris/gpdb,0x0FFF/gpdb,zaksoup/gpdb,50wu/gpdb,Quikling/gpdb,edespino/gpdb,lintzc/gpdb,greenplum-db/gpdb,50wu/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,rvs/gpdb,xinzweb/gpdb,kaknikhil/gpdb,ahachete/gpdb,xuegang/gpdb,royc1/gpdb,lisakowen/gpdb,chrishajas/gpdb,adam8157/gpdb,Chibin/gpdb,ahachete/gpdb,yuanzhao/gpdb,lisakowen/gpdb,Chibin/gpdb,yuanzhao/gpdb,0x0FFF/gpdb,lintzc/gpdb,ahachete/gpdb,royc1/gpdb,yuanzhao/gpdb,ahachete/gpdb,Quikling/gpdb,royc1/gpdb,kaknikhil/gpdb,ashwinstar/gpdb,CraigHarris/gpdb,lintzc/gpdb,zaksoup/gpdb,royc1/gpdb,janebeckman/gpdb,Chibin/gpdb,rvs/gpdb,cjcjameson/gpdb,0x0FFF/gpdb,lintzc/gpdb,50wu/gpdb,xinzweb/gpdb,CraigHarris/gpdb,rvs/gpdb,0x0FFF/gpdb,xinzweb/gpdb,cjcjameson/gpdb,Quikling/gpdb,rvs/gpdb,edespino/gpdb,0x0FFF/gpdb,royc1/gpdb,jmcatamney/gpdb,rvs/gpdb,Chibin/gpdb,greenplum-db/gpdb,janebeckman/gpdb,adam8157/gpdb,lintzc/gpdb,CraigHarris/gpdb,janebeckman/gpdb,royc1/gpdb,cjcjameson/gpdb,Quikling/gpdb,yuanzhao/gpdb,lisakowen/gpdb,50wu/gpdb,kaknikhil/gpdb,edespino/gpdb,janebeckman/gpdb,ashwinstar/gpdb,50wu/gpdb,chrishajas/gpdb,greenplum-db/gpdb,royc1/gpdb,zaksoup/gpdb,edespino/gpdb,adam8157/gpdb,janebeckman/gpdb,jmcatamney/gpdb,CraigHarris/gpdb,rvs/gpdb,ahachete/gpdb,Chibin/gpdb,jmcatamney/gpdb,lisakowen/gpdb,Quikling/gpdb,yuanzhao/gpdb,rvs/gpdb,chrishajas/gpdb,ashwinstar/gpdb,ahachete/gpdb,50wu/gpdb,lisakowen/gpdb,edespino/gpdb,Quikling/gpdb,xinzweb/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,0x0FFF/gpdb,edespino/gpdb,edespino/gpdb,adam8157/gpdb,xuegang/gpdb,chrishajas/gpdb,lintzc/gpdb,0x0FFF/gpdb,kaknikhil/gpdb,jmcatamney/gpdb,lisakowen/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,CraigHarris/gpdb,lintzc/gpdb,xuegang/gpdb,adam8157/gpdb