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

Commit03561a6

Browse files
committed
Fix unnecessary use of moving-aggregate mode with non-moving frame.
When a plain aggregate is used as a window function, and the windowframe start is specified as UNBOUNDED PRECEDING, the frame's headcannot move so we do not need to use moving-aggregate mode. The checkfor that was put into initialize_peragg(), failing to notice thatExecInitWindowAgg() calls that function before it's filled inwinstate->frameOptions. Since makeNode() would have zeroed the field,this didn't provoke uninitialized-value complaints, nor would theerroneous decision have resulted in more than a little inefficiency.Still, it's wrong, so move the initialization ofwinstate->frameOptions earlier to make it work properly.While here, also fix a thinko in a comment. Both errors crept in incommita9d9acb which introduced the moving-aggregate mode.Spotted by Vallimaharajan G. Back-patch to all supported branches.Discussion:https://postgr.es/m/18e7f2a5167.fe36253866818.977923893562469143@zohocorp.com
1 parentb48eda4 commit03561a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/backend/executor/nodeWindowAgg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,9 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
23972397
winstate->ss.ps.state=estate;
23982398
winstate->ss.ps.ExecProcNode=ExecWindowAgg;
23992399

2400+
/* copy frame options to state node for easy access */
2401+
winstate->frameOptions=frameOptions;
2402+
24002403
/*
24012404
* Create expression contexts. We need two, one for per-input-tuple
24022405
* processing and one for per-output-tuple processing. We cheat a little
@@ -2647,9 +2650,6 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
26472650
/* Set the status to running */
26482651
winstate->status=WINDOWAGG_RUN;
26492652

2650-
/* copy frame options to state node for easy access */
2651-
winstate->frameOptions=frameOptions;
2652-
26532653
/* initialize frame bound offset expressions */
26542654
winstate->startOffset=ExecInitExpr((Expr*)node->startOffset,
26552655
(PlanState*)winstate);
@@ -2800,7 +2800,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
28002800

28012801
/*
28022802
* Figure out whether we want to use the moving-aggregate implementation,
2803-
* and collect the right set of fields from thepg_attribute entry.
2803+
* and collect the right set of fields from thepg_aggregate entry.
28042804
*
28052805
* It's possible that an aggregate would supply a safe moving-aggregate
28062806
* implementation and an unsafe normal one, in which case our hand is

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp