Transaction bug

Lists: pgsql-bugs
From: Brage Førland <brage(at)zoo(dot)uib(dot)no>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Transaction bug
Date: 2003-10-27 13:02:08
Message-ID: 20031027130208.GA52887@sisyfos.zoo.uib.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

If you send a transaction as a single query to the backend, it ignores the
commit if the transaction is aborted:

Example:

testdb=# CREATE TEMP TABLE test(test INT PRIMARY KEY, CONSTRAINT testconstraint CHECK (test > 2) );
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'test_pkey' for table 'test'
CREATE TABLE
testdb=# START TRANSACTION\; INSERT INTO test VALUES(1)\; COMMIT\; ;
ERROR: ExecInsert: rejected due to CHECK constraint "testconstraint" on "test"
testdb=# SELECT * FROM test;
ERROR: current transaction is aborted, queries ignored until end of transaction block

(Tested with PostgreSQL 7.3.4)

--
Brage Førland


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brage Førland <brage(at)zoo(dot)uib(dot)no>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Transaction bug
Date: 2003-10-27 20:08:55
Message-ID: 2468.1067285335@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Brage =?iso-8859-1?Q?F=F8rland?= <brage(at)zoo(dot)uib(dot)no> writes:
> If you send a transaction as a single query to the backend, it ignores the
> commit if the transaction is aborted:

This is not a bug, it is the intended behavior. An error causes
processing of the current querystring to be abandoned. If you don't
want that, don't issue the commands in a single querystring.

regards, tom lane