X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7D4E03A48C0 for ; Thu, 4 Nov 2004 17:46:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53418-10 for ; Thu, 4 Nov 2004 17:46:39 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C071D3A48CF for ; Thu, 4 Nov 2004 17:46:35 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA4HkSsH026897; Thu, 4 Nov 2004 12:46:29 -0500 (EST) To: =?iso-8859-2?B?U1rbQ1MgR+Fib3I=?= Cc: pgsql-sql@postgresql.org Subject: Re: Delayed result from another connection In-reply-to: <012601c4c292$6804b810$0403a8c0@fejleszt4> References: <012601c4c292$6804b810$0403a8c0@fejleszt4> Comments: In-reply-to =?iso-8859-2?B?U1rbQ1MgR+Fib3I=?= message dated "Thu, 04 Nov 2004 18:19:13 +0100" Date: Thu, 04 Nov 2004 12:46:28 -0500 Message-ID: <26896.1099590388@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/39 X-Sequence-Number: 19358 =?iso-8859-2?B?U1rbQ1MgR+Fib3I=?= 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