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-12T22:50:40Z
Lists: pgsql-hackers
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
Commits
-
Avoid having two PKs in a partition
- 1f8a3327a9db 11.0 landed
-
Allow UNIQUE indexes on partitioned tables
- eb7ed3f30634 11.0 landed