Re: BUG #1295: Problem on trigger - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1295: Problem on trigger
Date
Msg-id 3410.1098756387@sss.pgh.pa.us
Whole thread Raw
In response to BUG #1295: Problem on trigger  ("PostgreSQL Bugs List" <pgsql-bugs@postgresql.org>)
List pgsql-bugs
"PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes:
> CREATE OR REPLACE FUNCTION _test_delete_and_drop()
> RETURNS void AS $$
> BEGIN
>     DELETE FROM _test;
>     DROP TABLE _test;
>     RETURN;
> 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
    EXECUTE 'DELETE FROM _test';
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

pgsql-bugs by date:

Previous
From: "PostgreSQL Bugs List"
Date:
Subject: BUG #1295: Problem on trigger
Next
From: Tom Lane
Date:
Subject: Re: BUG #1294: Random errors (failed connection)