Re: open transaction?

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: rod(at)iol(dot)ie
Cc: blackwater dev <blackwaterdev(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: open transaction?
Date: 2008-12-29 12:06:04
Message-ID: 4958BD2C.10906@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 29/12/2008 11:53, Raymond O'Donnell wrote:
> On 29/12/2008 11:48, blackwater dev wrote:
>
>> Without thinking I closed by connection before committing or rolling
>> back my transaction. Did postgres handle this for me? How do I see if
>> the transaction is still open?
>
> I'm reasonably sure that the transaction will get rolled back if the
> connection dies.

Just tried it, and that seems to be the case:

postgres=# create database test;
CREATE DATABASE
postgres=# \c test
You are now connected to database "test".
test=# create table t(f1 integer);
CREATE TABLE
test=# begin;
BEGIN
test=# insert into t values(1);
INSERT 0 1
test=# insert into t values(2);
INSERT 0 1
test=# \q
rod(at)teladesign:~$ psql -U postgres test
Password for user postgres:
Welcome to psql 8.3.5, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

test=# select * from t;
f1
----
(0 rows)

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-12-29 12:07:14 Re: encoding of PostgreSQL messages
Previous Message Terry Lee Tucker 2008-12-29 11:57:48 Re: open transaction?