pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix partitioned index creation with foreign partitions
Date: Wed, 26 Jun 2019 22:39:43 +0000
Message-ID: <E1hgGZr-00036Q-B9@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/55ed3defc966cf718fe1e8c0efe964580bb23351

Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml          |  2 +-
doc/src/sgml/ref/create_foreign_table.sgml |  4 +--
src/backend/commands/indexcmds.c           | 20 +++++++++++
src/backend/commands/tablecmds.c           | 45 ++++++++++++++++++++++++
src/backend/tcop/utility.c                 | 12 +++++--
src/test/regress/expected/foreign_data.out | 56 ++++++++++++++++++++++++++++--
src/test/regress/sql/foreign_data.sql      | 42 +++++++++++++++++++++-
7 files changed, 172 insertions(+), 9 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1hgGZr-00036Q-B9@gemulon.postgresql.org>
Permalink:  ../E1hgGZr-00036Q-B9@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hgGZr-00036Q-B9@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Fix partitioned index creation with foreign partitions
  In-Reply-To: <E1hgGZr-00036Q-B9@gemulon.postgresql.org>
  References: <E1hgGZr-00036Q-B9@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox