Re: cache problem (v2)

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: cache problem (v2)
Date: 2007-07-16 17:09:57
Message-ID: 20070716170957.GV18049@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)crankycanuck(dot)ca
Everything that happens in the world happens at some place.
--Jane Jacobs

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message De Leeuw Guy 2007-07-16 17:47:09 Re: cache problem (v2)
Previous Message Marc Cousin 2007-07-16 14:15:11 postgresql winsock problem