Skip to content

Commit 7607671

Browse files
committed
Backpatch missing check_stack_depth() to some recursive functions
Backpatch changes from d57b7cc, 75bcba6 to all supported branches per proposal of Egor Chindyaskin. Discussion: https://postgr.es/m/DE5FD776-A8CD-4378-BCFA-3BF30F1F6D60%40mail.ru
1 parent 6a9e2cb commit 7607671

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

src/backend/catalog/dependency.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include "commands/trigger.h"
7777
#include "commands/typecmds.h"
7878
#include "funcapi.h"
79+
#include "miscadmin.h"
7980
#include "nodes/nodeFuncs.h"
8081
#include "parser/parsetree.h"
8182
#include "rewrite/rewriteRemove.h"
@@ -524,6 +525,12 @@ findDependentObjects(const ObjectAddress *object,
524525
if (stack_address_present_add_flags(object, objflags, stack))
525526
return;
526527

528+
/*
529+
* since this function recurses, it could be driven to stack overflow,
530+
* because of the deep dependency tree, not only due to dependency loops.
531+
*/
532+
check_stack_depth();
533+
527534
/*
528535
* It's also possible that the target object has already been completely
529536
* processed and put into targetObjects. If so, again we just add the

src/backend/catalog/heap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,9 @@ CheckAttributeType(const char *attname,
552552
char att_typtype = get_typtype(atttypid);
553553
Oid att_typelem;
554554

555+
/* since this function recurses, it could be driven to stack overflow */
556+
check_stack_depth();
557+
555558
if (att_typtype == TYPTYPE_PSEUDO)
556559
{
557560
/*

src/backend/commands/tablecmds.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6802,6 +6802,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
68026802
TupleDesc tupdesc;
68036803
FormData_pg_attribute *aattr[] = {&attribute};
68046804

6805+
/* since this function recurses, it could be driven to stack overflow */
6806+
check_stack_depth();
6807+
68056808
/* At top level, permission check was done in ATPrepCmd, else do it */
68066809
if (recursing)
68076810
ATSimplePermissions((*cmd)->subtype, rel, ATT_TABLE | ATT_FOREIGN_TABLE);
@@ -8517,6 +8520,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
85178520

85188521
/* Initialize addrs on the first invocation */
85198522
Assert(!recursing || addrs != NULL);
8523+
8524+
/* since this function recurses, it could be driven to stack overflow */
8525+
check_stack_depth();
8526+
85208527
if (!recursing)
85218528
addrs = new_object_addresses();
85228529

@@ -10974,6 +10981,9 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
1097410981
Oid refrelid;
1097510982
bool changed = false;
1097610983

10984+
/* since this function recurses, it could be driven to stack overflow */
10985+
check_stack_depth();
10986+
1097710987
currcon = (Form_pg_constraint) GETSTRUCT(contuple);
1097810988
conoid = currcon->oid;
1097910989
refrelid = currcon->confrelid;
@@ -11981,6 +11991,9 @@ ATExecDropConstraint(Relation rel, const char *constrName,
1198111991
bool is_no_inherit_constraint = false;
1198211992
char contype;
1198311993

11994+
/* since this function recurses, it could be driven to stack overflow */
11995+
check_stack_depth();
11996+
1198411997
/* At top level, permission check was done in ATPrepCmd, else do it */
1198511998
if (recursing)
1198611999
ATSimplePermissions(AT_DropConstraint, rel, ATT_TABLE | ATT_FOREIGN_TABLE);

src/backend/optimizer/util/clauses.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,10 @@ static Node *
24232423
eval_const_expressions_mutator(Node *node,
24242424
eval_const_expressions_context *context)
24252425
{
2426+
2427+
/* since this function recurses, it could be driven to stack overflow */
2428+
check_stack_depth();
2429+
24262430
if (node == NULL)
24272431
return NULL;
24282432
switch (nodeTag(node))

src/backend/utils/adt/jsonpath_exec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,9 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp,
12321232
JsonPathBool res;
12331233
JsonPathBool res2;
12341234

1235+
/* since this function recurses, it could be driven to stack overflow */
1236+
check_stack_depth();
1237+
12351238
if (!canHaveNext && jspHasNext(jsp))
12361239
elog(ERROR, "boolean jsonpath item cannot have next item");
12371240

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy