Re: is ErrorResponse possible on Sync? - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: is ErrorResponse possible on Sync?
Date
Msg-id 20220113.085101.1181960333873795961.t-ishii@sranhm.sra.co.jp
Whole thread Raw
In response to Re: is ErrorResponse possible on Sync?  (Andrei Matei <andreimatei1@gmail.com>)
List pgsql-hackers
> Hmm, this got me curious. 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).

Yes, if you do not send Sync and terminate the session, then the
transaction will not be committed.

FE=> Parse(stmt="", query="INSERT INTO t1 VALUES(2)")
FE=> Bind(stmt="", portal="")
FE=> Execute(portal="")
FE=> Terminate

After this, I don't see the row (2) in table t1.

> Presumably, committing a transaction can fail even if no
> previous command/statement failed, right?

Right. Alvaro gave an excellent example.

Best reagards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp



pgsql-hackers by date:

Previous
From: "Bossart, Nathan"
Date:
Subject: Re: parse/analyze API refactoring
Next
From: Andres Freund
Date:
Subject: Re: Windows vs recovery tests