mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
PREPARE/EXECUTE statements. Patch by Neil Conway, some kibitzing
from Tom Lane.
This commit is contained in:
@ -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();
|
||||
|
||||
@ -65,6 +69,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).
|
||||
*
|
||||
|
Reference in New Issue
Block a user