Re: unique indexes on partitioned tables
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: "Shinoda, Noriyoshi" <noriyoshi.shinoda@hpe.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Jaime Casanova <jaime.casanova@2ndquadrant.com>, Jesper Pedersen <jesper.pedersen@redhat.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-03-08T15:29:01Z
Lists: pgsql-hackers
Hi, Shinoda, Noriyoshi wrote: > I tried this feature with the latest snapshot. When I executed the > following SQL statement, multiple primary keys were created on the > partition. Is this the intended behavior? Hahah. Is that a serious question? Of course it isn't. I'll fix it: > -- test > postgres=> CREATE TABLE part1(c1 INT PRIMARY KEY, c2 INT, c3 VARCHAR(10)) PARTITION BY RANGE(c1) ; > CREATE TABLE > postgres=> CREATE TABLE part1v1 (LIKE part1) ; > CREATE TABLE > postgres=> ALTER TABLE part1v1 ADD CONSTRAINT pk_part1v1 PRIMARY KEY (c1, c2) ; > ALTER TABLE > postgres=> ALTER TABLE part1 ATTACH PARTITION part1v1 FOR VALUES FROM (100) TO (200) ; > ALTER TABLE I think the correct behavior here is to error out the ATTACH PARTITION indicating that a primary key already exist. Thanks for pointing this out. Please keep testing, -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Avoid having two PKs in a partition
- 1f8a3327a9db 11.0 landed
-
Allow UNIQUE indexes on partitioned tables
- eb7ed3f30634 11.0 landed