Re: Boolean partitions syntax

From: "Jonathan S(dot) Katz" <jonathan(dot)katz(at)excoventures(dot)com>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: David Steele <david(at)pgmasters(dot)net>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Mark Dilger <hornschnorter(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Boolean partitions syntax
Date: 2018-04-07 15:16:22
Message-ID: A7BC8013-01B5-4225-B8AC-988BB27B07C7@excoventures.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On Mar 21, 2018, at 10:59 PM, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>
> Hi David.
>
> On 2018/03/21 23:31, David Steele wrote:
>> Hi Amit,
>>
>> On 3/6/18 9:44 AM, David Steele wrote:
>>> On 3/2/18 2:27 AM, Amit Langote wrote:
>>>> On 2018/03/02 15:58, Andres Freund wrote:
>>>>> On 2018-02-02 17:00:24 -0500, Tom Lane wrote:
>>>>>> Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
>>>>>>> There might be other options, but one way to solve this would be to
>>>>>>> treat partition bounds as a general expression in the grammar and then
>>>>>>> check in post-parse analysis that it's a constant.
>>>>>>
>>>>>> That's pretty much what I said upthread. What I basically don't like
>>>>>> about the current setup is that it's assuming that the bound item is
>>>>>> a bare literal. Even disregarding future-extension issues, that's bad
>>>>>> because it can't result in an error message smarter than "syntax error"
>>>>>> when someone tries the rather natural thing of writing a more complicated
>>>>>> expression.
>>>>>
>>>>> Given the current state of this patch, with a number of senior
>>>>> developers disagreeing with the design, and the last CF being in
>>>>> progress, I think we should mark this as returned with feedback.
>>>>
>>>> I see no problem with pursuing this in the next CF if the consensus is
>>>> that we should fix how partition bounds are parsed, instead of adopting
>>>> one of the patches to allow the Boolean literals to be accepted as
>>>> partition bounds.
>>>
>>> I'm inclined to mark this patch Returned with Feedback unless I hear
>>> opinions to the contrary.
>>
>> Hearing no opinions to the contrary I have marked this entry Returned
>> with Feedback. Please resubmit when you have an updated patch.
>
> OK.
>
> Btw, there is an 11dev open item recently added to the wiki that's related
> to this, but I think we might be able to deal with it independently of
> this proposal.
>
> * Partitions with bool partition keys *
> https://wiki.postgresql.org/wiki/PostgreSQL_11_Open_Items#Open_Issues <https://wiki.postgresql.org/wiki/PostgreSQL_11_Open_Items#Open_Issues>

While testing the new partitioning features yesterday I got bit by this issue
when creating a common use-case: a table split up by active/archived records:

CREATE TABLE records (
id int GENERATED BY DEFAULT AS IDENTITY NOT NULL,
record_date date NOT NULL,
record_text text,
archived bool NOT NULL DEFAULT FALSE
) PARTITION BY LIST(archived);

CREATE TABLE records_archive
PARTITION OF records
FOR VALUES IN (TRUE);

The last line yielding:

ERROR: syntax error at or near "TRUE"
LINE 3: FOR VALUES IN (TRUE);

[Omitted from example: the “records_active” partition]

I’m glad to see this was added to the open items. I would strongly suggest fixing
this prior to the 11 release as it is unintuitive from a user standpoint to use ‘TRUE’

Thanks,

Jonathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-04-07 15:26:39 Re: Online enabling of checksums
Previous Message Alvaro Herrera 2018-04-07 15:15:01 Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key