Skip to content

fix(postgres): inOpenTransaction must detect BEGIN without an assigned XID - #860

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/787-postgres-txid
Sep 20, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/787-postgres-txid

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

  • BEGIN + SELECT does not assign an XID, so pg_current_xact_id_if_assigned stayed NULL (badge off; autocommit-off prepended a second BEGIN).
  • The session tracks BEGIN/COMMIT/ROLLBACK (and ROLLBACK TO stays open). Otherwise probes pg_stat_activity.xact_start for pg_backend_pid() (PG 9+; no PG 13 requirement).
  • Implicit BEGIN when autocommit is off stays a separate execute (Parse cannot take BEGIN; concatenated with the next statement).

Test plan

  • SQL tab: BEGIN then SELECT 1 — transaction badge is on.
  • COMMIT / ROLLBACK — badge off.
  • Autocommit off: first SELECT issues a separate BEGIN, not BEGIN; SELECT … in one Parse.

Closes #787

Track BEGIN/COMMIT/ROLLBACK on the session so SELECT-only
transactions keep the SQL-tab badge on. Fall back to xact_start
(PG 9+) instead of pg_current_xact_id_if_assigned.
@github-actions github-actions Bot added bug Something isn't working editor Code/SQL editor error-handling Theme parser epic label: error-handling backend Backend database driver execution and queries labels Sep 20, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 945cb2f into dev Sep 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend database driver execution and queries bug Something isn't working editor Code/SQL editor error-handling Theme parser epic label: error-handling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant