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

Commit4fceb45

Browse files
committed
Add some recursion and looping defenses in prepjointree.c.
Andrey Lepikhov demonstrated a case where we spend an unreasonableamount of time in pull_up_subqueries(). Not only is that recursingwith no explicit check for stack overrun, but the code seems notinterruptable by control-C. Let's stick a CHECK_FOR_INTERRUPTSthere, along with sprinkling some stack depth checks.An actual fix for the excessive time consumption seems a bitrisky to back-patch; but this isn't, so let's do so.Discussion:https://postgr.es/m/703c09a2-08f3-d2ec-b33d-dbecd62428b8@postgrespro.ru
1 parentd35f1d4 commit4fceb45

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include"catalog/pg_type.h"
2929
#include"funcapi.h"
30+
#include"miscadmin.h"
3031
#include"nodes/makefuncs.h"
3132
#include"nodes/nodeFuncs.h"
3233
#include"optimizer/clauses.h"
@@ -239,6 +240,9 @@ static Node *
239240
pull_up_sublinks_jointree_recurse(PlannerInfo*root,Node*jtnode,
240241
Relids*relids)
241242
{
243+
/* Since this function recurses, it could be driven to stack overflow. */
244+
check_stack_depth();
245+
242246
if (jtnode==NULL)
243247
{
244248
*relids=NULL;
@@ -736,6 +740,11 @@ pull_up_subqueries_recurse(PlannerInfo *root, Node *jtnode,
736740
JoinExpr*lowest_nulling_outer_join,
737741
AppendRelInfo*containing_appendrel)
738742
{
743+
/* Since this function recurses, it could be driven to stack overflow. */
744+
check_stack_depth();
745+
/* Also, since it's a bit expensive, let's check for query cancel. */
746+
CHECK_FOR_INTERRUPTS();
747+
739748
Assert(jtnode!=NULL);
740749
if (IsA(jtnode,RangeTblRef))
741750
{
@@ -1855,6 +1864,9 @@ is_simple_union_all(Query *subquery)
18551864
staticbool
18561865
is_simple_union_all_recurse(Node*setOp,Query*setOpQuery,List*colTypes)
18571866
{
1867+
/* Since this function recurses, it could be driven to stack overflow. */
1868+
check_stack_depth();
1869+
18581870
if (IsA(setOp,RangeTblRef))
18591871
{
18601872
RangeTblRef*rtr= (RangeTblRef*)setOp;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp