Skip site navigation (1) Skip section navigation (2)

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

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 extensionscripts.
Date: 2012-03-08 20:53:22
Message-ID: (view raw, whole thread or download thread mbox)
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.



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(-)

pgsql-committers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group