diff options
author | Tom Lane | 2002-08-27 04:55:12 +0000 |
---|---|---|
committer | Tom Lane | 2002-08-27 04:55:12 +0000 |
commit | 28e82066a1d17dce2c28ca5391dab1e4f1eb0c0f (patch) | |
tree | 2204fa82946fd20ffaf10fd498de0c921ea301eb /src/backend/parser/parser.c | |
parent | bc8f725a4aa4e2118caaf9e7c4fe3cc5632a02c0 (diff) |
PREPARE/EXECUTE statements. Patch by Neil Conway, some kibitzing
from Tom Lane.
Diffstat (limited to 'src/backend/parser/parser.c')
-rw-r--r-- | src/backend/parser/parser.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index f4cd24e0c4f..8c129cb9161 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.53 2002/06/20 20:29:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.54 2002/08/27 04:55:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -30,6 +30,9 @@ List *parsetree; /* result of parsing is left here */ +static Oid *param_type_info; /* state for param_type() */ +static int param_count; + static int lookahead_token; /* one-token lookahead */ static bool have_lookahead; /* lookahead_token set? */ @@ -50,8 +53,9 @@ parser(StringInfo str, Oid *typev, int nargs) have_lookahead = false; scanner_init(str); - parser_init(typev, nargs); + parser_init(); parse_expr_init(); + parser_param_set(typev, nargs); yyresult = yyparse(); @@ -66,6 +70,35 @@ parser(StringInfo str, Oid *typev, int nargs) /* + * Save information needed to fill out the type of Param references ($n) + * + * This is used for SQL functions, PREPARE statements, etc. It's split + * out from parser() setup because PREPARE needs to change the info after + * the grammar runs and before parse analysis is done on the preparable + * query. + */ +void +parser_param_set(Oid *typev, int nargs) +{ + param_type_info = typev; + param_count = nargs; +} + +/* + * param_type() + * + * Fetch a parameter type previously passed to parser_param_set + */ +Oid +param_type(int t) +{ + if (t > param_count || t <= 0) + return InvalidOid; + return param_type_info[t - 1]; +} + + +/* * Intermediate filter between parser and base lexer (base_yylex in scan.l). * * The filter is needed because in some cases SQL92 requires more than one |