summaryrefslogtreecommitdiff
path: root/src/backend/executor/execQual.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-03-24 22:40:29 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-03-24 22:40:29 +0000
commit8899a2aba92c4a17f422172e7c9dd0e383eefa39 (patch)
treeaea400d25b0e9c32b84004728c995cd53ab33533 /src/backend/executor/execQual.c
parenta09b9a36d3cc8e4c5cd2877b2b764dc14a78f58e (diff)
Replace max_expr_depth parameter with a max_stack_depth parameter that
is measured in kilobytes and checked against actual physical execution stack depth, as per my proposal of 30-Dec. This gives us a fairly bulletproof defense against crashing due to runaway recursive functions.
Diffstat (limited to 'src/backend/executor/execQual.c')
-rw-r--r--src/backend/executor/execQual.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index fc16cccdda9..4c6f95a9a6f 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.156 2004/03/17 20:48:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.157 2004/03/24 22:40:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,6 +27,11 @@
* trying to speed it up, the execution plan should be pre-processed
* to facilitate attribute sharing between nodes wherever possible,
* instead of doing needless copying. -cim 5/31/91
+ *
+ * During expression evaluation, we check_stack_depth only in
+ * ExecMakeFunctionResult rather than at every single node. This
+ * is a compromise that trades off precision of the stack limit setting
+ * to gain speed.
*/
#include "postgres.h"
@@ -840,6 +845,9 @@ ExecMakeFunctionResult(FuncExprState *fcache,
bool hasSetArg;
int i;
+ /* Guard against stack overflow due to overly complex expressions */
+ check_stack_depth();
+
/*
* arguments is a list of expressions to evaluate before passing to
* the function manager. We skip the evaluation if it was already
@@ -1058,6 +1066,9 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
FunctionCallInfoData fcinfo;
int i;
+ /* Guard against stack overflow due to overly complex expressions */
+ check_stack_depth();
+
if (isDone)
*isDone = ExprSingleResult;
@@ -2503,6 +2514,10 @@ ExecInitExpr(Expr *node, PlanState *parent)
if (node == NULL)
return NULL;
+
+ /* Guard against stack overflow due to overly complex expressions */
+ check_stack_depth();
+
switch (nodeTag(node))
{
case T_Var: