Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit20693de

Browse files
author
Thomas G. Lockhart
committed
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).
1 parent7c30ac9 commit20693de

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

‎src/backend/parser/gram.y

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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
751751
n->constraints = $3;
752752
$$ = (Node *)n;
753753
}
754-
| ColId SERIAL
754+
| ColId SERIAL ColPrimaryKey
755755
{
756756
ColumnDef *n = makeNode(ColumnDef);
757757
n->colname = $1;
@@ -760,7 +760,7 @@ columnDef: ColId Typename ColQualifier
760760
n->defval = NULL;
761761
n->is_not_null = TRUE;
762762
n->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+
789801
ColConstraint:
790802
CONSTRAINT 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
*/
810827
ColConstraintElem: CHECK '(' constraint_expr ')'
811828
{
@@ -816,6 +833,15 @@ ColConstraintElem: CHECK '(' constraint_expr ')'
816833
n->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
{
821847
Constraint *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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp