1010 *
1111 *
1212 * IDENTIFICATION
13- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.30 1998/09/13 04:19:29 thomas Exp $
13+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.31 1998/09/16 14:29:35 thomas Exp $
1414 *
1515 * HISTORY
1616 * AUTHORDATEMAJOR EVENT
@@ -236,7 +236,7 @@ Oidparam_type(int t); /* used in parse_expr.c */
236236%type <node>TableConstraint
237237%type <list>constraint_list, constraint_expr
238238%type <list>default_list, default_expr
239- %type <list>ColQualList, ColQualifier
239+ %type <list>ColPrimaryKey, ColQualList, ColQualifier
240240%type <node>ColConstraint, ColConstraintElem
241241%type <list>key_actions, key_action
242242%type <str>key_match, key_reference
@@ -751,7 +751,7 @@ columnDef: ColId Typename ColQualifier
751751n->constraints = $3;
752752$$ = (Node *)n;
753753}
754- | ColId SERIAL
754+ | ColId SERIAL ColPrimaryKey
755755{
756756ColumnDef *n = makeNode(ColumnDef);
757757n->colname = $1;
@@ -760,7 +760,7 @@ columnDef: ColId Typename ColQualifier
760760n->defval = NULL;
761761n->is_not_null = TRUE;
762762n->is_sequence = TRUE;
763- n->constraints =NULL ;
763+ n->constraints =$3 ;
764764
765765$$ = (Node *)n;
766766}
@@ -786,6 +786,18 @@ ColQualList: ColQualList ColConstraint
786786}
787787;
788788
789+ ColPrimaryKey: PRIMARY KEY
790+ {
791+ Constraint *n = makeNode(Constraint);
792+ n->contype = CONSTR_PRIMARY;
793+ n->name = NULL;
794+ n->def = NULL;
795+ n->keys = NULL;
796+ $$ = lcons((Node *)n, NIL);
797+ }
798+ | /*EMPTY*/{ $$ = NULL; }
799+ ;
800+
789801ColConstraint:
790802CONSTRAINT name ColConstraintElem
791803{
@@ -806,6 +818,11 @@ ColConstraint:
806818$$ = NULL;
807819}
808820 * - thomas 1998-09-12
821+ *
822+ * DEFAULT NULL is already the default for Postgres.
823+ * Bue define it here and carry it forward into the system
824+ * to make it explicit.
825+ * - thomas 1998-09-13
809826 */
810827ColConstraintElem: CHECK '(' constraint_expr ')'
811828{
@@ -816,6 +833,15 @@ ColConstraintElem: CHECK '(' constraint_expr ')'
816833n->keys = NULL;
817834$$ = (Node *)n;
818835}
836+ | DEFAULT NULL_P
837+ {
838+ Constraint *n = makeNode(Constraint);
839+ n->contype = CONSTR_DEFAULT;
840+ n->name = NULL;
841+ n->def = NULL;
842+ n->keys = NULL;
843+ $$ = (Node *)n;
844+ }
819845| DEFAULT default_expr
820846{
821847Constraint *n = makeNode(Constraint);
@@ -870,10 +896,15 @@ default_list: default_list ',' default_expr
870896}
871897;
872898
873- default_expr: AexprConst
874- {$$ = makeConstantList((A_Const *) $1); }
899+ /* The Postgres default column value is NULL.
900+ * Rather than carrying DEFAULT NULL forward as a clause,
901+ * let's just have it be a no-op.
875902| NULL_P
876903{$$ = lcons( makeString("NULL"), NIL); }
904+ * - thomas 1998-09-13
905+ */
906+ default_expr: AexprConst
907+ {$$ = makeConstantList((A_Const *) $1); }
877908| '-' default_expr %prec UMINUS
878909{$$ = lcons( makeString( "-"), $2); }
879910| default_expr '+' default_expr