Skip to content

Commit

Permalink
Fix cursor quoting in FetchStmt (#267)
Browse files Browse the repository at this point in the history
* Fix cursor quoting in FetchStmt

Regression tests updated to test all cursor related statement with a name that
requires quoting.

* Test quoting in `deparse_tests.c`

---------

Co-authored-by: msepga <[email protected]>
  • Loading branch information
rjuju and msepga authored Oct 31, 2024
1 parent 7fb9821 commit e1a98c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/postgres_deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion test/deparse_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ const char* tests[] = {
"ALTER TABLE a DISABLE TRIGGER ALL",
"ALTER TABLE a DISABLE TRIGGER USER",
"CREATE INDEX myindex ON public.mytable USING btree (col1, (col2::varchar) varchar_pattern_ops)",
"SELECT * FROM CAST(1 AS text)"
"SELECT * FROM CAST(1 AS text)",
"DECLARE \"Foo1\" SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2",
"FETCH BACKWARD 23 \"Foo1\""
};

size_t testsLength = __LINE__ - 4;

0 comments on commit e1a98c3

Please sign in to comment.