public inbox for [email protected]  
help / color / mirror / Atom feed
From: Debraj Manna <[email protected]>
To: pgsql-admin <[email protected]>
Subject: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
Date: Fri, 29 Nov 2024 15:35:30 +0530
Message-ID: <CAF6DVKNEbSXLVOs=BBNxhQ_+pjQJL8uMrwx9GWHNyAZyvirvmA@mail.gmail.com> (raw)

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
);


view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
  In-Reply-To: <CAF6DVKNEbSXLVOs=BBNxhQ_+pjQJL8uMrwx9GWHNyAZyvirvmA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox