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

Commit94985c2

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 parent66dcb09 commit94985c2

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
@@ -833,6 +833,9 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
833833
EXPRKIND_LIMIT);
834834
wc->endOffset=preprocess_expression(root,wc->endOffset,
835835
EXPRKIND_LIMIT);
836+
wc->runCondition= (List*)preprocess_expression(root,
837+
(Node*)wc->runCondition,
838+
EXPRKIND_TARGET);
836839
}
837840

838841
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
@@ -2120,6 +2120,15 @@ perform_pullup_replace_vars(PlannerInfo *root,
21202120
pullup_replace_vars((Node*)parse->targetList,rvcontext);
21212121
parse->returningList= (List*)
21222122
pullup_replace_vars((Node*)parse->returningList,rvcontext);
2123+
2124+
foreach(lc,parse->windowClause)
2125+
{
2126+
WindowClause*wc=lfirst_node(WindowClause,lc);
2127+
2128+
if (wc->runCondition!=NIL)
2129+
wc->runCondition= (List*)
2130+
pullup_replace_vars((Node*)wc->runCondition,rvcontext);
2131+
}
21232132
if (parse->onConflict)
21242133
{
21252134
parse->onConflict->onConflictSet= (List*)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp