]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix partitioned index creation with foreign partitions
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 26 Jun 2019 22:38:51 +0000 (18:38 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 26 Jun 2019 22:38:51 +0000 (18:38 -0400)
commit9653ca2197e241ebeae127086ce1cc8b201a477e
tree3dc63bd8ceed9923bb90533a16de6d044224539d
parent0e08a3a1f541228e312111eda5122f6004fe7dbf
Fix partitioned index creation with foreign partitions

When a partitioned tables contains foreign tables as partitions, it is
not possible to implement unique or primary key indexes -- but when
regular indexes are created, there is no reason to do anything other
than ignoring such partitions.  We were raising errors upon encountering
the foreign partitions, which is unfriendly and doesn't protect against
any actual problems.

Relax this restriction so that index creation is allowed on partitioned
tables containing foreign partitions, becoming a no-op on them.  (We may
later want to redefine this so that the FDW is told to create the
indexes on the foreign side.)  This applies to CREATE INDEX, as well as
ALTER TABLE / ATTACH PARTITION and CREATE TABLE / PARTITION OF.

Backpatch to 11, where indexes on partitioned tables were introduced.

Discussion: https://postgr.es/m/15724-d5a58fa9472eef4f@postgresql.org
Author: Álvaro Herrera
Reviewed-by: Amit Langote
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/create_foreign_table.sgml
src/backend/commands/indexcmds.c
src/backend/commands/tablecmds.c
src/backend/tcop/utility.c
src/test/regress/expected/foreign_data.out
src/test/regress/sql/foreign_data.sql