]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Adjust errcode in checkPartition()
authorAlexander Korotkov <akorotkov@postgresql.org>
Mon, 5 Jan 2026 17:38:03 +0000 (19:38 +0200)
committerAlexander Korotkov <akorotkov@postgresql.org>
Mon, 5 Jan 2026 17:56:19 +0000 (19:56 +0200)
Replace ERRCODE_UNDEFINED_TABLE with ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
for the case where we don't find a parent-child relationship between the
partitioned table and its partition.  In this case, tables are present, but
they are not in a prerequisite state (no relationship).

Discussion: https://postgr.es/m/CAHewXNmBM%2B5qbrJMu60NxPn%2B0y-%3D2wXM-QVVs3xRp8NxFvDb9A%40mail.gmail.com
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
src/backend/parser/parse_utilcmd.c

index 652f7538c37d4755589f99cffe31bf301b0e8f98..3f4393b52eaeb46bd5cedc1f3e8dbe94e533310c 100644 (file)
@@ -3550,7 +3550,7 @@ checkPartition(Relation rel, Oid partRelOid, bool isMerge)
 
        if (get_partition_parent(partRelOid, false) != RelationGetRelid(rel))
                ereport(ERROR,
-                               errcode(ERRCODE_UNDEFINED_TABLE),
+                               errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
                                errmsg("relation \"%s\" is not a partition of relation \"%s\"",
                                           RelationGetRelationName(partRel), RelationGetRelationName(rel)),
                                isMerge