misleading error message in DefineIndex
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-11-17T04:06:16Z
Lists: pgsql-hackers
hi.
while working on virtual generated column as partition key, I found below
errmsg the constraint type is hardcoded.
if (!found)
{
Form_pg_attribute att;
att = TupleDescAttr(RelationGetDescr(rel),
key->partattrs[i] - 1);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("unique constraint on partitioned
table must include all partitioning columns"),
errdetail("%s constraint on table \"%s\"
lacks column \"%s\" which is part of the partition key.",
constraint_type,
RelationGetRelationName(rel),
NameStr(att->attname))));
}
create table idxpart (a int4range, constraint xx exclude USING GIST (a
with = ), b int4range ) partition by range (b);
ERROR: unique constraint on partitioned table must include all
partitioning columns
DETAIL: EXCLUDE constraint on table "idxpart" lacks column "b" which
is part of the partition key.
In the example above , the primary error message "unique
constraint..." seems confusing.
--
jian
https://www.enterprisedb.com/
Commits
-
Improve "constraint must include all partitioning columns" message.
- 7a1d422e39ba 19 (unreleased) landed