postgresql/src/backend/commands
Tom Lane 11e131854f Improve ruleutils.c's heuristics for dealing with rangetable aliases.
The previous scheme had bugs in some corner cases involving tables that had
been renamed since a view was made.  This could result in dumped views that
failed to reload or reloaded incorrectly, as seen in bug #7553 from Lloyd
Albin, as well as in some pgsql-hackers discussion back in January.  Also,
its behavior for printing EXPLAIN plans was sometimes confusing because of
willingness to use the same alias for multiple RTEs (it was Ashutosh
Bapat's complaint about that aspect that started the January thread).

To fix, ensure that each RTE in the query has a unique unqualified alias,
by modifying the alias if necessary (we add "_" and digits as needed to
create a non-conflicting name).  Then we can just print its variables with
that alias, avoiding the confusing and bug-prone scheme of sometimes
schema-qualifying variable names.  In EXPLAIN, it proves to be expedient to
take the further step of only assigning such aliases to RTEs that are
actually referenced in the query, since the planner has a habit of
generating extra RTEs with the same alias in situations such as
inheritance-tree expansion.

Although this fixes a bug of very long standing, I'm hesitant to back-patch
such a noticeable behavioral change.  My experiments while creating a
regression test convinced me that actually incorrect output (as opposed to
confusing output) occurs only in very narrow cases, which is backed up by
the lack of previous complaints from the field.  So we may be better off
living with it in released branches; and in any case it'd be smart to let
this ripen awhile in HEAD before we consider back-patching it.
2012-09-21 19:03:10 -04:00
..
aggregatecmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
alter.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
analyze.c Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
async.c Fix NOTIFY to cope with I/O problems, such as out-of-disk-space. 2012-06-29 00:51:34 -04:00
cluster.c Replace int2/int4 in C code with int16/int32 2012-06-25 01:51:46 +03:00
collationcmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
comment.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
constraint.c Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
conversioncmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
copy.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
createas.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
dbcommands.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
define.c Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
discard.c Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
dropcmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
event_trigger.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
explain.c Improve ruleutils.c's heuristics for dealing with rangetable aliases. 2012-09-21 19:03:10 -04:00
extension.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
foreigncmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
functioncmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
indexcmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
lockcmds.c Repair comment mangled by a pgindent run long ago 2012-06-21 15:37:05 -04:00
Makefile Syntax support and documentation for event triggers. 2012-07-18 10:16:16 -04:00
opclasscmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
operatorcmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
portalcmds.c Restructure SELECT INTO's parsetree representation into CreateTableAsStmt. 2012-03-19 21:38:12 -04:00
prepare.c Centralize the logic for detecting misplaced aggregates, window funcs, etc. 2012-08-10 11:36:15 -04:00
proclang.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
schemacmds.c Remove execdesc.h inclusion from tcopprot.h 2012-09-20 11:07:59 -03:00
seclabel.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
sequence.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
tablecmds.c Comment fixes. 2012-08-30 10:42:28 -04:00
tablespace.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
trigger.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
tsearchcmds.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
typecmds.c Fix a couple other leftover uses of 'conisonly' terminology. 2012-09-12 15:12:24 -04:00
user.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
vacuum.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
vacuumlazy.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
variable.c Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
view.c Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00