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

From PG Bug reporting form
Subject BUG #18949: 分区表创建主键或者唯一约束需要有分区键
Date
Msg-id 18949-ccd36f6989cab3cc@postgresql.org
Whole thread Raw
Responses Re: BUG #18949: 分区表创建主键或者唯一约束需要有分区键
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18949
Logged by:          余 大海
Email address:      1157357742@qq.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
中也并没有对此的改进。


pgsql-bugs by date:

Previous
From: vignesh C
Date:
Subject: Re: Logical replication 'invalid memory alloc request size 1585837200' after upgrading to 17.5
Next
From: Thomas Munro
Date:
Subject: Re: BUG #18940: PostgreSQL 18beta1 fails 'collate.windows.win1252' regression when building with MSYS/mingw