Avoid having two PKs in a partition
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 12 Mar 2018 22:42:32 +0000 (19:42 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 12 Mar 2018 22:42:32 +0000 (19:42 -0300)
commit1f8a3327a9db9a8a662fb39fdcde2337acffa68c
treeb2dc45fbf66156568b255ce526084f1ef65b52a1
parent63cbee6a786028790abc6ae9b9606366bae5e01d
Avoid having two PKs in a partition

If a table containing a primary key is attach as partition to a
partitioned table which has a primary key with a different definition,
we would happily create a second one in the new partition.  Oops.  It
turns out that this is because an error check in DefineIndex is executed
only if you tell it that it's being run by ALTER TABLE, and the original
code here wasn't.  Change it so that it does.

Added a couple of test cases for this, also.  A previously working test
started to fail in a different way than before patch because the new
check is called earlier; change the PK to plain UNIQUE so that the new
behavior isn't invoked, so that the test continues to verify what we
want it to verify.

Reported by: Noriyoshi Shinoda
Discussion: https://postgr.es/m/DF4PR8401MB102060EC2615EC9227CC73F7EEDF0@DF4PR8401MB1020.NAMPRD84.PROD.OUTLOOK.COM
src/backend/commands/indexcmds.c
src/backend/commands/tablecmds.c
src/test/regress/expected/indexing.out
src/test/regress/sql/indexing.sql