Re: Syntax for partitioning - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Syntax for partitioning
Date
Msg-id 603c8f070910291914i72b03d37kacadb0eabe3aeab@mail.gmail.com
Whole thread Raw
In response to Re: Syntax for partitioning  (Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: Syntax for partitioning
List pgsql-hackers
On Thu, Oct 29, 2009 at 9:51 PM, Itagaki Takahiro
<itagaki.takahiro@oss.ntt.co.jp> wrote:
>
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote:
>
>> > The keyword "PARTITION" is
>> > added to the full-reserved keyword list to support ADD/DROP PARTITION.
>>
>> Any chance to avoid that? PARTITION seems like something people might
>> well use as a column or variable name. OTOH, it is reserved in SQL2008
>> and SQL2003.
>
> CREATE TABLE does not require PARTITION to be a reserved keyword,
> but there are conflicts in ALTER TABLE ADD/DROP PARTITION:
>
>  * ALTER TABLE ... DROP [COLUMN]  name [CASCADE | RESTRICT]
>  * ALTER TABLE ... DROP PARTITION name [CASCADE | RESTRICT]
>
> There are some solutions:
>
>  1. Change COLUMN not to an optional word (unlikely)
>  2. Change syntax of DROP PARTITION to DROP TABLE PARITION or so
>  3. Change ALTER TABLE ADD/DROP PARTITION to top level
>      => CREATE/DROP PARTITION name ON table_name
>
> Any better ideas?

I'm not sure if this is better, but what about:

CREATE PARTITION name ON TABLE name
DROP PARTITION name

Since partitions will live in pg_class and are in some sense "top
level" objects, it seems like it would make sense to use a syntax that
is similar to the one we use for indices...  we can't say "DROP COLUMN
name", because the table must be specified.  But a partition name must
be unambiguous, so making the user write it out explicitly doesn't
seem friendly.

...Robert


pgsql-hackers by date:

Previous
From: Itagaki Takahiro
Date:
Subject: Re: Syntax for partitioning
Next
From: Itagaki Takahiro
Date:
Subject: Re: Syntax for partitioning