|
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"
|
@@ -2608,6 +2609,10 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
2608 | 2609 | deparse_context context;
|
2609 | 2610 | deparse_namespace dpns;
|
2610 | 2611 |
|
| 2612 | + /* Guard against excessively long or deeply-nested queries */ |
| 2613 | + CHECK_FOR_INTERRUPTS(); |
| 2614 | + check_stack_depth(); |
| 2615 | + |
2611 | 2616 | /*
|
2612 | 2617 | * Before we begin to examine the query, acquire locks on referenced
|
2613 | 2618 | * relations, and fix up deleted columns in JOIN RTEs. This ensures
|
@@ -3057,6 +3062,10 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
|
3057 | 3062 | StringInfo buf = context->buf;
|
3058 | 3063 | bool need_paren;
|
3059 | 3064 |
|
| 3065 | + /* Guard against excessively long or deeply-nested queries */ |
| 3066 | + CHECK_FOR_INTERRUPTS(); |
| 3067 | + check_stack_depth(); |
| 3068 | + |
3060 | 3069 | if (IsA(setOp, RangeTblRef))
|
3061 | 3070 | {
|
3062 | 3071 | RangeTblRef *rtr = (RangeTblRef *) setOp;
|
@@ -4842,6 +4851,10 @@ get_rule_expr(Node *node, deparse_context *context,
|
4842 | 4851 | if (node == NULL)
|
4843 | 4852 | return;
|
4844 | 4853 |
|
| 4854 | + /* Guard against excessively long or deeply-nested queries */ |
| 4855 | + CHECK_FOR_INTERRUPTS(); |
| 4856 | + check_stack_depth(); |
| 4857 | + |
4845 | 4858 | /*
|
4846 | 4859 | * Each level of get_rule_expr must emit an indivisible term
|
4847 | 4860 | * (parenthesized if necessary) to ensure result is reparsed into the same
|
|
0 commit comments