pgsql: Fix some issues with temp/transient tables in extension scripts.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix some issues with temp/transient tables in extension scripts.
Date: 2012-03-08 20:53:22
Message-ID: E1S5kKw-0000do-5I@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix some issues with temp/transient tables in extension scripts.

Phil Sorber reported that a rewriting ALTER TABLE within an extension
update script failed, because it creates and then drops a placeholder
table; the drop was being disallowed because the table was marked as an
extension member. We could hack that specific case but it seems likely
that there might be related cases now or in the future, so the most
practical solution seems to be to create an exception to the general rule
that extension member objects can only be dropped by dropping the owning
extension. To wit: if the DROP is issued within the extension's own
creation or update scripts, we'll allow it, implicitly performing an
"ALTER EXTENSION DROP object" first. This will simplify cases such as
extension downgrade scripts anyway.

No docs change since we don't seem to have documented the idea that you
would need ALTER EXTENSION DROP for such an action to begin with.

Also, arrange for explicitly temporary tables to not get linked as
extension members in the first place, and the same for the magic
pg_temp_nnn schemas that are created to hold them. This prevents assorted
unpleasant results if an extension script creates a temp table: the forced
drop at session end would either fail or remove the entire extension, and
neither of those outcomes is desirable. Note that this doesn't fix the
ALTER TABLE scenario, since the placeholder table is not temp (unless the
table being rewritten is).

Back-patch to 9.1.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/08dd23cec7d6b5493c83848d7568495815eda5c6

Modified Files
--------------
src/backend/catalog/dependency.c | 31 +++++++++++++++++++++++++------
src/backend/catalog/heap.c | 9 ++++++++-
src/backend/catalog/namespace.c | 6 ++++--
src/backend/catalog/pg_namespace.c | 15 ++++++++++++---
src/backend/commands/schemacmds.c | 2 +-
src/include/catalog/pg_namespace.h | 2 +-
6 files changed, 51 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2012-03-08 21:15:27 pgsql: psql: Remove useless code
Previous Message Peter Eisentraut 2012-03-08 20:40:07 Re: pgsql: psql: Fix invalid memory access