Skip to content

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Oct 5, 2025

Parse SET TRANSACTION statements and translate these to SET LOCAL statements. SET TRANSACTION may only be executed in a transaction block, and can only be used for a specific, limited set of connection properties. The syntax is specified by the SQL standard and PostgreSQL.

See also https://www.postgresql.org/docs/current/sql-set-transaction.html

This change has one limitation. The following feature will be added in a future change:

  1. SET TRANSACTION READ {WRITE | ONLY} is not picked up by the driver, as the type of transaction is set directly when BeginTx is called. A refactor of how transactions are started is needed to be able to pick up SET TRANSACTION READ ONLY / SET TRANSACTION READ WRITE statements that are executed after BeginTx has been called.

SET TRANSACTION ISOLATION LEVEL ... is picked up and used by the driver.

Parse SET TRANSACTION statements and translate these to SET LOCAL statements.
SET TRANSACTION may only be executed in a transaction block, and can only be
used for a specific, limited set of connection properties. The syntax is
specified by the SQL standard and PostgreSQL.

See also https://www.postgresql.org/docs/current/sql-set-transaction.html

This change only adds partial support. The following features will be added
in future changes:
1. SET TRANSACTION READ {WRITE | ONLY} is not picked up by the driver, as
   the type of transaction is set directly when BeginTx is called. A
   refactor of this transaction handling is needed to be able to pick up
   SET TRANSACTION READ ONLY / SET TRANSACTION READ WRITE statements that
   are executed after BeginTx has been called.
2. PostgreSQL allows multiple transaction modes to be set in a single
   SET TRANSACTION statement. E.g. the following is allowed:
   SET TRANSACTION READ WRITE, ISOLATION LEVEL SERIALIZABLE
   The current implementation only supports one transaction mode per
   SET statement.
@olavloite olavloite requested a review from a team as a code owner October 5, 2025 11:22
Copy link
Contributor

@bhatt4982 bhatt4982 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM...

@olavloite olavloite merged commit 6a396d3 into main Oct 7, 2025
26 checks passed
@olavloite olavloite deleted the parse-set-transaction branch October 7, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants