Re: unique indexes on partitioned tables - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: unique indexes on partitioned tables
Date
Msg-id 20180308152901.p3qxrjnty3tpoqk6@alvherre.pgsql
Whole thread Raw
In response to RE: unique indexes on partitioned tables  ("Shinoda, Noriyoshi" <noriyoshi.shinoda@hpe.com>)
List 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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key