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