Re: Mutating table (urgent)

From: "Cristian Custodio" <crstian(at)terra(dot)com(dot)br>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Mutating table (urgent)
Date: 2003-02-21 18:59:50
Message-ID: 001301c2d9db$6a9f3880$fb01a8c0@ttcristian
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It´s true, but why dont it trigger any error message?

It should raise and rollback, right?

It is seeming a bug, what do you think?

Cristian

----- Original Message -----
From: "Stephan Szabo" <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Cristian Custodio" <crstian(at)terra(dot)com(dot)br>
Cc: <pgsql-general(at)postgresql(dot)org>
Sent: Friday, February 21, 2003 3:33 PM
Subject: Re: [GENERAL] Mutating table (urgent)

On Fri, 21 Feb 2003, Cristian Custodio wrote:

> 3) Creating trigger on principal table
> CREATE OR REPLACE FUNCTION TR_AIPAI() RETURNS OPAQUE AS '
> BEGIN
> INSERT INTO FILHO (CODPAI, NOMFIL) VALUES (NEW.CODPAI, ''FILHO DO
PAI''||NEW.CODPAI);
> RETURN NULL;
> END;
> ' language 'plpgsql';
>
> CREATE TRIGGER AIPAI AFTER INSERT ON PAI FOR EACH ROW EXECUTE
PROCEDURE TR_AIPAI();
>
> If we taking a insert on principal table it will insert on child table,
> until here, thats all right...
>
> 4) Create a trigger on child table that make a select on principal table
> CREATE OR REPLACE FUNCTION TR_SELECT_PAI() RETURNS OPAQUE AS'
> DECLARE I INTEGER;
> BEGIN
> SELECT COUNT(*) INTO I FROM PAI;
> RETURN NULL;
> END;
> 'language 'plpgsql';
>
> CREATE TRIGGER BIFILHO BEFORE INSERT ON FILHO FOR EACH ROW EXECUTE
PROCEDURE TR_SELECT_PAI();

By returning NULL in a BEFORE trigger you're saying to drop the request on
the floor.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Copeland 2003-02-21 19:00:48 Re: Slow update - index problem?
Previous Message Hunter Hillegas 2003-02-21 18:51:34 Best PostgreSQL Tuning Reference