RE: unique indexes on partitioned tables

From: "Shinoda, Noriyoshi" <noriyoshi(dot)shinoda(at)hpe(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com>, Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: unique indexes on partitioned tables
Date: 2018-03-13 00:58:31
Message-ID: AT5PR8401MB0786420254C5E428F9FF6CEBEED20@AT5PR8401MB0786.NAMPRD84.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Álvaro,

Thank you for your developing the new patch.
I will continue testing.

-----Original Message-----
From: Alvaro Herrera [mailto:alvherre(at)2ndquadrant(dot)com]
Sent: Tuesday, March 13, 2018 7:51 AM
To: Shinoda, Noriyoshi <noriyoshi(dot)shinoda(at)hpe(dot)com>
Cc: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>; Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>; Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com>; Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>; Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unique indexes on partitioned tables

Shinoda, Noriyoshi wrote:

Hi,

> 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?

It turns out that the error check for duplicate PKs is only invoked if you tell this code that it's being invoked by ALTER TABLE, and my original patch wasn't. I changed it and now everything seems to behave as expected.

I added a test case pretty much like yours, which now works correctly.
I also added another one where the bogus PK is two levels down rather than one. This is because I had originally developed a different fix -- which fixed the problem for your test case, until I realized that since this code is recursive, we could cause trouble at a distance.

Thanks for reporting the problem

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2018-03-13 01:20:02 Re: Google Summer of Code: Potential Applicant
Previous Message Shinoda, Noriyoshi 2018-03-13 00:56:16 RE: [HACKERS] Commitfest 2018-9 duplicate patch deletion request.