|
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"
|
@@ -2661,6 +2662,10 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
2661 | 2662 | deparse_context context;
|
2662 | 2663 | deparse_namespace dpns;
|
2663 | 2664 |
|
| 2665 | + /* Guard against excessively long or deeply-nested queries */ |
| 2666 | + CHECK_FOR_INTERRUPTS(); |
| 2667 | + check_stack_depth(); |
| 2668 | + |
2664 | 2669 | /*
|
2665 | 2670 | * Before we begin to examine the query, acquire locks on referenced
|
2666 | 2671 | * relations, and fix up deleted columns in JOIN RTEs. This ensures
|
@@ -3178,6 +3183,10 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
|
3178 | 3183 | StringInfo buf = context->buf;
|
3179 | 3184 | bool need_paren;
|
3180 | 3185 |
|
| 3186 | + /* Guard against excessively long or deeply-nested queries */ |
| 3187 | + CHECK_FOR_INTERRUPTS(); |
| 3188 | + check_stack_depth(); |
| 3189 | + |
3181 | 3190 | if (IsA(setOp, RangeTblRef))
|
3182 | 3191 | {
|
3183 | 3192 | RangeTblRef *rtr = (RangeTblRef *) setOp;
|
@@ -5001,6 +5010,10 @@ get_rule_expr(Node *node, deparse_context *context,
|
5001 | 5010 | if (node == NULL)
|
5002 | 5011 | return;
|
5003 | 5012 |
|
| 5013 | + /* Guard against excessively long or deeply-nested queries */ |
| 5014 | + CHECK_FOR_INTERRUPTS(); |
| 5015 | + check_stack_depth(); |
| 5016 | + |
5004 | 5017 | /*
|
5005 | 5018 | * Each level of get_rule_expr must emit an indivisible term
|
5006 | 5019 | * (parenthesized if necessary) to ensure result is reparsed into the same
|
|
0 commit comments