pgsql: Fix ALTER EXTENSION / SET SCHEMA

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix ALTER EXTENSION / SET SCHEMA
Date: 2012-10-31 13:54:47
Message-ID: E1TTYkp-0007bo-HV@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix ALTER EXTENSION / SET SCHEMA

In its original conception, it was leaving some objects into the old
schema, but without their proper pg_depend entries; this meant that the
old schema could be dropped, causing future pg_dump calls to fail on the
affected database. This was originally reported by Jeff Frost as #6704;
there have been other complaints elsewhere that can probably be traced
to this bug.

To fix, be more consistent about altering a table's subsidiary objects
along the table itself; this requires some restructuring in how tables
are relocated when altering an extension -- hence the new
AlterTableNamespaceInternal routine which encapsulates it for both the
ALTER TABLE and the ALTER EXTENSION cases.

There was another bug lurking here, which was unmasked after fixing the
previous one: certain objects would be reached twice via the dependency
graph, and the second attempt to move them would cause the entire
operation to fail. Per discussion, it seems the best fix for this is to
do more careful tracking of objects already moved: we now maintain a
list of moved objects, to avoid attempting to do it twice for the same
object.

Authors: Alvaro Herrera, Dimitri Fontaine
Reviewed by Tom Lane

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/65225900de86044948c70e9732d02d99412eb171

Modified Files
--------------
src/backend/catalog/pg_constraint.c | 12 +++-
src/backend/commands/alter.c | 16 +----
src/backend/commands/extension.c | 7 ++-
src/backend/commands/tablecmds.c | 123 ++++++++++++++++++++++++-----------
src/backend/commands/typecmds.c | 34 +++++++--
src/include/catalog/pg_constraint.h | 3 +-
src/include/commands/alter.h | 6 +-
src/include/commands/tablecmds.h | 7 ++-
src/include/commands/typecmds.h | 8 ++-
9 files changed, 149 insertions(+), 67 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2012-10-31 14:09:52 pgsql: Fix erroneous choices of segNo variables
Previous Message Tom Lane 2012-10-30 21:28:03 Re: [COMMITTERS] pgsql: Preserve intermediate .c files in coverage mode