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

Commit4e9fb4b

Browse files
committed
Add stack-overflow guards in set-operation planning.
create_plan_recurse lacked any stack depth check. This is not perour normal coding rules, but I'd supposed it was safe because earlierplanner processing is more complex and presumably should eat morestack. But bug #15033 from Andrew Grossman shows this isn't true,at least not for queries having the form of a many-thousand-wayINTERSECT stack.Further testing showed that recurse_set_operations is also capableof being crashed in this way, since it likewise will recurse to thebottom of a parsetree before calling any support functions thatmight themselves contain any stack checks. However, its stackconsumption is only perhaps a third of create_plan_recurse's.It's possible that this particular problem with create_plan_recurse canonly manifest in 9.6 and later, since before that we didn't build a Pathtree for set operations. But having seen this example, I now have nofaith in the proposition that create_plan_recurse doesn't need a stackcheck, so back-patch to all supported branches.Discussion:https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org
1 parent462402b commit4e9fb4b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
343343
{
344344
Plan*plan;
345345

346+
/* Guard against stack overflow due to overly complex plans */
347+
check_stack_depth();
348+
346349
switch (best_path->pathtype)
347350
{
348351
caseT_SeqScan:

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ recurse_set_operations(Node *setOp, PlannerInfo *root,
253253
List**pTargetList,
254254
double*pNumGroups)
255255
{
256+
/* Guard against stack overflow due to overly complex setop nests */
257+
check_stack_depth();
258+
256259
if (IsA(setOp,RangeTblRef))
257260
{
258261
RangeTblRef*rtr= (RangeTblRef*)setOp;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp