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

2011-01-26 Thread Gurjeet Singh
On Wed, Jan 26, 2011 at 6:14 AM, Tom Lane wrote: > Gurjeet Singh writes: > > Attached is the updated patch with doc changes and test cases. > > Applied with assorted corrections. Aside from the refactoring I wanted, > there were various oversights. > Looking at the commit, the committed patch

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

2011-01-25 Thread Tom Lane
Gurjeet Singh writes: > Attached is the updated patch with doc changes and test cases. Applied with assorted corrections. Aside from the refactoring I wanted, there were various oversights. > I have consciously disallowed the ability to specify storage_parameters > using the WITH clause, if som

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

2011-01-25 Thread Gurjeet Singh
On Wed, Jan 26, 2011 at 5:31 AM, Tom Lane wrote: > In the end I think this is mainly an issue of setting appropriate > expectations in the documentation. I've added the following text to > the ALTER TABLE manual page: > > > After this command is executed, the index is owned by the >

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

2011-01-25 Thread Tom Lane
Gurjeet Singh writes: > On Tue, Jan 25, 2011 at 9:01 AM, Tom Lane wrote: >> One other issue that might be worthy of discussion is that as things >> stand, execution of the ADD CONSTRAINT USING INDEX syntax will cause >> the constraint to absorb the index as an INTERNAL dependency. That >> means

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

2011-01-25 Thread Gurjeet Singh
Sorry for not being on top of this. On Tue, Jan 25, 2011 at 9:01 AM, Tom Lane wrote: > I wrote: > > ... If that's the only issue then I don't see any need to wait on > > the author, so will take this one. > > I find myself quite dissatisfied with the way that this patch adds yet > another bool f

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

2011-01-25 Thread Joshua Tolley
On Mon, Jan 24, 2011 at 07:01:13PM -0500, Tom Lane wrote: > One other issue that might be worthy of discussion is that as things > stand, execution of the ADD CONSTRAINT USING INDEX syntax will cause > the constraint to absorb the index as an INTERNAL dependency. That > means dropping the constrai

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

2011-01-24 Thread Robert Haas
On Mon, Jan 24, 2011 at 7:01 PM, Tom Lane wrote: > One other issue that might be worthy of discussion is that as things > stand, execution of the ADD CONSTRAINT USING INDEX syntax will cause > the constraint to absorb the index as an INTERNAL dependency.  That > means dropping the constraint would

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

2011-01-24 Thread Tom Lane
I wrote: > ... If that's the only issue then I don't see any need to wait on > the author, so will take this one. I find myself quite dissatisfied with the way that this patch adds yet another bool flag to index_create (which has too many of those already), with the effect of causing it to exactly

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

2011-01-24 Thread Tom Lane
Steve Singer writes: > src/backend/parser/parse_utilcmd.c: 1452 > Your calling strdup on the attribute name. I don't have a good enough > grasp on the code to be able to trace this through to where the memory > gets free'd. Does it get freed? Should/could this be a call to pstrdup strdup() is

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

2011-01-16 Thread Robert Haas
On Sun, Jan 16, 2011 at 5:34 PM, Steve Singer wrote: > I'm marking this as returned with feedback pending your answer on the > possible memory leak above but I think the patch is very close to being > ready. Please use "Waiting on Author" if the patch is to be considered further for this CommitFe

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

2011-01-16 Thread Steve Singer
I've taken a look at this version of the patch. Submission Review This version of the patch applies cleanly to master. It matches your git repo and includes test + docs. Usability Review --- The command syntax now matches what was discussed during the last cf. T

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

2011-01-06 Thread Gurjeet Singh
On Thu, Dec 9, 2010 at 2:48 PM, Tom Lane wrote: > Gurjeet Singh writes: > > But I still hold a bias towards renaming the index to match constraint > name > > (with a NOTICE), rather than require that the constraint name match the > > index name, because the constraint name is optional and when i

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

2010-12-09 Thread Robert Haas
On Thu, Dec 9, 2010 at 2:51 PM, Kevin Grittner wrote: > Tom Lane wrote: >> If the constraint name is not specified, we should certainly use >> the existing index name, not randomly rename it. > > +1 +1 -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company

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

2010-12-09 Thread Kevin Grittner
Tom Lane wrote: > If the constraint name is not specified, we should certainly use > the existing index name, not randomly rename it. +1 -Kevin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgs

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

2010-12-09 Thread Tom Lane
Gurjeet Singh writes: > But I still hold a bias towards renaming the index to match constraint name > (with a NOTICE), rather than require that the constraint name match the > index name, because the constraint name is optional and when it is not > provided system has to generate a name and we hav

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

2010-12-09 Thread Gurjeet Singh
On Sun, Dec 5, 2010 at 2:09 PM, Peter Eisentraut wrote: > On fre, 2010-12-03 at 15:27 -0500, Robert Haas wrote: > > On Fri, Dec 3, 2010 at 2:56 PM, r t wrote: > > > What exactly was the objection to the following --> > > > ALTER TABLE table_name ADD PRIMARY KEY (column_list) USING index_name; >

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

2010-12-05 Thread Peter Eisentraut
On fre, 2010-12-03 at 15:27 -0500, Robert Haas wrote: > On Fri, Dec 3, 2010 at 2:56 PM, r t 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 co

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

2010-12-04 Thread Josh Berkus
On 12/04/2010 12:37 PM, Robert Haas wrote: What would make sense to me is: create a pk constraint with the sane name as the existing unique index. If that constraint name already exists, error. +1, agreed. Based on this, the syntax should be obvious. We'll need to doc what to do in the even

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

2010-12-04 Thread Robert Haas
On Dec 4, 2010, at 11:46 AM, Tom Lane wrote: > Robert Treat writes: >> Actually I think I'd even be comfortable with A, either you must name the >> constraint after the index, or you can leave the constraint name out, and >> we'll use the index name. > > Or we could omit the "CONSTRAINT name" cl

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

2010-12-04 Thread Tom Lane
Robert Treat writes: > Actually I think I'd even be comfortable with A, either you must name the > constraint after the index, or you can leave the constraint name out, and > we'll use the index name. Or we could omit the "CONSTRAINT name" clause from the syntax altogether. I think that allowing

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

2010-12-04 Thread Robert Treat
On Sat, Dec 4, 2010 at 6:48 AM, Robert Haas wrote: > On Dec 4, 2010, at 1:30 AM, Tom Lane wrote: > > "Ross J. Reedstrom" writes: > >> If you consider that an index basically is, in some sense, a pre-canned > >> column list, then: > > > >> ALTER TABLE table_name ADD PRIMARY KEY (column_list); >

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

2010-12-04 Thread Robert Haas
On Dec 4, 2010, at 1:30 AM, Tom Lane wrote: > "Ross J. Reedstrom" writes: >> If you consider that an index basically is, in some sense, a pre-canned >> column list, then: > >> ALTER TABLE table_name ADD PRIMARY KEY (column_list); >> ALTER TABLE table_name ADD PRIMARY KEY USING index_name; > >>

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

2010-12-03 Thread Tom Lane
"Ross J. Reedstrom" writes: > If you consider that an index basically is, in some sense, a pre-canned > column list, then: > ALTER TABLE table_name ADD PRIMARY KEY (column_list); > ALTER TABLE table_name ADD PRIMARY KEY USING index_name; > are parallel constructions. And it avoids the error case

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

2010-12-03 Thread Josh Berkus
On 12/3/10 2:16 PM, Robert Treat wrote: > 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.

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

2010-12-03 Thread Ross J. Reedstrom
On Fri, Dec 03, 2010 at 05:16:04PM -0500, Robert Treat wrote: > On Fri, Dec 3, 2010 at 4:41 PM, Josh Berkus wrote: > > > 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_na

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

2010-12-03 Thread Robert Treat
On Fri, Dec 3, 2010 at 4:41 PM, Josh Berkus wrote: > On 12/3/10 12:27 PM, Robert Haas wrote: > > On Fri, Dec 3, 2010 at 2:56 PM, r t wrote: > >> What exactly was the objection to the following --> > >> ALTER TABLE table_name ADD PRIMARY KEY (column_list) USING index_name; > >> Is the objection t

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

2010-12-03 Thread Josh Berkus
On 12/3/10 12:27 PM, Robert Haas wrote: > On Fri, Dec 3, 2010 at 2:56 PM, r t 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

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

2010-12-03 Thread Robert Haas
On Fri, Dec 3, 2010 at 2:56 PM, r t 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 mor

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

2010-12-03 Thread Heikki Linnakangas
On 03.12.2010 21:58, Alvaro Herrera wrote: Excerpts from Heikki Linnakangas's message of vie dic 03 16:45:59 -0300 2010: ALTER TABLE table_name SET PRIMARY KEY USING INDEX index_name. Quite verbose, but imho USING makes it much more clear that it's an existing index. I was going to post the s

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

2010-12-03 Thread r t
On Fri, Dec 3, 2010 at 2:43 PM, Robert Haas wrote: > On Fri, Dec 3, 2010 at 2:23 PM, Peter Eisentraut wrote: > > On sön, 2010-11-28 at 20:40 -0500, Robert Haas wrote: > >> On Sun, Nov 28, 2010 at 8:06 PM, Itagaki Takahiro > >> wrote: > >> > On Fri, Nov 26, 2010 at 05:58, Steve Singer > wrote:

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

2010-12-03 Thread Alvaro Herrera
Excerpts from Heikki Linnakangas's message of vie dic 03 16:45:59 -0300 2010: > ALTER TABLE table_name SET PRIMARY KEY USING INDEX index_name. Quite > verbose, but imho USING makes it much more clear that it's an existing > index. I was going to post the same thing (well except I was still thin

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

2010-12-03 Thread Heikki Linnakangas
On 03.12.2010 21:43, Robert Haas wrote: On Fri, Dec 3, 2010 at 2:23 PM, Peter Eisentraut wrote: On sön, 2010-11-28 at 20:40 -0500, Robert Haas wrote: On Sun, Nov 28, 2010 at 8:06 PM, Itagaki Takahiro wrote: On Fri, Nov 26, 2010 at 05:58, Steve Singer wrote: The attached version of the pat

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

2010-12-03 Thread Robert Haas
On Fri, Dec 3, 2010 at 2:23 PM, Peter Eisentraut wrote: > On sön, 2010-11-28 at 20:40 -0500, Robert Haas wrote: >> On Sun, Nov 28, 2010 at 8:06 PM, Itagaki Takahiro >> wrote: >> > On Fri, Nov 26, 2010 at 05:58, Steve Singer >> > wrote: >> >> The attached version of the patch gets your regressio

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

2010-12-03 Thread Peter Eisentraut
On sön, 2010-11-28 at 20:40 -0500, Robert Haas wrote: > On Sun, Nov 28, 2010 at 8:06 PM, Itagaki Takahiro > wrote: > > On Fri, Nov 26, 2010 at 05:58, Steve Singer wrote: > >> The attached version of the patch gets your regression tests to pass. > >> I'm going to mark this as ready for a committer

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

2010-11-28 Thread David Fetter
On Sun, Nov 28, 2010 at 08:40:08PM -0500, Robert Haas wrote: > On Sun, Nov 28, 2010 at 8:06 PM, Itagaki Takahiro > wrote: > > On Fri, Nov 26, 2010 at 05:58, Steve Singer wrote: > >> The attached version of the patch gets your regression tests to > >> pass. I'm going to mark this as ready for a c

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

2010-11-28 Thread Robert Haas
On Sun, Nov 28, 2010 at 8:06 PM, Itagaki Takahiro wrote: > On Fri, Nov 26, 2010 at 05:58, Steve Singer wrote: >> The attached version of the patch gets your regression tests to pass. >> I'm going to mark this as ready for a committer. > > I think we need more discussions about the syntax: >  ALTE

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

2010-11-28 Thread Itagaki Takahiro
On Fri, Nov 26, 2010 at 05:58, Steve Singer wrote: > The attached version of the patch gets your regression tests to pass. > I'm going to mark this as ready for a committer. I think we need more discussions about the syntax: ALTER TABLE table_name ADD PRIMARY KEY (...) WITH (INDEX='index_name')

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

2010-11-25 Thread Steve Singer
On 10-11-22 03:24 PM, Steve Singer wrote: On 10-11-22 09:37 AM, Gurjeet Singh wrote: On Sat, Nov 20, 2010 at 9:00 AM, Steve Singer Almost fixed. I still get an unexpected difference. ! DETAIL: cannot create PRIMARY KEY/UNIQUE constraint with a non-unique index. CREATE UNIQUE INDEX rpi_idx2 O

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

2010-11-22 Thread Steve Singer
On 10-11-22 09:37 AM, Gurjeet Singh wrote: On Sat, Nov 20, 2010 at 9:00 AM, Steve Singer > wrote: Submission Review: Tests The expected output for the regression tests you added don't match what I'm getti

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

2010-11-22 Thread Gurjeet Singh
On Sat, Nov 20, 2010 at 9:00 AM, Steve Singer wrote: > > Submission Review: > > > Tests > > The expected output for the regression tests you added don't match > what I'm getting when I run the tests with your patch applied. > I think you just need to regenerate th

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

2010-11-19 Thread Steve Singer
On 10-11-07 01:54 PM, Gurjeet Singh wrote: Attached is the patch that extends the same feature for UNIQUE indexes. It also includes some doc changes for the ALTER TABLE command, but I could not verify the resulting changes since I don't have the doc-building infrastructure installed. Regards,

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

2010-11-07 Thread Gurjeet Singh
Attached is the patch that extends the same feature for UNIQUE indexes. It also includes some doc changes for the ALTER TABLE command, but I could not verify the resulting changes since I don't have the doc-building infrastructure installed. Regards, On Mon, Nov 8, 2010 at 1:39 AM, Gurjeet Singh

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

2010-11-07 Thread Gurjeet Singh
Depesz brought that to my attention a few days after the initial submission, and adding support for UNIQUE was not much pain. I implemented it almost immediately, but didn't announce it as I was hoping I could submit some doc changes too with that. If you are the adventurous kind, you can follow t

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

2010-11-01 Thread Jim Nasby
UNIQUE constraints suffer from the same behavior; feel like fixing that too? :) On Oct 9, 2010, at 1:07 PM, Gurjeet Singh wrote: > This is a continuation from this thread: > http://archives.postgresql.org/pgsql-hackers/2010-09/msg02153.php > > The attached patch allows creating a primary key us

Re: archives, attachments, etc (was: [HACKERS] Patch to add a primary key using an existing index)

2010-10-09 Thread Gurjeet Singh
On Sat, Oct 9, 2010 at 3:30 PM, Dimitri Fontaine wrote: > Andrew Dunstan writes: > > I wish we could get the archive processor to provide access to the > > attachments even if they have a MIME type of text/whatever. That's a > > horrid inefficiency. Maybe we could restrict it to text attachments

archives, attachments, etc (was: [HACKERS] Patch to add a primary key using an existing index)

2010-10-09 Thread Dimitri Fontaine
Andrew Dunstan writes: > I wish we could get the archive processor to provide access to the > attachments even if they have a MIME type of text/whatever. That's a > horrid inefficiency. Maybe we could restrict it to text attachments > that have a Content-Type with a name attribute that contains th

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

2010-10-09 Thread Andrew Dunstan
On 10/09/2010 02:19 PM, Gurjeet Singh wrote: On Sat, Oct 9, 2010 at 2:07 PM, Gurjeet Singh > wrote: This is a continuation from this thread: http://archives.postgresql.org/pgsql-hackers/2010-09/msg02153.php The attached patch allows creating a prima

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

2010-10-09 Thread Gurjeet Singh
On Sat, Oct 9, 2010 at 2:07 PM, Gurjeet Singh wrote: > This is a continuation from this thread: > http://archives.postgresql.org/pgsql-hackers/2010-09/msg02153.php > > The attached patch allows creating a primary key using an existing index. > > I have attached two versions of the patch: one is