diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-11-22 19:46:15 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-11-22 19:53:34 -0500 |
commit | 44475e782f4674d257b9e5c1a3930218a4b4deea (patch) | |
tree | 2bf5afa62c678a3a29abfbadf41a41682837c809 /src/backend/commands/tablecmds.c | |
parent | 5272d7987506554f6b2bde740e1b4d7e4a0b8608 (diff) | |
download | postgresql-44475e782f4674d257b9e5c1a3930218a4b4deea.tar.gz postgresql-44475e782f4674d257b9e5c1a3930218a4b4deea.zip |
Centralize some ALTER <whatever> .. SET SCHEMA checks.
Any flavor of ALTER <whatever> .. SET SCHEMA fails if (1) the object
is already in the new schema, (2) either the old or new schema is
a temp schema, or (3) either the old or new schema is the TOAST schema.
Extraced from a patch by Dimitri Fontaine, with additional hacking by me.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index b22bcf0d663..11171eaa990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8114,24 +8114,8 @@ AlterTableNamespace(RangeVar *relation, const char *newschema, /* get schema OID and check its permissions */ nspOid = LookupCreationNamespace(newschema); - if (oldNspOid == nspOid) - ereport(ERROR, - (errcode(ERRCODE_DUPLICATE_TABLE), - errmsg("relation \"%s\" is already in schema \"%s\"", - RelationGetRelationName(rel), - newschema))); - - /* disallow renaming into or out of temp schemas */ - if (isAnyTempNamespace(nspOid) || isAnyTempNamespace(oldNspOid)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move objects into or out of temporary schemas"))); - - /* same for TOAST schema */ - if (nspOid == PG_TOAST_NAMESPACE || oldNspOid == PG_TOAST_NAMESPACE) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move objects into or out of TOAST schema"))); + /* 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); |