@ -6,7 +6,7 @@
* Portions Copyright ( c ) 1996 - 2001 , PostgreSQL Global Development Group
* Portions Copyright ( c ) 1996 - 2001 , PostgreSQL Global Development Group
* Portions Copyright ( c ) 1994 , Regents of the University of California
* Portions Copyright ( c ) 1994 , Regents of the University of California
*
*
* $ Header : / cvsroot / pgsql / src / backend / parser / analyze . c , v 1.191 2001 / 06 / 25 21 : 11 : 4 4 tgl Exp $
* $ Header : / cvsroot / pgsql / src / backend / parser / analyze . c , v 1.192 2001 / 07 / 04 17 : 36 : 5 4 tgl Exp $
*
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
*/
@ -954,8 +954,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
index = makeNode ( IndexStmt ) ;
index = makeNode ( IndexStmt ) ;
index - > unique = TRUE ;
index - > unique = true ;
index - > primary = ( constraint - > contype = = CONSTR_PRIMARY ? TRUE : FALSE ) ;
index - > primary = ( constraint - > contype = = CONSTR_PRIMARY ) ;
if ( index - > primary )
if ( index - > primary )
{
{
if ( pkey ! = NULL )
if ( pkey ! = NULL )
@ -1057,6 +1057,17 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
elog ( ERROR , " CREATE TABLE: column \" %s \" named in key does not exist " ,
elog ( ERROR , " CREATE TABLE: column \" %s \" named in key does not exist " ,
key - > name ) ;
key - > name ) ;
/* Check for PRIMARY KEY(foo, foo) */
foreach ( columns , index - > indexParams )
{
iparam = ( IndexElem * ) lfirst ( columns ) ;
if ( strcmp ( key - > name , iparam - > name ) = = 0 )
elog ( ERROR , " CREATE TABLE: column \" %s \" appears twice in %s constraint " ,
key - > name ,
index - > primary ? " PRIMARY KEY " : " UNIQUE " ) ;
}
/* OK, add it to the index definition */
iparam = makeNode ( IndexElem ) ;
iparam = makeNode ( IndexElem ) ;
iparam - > name = pstrdup ( key - > name ) ;
iparam - > name = pstrdup ( key - > name ) ;
iparam - > args = NIL ;
iparam - > args = NIL ;