From bc423879cc2db964231f1d4c912961f3e35a6ece Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Fri, 18 Feb 2011 11:16:16 +0100
Subject: [PATCH] =?UTF-8?q?Applied=20a=20patch=20by=20Zolt=C3=A1n=20B?=
 =?UTF-8?q?=C3=B6sz=C3=B6rm=C3=A9nyi=20that=20makes=20ecpg's=20parser=20ac?=
 =?UTF-8?q?cept=20dynamic=20cursornames=20even=20in=20WHERE=20CURRENT=20OF?=
 =?UTF-8?q?=20clauses.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/backend/parser/gram.y               | 2 +-
 src/interfaces/ecpg/preproc/ecpg.addons | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 3857205ef9b..077a10532eb 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -9031,7 +9031,7 @@ where_clause:
 /* variant for UPDATE and DELETE */
 where_or_current_clause:
 			WHERE a_expr							{ $$ = $2; }
-			| WHERE CURRENT_P OF name
+			| WHERE CURRENT_P OF cursor_name
 				{
 					CurrentOfExpr *n = makeNode(CurrentOfExpr);
 					/* cvarno is filled in by parse analysis */
diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons
index c14b2f302e7..a689dbc70e6 100644
--- a/src/interfaces/ecpg/preproc/ecpg.addons
+++ b/src/interfaces/ecpg/preproc/ecpg.addons
@@ -192,6 +192,11 @@ ECPG: stmtViewStmt rule
 
 		output_simple_statement($1);
 	}
+ECPG: where_or_current_clauseWHERECURRENT_POFcursor_name block
+	{
+		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
+		$$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
+	}
 ECPG: CopyStmtCOPYopt_binaryqualified_nameopt_column_listopt_oidscopy_fromcopy_file_namecopy_delimiteropt_withcopy_options addon
 			if (strcmp($6, "to") == 0 && strcmp($7, "stdin") == 0)
 				mmerror(PARSE_ERROR, ET_ERROR, "COPY TO STDIN is not possible");
-- 
GitLab