]> granicus.if.org Git - postgresql/commitdiff
Fix backwards logic in previous commit.
authorRobert Haas <rhaas@postgresql.org>
Sat, 7 Jan 2012 03:54:43 +0000 (22:54 -0500)
committerRobert Haas <rhaas@postgresql.org>
Sat, 7 Jan 2012 03:54:43 +0000 (22:54 -0500)
I wrote this code before committing it, but managed not to include it in
the actual commit.

src/backend/commands/tablecmds.c

index 0cd273e9c6ecb302d38954deff38785435699a92..c37301671e4a8f45f58d15ac54c224a71f580eb3 100644 (file)
@@ -9947,11 +9947,6 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 errmsg("\"%s\" is not a composite type", rv->relname)));
 
-       if (reltype == OBJECT_FOREIGN_TABLE && relkind != RELKIND_FOREIGN_TABLE)
-               ereport(ERROR,
-                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                errmsg("\"%s\" is not a foreign table", rv->relname)));
-
        if (reltype == OBJECT_INDEX && relkind != RELKIND_INDEX
                && !IsA(stmt, RenameStmt))
                ereport(ERROR,
@@ -9968,6 +9963,12 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
                                 errmsg("\"%s\" is a composite type", rv->relname),
                                 errhint("Use ALTER TYPE instead.")));
 
+       if (reltype != OBJECT_FOREIGN_TABLE && relkind == RELKIND_FOREIGN_TABLE)
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                errmsg("\"%s\" is a foreign table", rv->relname),
+                                errhint("Use ALTER FOREIGN TABLE instead.")));
+
        /*
         * Don't allow ALTER TABLE .. SET SCHEMA on relations that can't be
         * moved to a different schema, such as indexes and TOAST tables.