Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group