Skip to content

Commit 98bfb75

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 9301e0f commit 98bfb75

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
@@ -73,6 +73,7 @@
7373
#include "commands/sequence.h"
7474
#include "commands/trigger.h"
7575
#include "commands/typecmds.h"
76+
#include "miscadmin.h"
7677
#include "nodes/nodeFuncs.h"
7778
#include "parser/parsetree.h"
7879
#include "rewrite/rewriteRemove.h"
@@ -509,6 +510,12 @@ findDependentObjects(const ObjectAddress *object,
509510
if (stack_address_present_add_flags(object, objflags, stack))
510511
return;
511512

513+
/*
514+
* since this function recurses, it could be driven to stack overflow,
515+
* because of the deep dependency tree, not only due to dependency loops.
516+
*/
517+
check_stack_depth();
518+
512519
/*
513520
* It's also possible that the target object has already been completely
514521
* 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
@@ -595,6 +595,9 @@ CheckAttributeType(const char *attname,
595595
char att_typtype = get_typtype(atttypid);
596596
Oid att_typelem;
597597

598+
/* since this function recurses, it could be driven to stack overflow */
599+
check_stack_depth();
600+
598601
if (att_typtype == TYPTYPE_PSEUDO)
599602
{
600603
/*

src/backend/commands/tablecmds.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5941,6 +5941,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
59415941
AclResult aclresult;
59425942
ObjectAddress address;
59435943

5944+
/* since this function recurses, it could be driven to stack overflow */
5945+
check_stack_depth();
5946+
59445947
/* At top level, permission check was done in ATPrepCmd, else do it */
59455948
if (recursing)
59465949
ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE);
@@ -7505,6 +7508,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
75057508

75067509
/* Initialize addrs on the first invocation */
75077510
Assert(!recursing || addrs != NULL);
7511+
7512+
/* since this function recurses, it could be driven to stack overflow */
7513+
check_stack_depth();
7514+
75087515
if (!recursing)
75097516
addrs = new_object_addresses();
75107517

@@ -9632,6 +9639,9 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
96329639
Oid refrelid;
96339640
bool changed = false;
96349641

9642+
/* since this function recurses, it could be driven to stack overflow */
9643+
check_stack_depth();
9644+
96359645
currcon = (Form_pg_constraint) GETSTRUCT(contuple);
96369646
conoid = currcon->oid;
96379647
refrelid = currcon->confrelid;
@@ -10616,6 +10626,9 @@ ATExecDropConstraint(Relation rel, const char *constrName,
1061610626
bool is_no_inherit_constraint = false;
1061710627
char contype;
1061810628

10629+
/* since this function recurses, it could be driven to stack overflow */
10630+
check_stack_depth();
10631+
1061910632
/* At top level, permission check was done in ATPrepCmd, else do it */
1062010633
if (recursing)
1062110634
ATSimplePermissions(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
@@ -2458,6 +2458,10 @@ static Node *
24582458
eval_const_expressions_mutator(Node *node,
24592459
eval_const_expressions_context *context)
24602460
{
2461+
2462+
/* since this function recurses, it could be driven to stack overflow */
2463+
check_stack_depth();
2464+
24612465
if (node == NULL)
24622466
return NULL;
24632467
switch (nodeTag(node))

src/backend/utils/adt/jsonpath_exec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,9 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp,
11601160
JsonPathBool res;
11611161
JsonPathBool res2;
11621162

1163+
/* since this function recurses, it could be driven to stack overflow */
1164+
check_stack_depth();
1165+
11631166
if (!canHaveNext && jspHasNext(jsp))
11641167
elog(ERROR, "boolean jsonpath item cannot have next item");
11651168

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