postgresql/src/backend/commands
Tom Lane 4d042999f9 Print a given subplan only once in EXPLAIN.
We have, for a very long time, allowed the same subplan (same member of the
PlannedStmt.subplans list) to be referenced by more than one SubPlan node;
this avoids problems for cases such as subplans within an IndexScan's
indxqual and indxqualorig fields.  However, EXPLAIN had not gotten the memo
and would print each reference as though it were an independent identical
subplan.  To fix, track plan_ids of subplans we've printed and don't print
the same plan_id twice.  Per report from Pavel Stehule.

BTW: the particular case of IndexScan didn't cause visible duplication
in a plain EXPLAIN, only EXPLAIN ANALYZE, because in the former case we
short-circuit executor startup before the indxqual field is processed by
ExecInitExpr.  That seems like it could easily lead to other EXPLAIN
problems in future, but it's not clear how to avoid it without breaking
the "EXPLAIN a plan using hypothetical indexes" use-case.  For now I've
left that issue alone.

Although this is a longstanding bug, it's purely cosmetic (no great harm
is done by the repeat printout) and we haven't had field complaints before.
So I'm hesitant to back-patch it, especially since there is some small risk
of ABI problems due to the need to add a new field to ExplainState.

In passing, rearrange order of fields in ExplainState to be less random,
and update some obsolete comments about when/where to initialize them.

Report: <CAFj8pRAimq+NK-menjt+3J4-LFoodDD8Or6=Lc_stcFD+eD4DA@mail.gmail.com>
2016-07-11 18:14:29 -04:00
..
Makefile Support CREATE ACCESS METHOD 2016-03-23 23:01:35 -03:00
aggregatecmds.c Fix type-safety problem with parallel aggregate serial/deserialization. 2016-06-22 16:52:41 -04:00
alter.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
amcmds.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
analyze.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
async.c Fix several mistakes around parallel workers and client_encoding. 2016-06-30 18:35:32 -04:00
cluster.c Fix various common mispellings. 2016-06-03 16:08:45 +01:00
collationcmds.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
comment.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
constraint.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
conversioncmds.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
copy.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
createas.c Fix CREATE MATVIEW/CREATE TABLE AS ... WITH NO DATA to not plan the query. 2016-06-27 15:57:50 -04:00
dbcommands.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
define.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
discard.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
dropcmds.c Fix DROP ACCESS METHOD IF EXISTS. 2016-05-27 11:03:18 -04:00
event_trigger.c Type names should not be quoted 2016-04-01 13:35:48 -03:00
explain.c Print a given subplan only once in EXPLAIN. 2016-07-11 18:14:29 -04:00
extension.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
foreigncmds.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
functioncmds.c Fix parallel-safety code for parallel aggregation. 2016-04-05 16:06:15 -04:00
indexcmds.c Disallow creation of indexes on system columns (except for OID). 2016-04-16 12:11:41 -04:00
lockcmds.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
matview.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
opclasscmds.c Fix broken dependency-mongering for index operator classes/families. 2016-04-13 23:33:31 -04:00
operatorcmds.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
policy.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
portalcmds.c Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
prepare.c On second thought, disable parallelism for prepared statements. 2016-02-26 16:33:37 +05:30
proclang.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
schemacmds.c Remove various special checks around default roles 2016-05-06 14:06:50 -04:00
seclabel.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
sequence.c Revert no-op changes to BufferGetPage() 2016-04-20 08:31:19 -05:00
tablecmds.c Remove various special checks around default roles 2016-05-06 14:06:50 -04:00
tablespace.c Remove various special checks around default roles 2016-05-06 14:06:50 -04:00
trigger.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
tsearchcmds.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
typecmds.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
user.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
vacuum.c Add VACUUM (DISABLE_PAGE_SKIPPING) for emergencies. 2016-06-17 15:48:57 -04:00
vacuumlazy.c Add VACUUM (DISABLE_PAGE_SKIPPING) for emergencies. 2016-06-17 15:48:57 -04:00
variable.c Fix several mistakes around parallel workers and client_encoding. 2016-06-30 18:35:32 -04:00
view.c Fix CREATE MATVIEW/CREATE TABLE AS ... WITH NO DATA to not plan the query. 2016-06-27 15:57:50 -04:00