Add missing error code to "cannot attach index ..." error.
authorHeikki Linnakangas
Thu, 28 May 2020 09:37:00 +0000 (12:37 +0300)
committerHeikki Linnakangas
Thu, 28 May 2020 09:37:00 +0000 (12:37 +0300)
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE was used in an ereport with the
same message but different errdetail a few lines earlier, so use that
here as well.

Backpatch-through: 11

src/backend/commands/tablecmds.c

index 8801af589cf351326ce7d2607524ddb3f385f171..2ab02e01a0285b5677b5eb05091ad9ab1ddd6227 100644 (file)
@@ -17191,7 +17191,8 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
        }
        if (!found)
            ereport(ERROR,
-                   (errmsg("cannot attach index \"%s\" as a partition of index \"%s\"",
+                   (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+                    errmsg("cannot attach index \"%s\" as a partition of index \"%s\"",
                            RelationGetRelationName(partIdx),
                            RelationGetRelationName(parentIdx)),
                     errdetail("Index \"%s\" is not an index on any partition of table \"%s\".",