Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb8e015

Browse files
committed
Code review for nodeGatherMerge.c.
Comment the fields of GatherMergeState, and organize them a bit moresensibly. Comment GMReaderTupleBuffer more usefully too. Improveassorted other comments that were obsolete or just not very good English.Get rid of the use of a GMReaderTupleBuffer for the leader process;that was confusing, since only the "done" field was used, and thatin a way redundant with need_to_scan_locally.In gather_merge_init, avoid calling load_tuple_array foralready-known-exhausted workers. I'm not sure if there's a live bug there,but the case is unlikely to be well tested due to timing considerations.Remove some useless code, such as duplicating the tts_isempty test done byTupIsNull.Remove useless initialization of ps.qual, replacing that with an assertionthat we have no qual to check. (If we did, the code would fail to checkit.)Avoid applying heap_copytuple to a null tuple. While that fails to crash,it's confusing and it makes the code less legible not more so IMO.Propagate a couple of these changes into nodeGather.c, as well.Back-patch to v10, partly because of the possibility that thegather_merge_init change is fixing a live bug, but mostly to keepthe branches in sync to ease future bug fixes.
1 parentd6a149f commitcb8e015

File tree

3 files changed

+136
-112
lines changed

3 files changed

+136
-112
lines changed

‎src/backend/executor/nodeGather.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ ExecInitGather(Gather *node, EState *estate, int eflags)
7171
gatherstate->ps.plan= (Plan*)node;
7272
gatherstate->ps.state=estate;
7373
gatherstate->ps.ExecProcNode=ExecGather;
74+
75+
gatherstate->initialized= false;
7476
gatherstate->need_to_scan_locally= !node->single_copy;
7577

7678
/*
@@ -81,10 +83,10 @@ ExecInitGather(Gather *node, EState *estate, int eflags)
8183
ExecAssignExprContext(estate,&gatherstate->ps);
8284

8385
/*
84-
* initialize child expressions
86+
* Gather doesn't support checking a qual (it's always more efficient to
87+
* do it in the child node).
8588
*/
86-
gatherstate->ps.qual=
87-
ExecInitQual(node->plan.qual, (PlanState*)gatherstate);
89+
Assert(!node->plan.qual);
8890

8991
/*
9092
* tuple table initialization
@@ -167,15 +169,16 @@ ExecGather(PlanState *pstate)
167169
*/
168170
pcxt=node->pei->pcxt;
169171
LaunchParallelWorkers(pcxt);
172+
/* We save # workers launched for the benefit of EXPLAIN */
170173
node->nworkers_launched=pcxt->nworkers_launched;
174+
node->nreaders=0;
175+
node->nextreader=0;
171176

172177
/* Set up tuple queue readers to read the results. */
173178
if (pcxt->nworkers_launched>0)
174179
{
175-
node->nreaders=0;
176-
node->nextreader=0;
177-
node->reader=
178-
palloc(pcxt->nworkers_launched*sizeof(TupleQueueReader*));
180+
node->reader=palloc(pcxt->nworkers_launched*
181+
sizeof(TupleQueueReader*));
179182

180183
for (i=0;i<pcxt->nworkers_launched;++i)
181184
{
@@ -314,8 +317,8 @@ gather_readnext(GatherState *gatherstate)
314317
tup=TupleQueueReaderNext(reader, true,&readerdone);
315318

316319
/*
317-
* If this reader is done, remove it. If all readers are done, clean
318-
* up remaining worker state.
320+
* If this reader is done, remove it, and collapse the array. If all
321+
*readers are done, cleanup remaining worker state.
319322
*/
320323
if (readerdone)
321324
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp