*** ../src/backend/parser/gram.y.orig Sun Sep 13 04:35:12 1998 --- ../src/backend/parser/gram.y Wed Sep 16 04:43:47 1998 *************** *** 236,242 **** %type TableConstraint %type constraint_list, constraint_expr %type default_list, default_expr ! %type ColQualList, ColQualifier %type ColConstraint, ColConstraintElem %type key_actions, key_action %type key_match, key_reference --- 236,242 ---- %type TableConstraint %type constraint_list, constraint_expr %type default_list, default_expr ! %type ColPrimaryKey, ColQualList, ColQualifier %type ColConstraint, ColConstraintElem %type key_actions, key_action %type key_match, key_reference *************** *** 751,757 **** n->constraints = $3; $$ = (Node *)n; } ! | ColId SERIAL { ColumnDef *n = makeNode(ColumnDef); n->colname = $1; --- 751,757 ---- n->constraints = $3; $$ = (Node *)n; } ! | ColId SERIAL ColPrimaryKey { ColumnDef *n = makeNode(ColumnDef); n->colname = $1; *************** *** 760,766 **** n->defval = NULL; n->is_not_null = TRUE; n->is_sequence = TRUE; ! n->constraints = NULL; $$ = (Node *)n; } --- 760,766 ---- n->defval = NULL; n->is_not_null = TRUE; n->is_sequence = TRUE; ! n->constraints = $3; $$ = (Node *)n; } *************** *** 786,791 **** --- 786,803 ---- } ; + ColPrimaryKey: PRIMARY KEY + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; + n->name = NULL; + n->def = NULL; + n->keys = NULL; + $$ = lcons((Node *)n, NIL); + } + | /*EMPTY*/ { $$ = NULL; } + ; + ColConstraint: CONSTRAINT name ColConstraintElem { *************** *** 806,811 **** --- 818,828 ---- $$ = NULL; } * - thomas 1998-09-12 + * + * DEFAULT NULL is already the default for Postgres. + * Bue define it here and carry it forward into the system + * to make it explicit. + * - thomas 1998-09-13 */ ColConstraintElem: CHECK '(' constraint_expr ')' { *************** *** 816,821 **** --- 833,847 ---- n->keys = NULL; $$ = (Node *)n; } + | DEFAULT NULL_P + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_DEFAULT; + n->name = NULL; + n->def = NULL; + n->keys = NULL; + $$ = (Node *)n; + } | DEFAULT default_expr { Constraint *n = makeNode(Constraint); *************** *** 870,879 **** } ; ! default_expr: AexprConst ! { $$ = makeConstantList((A_Const *) $1); } | NULL_P { $$ = lcons( makeString("NULL"), NIL); } | '-' default_expr %prec UMINUS { $$ = lcons( makeString( "-"), $2); } | default_expr '+' default_expr --- 896,910 ---- } ; ! /* The Postgres default column value is NULL. ! * Rather than carrying DEFAULT NULL forward as a clause, ! * let's just have it be a no-op. | NULL_P { $$ = lcons( makeString("NULL"), NIL); } + * - thomas 1998-09-13 + */ + default_expr: AexprConst + { $$ = makeConstantList((A_Const *) $1); } | '-' default_expr %prec UMINUS { $$ = lcons( makeString( "-"), $2); } | default_expr '+' default_expr