Skip site navigation (1) Skip section navigation (2)

CREATE TABLE .. PRIMARY KEY quirk

From: Colin Strickland <cms(at)sift(dot)co(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: CREATE TABLE .. PRIMARY KEY quirk
Date: 2001-07-04 13:28:46
Message-ID: 200107041328.f64DSkR01802@mongoose.office.sift.co.uk (view raw or flat)
Thread:
Lists: pgsql-hackers
Issuing the following ( admittedly bogus ) statement against 7.1.1

CREATE TABLE dir_suppliers_var_prodtype (
  dir_suppliers_var_prodtype_id INTEGER ,
  dir_suppliers_var_id  integer DEFAULT 0 NOT NULL,
  prodtype_id  smallint DEFAULT 0 NOT NULL,
  PRIMARY KEY
(dir_suppliers_var_prodtype_id,dir_suppliers_var_prodtype_id)
);

gives the following , initially slightly cryptic response.

NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index
'dir_suppliers_var_prodtype_pkey' for table 'dir_suppliers_var_prodtype'

ERROR:  Cannot insert a duplicate key into unique index
pg_attribute_relid_attnam_index

This is obviously because of the broken primary key definition.
 
My question is, should this not raise a parser error ? It took me a
little while to actually spot the problem with the users statement.



-- 
Colin M Strickland  perl -e'print "\n",map{chr(ord()-3)}(reverse split 
             //,"\015%vhlwlqxpprF#ir#uhzrS#hkw#jqlvvhqudK%#\015\015nx".
"1rf1wilv1zzz22=swwk###369<#84<#:44#77.={di##339<#84<#:44#77.=ohw\015]".
"K9#4VE#/ORWVLUE#/whhuwV#dlurwflY#334#/wilV\015uhsrohyhG#ehZ#urlqhV");'

Responses

pgsql-hackers by date

Next:From: Michel SotoDate: 2001-07-04 14:30:18
Subject: Strange query execution time
Previous:From: Damien ClermontéDate: 2001-07-04 12:51:49
Subject: Re: [PATCH] Patch to make pg_hba.conf handle virtualhost access control and samehost keyword

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group