From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-admin@postgresql.org
Subject: Re: cache problem (v2)
Date: Mon, 16 Jul 2007 13:09:57 -0400
Message-ID: <20070716170957.GV18049@phlogiston.dyndns.org> (raw)
In-Reply-To: <469B4927.9030604@eurofer.be>
References: <469B4927.9030604@eurofer.be>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: ajs@crankycanuck.ca
Subject: Re: cache problem (v2)
In-Reply-To: <20070716170957.GV18049@phlogiston.dyndns.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox