mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Fix WHERE CURRENT OF to work as designed within plpgsql. The argument
can be the name of a plpgsql cursor variable, which formerly was converted to $N before the core parser saw it, but that's no longer the case. Deal with plain name references to plpgsql variables, and add a regression test case that exposes the failure.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execCurrent.c,v 1.13 2009/11/04 22:26:05 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execCurrent.c,v 1.14 2009/11/09 02:36:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -20,7 +20,7 @@
|
||||
#include "utils/portal.h"
|
||||
|
||||
|
||||
static char *fetch_param_value(ExprContext *econtext, int paramId);
|
||||
static char *fetch_cursor_param_value(ExprContext *econtext, int paramId);
|
||||
static ScanState *search_plan_tree(PlanState *node, Oid table_oid);
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ execCurrentOf(CurrentOfExpr *cexpr,
|
||||
if (cexpr->cursor_name)
|
||||
cursor_name = cexpr->cursor_name;
|
||||
else
|
||||
cursor_name = fetch_param_value(econtext, cexpr->cursor_param);
|
||||
cursor_name = fetch_cursor_param_value(econtext, cexpr->cursor_param);
|
||||
|
||||
/* Fetch table name for possible use in error messages */
|
||||
table_name = get_rel_name(table_oid);
|
||||
@ -203,12 +203,12 @@ execCurrentOf(CurrentOfExpr *cexpr,
|
||||
}
|
||||
|
||||
/*
|
||||
* fetch_param_value
|
||||
* fetch_cursor_param_value
|
||||
*
|
||||
* Fetch the string value of a param, verifying it is of type REFCURSOR.
|
||||
*/
|
||||
static char *
|
||||
fetch_param_value(ExprContext *econtext, int paramId)
|
||||
fetch_cursor_param_value(ExprContext *econtext, int paramId)
|
||||
{
|
||||
ParamListInfo paramInfo = econtext->ecxt_param_list_info;
|
||||
|
||||
|
Reference in New Issue
Block a user