Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3897ee9

Browse files
committed
Check for interrupts and stack overflow during rule/view dumps.
Since ruleutils.c recurses, it could be driven to stack overflow bydeeply nested constructs. Very large queries might also take longenough to deparse that a check for interrupts seems like a good idea.Stick appropriate tests into a couple of key places.Noted by Greg Stark. Back-patch to all supported branches.
1 parent94095e3 commit3897ee9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include"commands/tablespace.h"
3737
#include"executor/spi.h"
3838
#include"funcapi.h"
39+
#include"miscadmin.h"
3940
#include"nodes/makefuncs.h"
4041
#include"nodes/nodeFuncs.h"
4142
#include"optimizer/clauses.h"
@@ -2608,6 +2609,10 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
26082609
deparse_contextcontext;
26092610
deparse_namespacedpns;
26102611

2612+
/* Guard against excessively long or deeply-nested queries */
2613+
CHECK_FOR_INTERRUPTS();
2614+
check_stack_depth();
2615+
26112616
/*
26122617
* Before we begin to examine the query, acquire locks on referenced
26132618
* 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,
30573062
StringInfobuf=context->buf;
30583063
boolneed_paren;
30593064

3065+
/* Guard against excessively long or deeply-nested queries */
3066+
CHECK_FOR_INTERRUPTS();
3067+
check_stack_depth();
3068+
30603069
if (IsA(setOp,RangeTblRef))
30613070
{
30623071
RangeTblRef*rtr= (RangeTblRef*)setOp;
@@ -4842,6 +4851,10 @@ get_rule_expr(Node *node, deparse_context *context,
48424851
if (node==NULL)
48434852
return;
48444853

4854+
/* Guard against excessively long or deeply-nested queries */
4855+
CHECK_FOR_INTERRUPTS();
4856+
check_stack_depth();
4857+
48454858
/*
48464859
* Each level of get_rule_expr must emit an indivisible term
48474860
* (parenthesized if necessary) to ensure result is reparsed into the same

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp