Hi,
there was recently discussion about schema changes (utility
queries) inside of PL functions etc.
I've thought about it some more and came to the conclusion
that it doesn't make much sense to support something like
that in PL/pgSQL.
The reason for this is that PL/pgSQL does prepare and save
ALL plans on the first call of the function. As it is now, a
PL/pgSQL function used once in a connection will get broken
if an object it uses gets dropped and recreated. The saved
SPI plans still use the OLD object, which isn't available any
more. So the function needs to be recompiled and that will
only happen on a new backend connection.
There is no syntax that could tell PL/pgSQL not to save a
particular prepared plan (like in PL/Tcl where planning and
saving is done separately, so the programmer has control
which plans to save and which not).
Since dropping an object in Postgres is a general problem
that affects saved SPI plans (not only in PL, C language
functions using the SPI saved plan feature will break too),
I'll not add support for it to PL/pgSQL. I think this problem
will also show up if any function using prepared plans will
be used on the temp tables Bruce currently is working on.
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #