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

From: Robert Treat <rob(at)xzilla(dot)net>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: PGSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch to add a primary key using an existing index
Date: 2010-12-03 22:16:04
Message-ID: AANLkTine3ypcFGAc=bTHFPg=bOFFHMDN3zGD4xWLj4na@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 3, 2010 at 4:41 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:

> On 12/3/10 12:27 PM, Robert Haas wrote:
> > On Fri, Dec 3, 2010 at 2:56 PM, r t <pgsql(at)xzilla(dot)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
play: http://www.xzilla.net
work: http://www.omniti.com/is/hiring

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ross J. Reedstrom 2010-12-03 23:10:08 Re: Patch to add a primary key using an existing index
Previous Message Heikki Linnakangas 2010-12-03 22:04:03 Re: ERROR: could not identify an equality operator for type box