Re: Patch to add a primary key using an existing index

Поиск
Список
Период
Сортировка
От Robert Treat
Тема Re: Patch to add a primary key using an existing index
Дата
Msg-id AANLkTine3ypcFGAc=bTHFPg=bOFFHMDN3zGD4xWLj4na@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Patch to add a primary key using an existing index  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: Patch to add a primary key using an existing index  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Re: Patch to add a primary key using an existing index  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-hackers
On Fri, Dec 3, 2010 at 4:41 PM, Josh Berkus <josh@agliodbs.com> wrote:
On 12/3/10 12:27 PM, Robert Haas wrote:
> On Fri, Dec 3, 2010 at 2:56 PM, r t <pgsql@xzilla.net> wrote:
>> What exactly was the objection to the following -->
>> ALTER TABLE table_name ADD PRIMARY KEY (column_list) USING index_name;
>> Is the objection that you might have been trying to specify a constraint
>> named "using" ? I'm willing to make that option more difficult. :-)
>
> I think it's that someone might expect the word after USING to be the
> name of an index AM.

Seems unlikely to cause confusion to me.


+1. And were we ever to support that, I think that would be the case to use WITH (storage_parameter) type syntax, where you would specify access_method=hash (or whatever). Although, let's not debate that syntax right now, at this point :-)
 
However, I don't see why we need (column_list). Surely the index has a
column list already?

ALTER TABLE table_name ADD CONSTRAINT pk_name PRIMARY KEY USING index_name

... seems like the syntax most consistent with the existing commands.
Anything else would be confusingly inconsistent with the way you add a
brand-new PK.


Uh, the syntax I posted was based on this currently valid syntax: 

ALTER TABLE table_name ADD PRIMARY KEY (column_list); 

The constraint bit is optional, which is why I left it out, but I presume it would be optional with the new syntax as well... Also, I'm not wedded to the idea of keeping the column list, but if you are arguing to make it super consistent, then I think you need to include it.   

Robert Treat

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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: ERROR: could not identify an equality operator for type box
Следующее
От: "Ross J. Reedstrom"
Дата:
Сообщение: Re: Patch to add a primary key using an existing index