Re: Problem with function and trigger... - Mailing list pgsql-sql

From Tom Lane
Subject Re: Problem with function and trigger...
Date
Msg-id 7747.1127929968@sss.pgh.pa.us
Whole thread Raw
In response to Problem with function and trigger...  (Ian Meyer <ianmmeyer@gmail.com>)
Responses Re: Problem with function and trigger...
List pgsql-sql
Ian Meyer <ianmmeyer@gmail.com> writes:
>   IF TG_OP = 'DELETE' AND OLD.deleted = FALSE THEN

> ERROR:  record "old" is not assigned yet
> DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
> CONTEXT:  PL/pgSQL function "thread_sync" line 2 at if

> What am I failing to understand with this?

We don't guarantee short-circuit evaluation of boolean expressions.
You'll have to break that into two IFs, ie,
IF TG_OP = 'DELETE' THEN    IF ... test on OLD.something ...
        regards, tom lane


pgsql-sql by date:

Previous
From: Ian Meyer
Date:
Subject: Problem with function and trigger...
Next
From: Axel Rau
Date:
Subject: Selecting count of details along with details columns