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

Commit04788ee

Browse files
committed
Add subquery pullup handling for WindowClause runCondition
9d9c02c added code to allow WindowAgg to take some shortcuts when amonotonic WindowFunc reached some value that it could never come backfrom due to the function's monotonic nature. That commit added arunCondition field to WindowClause to store the condition which, when itbecomes false we can start taking shortcuts in nodeWindowAgg.c.Here we fix an issue where subquery pullups didn't properly update therunCondition to update the Vars to properly reference the new query level.Here we also add a missing call to preprocess_expression() for theWindowClause's runCondtion. The WindowFuncs in the targetlist will havehad this process done, so we must also do it for the WindowFuncs in therunCondition so that they can be correctly found in the targetlistduring setrefs.cBug: #17709Reported-by: Alexey MakhmutovAuthor: Richard Guo, David RowleyDiscussion:https://postgr.es/m/17709-4f557160e3e8ee9a@postgresql.orgBackpatch-through: 15, where9d9c02c was introduced
1 parentee1c672 commit04788ee

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

‎src/backend/optimizer/plan/planner.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,9 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
826826
EXPRKIND_LIMIT);
827827
wc->endOffset=preprocess_expression(root,wc->endOffset,
828828
EXPRKIND_LIMIT);
829+
wc->runCondition= (List*)preprocess_expression(root,
830+
(Node*)wc->runCondition,
831+
EXPRKIND_TARGET);
829832
}
830833

831834
parse->limitOffset=preprocess_expression(root,parse->limitOffset,

‎src/backend/optimizer/prep/prepjointree.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,15 @@ perform_pullup_replace_vars(PlannerInfo *root,
21242124
pullup_replace_vars((Node*)parse->targetList,rvcontext);
21252125
parse->returningList= (List*)
21262126
pullup_replace_vars((Node*)parse->returningList,rvcontext);
2127+
2128+
foreach(lc,parse->windowClause)
2129+
{
2130+
WindowClause*wc=lfirst_node(WindowClause,lc);
2131+
2132+
if (wc->runCondition!=NIL)
2133+
wc->runCondition= (List*)
2134+
pullup_replace_vars((Node*)wc->runCondition,rvcontext);
2135+
}
21272136
if (parse->onConflict)
21282137
{
21292138
parse->onConflict->onConflictSet= (List*)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp