diff options
| author | Tom Lane | 2004-03-24 22:40:29 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-03-24 22:40:29 +0000 |
| commit | 8899a2aba92c4a17f422172e7c9dd0e383eefa39 (patch) | |
| tree | aea400d25b0e9c32b84004728c995cd53ab33533 /src/include | |
| parent | a09b9a36d3cc8e4c5cd2877b2b764dc14a78f58e (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/include')
| -rw-r--r-- | src/include/miscadmin.h | 13 | ||||
| -rw-r--r-- | src/include/parser/parse_expr.h | 4 | ||||
| -rw-r--r-- | src/include/pg_config_manual.h | 7 | ||||
| -rw-r--r-- | src/include/tcop/tcopprot.h | 7 |
4 files changed, 17 insertions, 14 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index f34ebb0986..4aba00bb71 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -1,18 +1,19 @@ /*------------------------------------------------------------------------- * * miscadmin.h - * this file contains general postgres administration and initialization + * This file contains general postgres administration and initialization * stuff that used to be spread out between the following files: * globals.h global variables * pdir.h directory path crud * pinit.h postgres initialization * pmod.h processing modes - * + * Over time, this has also become the preferred place for widely known + * resource-limitation stuff, such as work_mem and check_stack_depth(). * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.154 2004/03/23 01:23:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.155 2004/03/24 22:40:29 tgl Exp $ * * NOTES * some of the information in this file should be moved to @@ -70,7 +71,7 @@ extern volatile bool ImmediateInterruptOK; extern volatile uint32 InterruptHoldoffCount; extern volatile uint32 CritSectionCount; -/* in postgres.c */ +/* in tcop/postgres.c */ extern void ProcessInterrupts(void); #ifndef WIN32 @@ -224,6 +225,10 @@ extern char *UnixSocketDir; extern char *ListenAddresses; +/* in tcop/postgres.c */ +extern void check_stack_depth(void); + + /***************************************************************************** * pdir.h -- * * POSTGRES directory path definitions. * diff --git a/src/include/parser/parse_expr.h b/src/include/parser/parse_expr.h index d5b87da1b7..a8be03a534 100644 --- a/src/include/parser/parse_expr.h +++ b/src/include/parser/parse_expr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_expr.h,v 1.32 2003/11/29 22:41:09 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_expr.h,v 1.33 2004/03/24 22:40:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,6 @@ /* GUC parameters */ -extern int max_expr_depth; extern bool Transform_null_equals; @@ -26,6 +25,5 @@ extern Node *transformExpr(ParseState *pstate, Node *expr); extern Oid exprType(Node *expr); extern int32 exprTypmod(Node *expr); extern bool exprIsLengthCoercion(Node *expr, int32 *coercedTypmod); -extern void parse_expr_init(void); #endif /* PARSE_EXPR_H */ diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index 6fcf38ec7b..87ddd1f196 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -6,7 +6,7 @@ * for developers. If you edit any of these, be sure to do a *full* * rebuild (and an initdb if noted). * - * $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.11 2004/03/12 00:25:40 neilc Exp $ + * $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.12 2004/03/24 22:40:29 tgl Exp $ *------------------------------------------------------------------------ */ @@ -113,11 +113,6 @@ #define MAXPGPATH 1024 /* - * DEFAULT_MAX_EXPR_DEPTH: default value of max_expr_depth SET variable. - */ -#define DEFAULT_MAX_EXPR_DEPTH 10000 - -/* * PG_SOMAXCONN: maximum accept-queue length limit passed to * listen(2). You'd think we should use SOMAXCONN from * <sys/socket.h>, but on many systems that symbol is much smaller diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 20c84dd925..b2520b210e 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.62 2004/03/15 15:56:27 momjian Exp $ + * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.63 2004/03/24 22:40:29 tgl Exp $ * * OLD COMMENTS * This file was created so that other c files could get the two @@ -23,6 +23,7 @@ #include "executor/execdesc.h" #include "tcop/dest.h" +#include "utils/guc.h" extern DLLIMPORT sigjmp_buf Warn_restart; @@ -32,6 +33,7 @@ extern CommandDest whereToSendOutput; extern bool log_hostname; extern DLLIMPORT const char *debug_query_string; extern char *rendezvous_name; +extern int max_stack_depth; #ifndef BOOTSTRAP_INCLUDE @@ -43,6 +45,9 @@ extern List *pg_analyze_and_rewrite(Node *parsetree, extern List *pg_rewrite_queries(List *querytree_list); extern Plan *pg_plan_query(Query *querytree); extern List *pg_plan_queries(List *querytrees, bool needSnapshot); + +extern bool assign_max_stack_depth(int newval, bool doit, GucSource source); + #endif /* BOOTSTRAP_INCLUDE */ extern void die(SIGNAL_ARGS); |
