Skip to content

Instantly share code, notes, and snippets.

@cgimenes
Last active September 24, 2025 14:53
Show Gist options
  • Select an option

  • Save cgimenes/f93a0172cb2d9b7ac45d5833d79a9555 to your computer and use it in GitHub Desktop.

Select an option

Save cgimenes/f93a0172cb2d9b7ac45d5833d79a9555 to your computer and use it in GitHub Desktop.
Check if inside a transaction
CREATE TEMPORARY TABLE a (b int) ON COMMIT DROP;
SELECT pg_current_xact_id_if_assigned() IS NOT NULL AS is_transaction;
-- source: https://dba.stackexchange.com/a/311714
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment