pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: Ligia Pimentel <lmpimentel@yahoo.com>
Cc: Hackers <pgsql-hackers@postgresql.org>
Subject: Re: [SQL] An easy question about creating a primary key
Date: Mon, 03 Dec 2001 21:29:49 -0500
Message-ID: <21379.1007432989@sss.pgh.pa.us> (raw)
In-Reply-To: <GNELIHDDFBOCMGBFGEFOCEKHCAAA.chriskl@familyhealth.com.au>
References: <GNELIHDDFBOCMGBFGEFOCEKHCAAA.chriskl@familyhealth.com.au>

"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
>> I think you've forgotten your own work, Chris.
>> 
>> regression=# create table foo (bar int not null);
>> CREATE
>> regression=# alter table foo add primary key (bar);
>> NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index
>> 'foo_pkey' for table 'foo'
>> CREATE
>> regression=#

> Bizarre.  That patch was never committed.  If you check
> src/backend/commands/command.c and search for 'CONSTR_' you'll notice that
> the CONSTR_UNIQUE function I implemented is there, but CONSTR_PRIMARY is
> definitely not being handled.  (I'm looking at the 7.2b2 source code)

Hmm ... actually, I wonder whether that code in command.c isn't entirely
dead code.  I believe that as things stand, parser/analyze.c converts
UNIQUE and PRIMARY constraints into CREATE INDEX statements; the
constraint nodes themselves never make it past the parser.  It looks to
me like command.c only needs to handle CHECK constraints and foreign-key
constraints, cf transformAlterTableStmt().

			regards, tom lane



view thread (13+ messages)  latest in thread

Message-ID: <21379.1007432989@sss.pgh.pa.us>
Permalink:  ../21379.1007432989@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21379.1007432989@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, chriskl@familyhealth.com.au, lmpimentel@yahoo.com, pgsql-hackers@postgresql.org
  Subject: Re: [SQL] An easy question about creating a primary key
  In-Reply-To: <21379.1007432989@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox