public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
To: Andrei Matei <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: is ErrorResponse possible on Sync?
Date: Wed, 12 Jan 2022 16:39:20 -0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <CABWLsevei_ZN45esJ7LSSvJ1A2X7vt2ygu9u5jSz4dpD8TaSFw@mail.gmail.com>
On 2022-Jan-12, Andrei Matei wrote:
> If Sync itself cannot fail, then what is this
> sentence really saying: "This parameterless message (ed. Sync) causes the
> backend to close the current transaction if it's not inside a BEGIN/COMMIT
> transaction block (“close” meaning to commit if no error, or roll back if
> error)." ?
> This seems to say that, outside of BEGIN/END, the transaction is committed
> at Sync time (i.e. if the Sync is never sent, nothing is committed).
> Presumably, committing a transaction can fail even if no
> previous command/statement failed, right?
A deferred trigger can cause a failure at COMMIT time for which no
previous error was reported.
alvherre=# create table t (a int unique deferrable initially deferred);
CREATE TABLE
alvherre=# insert into t values (1);
INSERT 0 1
alvherre=# begin;
BEGIN
alvherre=*# insert into t values (1);
INSERT 0 1
alvherre=*# commit;
ERROR: duplicate key value violates unique constraint "t_a_key"
DETALLE: Key (a)=(1) already exists.
I'm not sure if you can cause this to explode with just a Sync message, though.
--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/
view thread (2+ messages)
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], [email protected], [email protected], [email protected]
Subject: Re: is ErrorResponse possible on Sync?
In-Reply-To: <[email protected]>
* 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