Skip to content

feat: add new client.getTransactionStatus() method#3645

Open
panga wants to merge 4 commits intobrianc:masterfrom
panga:client-get-transaction-status
Open

feat: add new client.getTransactionStatus() method#3645
panga wants to merge 4 commits intobrianc:masterfrom
panga:client-get-transaction-status

Conversation

@panga
Copy link
Copy Markdown

@panga panga commented Apr 1, 2026

  • Add _txStatus tracking to pg.Client, populated from PostgreSQL's ReadyForQuery message.
  • Add a new client.getTransactionStatus() method to return the _txStatus value.

Note: Split from #3597

panga added 3 commits April 1, 2026 08:37
Adds a new public method to retrieve the current transaction status
of the client connection. Returns 'I' (idle), 'T' (in transaction),
'E' (error/aborted), or null (initial state/native client).

The transaction status is tracked from PostgreSQL's ReadyForQuery
message after each query completes.

Native client returns null as it does not support this feature yet.
- Add getTransactionStatus() to pg-native using libpq's
  PQtransactionStatus() with status mapping (0->I, 2->T, 3->E)
- Update pg native client wrapper to delegate to pg-native
- Remove native guard from txstatus tests (now runs in both modes)
- Bump libpq to ^1.10.0 for transactionStatus() binding support
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.

1 participant