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

Re: BUG #1295: Problem on trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "shancheng" <sd_shancheng(at)hotmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1295: Problem on trigger
Date: 2004-10-26 02:06:27
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
"PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org> writes:
> CREATE OR REPLACE FUNCTION _test_delete_and_drop()
> RETURNS void AS $$
> 	DELETE FROM _test;
> 	DROP TABLE _test;
> END;
> $$ LANGUAGE plpgsql;

This will work fine the first time.  When you recreate the "_test" table
and try to use the function again, the DELETE will fail because it's
cached a plan referring to the prior incarnation of the table.  plpgsql
has always worked like that; it's not a new issue.

You can work around this by executing the DELETE with EXECUTE, viz
so that it gets re-planned each time.

There are plans to improve this situation, but it won't happen in the
near future (certainly not for 8.0).

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2004-10-26 02:08:11
Subject: Re: BUG #1294: Random errors (failed connection)
Previous:From: PostgreSQL Bugs ListDate: 2004-10-26 01:56:11
Subject: BUG #1295: Problem on trigger

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