Re: Adding support for Default partition in partitioning

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Rahila Syed <rahilasyed90(at)gmail(dot)com>, Keith Fiske <keith(at)omniti(dot)com>, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, David Steele <david(at)pgmasters(dot)net>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Adding support for Default partition in partitioning
Date: 2017-04-25 06:03:42
Message-ID: 657ded6c-40de-d5e9-a9a6-5018a65431cc@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/04/25 14:20, Ashutosh Bapat wrote:
> On Tue, Apr 25, 2017 at 1:46 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Mon, Apr 24, 2017 at 8:14 AM, Ashutosh Bapat
>> <ashutosh(dot)bapat(at)enterprisedb(dot)com> wrote:
>>> On Mon, Apr 24, 2017 at 4:24 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>>> On Mon, Apr 24, 2017 at 5:10 AM, Rahila Syed <rahilasyed90(at)gmail(dot)com> wrote:
>>>>> Following can also be considered as it specifies more clearly that the
>>>>> partition holds default values.
>>>>>
>>>>> CREATE TABLE ...PARTITION OF...FOR VALUES DEFAULT;
>>>>
>>>> The partition doesn't contain default values; it is itself a default.
>>>
>>> Is CREATE TABLE ... DEFAULT PARTITION OF ... feasible? That sounds more natural.
>>
>> I suspect it could be done as of now, but I'm a little worried that it
>> might create grammar conflicts in the future as we extend the syntax
>> further. If we use CREATE TABLE ... PARTITION OF .. DEFAULT, then the
>> word DEFAULT appears in the same position where we'd normally have FOR
>> VALUES, and so the parser will definitely be able to figure out what's
>> going on. When it gets to that position, it will see FOR or it will
>> see DEFAULT, and all is clear. OTOH, if we use CREATE TABLE ...
>> DEFAULT PARTITION OF ..., then we have action at a distance: whether
>> or not the word DEFAULT is present before PARTITION affects which
>> tokens are legal after the parent table name.
>
> As long as we handle this at the transformation stage, it shouldn't be
> a problem. The grammar would be something like
> CREATE TABLE ... optDefault PARTITION OF ...
>
> If user specifies DEFAULT PARTITION OF t1 FOR VALUES ..., parser will
> allow that but in transformation stage, we will detect it and throw an
> error "DEFAULT partitions can not contains partition bound clause" or
> something like that. Also, documentation would say that DEFAULT and
> partition bound specification are not allowed together.

FWIW, one point to like about PARTITION OF .. DEFAULT is that it wouldn't
need us to do things you mention we could do. A point to not like it may
be that it might read backwards to some users, but then the DEFAULT
PARTITION OF have all those possibilities of error-causing user input.

Thanks,
Amit

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-04-25 06:09:56 Re: Patch - Tcl 8.6 version support for PostgreSQL
Previous Message Andres Freund 2017-04-25 05:57:39 Re: Patch - Tcl 8.6 version support for PostgreSQL