Thread: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
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 counter
SET value = value + 1
RETURNING value;
COMMIT;
and
UPDATE counter
SET 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
);
On Fri, 2024-11-29 at 15:35 +0530, Debraj Manna wrote: > Can someone let me know if Postgres 15 uses implicit transactions for UPDATE...RETURNING queries? Yes, PostgreSQL always uses autocommit. Yours, Laurenz Albe
Hi Laurenz et al
I would like to say in this way : Many clients like psql set autocommit on as default.
It is up to the client to define the default and there are clients that default to autocommit off.
Med venlig hilsen
Peter Gram
Sæbyholmsvej 18
Peter Gram
Sæbyholmsvej 18
2500 Valby
Mobile: (+45) 5374 7107
Email: peter.m.gram@gmail.com
On Fri, 29 Nov 2024 at 11:10, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Fri, 2024-11-29 at 15:35 +0530, Debraj Manna wrote:
> Can someone let me know if Postgres 15 uses implicit transactions for UPDATE...RETURNING queries?
Yes, PostgreSQL always uses autocommit.
Yours,
Laurenz Albe
On Fri, 2024-11-29 at 13:39 +0100, Peter Gram wrote: > I would like to say in this way : Many clients like psql set autocommit on as default. > It is up to the client to define the default and there are clients that default to autocommit off. The server is always in autocommit mode. Clients can fake "autocommit off" by tacitly sending transaction control statements. Yours, Laurenz Albe