77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.86 1998/09/03 14:21:06 thomas Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.87 1998/09/16 14:25:37 thomas Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -530,11 +530,26 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
530530constraint -> def = cstring ;
531531constraint -> keys = NULL ;
532532
533+ /* The parser only allows PRIMARY KEY as a constraint for the SERIAL type.
534+ * So, if there is a constraint of any kind, assume it is that.
535+ * If PRIMARY KEY is specified, then don't need to gin up a UNIQUE constraint
536+ * since that will be covered already.
537+ * - thomas 1998-09-15
538+ */
533539if (column -> constraints != NIL )
540+ {
534541column -> constraints = lappend (column -> constraints ,constraint );
542+ }
535543else
544+ {
536545column -> constraints = lcons (constraint ,NIL );
537546
547+ constraint = makeNode (Constraint );
548+ constraint -> contype = CONSTR_UNIQUE ;
549+ constraint -> name = makeTableName (stmt -> relname ,column -> colname ,"key" ,NULL );
550+ column -> constraints = lappend (column -> constraints ,constraint );
551+ }
552+
538553sequence = makeNode (CreateSeqStmt );
539554sequence -> seqname = pstrdup (constraint -> name );
540555sequence -> options = NIL ;
@@ -543,12 +558,6 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
543558sequence -> seqname ,stmt -> relname ,column -> colname );
544559
545560ilist = lcons (sequence ,NIL );
546-
547- constraint = makeNode (Constraint );
548- constraint -> contype = CONSTR_UNIQUE ;
549- constraint -> name = makeTableName (stmt -> relname ,column -> colname ,"key" ,NULL );
550-
551- column -> constraints = lappend (column -> constraints ,constraint );
552561}
553562
554563if (column -> constraints != NIL )