Do postgres use implicit transaction in UPDATE ... RETURNING queries?

From: Debraj Manna <subharaj(dot)manna(at)gmail(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
Date: 2024-11-29 10:05:30
Message-ID: CAF6DVKNEbSXLVOs=BBNxhQ_+pjQJL8uMrwx9GWHNyAZyvirvmA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Can someone let me know if Postgres 15 uses implicit transactions for
UPDATE...RETURNING queries?

For example, is there any differences between the two queries

BEGIN;UPDATE counterSET value = value + 1
RETURNING value;COMMIT;

and

UPDATE counterSET value = value + 1
RETURNING value;

Table is like below

CREATE TABLE IF NOT EXISTS counter
(
value bigint PRIMARY KEY NOT NULL DEFAULT 0,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2024-11-29 10:10:16 Re: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
Previous Message Tom Lane 2024-11-28 16:31:22 Re: Out of Memory error triggering replica to transition into recovery mode