Re: [HACKERS] Adding support for Default partition in partitioning

Поиск
Список
Период
Сортировка
От Ashutosh Bapat
Тема Re: [HACKERS] Adding support for Default partition in partitioning
Дата
Msg-id CAFjFpRc7MuN5Z17VVggpcQsRmwfX42RXjLsb4nOLFC5KdUancA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Adding support for Default partition in partitioning  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Tue, Apr 25, 2017 at 11:23 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Tue, Apr 25, 2017 at 1:20 AM, Ashutosh Bapat
> <ashutosh.bapat@enterprisedb.com> wrote:
>>> 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.
>
> That's not what I'm concerned about.  I'm concerned about future
> syntax additions resulting in difficult-to-resolve grammar conflicts.
> For an example what of what I mean, consider this example:
>
> http://postgr.es/m/9253.1295031520@sss.pgh.pa.us
>
> The whole thread is worth a read.  In brief, I wanted to add syntax
> like LOCK VIEW xyz, and it wasn't possible to do that without breaking
> backward compatibility.  In a nutshell, the problem with making that
> syntax work was that LOCK VIEW NOWAIT would then potentially mean
> either lock a table called VIEW with the NOWAIT option, or else it
> might mean lock a view called NOWAIT.  If the NOWAIT key word were not
> allowed at the end or if the TABLE keyword were mandatory, then it
> would be possible to make it work, but because we already decided both
> to make the TABLE keyword optional and allow an optional NOWAIT
> keyword at the end, the syntax couldn't be further extended in the way
> that I wanted to extend it without confusing the parser.  The problem
> was basically unfixable without breaking backward compatibility, and
> we gave up.  I don't want to make the same mistake with the default
> partition syntax that we made with the LOCK TABLE syntax.
>
> Aside from unfixable grammar conflicts, there's another way that this
> kind of syntax can become problematic, which is when you end up with
> multiple optional keywords in the same part of the syntax.  For an
> example of that, see
> http://postgr.es/m/603c8f070905231747j2e099c23hef8eafbf26682e5f@mail.gmail.com
> - that discusses the problems with EXPLAIN; we later ran into the same
> problem with VACUUM.  Users can't remember whether they are supposed
> to type VACUUM FULL VERBOSE or VACUUM VERBOSE FULL and trying to
> support both creates parser problems and tends to involve adding too
> many keywords, so we switched to a new and more extensible syntax for
> future options.
>

Thanks for taking out time for detailed explanation.

> Now, you may think that that's never going to happen in this case.
> What optional keyword other than DEFAULT could we possibly want to add
> just before PARTITION OF?

Since the grammar before PARTITION OF is shared with CREATE TABLE ()
there is high chance that we will have an optional keyword unrelated
to partitioning there. I take back my proposal for that syntax.

-- 
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ashutosh Bapat
Дата:
Сообщение: Re: [HACKERS] Foreign Join pushdowns not working properly for outer joins
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: [HACKERS] some review comments on logical rep code