In backend/commands/tablecmds.c, function ATAddForeignKeyConstraint, I find:
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
if (!recurse)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("foreign key referencing partitioned table \"%s\" must not be ONLY",
RelationGetRelationName(pkrel))));
That message is wrong, because "rel" and not "pkrel" is the partitioned table.
I think it should be
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("foreign key cannot be defined on ONLY \"%s\" for a partitioned table",
Relatio
nGetRelationName(rel))));
Yours,
Laurenz Albe