Re: auto-reconnect: temp schemas, sequences, transactions - Mailing list pgsql-general

From Marek Więckowski
Subject Re: auto-reconnect: temp schemas, sequences, transactions
Date
Msg-id 201105021717.12058.wieckom@foxi.nl
Whole thread Raw
In response to Re: auto-reconnect: temp schemas, sequences, transactions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: auto-reconnect: temp schemas, sequences, transactions
List pgsql-general
Hi,

On Monday 02 May 2011 16:43:54 Tom Lane wrote:
> Marek Wieckowski <wieckom@foxi.nl> writes:
> > If I understand correctly, Tom's reply in:
> > http://archives.postgresql.org/pgsql-general/2007-06/msg01668.php
> > suggests that temp schemas are kept when a session gets disconnected
> > because connections get automatically re-established with the same
> > backend id, and if this succeeds the old temp tables get picked up by the
> > new connection as if there was no disconnection at all.
>
> Uh, no, surely not.  The schema itself is re-used if it exists, but all
> the contained tables get flushed by the new session (if for some reason
> the old session failed to do that, as it would in case of a crash).

Clear. Thanks for your answer.


But what happens with a db transaction upon disconnect? If I have (say, in c++
code or a script):

begin;
query1;
query2;
query3;
query4;
query5;
commit;

(with possibly some extra c++ or script code in between queries), and
somewhere at the time when query2 is being executed some other backend
crashes; session gets disconnected and automatically connected: what would
happen to next queries which would be executed by the external code (query3, 4
and so on)? They would not be executed outside of db transaction, wouldn't
they? I would hope that they all keep failing up until next commit/rollback or
something similar...

Best,
~Marek


pgsql-general by date:

Previous
From: Greg Smith
Date:
Subject: Re: pervasiveness of surrogate (also called synthetic) keys
Next
From: Tom Lane
Date:
Subject: Re: auto-reconnect: temp schemas, sequences, transactions