From 5a3fa6ed44af61bfe76807740bf3cb9384f6efd4 Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Sun, 20 Oct 2024 09:06:02 +0800 Subject: [PATCH] Fix cursor quoting in FetchStmt Regression tests updated to test all cursor related statement with a name that requires quoting. --- src/postgres_deparse.c | 2 +- test/sql/postgres_regress/portals.sql | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/postgres_deparse.c b/src/postgres_deparse.c index 1a97abbe..fd4e0add 100644 --- a/src/postgres_deparse.c +++ b/src/postgres_deparse.c @@ -8707,7 +8707,7 @@ static void deparseFetchStmt(StringInfo str, FetchStmt *fetch_stmt) appendStringInfo(str, "RELATIVE %ld ", fetch_stmt->howMany); } - appendStringInfoString(str, fetch_stmt->portalname); + appendStringInfoString(str, quote_identifier(fetch_stmt->portalname)); } static void deparseAlterDefaultPrivilegesStmt(StringInfo str, AlterDefaultPrivilegesStmt *alter_default_privileges_stmt) diff --git a/test/sql/postgres_regress/portals.sql b/test/sql/postgres_regress/portals.sql index fc4cccb9..4ed0fc49 100644 --- a/test/sql/postgres_regress/portals.sql +++ b/test/sql/postgres_regress/portals.sql @@ -4,7 +4,7 @@ BEGIN; -DECLARE foo1 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; +DECLARE "Foo1" SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; DECLARE foo2 SCROLL CURSOR FOR SELECT * FROM tenk2; @@ -50,7 +50,7 @@ DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2; DECLARE foo23 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -FETCH 1 in foo1; +FETCH 1 in "Foo1"; FETCH 2 in foo2; @@ -140,9 +140,9 @@ FETCH backward 21 in foo3; FETCH backward 22 in foo2; -FETCH backward 23 in foo1; +FETCH backward 23 in "Foo1"; -CLOSE foo1; +CLOSE "Foo1"; CLOSE foo2;