PL/pgSQL / SPI and UTILITY statements

From: jwieck(at)debis(dot)com (Jan Wieck)
To: pawel(at)astercity(dot)net
Cc: pgsql-sql(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org (PostgreSQL HACKERS)
Subject: PL/pgSQL / SPI and UTILITY statements
Date: 1999-02-01 14:20:50
Message-ID: m107KDa-000EBPC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

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(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jose' soares 1999-02-01 14:57:52 Re: [SQL] Re: [HACKERS] Re: SELECT DISTINCT ON ... ORDER BY ...
Previous Message Oleg Broytmann 1999-02-01 14:10:15 Re: [HACKERS] Patch (was: tough locale bug)

Browse pgsql-sql by date

  From Date Subject
Next Message jose' soares 1999-02-01 14:57:52 Re: [SQL] Re: [HACKERS] Re: SELECT DISTINCT ON ... ORDER BY ...
Previous Message Remigiusz Sokolowski 1999-02-01 08:50:57 Re: [SQL] index on aggregate function