Support specifying PRIMARY KEY for the SERIAL type.
Change DEFAULT NULL to send back a NULL pointer rather than a string "NULL". This seems to work, where sending the string led to type conversion problems (and probably the wrong thing anyway).
This commit is contained in:
parent
7c30ac961f
commit
20693de474
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -236,7 +236,7 @@ Oid param_type(int t); /* used in parse_expr.c */
|
|||||||
%type <node> TableConstraint
|
%type <node> TableConstraint
|
||||||
%type <list> constraint_list, constraint_expr
|
%type <list> constraint_list, constraint_expr
|
||||||
%type <list> default_list, default_expr
|
%type <list> default_list, default_expr
|
||||||
%type <list> ColQualList, ColQualifier
|
%type <list> ColPrimaryKey, ColQualList, ColQualifier
|
||||||
%type <node> ColConstraint, ColConstraintElem
|
%type <node> ColConstraint, ColConstraintElem
|
||||||
%type <list> key_actions, key_action
|
%type <list> key_actions, key_action
|
||||||
%type <str> key_match, key_reference
|
%type <str> key_match, key_reference
|
||||||
@ -751,7 +751,7 @@ columnDef: ColId Typename ColQualifier
|
|||||||
n->constraints = $3;
|
n->constraints = $3;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| ColId SERIAL
|
| ColId SERIAL ColPrimaryKey
|
||||||
{
|
{
|
||||||
ColumnDef *n = makeNode(ColumnDef);
|
ColumnDef *n = makeNode(ColumnDef);
|
||||||
n->colname = $1;
|
n->colname = $1;
|
||||||
@ -760,7 +760,7 @@ columnDef: ColId Typename ColQualifier
|
|||||||
n->defval = NULL;
|
n->defval = NULL;
|
||||||
n->is_not_null = TRUE;
|
n->is_not_null = TRUE;
|
||||||
n->is_sequence = TRUE;
|
n->is_sequence = TRUE;
|
||||||
n->constraints = NULL;
|
n->constraints = $3;
|
||||||
|
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
@ -786,6 +786,18 @@ ColQualList: ColQualList ColConstraint
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
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:
|
ColConstraint:
|
||||||
CONSTRAINT name ColConstraintElem
|
CONSTRAINT name ColConstraintElem
|
||||||
{
|
{
|
||||||
@ -806,6 +818,11 @@ ColConstraint:
|
|||||||
$$ = NULL;
|
$$ = NULL;
|
||||||
}
|
}
|
||||||
* - thomas 1998-09-12
|
* - 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 ')'
|
ColConstraintElem: CHECK '(' constraint_expr ')'
|
||||||
{
|
{
|
||||||
@ -816,6 +833,15 @@ ColConstraintElem: CHECK '(' constraint_expr ')'
|
|||||||
n->keys = NULL;
|
n->keys = NULL;
|
||||||
$$ = (Node *)n;
|
$$ = (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
|
| DEFAULT default_expr
|
||||||
{
|
{
|
||||||
Constraint *n = makeNode(Constraint);
|
Constraint *n = makeNode(Constraint);
|
||||||
@ -870,10 +896,15 @@ default_list: default_list ',' default_expr
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
default_expr: AexprConst
|
/* The Postgres default column value is NULL.
|
||||||
{ $$ = makeConstantList((A_Const *) $1); }
|
* Rather than carrying DEFAULT NULL forward as a clause,
|
||||||
|
* let's just have it be a no-op.
|
||||||
| NULL_P
|
| NULL_P
|
||||||
{ $$ = lcons( makeString("NULL"), NIL); }
|
{ $$ = lcons( makeString("NULL"), NIL); }
|
||||||
|
* - thomas 1998-09-13
|
||||||
|
*/
|
||||||
|
default_expr: AexprConst
|
||||||
|
{ $$ = makeConstantList((A_Const *) $1); }
|
||||||
| '-' default_expr %prec UMINUS
|
| '-' default_expr %prec UMINUS
|
||||||
{ $$ = lcons( makeString( "-"), $2); }
|
{ $$ = lcons( makeString( "-"), $2); }
|
||||||
| default_expr '+' default_expr
|
| default_expr '+' default_expr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user