diff options
author | Robert Haas <rhaas@postgresql.org> | 2015-11-19 10:49:25 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2015-11-19 10:49:25 -0500 |
commit | bc4996e61b98d41eacf991c18508b7a2305a68c6 (patch) | |
tree | b0f8404f7f1fe62f6fe0c530c23e4c70acc7dede /src/backend/commands/tablecmds.c | |
parent | f11c557e92c50d3d613d1173c15feb5310ba4744 (diff) | |
download | postgresql-bc4996e61b98d41eacf991c18508b7a2305a68c6.tar.gz postgresql-bc4996e61b98d41eacf991c18508b7a2305a68c6.zip |
Make ALTER .. SET SCHEMA do nothing, instead of throwing an ERROR.
This was already true for CREATE EXTENSION, but historically has not
been true for other object types. Therefore, this is a backward
incompatibility. Per discussion on pgsql-hackers, everyone seems to
agree that the new behavior is better.
Marti Raudsepp, reviewed by Haribabu Kommi and myself
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 44ea7311639..b5d3708a6c1 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -11350,7 +11350,7 @@ AlterTableNamespace(AlterObjectSchemaStmt *stmt, Oid *oldschema) nspOid = RangeVarGetAndCheckCreationNamespace(newrv, NoLock, NULL); /* common checks on switching namespaces */ - CheckSetNamespace(oldNspOid, nspOid, RelationRelationId, relid); + CheckSetNamespace(oldNspOid, nspOid); objsMoved = new_object_addresses(); AlterTableNamespaceInternal(rel, oldNspOid, nspOid, objsMoved); @@ -11418,6 +11418,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid, HeapTuple classTup; Form_pg_class classForm; ObjectAddress thisobj; + bool already_done = false; classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid)); if (!HeapTupleIsValid(classTup)) @@ -11431,9 +11432,12 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid, thisobj.objectSubId = 0; /* - * Do nothing when there's nothing to do. + * If the object has already been moved, don't move it again. If it's + * already in the right place, don't move it, but still fire the object + * access hook. */ - if (!object_address_present(&thisobj, objsMoved)) + already_done = object_address_present(&thisobj, objsMoved); + if (!already_done && oldNspOid != newNspOid) { /* check for duplicate name (more friendly than unique-index failure) */ if (get_relname_relid(NameStr(classForm->relname), @@ -11459,7 +11463,9 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid, newNspOid) != 1) elog(ERROR, "failed to change schema dependency for relation \"%s\"", NameStr(classForm->relname)); - + } + if (!already_done) + { add_exact_object_address(&thisobj, objsMoved); InvokeObjectPostAlterHook(RelationRelationId, relOid, 0); |