In PostgreSQL versions < 8.3, PL/PgSQL caches function scripts, and an unfortunate side effect is that if a PL/PgSQL function accesses a temporary table, and that table is later dropped and recreated, and the function called again, the function will fail because the cached function contents still point to the old temporary table. The solution is to use EXECUTE for temporary table access in PL/PgSQL. This will cause the query to be reparsed every time.
This problem does not occur in PostgreSQL 8.3 and later.
</snip>Shantanu wrote:PostgreSQL 8.3 includes support for EXECUTE ... INTO, so you may want to look at an upgrade.
ERROR: EXECUTE of SELECT ... INTO is not implemented yet
Personally I wouldn't call this a bug at all. It's just that PostgreSQL knew how to parse that query before the support for actually executing it was written.
--
Craig Ringer