public inbox for [email protected]
help / color / mirror / Atom feedDo postgres use implicit transaction in UPDATE ... RETURNING queries?
4+ messages / 3 participants
[nested] [flat]
* Do postgres use implicit transaction in UPDATE ... RETURNING queries?
@ 2024-11-29 10:05 Debraj Manna <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Debraj Manna @ 2024-11-29 10:05 UTC (permalink / raw)
To: 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
);
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
@ 2024-11-29 10:10 Laurenz Albe <[email protected]>
parent: Debraj Manna <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Laurenz Albe @ 2024-11-29 10:10 UTC (permalink / raw)
To: Debraj Manna <[email protected]>; pgsql-admin
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
@ 2024-11-29 12:39 Peter Gram <[email protected]>
parent: Laurenz Albe <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Gram @ 2024-11-29 12:39 UTC (permalink / raw)
To: Laurenz Albe <[email protected]>; +Cc: Debraj Manna <[email protected]>; pgsql-admin
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
2500 Valby
Mobile: (+45) 5374 7107
Email: [email protected]
On Fri, 29 Nov 2024 at 11:10, Laurenz Albe <[email protected]> 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
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Do postgres use implicit transaction in UPDATE ... RETURNING queries?
@ 2024-11-29 13:09 Laurenz Albe <[email protected]>
parent: Peter Gram <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Laurenz Albe @ 2024-11-29 13:09 UTC (permalink / raw)
To: Peter Gram <[email protected]>; +Cc: Debraj Manna <[email protected]>; pgsql-admin
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-11-29 13:09 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-29 10:05 Do postgres use implicit transaction in UPDATE ... RETURNING queries? Debraj Manna <[email protected]>
2024-11-29 10:10 ` Laurenz Albe <[email protected]>
2024-11-29 12:39 ` Peter Gram <[email protected]>
2024-11-29 13:09 ` Laurenz Albe <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox