Re: Should new partitions inherit their tablespace from their parent?

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Should new partitions inherit their tablespace from their parent?
Date: 2018-12-07 07:15:08
Message-ID: 20181207071508.GS2407@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 24, 2018 at 10:18:17AM +0900, Michael Paquier wrote:
> On Sat, Nov 24, 2018 at 12:32:36PM +1300, David Rowley wrote:
>> On Fri, 23 Nov 2018 at 17:03, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> wrote:
>> > Here's a patch for that. Parking here until January's commitfest.
>>
>> And another, now rebased atop of de38ce1b8 (which I probably should
>> have waited for).

Thanks for the patch, David. I can see that this patch makes the code
more consistent for partitioned tables and partitioned indexes when it
comes to tablespace handling, which is a very good thing.

-ATExecPartedIdxSetTableSpace(Relation rel, Oid newTableSpace)
+ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
NoStorage looks strange as routine name for this case. Would something
like ATExecPartedRelSetTableSpace be more adapted perhaps?

+ else if (stmt->partbound)
+ {
+ RangeVar *parent;
+ Relation parentrel;
+
+ /*
+ * For partitions, when no other tablespace is specified, we default
+ * the tablespace to the parent partitioned table's.
+ */
Okay, so the direct parent is what counts, and not the top-most parent.
Could you add a test with multiple level of partitioned tables, like:
- parent is in tablespace 1.
- child is created in tablespace 2.
- grandchild is created, which should inherit tablespace 2 from the
child, but not tablespace 1 from the parent. In the existing example,
as one partition is used to test the top-most parent and another for the
new default, it looks cleaner to create a third partition which would be
itself a partitioned table.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2018-12-07 07:45:59 Re: Too many logs are written on Windows (LOG: could not reserve shared memory region (addr=%p) for child %p:)
Previous Message Noah Misch 2018-12-07 07:10:08 Re: Support custom socket directory in pg_upgrade