pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 1157357742@qq.com
Subject:  BUG #18949: 分区表创建主键或者唯一约束需要有分区键
Date: Sat, 07 Jun 2025 09:29:06 +0000
Message-ID: <18949-ccd36f6989cab3cc@postgresql.org> (raw)

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
中也并没有对此的改进。



view thread (2+ messages)  latest in thread

Message-ID: <18949-ccd36f6989cab3cc@postgresql.org>
Permalink:  ../18949-ccd36f6989cab3cc@postgresql.org/
Also on:    postgresql.org/message-id/18949-ccd36f6989cab3cc@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, 1157357742@qq.com
  Subject: Re:  BUG #18949: 分区表创建主键或者唯一约束需要有分区键
  In-Reply-To: <18949-ccd36f6989cab3cc@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox