mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.427 2004/07/31 00:45:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.428 2004/08/02 01:30:44 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@@ -1488,6 +1488,7 @@ exec_bind_message(StringInfo input_message)
|
||||
|
||||
params[i].kind = PARAM_NUM;
|
||||
params[i].id = i + 1;
|
||||
params[i].ptype = ptype;
|
||||
params[i].isnull = isNull;
|
||||
|
||||
i++;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.82 2004/07/31 00:45:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.83 2004/08/02 01:30:45 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -833,14 +833,14 @@ PortalRunUtility(Portal portal, Query *query,
|
||||
if (query->canSetTag)
|
||||
{
|
||||
/* utility statement can override default tag string */
|
||||
ProcessUtility(utilityStmt, dest, completionTag);
|
||||
ProcessUtility(utilityStmt, portal->portalParams, dest, completionTag);
|
||||
if (completionTag && completionTag[0] == '\0' && portal->commandTag)
|
||||
strcpy(completionTag, portal->commandTag); /* use the default */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* utility added by rewrite cannot set tag */
|
||||
ProcessUtility(utilityStmt, dest, NULL);
|
||||
ProcessUtility(utilityStmt, portal->portalParams, dest, NULL);
|
||||
}
|
||||
|
||||
/* Some utility statements may change context on us */
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.222 2004/08/01 17:32:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.223 2004/08/02 01:30:45 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -294,6 +294,7 @@ check_xact_readonly(Node *parsetree)
|
||||
* general utility function invoker
|
||||
*
|
||||
* parsetree: the parse tree for the utility statement
|
||||
* params: parameters to use during execution (currently only used by DECLARE)
|
||||
* dest: where to send results
|
||||
* completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE
|
||||
* in which to store a command completion status string.
|
||||
@@ -305,6 +306,7 @@ check_xact_readonly(Node *parsetree)
|
||||
*/
|
||||
void
|
||||
ProcessUtility(Node *parsetree,
|
||||
ParamListInfo params,
|
||||
DestReceiver *dest,
|
||||
char *completionTag)
|
||||
{
|
||||
@@ -406,7 +408,7 @@ ProcessUtility(Node *parsetree,
|
||||
* Portal (cursor) manipulation
|
||||
*/
|
||||
case T_DeclareCursorStmt:
|
||||
PerformCursorOpen((DeclareCursorStmt *) parsetree);
|
||||
PerformCursorOpen((DeclareCursorStmt *) parsetree, params);
|
||||
break;
|
||||
|
||||
case T_ClosePortalStmt:
|
||||
|
||||
Reference in New Issue
Block a user