Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A88619FA220 for ; Mon, 16 Jul 2007 14:10:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 36810-04 for ; Mon, 16 Jul 2007 14:10:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 986029FB1F3 for ; Mon, 16 Jul 2007 14:10:13 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1IAU5C-0004GD-RD for pgsql-admin@postgresql.org; Mon, 16 Jul 2007 13:10:02 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 5B9883F9E; Mon, 16 Jul 2007 13:09:57 -0400 (EDT) Date: Mon, 16 Jul 2007 13:09:57 -0400 From: Andrew Sullivan To: pgsql-admin@postgresql.org Subject: Re: cache problem (v2) Message-ID: <20070716170957.GV18049@phlogiston.dyndns.org> References: <469B4927.9030604@eurofer.be> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <469B4927.9030604@eurofer.be> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/157 X-Sequence-Number: 26138 I tried to answer the previous version of this mail, but I don't understand it. Let me see if my questions trigger something for you, though. On Mon, Jul 16, 2007 at 12:32:07PM +0200, De Leeuw Guy wrote: > > a table : > CREATE TABLE test ( > code int8 NOT NULL, > qte float8, > CONSTRAINT test_pkey PRIMARY KEY (code) > ) > CREATE TRIGGER trig_update_sum BEFORE INSERT OR UPDATE OR DELETE ON > table_test > FOR EACH ROW EXECUTE PROCEDURE gd_trigfunc_before_buildsum(); > EOF > > code maybe 1,2,3 > 3 = sum of 1 & 2 > > the trigger make the sum : > if event = INSERT code = 3 ==> skip > if event = INSERT code = 1 or 2 > if select code 3 exist ? yes = update qte code 3 + qte code x > no = insert qte to code 3 So if I am reading you correctly, IF code IN (1,2) THEN {do something}? What do you do then? I don't get this part. > INSERT INTO test VALUES (1, 50); > INSERT INTO test VALUES (3, 60); > ok code 3 = 110 > > psql : delete from test; > code 1 & 2 deleted > code 3 = 50 I don't see how this is possible either. You just deleted from test; how can you hae anything left in there? > maybe this is because these commands start a transaction with a cache > and each time that I request a select for a sum code that are on the > cache the value returned are not the real new value. No, but a trigger that executes SQL can cause the trigger to fire again. Are you sure that's not happening? A -- Andrew Sullivan | ajs@crankycanuck.ca Everything that happens in the world happens at some place. --Jane Jacobs