> Weid is that test2 and test work only once per psql
> connection (i.e. "session", am I correct?).
> Can anyone help?
The reason is that the query plans are getting cached.
AFAIK, if you want to work with temp tables in plpgsql,
you're going to need to use EXECUTE to generate all the
queries that relate to the temp table.