Postgresql prepared transactions

Started by Radosław Smoguraabout 15 years ago4 messagesgeneral
Jump to latest
#1Radosław Smogura
rsmogura@softperience.eu

Hi,

I do following commands

test=# BEGIN;
BEGIN
test=# insert into testxa1 values(1);
INSERT 0 1
test=# insert ddddduuuuuppppp;
ERROR: syntax error at or near "ddddduuuuuppppp"
LINE 1: insert ddddduuuuuppppp;
^
test=# PREPARE TRANSACTION 'a';
ROLLBACK

Why on prepare transaction I got rollback. If I skip error, each RM will try
to do two-phase commit, but it's looks impossible to do two-phase commit.

Regards,
Radek

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Radosław Smogura (#1)
Re: Postgresql prepared transactions

=?utf-8?q?Rados=C5=82aw_Smogura?= <rsmogura@softperience.eu> writes:

I do following commands

test=# BEGIN;
BEGIN
test=# insert into testxa1 values(1);
INSERT 0 1
test=# insert ddddduuuuuppppp;
ERROR: syntax error at or near "ddddduuuuuppppp"
LINE 1: insert ddddduuuuuppppp;
^
test=# PREPARE TRANSACTION 'a';
ROLLBACK

Why on prepare transaction I got rollback.

Because the transaction had already failed due to the error. This is
the same as if you'd done a plain COMMIT at that point.

regards, tom lane

#3Radosław Smogura
rsmogura@softperience.eu
In reply to: Tom Lane (#2)
Re: Postgresql prepared transactions

Tom Lane <tgl@sss.pgh.pa.us> Saturday 19 February 2011 00:48:00

=?utf-8?q?Rados=C5=82aw_Smogura?= <rsmogura@softperience.eu> writes:

I do following commands

test=# BEGIN;
BEGIN
test=# insert into testxa1 values(1);
INSERT 0 1
test=# insert ddddduuuuuppppp;
ERROR: syntax error at or near "ddddduuuuuppppp"
LINE 1: insert ddddduuuuuppppp;

^

test=# PREPARE TRANSACTION 'a';
ROLLBACK

Why on prepare transaction I got rollback.

Because the transaction had already failed due to the error. This is
the same as if you'd done a plain COMMIT at that point.

regards, tom lane

Sorry, my wrong. I thought I can commit or rollback. In any way next bug JDBC.

Regards

#4Radosław Smogura
rsmogura@softperience.eu
In reply to: Radosław Smogura (#3)
Re: Postgresql prepared transactions

Hi,

In any way may I ask to add information in protocol-message-formats.html that
for command status for queries like COMMIT, ROLLBACK, PREPARE TRANSACTION
status may be ROLLBACK. It is important for XA resources to check what
actually happend. I can't find this in documentation as well.

Radek,

Radosław Smogura <rsmogura@softperience.eu> Saturday 19 February 2011 01:02:36

Show quoted text

Tom Lane <tgl@sss.pgh.pa.us> Saturday 19 February 2011 00:48:00

=?utf-8?q?Rados=C5=82aw_Smogura?= <rsmogura@softperience.eu> writes:

I do following commands

test=# BEGIN;
BEGIN
test=# insert into testxa1 values(1);
INSERT 0 1
test=# insert ddddduuuuuppppp;
ERROR: syntax error at or near "ddddduuuuuppppp"
LINE 1: insert ddddduuuuuppppp;

^

test=# PREPARE TRANSACTION 'a';
ROLLBACK

Why on prepare transaction I got rollback.

Because the transaction had already failed due to the error. This is
the same as if you'd done a plain COMMIT at that point.

regards, tom lane

Sorry, my wrong. I thought I can commit or rollback. In any way next bug
JDBC.

Regards