postgresql/src/backend/commands
Tom Lane 6ef77cf46e Further adjust EXPLAIN's choices of table alias names.
This patch causes EXPLAIN to always assign a separate table alias to the
parent RTE of an append relation (inheritance set); before, such RTEs
were ignored if not actually scanned by the plan.  Since the child RTEs
now always have that same alias to start with (cf. commit 55a1954da),
the net effect is that the parent RTE usually gets the alias used or
implied by the query text, and the children all get that alias with "_N"
appended.  (The exception to "usually" is if there are duplicate aliases
in different subtrees of the original query; then some of those original
RTEs will also have "_N" appended.)

This results in more uniform output for partitioned-table plans than
we had before: the partitioned table itself gets the original alias,
and all child tables have aliases with "_N", rather than the previous
behavior where one of the children would get an alias without "_N".

The reason for giving the parent RTE an alias, even if it isn't scanned
by the plan, is that we now use the parent's alias to qualify Vars that
refer to an appendrel output column and appear above the Append or
MergeAppend that computes the appendrel.  But below the append, Vars
refer to some one of the child relations, and are displayed that way.
This seems clearer than the old behavior where a Var that could carry
values from any child relation was displayed as if it referred to only
one of them.

While at it, change ruleutils.c so that the code paths used by EXPLAIN
deal in Plan trees not PlanState trees.  This effectively reverts a
decision made in commit 1cc29fe7c, which seemed like a good idea at
the time to make ruleutils.c consistent with explain.c.  However,
it's problematic because we'd really like to allow executor startup
pruning to remove all the children of an append node when possible,
leaving no child PlanState to resolve Vars against.  (That's not done
here, but will be in the next patch.)  This requires different handling
of subplans and initplans than before, but is otherwise a pretty
straightforward change.

Discussion: https://postgr.es/m/001001d4f44b$2a2cca50$7e865ef0$@lab.ntt.co.jp
2019-12-11 17:05:18 -05:00
..
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
aggregatecmds.c
alter.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
amcmds.c
analyze.c Remove configure --disable-float4-byval 2019-11-21 18:29:21 +01:00
async.c Doc: improve discussion of race conditions involved in LISTEN. 2019-11-24 18:03:39 -05:00
cluster.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
collationcmds.c
comment.c
constraint.c
conversioncmds.c
copy.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
createas.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
dbcommands.c Make DROP DATABASE command generate less WAL records. 2019-11-21 21:10:37 +09:00
define.c Fix inconsistencies and typos in the tree, take 9 2019-08-05 12:14:58 +09:00
discard.c
dropcmds.c
event_trigger.c Have LookupFuncName accept NULL argtypes for 0 args 2019-11-12 17:06:58 -03:00
explain.c Further adjust EXPLAIN's choices of table alias names. 2019-12-11 17:05:18 -05:00
extension.c PG_FINALLY 2019-11-01 11:18:03 +01:00
foreigncmds.c Have LookupFuncName accept NULL argtypes for 0 args 2019-11-12 17:06:58 -03:00
functioncmds.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
indexcmds.c Handle interrupts within a transaction context in REINDEX CONCURRENTLY 2019-10-25 10:20:08 +09:00
lockcmds.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
matview.c
opclasscmds.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
operatorcmds.c Fix inconsistencies and typos in the tree 2019-07-29 12:28:30 +09:00
policy.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
portalcmds.c
prepare.c Add error position to an error message 2019-11-29 09:10:17 +01:00
proclang.c Have LookupFuncName accept NULL argtypes for 0 args 2019-11-12 17:06:58 -03:00
publicationcmds.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
schemacmds.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
seclabel.c
sequence.c Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
statscmds.c Remove last traces of heap_open/close in the tree 2019-10-19 11:18:15 +09:00
subscriptioncmds.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
tablecmds.c Remove ATPrepSetStatistics 2019-12-11 09:04:04 +01:00
tablespace.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
trigger.c Fix handling of multiple AFTER ROW triggers on a foreign table. 2019-12-10 18:00:30 +09:00
tsearchcmds.c
typecmds.c
user.c
vacuum.c PG_FINALLY 2019-11-01 11:18:03 +01:00
variable.c Make the order of the header file includes consistent in backend modules. 2019-11-12 08:30:16 +05:30
view.c Allow ALTER VIEW command to rename the column in the view. 2019-11-21 19:55:13 +09:00