diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-03-17 05:29:07 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-03-17 05:29:07 +0000 |
commit | 0e314d747e2803a9bea7ee69ab0c7df881277eba (patch) | |
tree | 45ea45c0dba5c1b2e950d156949be0d8d841746d /src/backend/commands/variable.c | |
parent | 341b328b180e65d1fa5c8f2235cf101c8a12824f (diff) | |
download | postgresql-0e314d747e2803a9bea7ee69ab0c7df881277eba.tar.gz postgresql-0e314d747e2803a9bea7ee69ab0c7df881277eba.zip |
Add safety check on expression nesting depth. Default value is set by
a config.h #define, and the runtime value can be controlled via SET.
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r-- | src/backend/commands/variable.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 81c1e10bbd4..482b9a23ae0 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.31 2000/02/27 21:10:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.32 2000/03/17 05:29:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,6 +25,7 @@ #include "miscadmin.h" #include "optimizer/cost.h" #include "optimizer/paths.h" +#include "parser/parse_expr.h" #include "utils/builtins.h" #include "utils/tqual.h" #include "utils/trace.h" @@ -86,6 +87,9 @@ static bool parse_geqo(char *); static bool show_ksqo(void); static bool reset_ksqo(void); static bool parse_ksqo(char *); +static bool reset_max_expr_depth(void); +static bool show_max_expr_depth(void); +static bool parse_max_expr_depth(char *); static bool show_XactIsoLevel(void); static bool reset_XactIsoLevel(void); static bool parse_XactIsoLevel(char *); @@ -935,6 +939,44 @@ reset_ksqo() return TRUE; } +/* + * MAX_EXPR_DEPTH + */ +static bool +parse_max_expr_depth(char *value) +{ + int newval; + + if (value == NULL) + { + reset_max_expr_depth(); + return TRUE; + } + + newval = pg_atoi(value, sizeof(int), '\0'); + + if (newval < 10) /* somewhat arbitrary limit */ + elog(ERROR, "Bad value for MAX_EXPR_DEPTH (%s)", value); + + max_expr_depth = newval; + + return TRUE; +} + +static bool +show_max_expr_depth() +{ + elog(NOTICE, "MAX_EXPR_DEPTH is %d", max_expr_depth); + return TRUE; +} + +static bool +reset_max_expr_depth(void) +{ + max_expr_depth = DEFAULT_MAX_EXPR_DEPTH; + return TRUE; +} + /* SET TRANSACTION */ static bool @@ -1104,6 +1146,10 @@ static struct VariableParsers "ksqo", parse_ksqo, show_ksqo, reset_ksqo }, { + "max_expr_depth", parse_max_expr_depth, + show_max_expr_depth, reset_max_expr_depth + }, + { "XactIsoLevel", parse_XactIsoLevel, show_XactIsoLevel, reset_XactIsoLevel }, { |