Two phase commit in ECPG

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Two phase commit in ECPG
Date: 2017-03-02 17:16:32
Message-ID: CAD21AoDZTi+C06oF3-i15r-ZMx+cCx7PjK_m859YKA-08CbyHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi all,

I found that ecpg has not been supporting COMMIT PREPARED and ROLLBACK
PREPARED since version 9.0.2.
For example, if the test code does,
EXEC SQL BEGIN;
EXEC SQL INSERT INTO t1 VALUES(1);
EXEC SQL PREPARE TRANSACTION 'gxid';
EXEC SQL COMMIT PREPARED 'gxid';
I got error "COMMIT PREPARED cannot run inside a transaction block".

This cause is that the "begin transaction" is issued automatically
before executing COMMIT PREPARED if we're not in auto commit. The
Commit 816b008eaf1a1ff1069f3bafff363a9a8bf04a21 fixed bug of incorrect
status calculation but at the same time it became the cause of this
behavior.
Is this a bug?

Attached 001 patch fixes this issue and add regression test for two
phase commit in ecpg.

Also, in spite of ecpg identifies these two commands as transaction
command similar to other transaction commands like commit and rollback
the documentation doesn't mentioned about these at all. Attached 002
patch add description about these to documentation.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
002_ecpg_commit_rollback_prepared_doc.patch application/octet-stream 934 bytes
001_ecpg_commit_rollback_prepared.patch application/octet-stream 7.9 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-03-02 19:25:22 Re: BUG #14573: lateral joins, ambuiguity
Previous Message Tom Lane 2017-03-02 17:07:07 Re: Error with Softlinks after using pg_upgrade

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2017-03-02 17:46:23 Re: patch: function xmltable
Previous Message Alvaro Herrera 2017-03-02 17:13:53 Re: patch: function xmltable