|
36 | 36 | #include "commands/tablespace.h"
|
37 | 37 | #include "executor/spi.h"
|
38 | 38 | #include "funcapi.h"
|
| 39 | +#include "miscadmin.h" |
39 | 40 | #include "nodes/makefuncs.h"
|
40 | 41 | #include "nodes/nodeFuncs.h"
|
41 | 42 | #include "optimizer/clauses.h"
|
@@ -4000,6 +4001,10 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
4000 | 4001 | deparse_context context;
|
4001 | 4002 | deparse_namespace dpns;
|
4002 | 4003 |
|
| 4004 | + /* Guard against excessively long or deeply-nested queries */ |
| 4005 | + CHECK_FOR_INTERRUPTS(); |
| 4006 | + check_stack_depth(); |
| 4007 | + |
4003 | 4008 | /*
|
4004 | 4009 | * Before we begin to examine the query, acquire locks on referenced
|
4005 | 4010 | * relations, and fix up deleted columns in JOIN RTEs. This ensures
|
@@ -4556,6 +4561,10 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
|
4556 | 4561 | StringInfo buf = context->buf;
|
4557 | 4562 | bool need_paren;
|
4558 | 4563 |
|
| 4564 | + /* Guard against excessively long or deeply-nested queries */ |
| 4565 | + CHECK_FOR_INTERRUPTS(); |
| 4566 | + check_stack_depth(); |
| 4567 | + |
4559 | 4568 | if (IsA(setOp, RangeTblRef))
|
4560 | 4569 | {
|
4561 | 4570 | RangeTblRef *rtr = (RangeTblRef *) setOp;
|
@@ -6393,6 +6402,10 @@ get_rule_expr(Node *node, deparse_context *context,
|
6393 | 6402 | if (node == NULL)
|
6394 | 6403 | return;
|
6395 | 6404 |
|
| 6405 | + /* Guard against excessively long or deeply-nested queries */ |
| 6406 | + CHECK_FOR_INTERRUPTS(); |
| 6407 | + check_stack_depth(); |
| 6408 | + |
6396 | 6409 | /*
|
6397 | 6410 | * Each level of get_rule_expr must emit an indivisible term
|
6398 | 6411 | * (parenthesized if necessary) to ensure result is reparsed into the same
|
|
0 commit comments