From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: jeff <jeff@pgexperts.com>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #6704: ALTER EXTENSION postgis SET SCHEMA leaves dangling relations
Date: Mon, 29 Oct 2012 11:19:21 -0300
Message-ID: <20121029141921.GC12961@alvh.no-ip.org> (raw)
In-Reply-To: <m2zk4e6p7m.fsf@2ndQuadrant.fr>
References: <1346430351-sup-5026@alvh.no-ip.org>
<1346439762-sup-9541@alvh.no-ip.org>
<18412.1346443263@sss.pgh.pa.us>
<1346444697-sup-476@alvh.no-ip.org>
<1346445756-sup-1463@alvh.no-ip.org>
<22747.1346449841@sss.pgh.pa.us>
<1346785382-sup-6256@alvh.no-ip.org>
<15660.1348455860@sss.pgh.pa.us>
<m2r4pq9xbg.fsf@2ndQuadrant.fr>
<m2zk4e6p7m.fsf@2ndQuadrant.fr>
Here's a cleaned up version of this patch, for HEAD. (The patches for
9.1 and 9.2 required minor conflict fixes, but nothing substantial).
The main difference from Dimitri's patch is that I added enough support
code so that AlterRelationNamespaceInternal() is always getting a valid
ObjectAddresses list, and get rid of the checks for a NULL one. It
seems cleaner and simpler to me this way. This means I had to add
support for object types that may never be visited more than once
(indexes), but I don't think this is a problem.
Remaining object types are those that use the generic code path in HEAD
(as patched by KaiGai). We know (because the generic code path checks)
that in these cases, relations are never involved; the only other funny
cases I saw were collations and functions, but those are funny only
because the lookups are unlike the normal cases; they don't have any
subsidiary objects that would cause trouble.
While I am looking at this code: I am uneasy about
AlterObjectNamespace_oid() ignoring object classes that it doesn't
explicitely know about. This means we will fail to cover new cases we
might come up with. For example, can we have event triggers in
extensions, and do event triggers belong to a schema? If so, we already
have a bug here in HEAD. I would like us to get rid of the "default:
break;" case, and instead explicitely list the object classes we ignore.
That way, the compiler will warn us as soon as we add a new object
class and neglect to add it here.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:alter-ext-schema-4.patch (text/x-diff, 24.0K) download
*** a/src/backend/catalog/pg_constraint.c
--- b/src/backend/catalog/pg_constraint.c
***************
*** 679,685 **** RenameConstraintById(Oid conId, const char *newname)
*/
void
AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
! Oid newNspId, bool isType)
{
Relation conRel;
ScanKeyData key[1];
--- 679,685 ----
*/
void
AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
! Oid newNspId, bool isType, ObjectAddresses *objsMoved)
{
Relation conRel;
ScanKeyData key[1];
***************
*** 712,717 **** AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
--- 712,725 ----
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(tup);
+ ObjectAddress thisobj;+ + thisobj.classId = ConstraintRelationId;+ thisobj.objectId = HeapTupleGetOid(tup);+ thisobj.objectSubId = 0;+ + if (object_address_present(&thisobj, objsMoved))+ continue;
if (conform->connamespace == oldNspId)
{
***************
*** 729,734 **** AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
--- 737,744 ----
* changeDependencyFor().
*/
}
+ + add_exact_object_address(&thisobj, objsMoved);
}
systable_endscan(scan);
*** a/src/backend/commands/alter.c
--- b/src/backend/commands/alter.c
***************
*** 252,258 **** ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
* object doesn't have a schema.
*/
Oid
! AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid)
{
Oid oldNspOid = InvalidOid;
ObjectAddress dep;
--- 252,259 ----
* object doesn't have a schema.
*/
Oid
! AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
! ObjectAddresses *objsMoved)
{
Oid oldNspOid = InvalidOid;
ObjectAddress dep;
***************
*** 266,285 **** AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid)
case OCLASS_CLASS:
{
Relation rel;
- Relation classRel;
rel = relation_open(objid, AccessExclusiveLock);
oldNspOid = RelationGetNamespace(rel);
! classRel = heap_open(RelationRelationId, RowExclusiveLock);
!
! AlterRelationNamespaceInternal(classRel,
! objid,
! oldNspOid,
! nspOid,
! true);
!
! heap_close(classRel, RowExclusiveLock);
relation_close(rel, NoLock);
break;
--- 267,277 ----
case OCLASS_CLASS:
{
Relation rel;
rel = relation_open(objid, AccessExclusiveLock);
oldNspOid = RelationGetNamespace(rel);
! AlterTableNamespaceInternal(rel, oldNspOid, nspOid, objsMoved);
relation_close(rel, NoLock);
break;
***************
*** 290,296 **** AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid)
break;
case OCLASS_TYPE:
! oldNspOid = AlterTypeNamespace_oid(objid, nspOid);
break;
case OCLASS_COLLATION:
--- 282,288 ----
break;
case OCLASS_TYPE:
! oldNspOid = AlterTypeNamespace_oid(objid, nspOid, objsMoved);
break;
case OCLASS_COLLATION:
*** a/src/backend/commands/extension.c
--- b/src/backend/commands/extension.c
***************
*** 2204,2209 **** AlterExtensionNamespace(List *names, const char *newschema)
--- 2204,2210 ----
Relation depRel;
SysScanDesc depScan;
HeapTuple depTup;
+ ObjectAddresses *objsMoved;
if (list_length(names) != 1)
ereport(ERROR,
***************
*** 2278,2283 **** AlterExtensionNamespace(List *names, const char *newschema)
--- 2279,2286 ----
errmsg("extension \"%s\" does not support SET SCHEMA",
NameStr(extForm->extname))));
+ objsMoved = new_object_addresses();+
/*
* Scan pg_depend to find objects that depend directly on the extension,
* and alter each one's schema.
***************
*** 2317,2325 **** AlterExtensionNamespace(List *names, const char *newschema)
if (dep.objectSubId != 0) /* should not happen */
elog(ERROR, "extension should not have a sub-object dependency");
dep_oldNspOid = AlterObjectNamespace_oid(dep.classId,
dep.objectId,
! nspOid);
/*
* Remember previous namespace of first object that has one
--- 2320,2330 ----
if (dep.objectSubId != 0) /* should not happen */
elog(ERROR, "extension should not have a sub-object dependency");
+ /* Relocate the object */
dep_oldNspOid = AlterObjectNamespace_oid(dep.classId,
dep.objectId,
! nspOid,
! objsMoved);
/*
* Remember previous namespace of first object that has one
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
***************
*** 261,270 **** static void StoreCatalogInheritance1(Oid relationId, Oid parentOid,
int16 seqNumber, Relation inhRelation);
static int findAttrByName(const char *attributeName, List *schema);
static void AlterIndexNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid);
static void AlterSeqNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid,
! const char *newNspName, LOCKMODE lockmode);
static void ATExecValidateConstraint(Relation rel, char *constrName,
bool recurse, bool recursing, LOCKMODE lockmode);
static int transformColumnNameList(Oid relId, List *colList,
--- 261,270 ----
int16 seqNumber, Relation inhRelation);
static int findAttrByName(const char *attributeName, List *schema);
static void AlterIndexNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved);
static void AlterSeqNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved,
! LOCKMODE lockmode);
static void ATExecValidateConstraint(Relation rel, char *constrName,
bool recurse, bool recursing, LOCKMODE lockmode);
static int transformColumnNameList(Oid relId, List *colList,
***************
*** 9711,9718 **** AlterTableNamespace(AlterObjectSchemaStmt *stmt)
Oid relid;
Oid oldNspOid;
Oid nspOid;
- Relation classRel;
RangeVar *newrv;
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
stmt->missing_ok, false,
--- 9711,9718 ----
Oid relid;
Oid oldNspOid;
Oid nspOid;
RangeVar *newrv;
+ ObjectAddresses *objsMoved;
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
stmt->missing_ok, false,
***************
*** 9753,9779 **** AlterTableNamespace(AlterObjectSchemaStmt *stmt)
/* common checks on switching namespaces */
CheckSetNamespace(oldNspOid, nspOid, RelationRelationId, relid);
/* OK, modify the pg_class row and pg_depend entry */
classRel = heap_open(RelationRelationId, RowExclusiveLock);
! AlterRelationNamespaceInternal(classRel, relid, oldNspOid, nspOid, true);
/* Fix the table's row type too */
! AlterTypeNamespaceInternal(rel->rd_rel->reltype, nspOid, false, false);
/* Fix other dependent stuff */
if (rel->rd_rel->relkind == RELKIND_RELATION)
{
! AlterIndexNamespaces(classRel, rel, oldNspOid, nspOid);
! AlterSeqNamespaces(classRel, rel, oldNspOid, nspOid, stmt->newschema,
! AccessExclusiveLock);
! AlterConstraintNamespaces(relid, oldNspOid, nspOid, false);
}
heap_close(classRel, RowExclusiveLock);
- - /* close rel, but keep lock until commit */- relation_close(rel, NoLock);
}
/*
--- 9753,9799 ----
/* common checks on switching namespaces */
CheckSetNamespace(oldNspOid, nspOid, RelationRelationId, relid);
+ objsMoved = new_object_addresses();+ AlterTableNamespaceInternal(rel, oldNspOid, nspOid, objsMoved);+ free_object_addresses(objsMoved);+ + /* close rel, but keep lock until commit */+ relation_close(rel, NoLock);+ }+ + /*+ * The guts of relocating a table to another namespace: besides moving+ * the table itself, its dependent objects are relocated to the new schema.+ */+ void+ AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid,+ ObjectAddresses *objsMoved)+ {+ Relation classRel;+ + Assert(objsMoved != NULL);+
/* OK, modify the pg_class row and pg_depend entry */
classRel = heap_open(RelationRelationId, RowExclusiveLock);
! AlterRelationNamespaceInternal(classRel, RelationGetRelid(rel), oldNspOid,
! nspOid, true, objsMoved);
/* Fix the table's row type too */
! AlterTypeNamespaceInternal(rel->rd_rel->reltype,
! nspOid, false, false, objsMoved);
/* Fix other dependent stuff */
if (rel->rd_rel->relkind == RELKIND_RELATION)
{
! AlterIndexNamespaces(classRel, rel, oldNspOid, nspOid, objsMoved);
! AlterSeqNamespaces(classRel, rel, oldNspOid, nspOid,
! objsMoved, AccessExclusiveLock);
! AlterConstraintNamespaces(RelationGetRelid(rel), oldNspOid, nspOid,
! false, objsMoved);
}
heap_close(classRel, RowExclusiveLock);
}
/*
***************
*** 9784,9793 **** AlterTableNamespace(AlterObjectSchemaStmt *stmt)
void
AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
Oid oldNspOid, Oid newNspOid,
! bool hasDependEntry)
{
HeapTuple classTup;
Form_pg_class classForm;
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(classTup))
--- 9804,9814 ----
void
AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
Oid oldNspOid, Oid newNspOid,
! bool hasDependEntry, ObjectAddresses *objsMoved)
{
HeapTuple classTup;
Form_pg_class classForm;
+ ObjectAddress thisobj;
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(classTup))
***************
*** 9796,9822 **** AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
Assert(classForm->relnamespace == oldNspOid);
! /* check for duplicate name (more friendly than unique-index failure) */
! if (get_relname_relid(NameStr(classForm->relname),
! newNspOid) != InvalidOid)
! ereport(ERROR,
! (errcode(ERRCODE_DUPLICATE_TABLE),
! errmsg("relation \"%s\" already exists in schema \"%s\"",
! NameStr(classForm->relname),
! get_namespace_name(newNspOid))));
! /* classTup is a copy, so OK to scribble on */
! classForm->relnamespace = newNspOid;
! simple_heap_update(classRel, &classTup->t_self, classTup);
! CatalogUpdateIndexes(classRel, classTup);
! /* Update dependency on schema if caller said so */
! if (hasDependEntry &&
! changeDependencyFor(RelationRelationId, relOid,
! NamespaceRelationId, oldNspOid, newNspOid) != 1)
! elog(ERROR, "failed to change schema dependency for relation \"%s\"",
! NameStr(classForm->relname));
heap_freetuple(classTup);
}
--- 9817,9855 ----
Assert(classForm->relnamespace == oldNspOid);
! thisobj.classId = RelationRelationId;
! thisobj.objectId = relOid;
! thisobj.objectSubId = 0;
!
! /*
! * Do nothing when there's nothing to do.
! */
! if (!object_address_present(&thisobj, objsMoved))
! {
! /* check for duplicate name (more friendly than unique-index failure) */
! if (get_relname_relid(NameStr(classForm->relname),
! newNspOid) != InvalidOid)
! ereport(ERROR,
! (errcode(ERRCODE_DUPLICATE_TABLE),
! errmsg("relation \"%s\" already exists in schema \"%s\"",
! NameStr(classForm->relname),
! get_namespace_name(newNspOid))));
! /* classTup is a copy, so OK to scribble on */
! classForm->relnamespace = newNspOid;
! simple_heap_update(classRel, &classTup->t_self, classTup);
! CatalogUpdateIndexes(classRel, classTup);
! /* Update dependency on schema if caller said so */
! if (hasDependEntry &&
! changeDependencyFor(RelationRelationId, relOid,
! NamespaceRelationId, oldNspOid, newNspOid) != 1)
! elog(ERROR, "failed to change schema dependency for relation \"%s\"",
! NameStr(classForm->relname));
!
! add_exact_object_address(&thisobj, objsMoved);
! }
heap_freetuple(classTup);
}
***************
*** 9829,9835 **** AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
*/
static void
AlterIndexNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid)
{
List *indexList;
ListCell *l;
--- 9862,9868 ----
*/
static void
AlterIndexNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved)
{
List *indexList;
ListCell *l;
***************
*** 9839,9853 **** AlterIndexNamespaces(Relation classRel, Relation rel,
foreach(l, indexList)
{
Oid indexOid = lfirst_oid(l);
/*
* Note: currently, the index will not have its own dependency on the
* namespace, so we don't need to do changeDependencyFor(). There's no
* row type in pg_type, either.
*/
! AlterRelationNamespaceInternal(classRel, indexOid,
! oldNspOid, newNspOid,
! false);
}
list_free(indexList);
--- 9872,9898 ----
foreach(l, indexList)
{
Oid indexOid = lfirst_oid(l);
+ ObjectAddress thisobj;+ + thisobj.classId = RelationRelationId;+ thisobj.objectId = indexOid;+ thisobj.objectSubId = 0;
/*
* Note: currently, the index will not have its own dependency on the
* namespace, so we don't need to do changeDependencyFor(). There's no
* row type in pg_type, either.
+ *+ * XXX this objsMoved test may be pointless -- surely we have a single+ * dependency link from a relation to each index?
*/
! if (!object_address_present(&thisobj, objsMoved))
! {
! AlterRelationNamespaceInternal(classRel, indexOid,
! oldNspOid, newNspOid,
! false, objsMoved);
! add_exact_object_address(&thisobj, objsMoved);
! }
}
list_free(indexList);
***************
*** 9862,9868 **** AlterIndexNamespaces(Relation classRel, Relation rel,
*/
static void
AlterSeqNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid, const char *newNspName, LOCKMODE lockmode)
{
Relation depRel;
SysScanDesc scan;
--- 9907,9914 ----
*/
static void
AlterSeqNamespaces(Relation classRel, Relation rel,
! Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved,
! LOCKMODE lockmode)
{
Relation depRel;
SysScanDesc scan;
***************
*** 9914,9927 **** AlterSeqNamespaces(Relation classRel, Relation rel,
/* Fix the pg_class and pg_depend entries */
AlterRelationNamespaceInternal(classRel, depForm->objid,
oldNspOid, newNspOid,
! true);
/*
* Sequences have entries in pg_type. We need to be careful to move
* them to the new namespace, too.
*/
AlterTypeNamespaceInternal(RelationGetForm(seqRel)->reltype,
! newNspOid, false, false);
/* Now we can close it. Keep the lock till end of transaction. */
relation_close(seqRel, NoLock);
--- 9960,9973 ----
/* Fix the pg_class and pg_depend entries */
AlterRelationNamespaceInternal(classRel, depForm->objid,
oldNspOid, newNspOid,
! true, objsMoved);
/*
* Sequences have entries in pg_type. We need to be careful to move
* them to the new namespace, too.
*/
AlterTypeNamespaceInternal(RelationGetForm(seqRel)->reltype,
! newNspOid, false, false, objsMoved);
/* Now we can close it. Keep the lock till end of transaction. */
relation_close(seqRel, NoLock);
*** a/src/backend/commands/typecmds.c
--- b/src/backend/commands/typecmds.c
***************
*** 3322,3327 **** AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype)
--- 3322,3328 ----
TypeName *typename;
Oid typeOid;
Oid nspOid;
+ ObjectAddresses *objsMoved;
/* Make a TypeName so we can use standard type lookup machinery */
typename = makeTypeNameFromNameList(names);
***************
*** 3337,3347 **** AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype)
/* get schema OID and check its permissions */
nspOid = LookupCreationNamespace(newschema);
! AlterTypeNamespace_oid(typeOid, nspOid);
}
Oid
! AlterTypeNamespace_oid(Oid typeOid, Oid nspOid)
{
Oid elemOid;
--- 3338,3350 ----
/* get schema OID and check its permissions */
nspOid = LookupCreationNamespace(newschema);
! objsMoved = new_object_addresses();
! AlterTypeNamespace_oid(typeOid, nspOid, objsMoved);
! free_object_addresses(objsMoved);
}
Oid
! AlterTypeNamespace_oid(Oid typeOid, Oid nspOid, ObjectAddresses *objsMoved)
{
Oid elemOid;
***************
*** 3360,3366 **** AlterTypeNamespace_oid(Oid typeOid, Oid nspOid)
format_type_be(elemOid))));
/* and do the work */
! return AlterTypeNamespaceInternal(typeOid, nspOid, false, true);
}
/*
--- 3363,3369 ----
format_type_be(elemOid))));
/* and do the work */
! return AlterTypeNamespaceInternal(typeOid, nspOid, false, true, objsMoved);
}
/*
***************
*** 3381,3387 **** AlterTypeNamespace_oid(Oid typeOid, Oid nspOid)
Oid
AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
bool isImplicitArray,
! bool errorOnTableType)
{
Relation rel;
HeapTuple tup;
--- 3384,3391 ----
Oid
AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
bool isImplicitArray,
! bool errorOnTableType,
! ObjectAddresses *objsMoved)
{
Relation rel;
HeapTuple tup;
***************
*** 3389,3394 **** AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
--- 3393,3409 ----
Oid oldNspOid;
Oid arrayOid;
bool isCompositeType;
+ ObjectAddress thisobj;+ + /*+ * Make sure we haven't moved this object previously.+ */+ thisobj.classId = TypeRelationId;+ thisobj.objectId = typeOid;+ thisobj.objectSubId = 0;+ + if (object_address_present(&thisobj, objsMoved))+ return InvalidOid;
rel = heap_open(TypeRelationId, RowExclusiveLock);
***************
*** 3449,3455 **** AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
AlterRelationNamespaceInternal(classRel, typform->typrelid,
oldNspOid, nspOid,
! false);
heap_close(classRel, RowExclusiveLock);
--- 3464,3470 ----
AlterRelationNamespaceInternal(classRel, typform->typrelid,
oldNspOid, nspOid,
! false, objsMoved);
heap_close(classRel, RowExclusiveLock);
***************
*** 3458,3470 **** AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
* currently support this, but probably will someday).
*/
AlterConstraintNamespaces(typform->typrelid, oldNspOid,
! nspOid, false);
}
else
{
/* If it's a domain, it might have constraints */
if (typform->typtype == TYPTYPE_DOMAIN)
! AlterConstraintNamespaces(typeOid, oldNspOid, nspOid, true);
}
/*
--- 3473,3486 ----
* currently support this, but probably will someday).
*/
AlterConstraintNamespaces(typform->typrelid, oldNspOid,
! nspOid, false, objsMoved);
}
else
{
/* If it's a domain, it might have constraints */
if (typform->typtype == TYPTYPE_DOMAIN)
! AlterConstraintNamespaces(typeOid, oldNspOid, nspOid, true,
! objsMoved);
}
/*
***************
*** 3482,3490 **** AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
heap_close(rel, RowExclusiveLock);
/* Recursively alter the associated array type, if any */
if (OidIsValid(arrayOid))
! AlterTypeNamespaceInternal(arrayOid, nspOid, true, true);
return oldNspOid;
}
--- 3498,3508 ----
heap_close(rel, RowExclusiveLock);
+ add_exact_object_address(&thisobj, objsMoved);+
/* Recursively alter the associated array type, if any */
if (OidIsValid(arrayOid))
! AlterTypeNamespaceInternal(arrayOid, nspOid, true, true, objsMoved);
return oldNspOid;
}
*** a/src/include/catalog/pg_constraint.h
--- b/src/include/catalog/pg_constraint.h
***************
*** 20,25 ****
--- 20,26 ----
#define PG_CONSTRAINT_H
#include "catalog/genbki.h"
+ #include "catalog/dependency.h"
#include "nodes/pg_list.h"
/* ----------------
***************
*** 244,250 **** extern char *ChooseConstraintName(const char *name1, const char *name2,
List *others);
extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
! Oid newNspId, bool isType);
extern Oid get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok);
extern Oid get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok);
--- 245,251 ----
List *others);
extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
! Oid newNspId, bool isType, ObjectAddresses *objsMoved);
extern Oid get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok);
extern Oid get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok);
*** a/src/include/commands/alter.h
--- b/src/include/commands/alter.h
***************
*** 14,26 ****
#ifndef ALTER_H
#define ALTER_H
#include "nodes/parsenodes.h"
#include "utils/relcache.h"
extern void ExecRenameStmt(RenameStmt *stmt);
extern void ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt);
! extern Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid);
extern Oid AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid);
extern void ExecAlterOwnerStmt(AlterOwnerStmt *stmt);
--- 14,28 ----
#ifndef ALTER_H
#define ALTER_H
+ #include "catalog/dependency.h"
#include "nodes/parsenodes.h"
#include "utils/relcache.h"
extern void ExecRenameStmt(RenameStmt *stmt);
extern void ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt);
! extern Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
! ObjectAddresses *objsMoved);
extern Oid AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid);
extern void ExecAlterOwnerStmt(AlterOwnerStmt *stmt);
*** a/src/include/commands/tablecmds.h
--- b/src/include/commands/tablecmds.h
***************
*** 15,20 ****
--- 15,21 ----
#define TABLECMDS_H
#include "access/htup.h"
+ #include "catalog/dependency.h"
#include "nodes/parsenodes.h"
#include "storage/lock.h"
#include "utils/relcache.h"
***************
*** 36,44 **** extern void AlterTableInternal(Oid relid, List *cmds, bool recurse);
extern void AlterTableNamespace(AlterObjectSchemaStmt *stmt);
extern void AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
Oid oldNspOid, Oid newNspOid,
! bool hasDependEntry);
extern void CheckTableNotInUse(Relation rel, const char *stmt);
--- 37,49 ----
extern void AlterTableNamespace(AlterObjectSchemaStmt *stmt);
+ extern void AlterTableNamespaceInternal(Relation rel, Oid oldNspOid,+ Oid nspOid, ObjectAddresses *objsMoved);+
extern void AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
Oid oldNspOid, Oid newNspOid,
! bool hasDependEntry,
! ObjectAddresses *objsMoved);
extern void CheckTableNotInUse(Relation rel, const char *stmt);
*** a/src/include/commands/typecmds.h
--- b/src/include/commands/typecmds.h
***************
*** 15,20 ****
--- 15,21 ----
#define TYPECMDS_H
#include "access/htup.h"
+ #include "catalog/dependency.h"
#include "nodes/parsenodes.h"
***************
*** 45,53 **** extern void AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype);
extern void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId,
bool hasDependEntry);
extern void AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype);
! extern Oid AlterTypeNamespace_oid(Oid typeOid, Oid nspOid);
! extern Oid AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
bool isImplicitArray,
! bool errorOnTableType);
#endif /* TYPECMDS_H */
--- 46,55 ----
extern void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId,
bool hasDependEntry);
extern void AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype);
! extern Oid AlterTypeNamespace_oid(Oid typeOid, Oid nspOid, ObjectAddresses *objsMoved);
! extern Oid AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
bool isImplicitArray,
! bool errorOnTableType,
! ObjectAddresses *objsMoved);
#endif /* TYPECMDS_H */
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: alvherre@2ndquadrant.com, dimitri@2ndQuadrant.fr, tgl@sss.pgh.pa.us, jeff@pgexperts.com
Subject: Re: BUG #6704: ALTER EXTENSION postgis SET SCHEMA leaves dangling relations
In-Reply-To: <20121029141921.GC12961@alvh.no-ip.org>
References: <1346430351-sup-5026@alvh.no-ip.org> <1346439762-sup-9541@alvh.no-ip.org> <18412.1346443263@sss.pgh.pa.us> <1346444697-sup-476@alvh.no-ip.org> <1346445756-sup-1463@alvh.no-ip.org> <22747.1346449841@sss.pgh.pa.us> <1346785382-sup-6256@alvh.no-ip.org> <15660.1348455860@sss.pgh.pa.us> <m2r4pq9xbg.fsf@2ndQuadrant.fr> <m2zk4e6p7m.fsf@2ndQuadrant.fr> <20121029141921.GC12961@alvh.no-ip.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox