Re: no partition pruning when partitioning using array type - Mailing list pgsql-hackers

From Amit Langote
Subject Re: no partition pruning when partitioning using array type
Date
Msg-id 39c7f34f-f888-ac78-a2bc-a741bddbc4c9@lab.ntt.co.jp
Whole thread Raw
In response to Re: no partition pruning when partitioning using array type  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: no partition pruning when partitioning using array type  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
On 2018/07/11 13:12, Alvaro Herrera wrote:
> On 2018-Jul-11, Amit Langote wrote:
> 
>> What's the solution here then?  Prevent domains as partition key?
> 
> Maybe if a domain is used in a partition key somewhere, prevent
> constraints from being added?

Maybe, but I guess you mean only prevent adding such a constraint
after-the-fact.

If a domain has a constraint before creating any partitions based on the
domain, then partition creation command would check that the partition
bound values satisfy those constraints.

> Another thing worth considering: are you prevented from dropping a
> domain that's used in a partition key?  If not, you get an ugly message
> when you later try to drop the table.

Yeah, I was about to write a message about that.  I think we need to teach
RemoveAttributeById, which dependency.c calls when dropping the
referencing domain with cascade option, to abort if the attribute passed
to it belongs to the partition key of the input relation.

I tried that in the attached, but not sure about the order of messages
that appear in the output of DROP DOMAIN .. CASCADE.  It contains a NOTICE
message followed by an ERROR message.

Thanks,
Amit

Attachment

pgsql-hackers by date:

Previous
From: Amit Khandekar
Date:
Subject: Re: Concurrency bug in UPDATE of partition-key
Next
From: Thomas Munro
Date:
Subject: Re: patch to allow disable of WAL recycling