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

Commit920fbc1

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 parente2558e0 commit920fbc1

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
@@ -35,6 +35,7 @@
3535
#include"commands/tablespace.h"
3636
#include"executor/spi.h"
3737
#include"funcapi.h"
38+
#include"miscadmin.h"
3839
#include"nodes/makefuncs.h"
3940
#include"nodes/nodeFuncs.h"
4041
#include"optimizer/clauses.h"
@@ -2661,6 +2662,10 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
26612662
deparse_contextcontext;
26622663
deparse_namespacedpns;
26632664

2665+
/* Guard against excessively long or deeply-nested queries */
2666+
CHECK_FOR_INTERRUPTS();
2667+
check_stack_depth();
2668+
26642669
/*
26652670
* Before we begin to examine the query, acquire locks on referenced
26662671
* 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,
31783183
StringInfobuf=context->buf;
31793184
boolneed_paren;
31803185

3186+
/* Guard against excessively long or deeply-nested queries */
3187+
CHECK_FOR_INTERRUPTS();
3188+
check_stack_depth();
3189+
31813190
if (IsA(setOp,RangeTblRef))
31823191
{
31833192
RangeTblRef*rtr= (RangeTblRef*)setOp;
@@ -5001,6 +5010,10 @@ get_rule_expr(Node *node, deparse_context *context,
50015010
if (node==NULL)
50025011
return;
50035012

5013+
/* Guard against excessively long or deeply-nested queries */
5014+
CHECK_FOR_INTERRUPTS();
5015+
check_stack_depth();
5016+
50045017
/*
50055018
* Each level of get_rule_expr must emit an indivisible term
50065019
* (parenthesized if necessary) to ensure result is reparsed into the same

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp