diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-02 01:30:51 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-02 01:30:51 +0000 |
commit | f622c5404905cb998adabe3a3527f7e9cdace229 (patch) | |
tree | bc65d3f7d71a9a8c09945e7072bbca2baeb937a3 /src/backend/commands/prepare.c | |
parent | 410b1dfb885f5b6d60f89003baba32a4efe93225 (diff) |
Allow DECLARE CURSOR to take parameters from the portal in which it is
executed. Previously, the DECLARE would succeed but subsequent FETCHes
would fail since the parameter values supplied to DECLARE were not
propagated to the portal created for the cursor.
In support of this, add type Oids to ParamListInfo entries, which seems
like a good idea anyway since code that extracts a value can double-check
that it got the type of value it was expecting.
Oliver Jowett, with minor editorialization by Tom Lane.
Diffstat (limited to 'src/backend/commands/prepare.c')
-rw-r--r-- | src/backend/commands/prepare.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 9c183cb7827..d4c8357ff0b 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -10,7 +10,7 @@ * Copyright (c) 2002-2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.28 2004/06/11 01:08:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.29 2004/08/02 01:30:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -200,7 +200,7 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag) /* * Evaluates a list of parameters, using the given executor state. It - * requires a list of the parameter values themselves, and a list of + * requires a list of the parameter expressions themselves, and a list of * their types. It returns a filled-in ParamListInfo -- this can later * be passed to CreateQueryDesc(), which allows the executor to make use * of the parameters during query execution. @@ -211,7 +211,7 @@ EvaluateParams(EState *estate, List *params, List *argtypes) int nargs = list_length(argtypes); ParamListInfo paramLI; List *exprstates; - ListCell *l; + ListCell *le, *la; int i = 0; /* Parser should have caught this error, but check for safety */ @@ -223,9 +223,9 @@ EvaluateParams(EState *estate, List *params, List *argtypes) paramLI = (ParamListInfo) palloc0((nargs + 1) * sizeof(ParamListInfoData)); - foreach(l, exprstates) + forboth(le, exprstates, la, argtypes) { - ExprState *n = lfirst(l); + ExprState *n = lfirst(le); bool isNull; paramLI[i].value = ExecEvalExprSwitchContext(n, @@ -234,6 +234,7 @@ EvaluateParams(EState *estate, List *params, List *argtypes) NULL); paramLI[i].kind = PARAM_NUM; paramLI[i].id = i + 1; + paramLI[i].ptype = lfirst_oid(la); paramLI[i].isnull = isNull; i++; |