|
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"
|
@@ -2416,6 +2417,10 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
2416 | 2417 | deparse_context context;
|
2417 | 2418 | deparse_namespace dpns;
|
2418 | 2419 |
|
| 2420 | + /* Guard against excessively long or deeply-nested queries */ |
| 2421 | + CHECK_FOR_INTERRUPTS(); |
| 2422 | + check_stack_depth(); |
| 2423 | + |
2419 | 2424 | /*
|
2420 | 2425 | * Before we begin to examine the query, acquire locks on referenced
|
2421 | 2426 | * relations, and fix up deleted columns in JOIN RTEs. This ensures
|
@@ -2866,6 +2871,10 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
|
2866 | 2871 | StringInfo buf = context->buf;
|
2867 | 2872 | bool need_paren;
|
2868 | 2873 |
|
| 2874 | + /* Guard against excessively long or deeply-nested queries */ |
| 2875 | + CHECK_FOR_INTERRUPTS(); |
| 2876 | + check_stack_depth(); |
| 2877 | + |
2869 | 2878 | if (IsA(setOp, RangeTblRef))
|
2870 | 2879 | {
|
2871 | 2880 | RangeTblRef *rtr = (RangeTblRef *) setOp;
|
@@ -4512,6 +4521,10 @@ get_rule_expr(Node *node, deparse_context *context,
|
4512 | 4521 | if (node == NULL)
|
4513 | 4522 | return;
|
4514 | 4523 |
|
| 4524 | + /* Guard against excessively long or deeply-nested queries */ |
| 4525 | + CHECK_FOR_INTERRUPTS(); |
| 4526 | + check_stack_depth(); |
| 4527 | + |
4515 | 4528 | /*
|
4516 | 4529 | * Each level of get_rule_expr must emit an indivisible term
|
4517 | 4530 | * (parenthesized if necessary) to ensure result is reparsed into the same
|
|
0 commit comments