|
35 | 35 | #include "commands/tablespace.h"
|
36 | 36 | #include "executor/spi.h"
|
37 | 37 | #include "funcapi.h"
|
| 38 | +#include "miscadmin.h" |
38 | 39 | #include "nodes/makefuncs.h"
|
39 | 40 | #include "nodes/nodeFuncs.h"
|
40 | 41 | #include "optimizer/clauses.h"
|
@@ -2265,6 +2266,10 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
2265 | 2266 | deparse_context context;
|
2266 | 2267 | deparse_namespace dpns;
|
2267 | 2268 |
|
| 2269 | + /* Guard against excessively long or deeply-nested queries */ |
| 2270 | + CHECK_FOR_INTERRUPTS(); |
| 2271 | + check_stack_depth(); |
| 2272 | + |
2268 | 2273 | /*
|
2269 | 2274 | * Before we begin to examine the query, acquire locks on referenced
|
2270 | 2275 | * relations, and fix up deleted columns in JOIN RTEs. This ensures
|
@@ -2708,6 +2713,10 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
|
2708 | 2713 | StringInfo buf = context->buf;
|
2709 | 2714 | bool need_paren;
|
2710 | 2715 |
|
| 2716 | + /* Guard against excessively long or deeply-nested queries */ |
| 2717 | + CHECK_FOR_INTERRUPTS(); |
| 2718 | + check_stack_depth(); |
| 2719 | + |
2711 | 2720 | if (IsA(setOp, RangeTblRef))
|
2712 | 2721 | {
|
2713 | 2722 | RangeTblRef *rtr = (RangeTblRef *) setOp;
|
@@ -4297,6 +4306,10 @@ get_rule_expr(Node *node, deparse_context *context,
|
4297 | 4306 | if (node == NULL)
|
4298 | 4307 | return;
|
4299 | 4308 |
|
| 4309 | + /* Guard against excessively long or deeply-nested queries */ |
| 4310 | + CHECK_FOR_INTERRUPTS(); |
| 4311 | + check_stack_depth(); |
| 4312 | + |
4300 | 4313 | /*
|
4301 | 4314 | * Each level of get_rule_expr must emit an indivisible term
|
4302 | 4315 | * (parenthesized if necessary) to ensure result is reparsed into the same
|
|
0 commit comments