Re: Bug in plpgsql, when using NEW with composite field value.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Oleg Serov" <serovov(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug in plpgsql, when using NEW with composite field value.
Date: 2008-12-10 16:44:12
Message-ID: 2859.1228927452@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Oleg Serov" <serovov(at)gmail(dot)com> writes:
> CREATE OR REPLACE FUNCTION "bug_with_triggers" () RETURNS trigger AS
> $body$
> BEGIN
> PERFORM COALESCE(NEW.some_composite_field.field, TRUE);
> END;
> $body$
> LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

> Error:
> ERROR: NEW used in query that is not in a rule

I agree that this error message is pretty unhelpful, but the code is
wrong anyway. The correct way to do this is
PERFORM COALESCE((NEW.some_composite_field).field, TRUE);

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2008-12-10 23:31:57 Re: BUG #4565: nextval not updated during wal replication, leading to pk violations
Previous Message Yuri Steindorfer 2008-12-10 15:12:29 Connection refused