misleading error message in DefineIndex

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: misleading error message in DefineIndex
Date: 2025-11-17 04:06:16
Message-ID: CACJufxH6VhAf65Vghg4T2q315gY=Rt4BUfMyunkfRj0n2S9n-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-11-17 04:15:17 Re: Patch: dumping tables data in multiple chunks in pg_dump
Previous Message Steven Niu 2025-11-17 03:56:22 Re: Compile error on the aarch64 platform: Missing asm/hwcap.h