*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.30 1998/09/13 04:19:29 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.31 1998/09/16 14:29:35 thomas Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
%type TableConstraint
%type constraint_list, constraint_expr
%type default_list, default_expr
-%type ColQualList, ColQualifier
+%type ColPrimaryKey, ColQualList, ColQualifier
%type ColConstraint, ColConstraintElem
%type key_actions, key_action
%type key_match, key_reference
n->constraints = $3;
$$ = (Node *)n;
}
- | ColId SERIAL
+ | ColId SERIAL ColPrimaryKey
{
ColumnDef *n = makeNode(ColumnDef);
n->colname = $1;
n->defval = NULL;
n->is_not_null = TRUE;
n->is_sequence = TRUE;
- n->constraints = NULL;
+ n->constraints = $3;
$$ = (Node *)n;
}
}
;
+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
{
$$ = 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 ')'
{
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);
}
;
-default_expr: AexprConst
- { $$ = makeConstantList((A_Const *) $1); }
+/* 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