X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8382BD1B45A for ; Wed, 28 Jan 2004 21:46:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14133-10 for ; Wed, 28 Jan 2004 17:45:40 -0400 (AST) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id 1DBB1D1BA96 for ; Wed, 28 Jan 2004 17:45:37 -0400 (AST) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AlxVC-0002i1-00 for ; Wed, 28 Jan 2004 22:45:38 +0100 Received: from willow.rfc1149.net ([81.56.47.149]) by news.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed Jan 28 21:45:38 2004 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AlxVB-0002ht-00 for ; Wed, 28 Jan 2004 22:45:37 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AlxVB-0004yG-00 for ; Wed, 28 Jan 2004 22:45:37 +0100 From: Samuel Tardieu Subject: Re: Question about isolation Date: Wed, 28 Jan 2004 22:45:13 +0100 Organization: Avian Carrier & Friends Lines: 34 Message-ID: <871xpj928m.fsf@beeblebrox.enst.fr> References: Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@sea.gmane.org Gmane-NNTP-Posting-Host: willow.rfc1149.net User-Agent: T-gnus/6.16.2 (based on Gnus v5.10.2) (revision 02) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3 (i386--freebsd) MULE/5.0 (SAKAKI) Cancel-Lock: sha1:jo8lnzwyx7yJhNhnzob9wwJ5dkI= X-Leafnode-NNTP-Posting-Host: 3ffe:304:103:111:200:39ff:fe25:3aa2 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/242 X-Sequence-Number: 16635 >>>>> "Chester" == Chester Kustarz writes: > On Wed, 28 Jan 2004, Chester Kustarz wrote: >> On Wed, 28 Jan 2004, Samuel Tardieu wrote: > If in a transaction I >> call an embedded function in Pl/PgSQL, in which > I have: >> > >> > delete from t where condition; > for e in select distinct on (f) >> * from t where ... loop > ... > end loop; >> > >> > Do I have the guarantee that, in any event, rows deleted from >> table t > by the delete won't reappear in the select result? >> >> i do not think you have that guarantee in READ COMMITTED mode >> because there is a slight possibility another backend sneaked a >> committed insert in between the delete and select >> statement. perhaps you want to change to SERIALIZABLE transaction >> isolation. or perhaps you would like to repeat the WHERE condition >> from the DELETE in the following SELECT so as to not gather any of >> the offending rows. >> >> http://www.postgresql.org/docs/7.4/static/sql-set-transaction.html > perhaps the isolation level applies to the statement that called the > function, in which case you would be ok. that would make more sense, > no? Yes. But the possible effect your describe (insertion of new rows after the DELETE statement and before the SELECT) matches accurately the symptoms we are observing. However, as we do have a lot of transactions, this is not easy to reproduce. Sam -- Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/sam