Skip to content

Commit

Permalink
sql: allow CLOSE CURSOR in read-only txns
Browse files Browse the repository at this point in the history
This is allowed in PG, so we now will allow this too. The fix is similar
to what we did for DECLARE and FETCH in 50a7999.

Release note (bug fix): CLOSE CURSOR statements are now allowed in
read-only transactions, similat to Postgres. The bug has been present
since at least 23.1 version.
  • Loading branch information
yuzefovich committed Dec 23, 2024
1 parent 3b46aff commit 05321e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/sql/logictest/testdata/logic_test/txn
Original file line number Diff line number Diff line change
Expand Up @@ -1483,13 +1483,16 @@ SET SESSION AUTHORIZATION DEFAULT
statement ok
BEGIN

# DECLARE and FETCH CURSOR should work in a read-only txn.
# DECLARE, FETCH, and CLOSE CURSOR should work in a read-only txn.
statement ok
DECLARE foo CURSOR FOR SELECT 1

statement ok
FETCH 1 foo

statement ok
CLOSE foo

statement ok
COMMIT

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/sem/tree/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ func (*CannedOptPlan) StatementTag() string { return "PREPARE AS OPT PLAN" }
func (*CloseCursor) StatementReturnType() StatementReturnType { return Ack }

// StatementType implements the Statement interface.
func (*CloseCursor) StatementType() StatementType { return TypeDCL }
func (*CloseCursor) StatementType() StatementType { return TypeDML }

// StatementTag returns a short string identifying the type of statement.
func (*CloseCursor) StatementTag() string { return "CLOSE" }
Expand Down

0 comments on commit 05321e6

Please sign in to comment.