diff options
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r-- | src/backend/commands/indexcmds.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f00291da1b6..11370c65906 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -922,6 +922,26 @@ DefineIndex(Oid relationId, int maplen; childrel = heap_open(childRelid, lockmode); + + /* + * Don't try to create indexes on foreign tables, though. + * Skip those if a regular index, or fail if trying to create + * a constraint index. + */ + if (childrel->rd_rel->relkind == RELKIND_FOREIGN_TABLE) + { + if (stmt->unique || stmt->primary) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot create unique index on partitioned table \"%s\"", + RelationGetRelationName(rel)), + errdetail("Table \"%s\" contains partitions that are foreign tables.", + RelationGetRelationName(rel)))); + + heap_close(childrel, lockmode); + continue; + } + childidxs = RelationGetIndexList(childrel); attmap = convert_tuples_by_name_map(RelationGetDescr(childrel), |