BUG #18949: 分区表创建主键或者唯一约束需要有分区键

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: 1157357742(at)qq(dot)com
Subject: BUG #18949: 分区表创建主键或者唯一约束需要有分区键
Date: 2025-06-07 09:29:06
Message-ID: 18949-ccd36f6989cab3cc@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18949
Logged by: 余 大海
Email address: 1157357742(at)qq(dot)com
PostgreSQL version: 16.2
Operating system: centos7.9
Description:

postgres=# CREATE TABLE hash_sales (
postgres(# id INT,
postgres(# sale_date DATE,
postgres(# amount NUMERIC,
postgres(# PRIMARY KEY (id) -- 主键必须包含分区键
postgres(# ) PARTITION BY hash(sale_date );
ERROR: unique constraint on partitioned table must include all partitioning
columns
DETAIL: PRIMARY KEY constraint on table "hash_sales" lacks column
"sale_date" which is part of the partition key.
在oracle中,以上SQL语句可以创建成功,并能保证ID的全局唯一性,但是在PG15\16\17中,分区表创建主键或者唯一约束都需要有分区键,这样会导致ID字段的无法保证全局唯一性。PG18released
中也并没有对此的改进。

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2025-06-07 10:11:09 Re: BUG #18940: PostgreSQL 18beta1 fails 'collate.windows.win1252' regression when building with MSYS/mingw
Previous Message BATBAATAR Dorjpalam 2025-06-07 07:20:56 Re: BUG #18907: SSL error: bad length failure during transfer data in pipeline mode with libpq