From: Arseny Sher <a.sher@postgrespro.ru>
To: pgsql-hackers\@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Indexes on partitioned tables and foreign partitions
Date: Wed, 09 May 2018 14:50:04 +0300
Message-ID: <87sh71cakz.fsf@ars-thinkpad> (raw)
Hi,
8b08f7d4 added propagation of indexes on partitioned tables to
partitions, which is very cool. However, index creation also recurses
down to foreign tables. I doubt this is intentional, as such indexes are
forbidden as not making much sense; attempt to create index on
partitioned table with foreign partition leads to an error
now. Attached lines fix this.
--
Arseny Sher
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:dont_create_part_index_on_ftable.patch (text/x-diff, 1010B) download
*** a/src/backend/commands/indexcmds.c
--- b/src/backend/commands/indexcmds.c
*************** DefineIndex(Oid relationId,
*** 915,920 ****
--- 915,926 ----
int maplen;
childrel = heap_open(childRelid, lockmode);
+ /* Foreign table doesn't need indexes */+ if (childrel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)+ {+ heap_close(childrel, NoLock);+ continue;+ }
childidxs = RelationGetIndexList(childrel);
attmap =
convert_tuples_by_name_map(RelationGetDescr(childrel),
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
*************** AttachPartitionEnsureIndexes(Relation re
*** 14352,14357 ****
--- 14352,14361 ----
MemoryContext cxt;
MemoryContext oldcxt;
+ /* Foreign table doesn't need indexes */+ if (attachrel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)+ return;+
cxt = AllocSetContextCreate(CurrentMemoryContext,
"AttachPartitionEnsureIndexes",
ALLOCSET_DEFAULT_SIZES);
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: a.sher@postgrespro.ru, pgsql-hackers@lists.postgresql.org
Subject: Re: Indexes on partitioned tables and foreign partitions
In-Reply-To: <87sh71cakz.fsf@ars-thinkpad>
* 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