Re: Delayed result from another connection - Mailing list pgsql-sql

From Tom Lane
Subject Re: Delayed result from another connection
Date
Msg-id 26896.1099590388@sss.pgh.pa.us
Whole thread Raw
In response to Delayed result from another connection  (SZŰCS Gábor <surrano@mailbox.hu>)
List pgsql-sql
SZŰCS Gábor <surrano@mailbox.hu> writes:
> The php connects to the database and updates retval where id=seq.
> It seems to be OK, but the function returns the value of php_retval.retval
> _before_ the call.

Yes, because your transaction is working with a database snapshot that
predates the other transaction run by the separate PHP connection.

> I thought it's something about "35.2 Visibility of Data Changes", but that's
> only for triggers, isn't it?

Nope.

> Also, the rule "query sees results of any
> previously started queries" seems to be invaded: the perform runs right
> before the query for retval.

Prior to PG 8.0, new snapshots are not taken between commands of a function,
even in READ COMMITTED mode.  You could get the behavior you want by
issuing separate interactive commands instead of wrapping the sequence
in a function.

This has been a sore spot for a long time, but we didn't get consensus
about changing it till recently ...
        regards, tom lane


pgsql-sql by date:

Previous
From: Franco Bruno Borghesi
Date:
Subject: Re: Group by and aggregates
Next
From: Oliver Elphick
Date:
Subject: Re: Group by and aggregates