aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/sequence.c7
-rw-r--r--src/backend/commands/tablecmds.c15
2 files changed, 10 insertions, 12 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index ff855d60e5d..49e409a5eed 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1440,11 +1440,12 @@ process_owned_by(Relation seqrel, List *owned_by)
rel = makeRangeVarFromNameList(relname);
tablerel = relation_openrv(rel, AccessShareLock);
- /* Must be a regular table */
- if (tablerel->rd_rel->relkind != RELKIND_RELATION)
+ /* Must be a regular or foreign table */
+ if (!(tablerel->rd_rel->relkind == RELKIND_RELATION ||
+ tablerel->rd_rel->relkind == RELKIND_FOREIGN_TABLE))
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("referenced relation \"%s\" is not a table",
+ errmsg("referenced relation \"%s\" is not a table or foreign table",
RelationGetRelationName(tablerel))));
/* We insist on same owner and schema */
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index cd2c9610085..fe328349533 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -10518,19 +10518,16 @@ 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.
*/
- if (IsA(stmt, AlterObjectSchemaStmt) && relkind != RELKIND_RELATION
- && relkind != RELKIND_VIEW && relkind != RELKIND_MATVIEW
- && relkind != RELKIND_SEQUENCE && relkind != RELKIND_FOREIGN_TABLE)
+ if (IsA(stmt, AlterObjectSchemaStmt) &&
+ relkind != RELKIND_RELATION &&
+ relkind != RELKIND_VIEW &&
+ relkind != RELKIND_MATVIEW &&
+ relkind != RELKIND_SEQUENCE &&
+ relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table, view, sequence, or foreign table",