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

Commit7c30ac9

Browse files
author
Thomas G. Lockhart
committed
Support specifying PRIMARY KEY for the SERIAL type.
Check for a constraint if is_sequence is set and omit making a UNIQUE index if so, since the primary key will cover that for us.
1 parent198bcef commit7c30ac9

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

‎src/backend/parser/analyze.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.86 1998/09/03 14:21:06 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.87 1998/09/16 14:25:37 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -530,11 +530,26 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
530530
constraint->def=cstring;
531531
constraint->keys=NULL;
532532

533+
/* The parser only allows PRIMARY KEY as a constraint for the SERIAL type.
534+
* So, if there is a constraint of any kind, assume it is that.
535+
* If PRIMARY KEY is specified, then don't need to gin up a UNIQUE constraint
536+
* since that will be covered already.
537+
* - thomas 1998-09-15
538+
*/
533539
if (column->constraints!=NIL)
540+
{
534541
column->constraints=lappend(column->constraints,constraint);
542+
}
535543
else
544+
{
536545
column->constraints=lcons(constraint,NIL);
537546

547+
constraint=makeNode(Constraint);
548+
constraint->contype=CONSTR_UNIQUE;
549+
constraint->name=makeTableName(stmt->relname,column->colname,"key",NULL);
550+
column->constraints=lappend(column->constraints,constraint);
551+
}
552+
538553
sequence=makeNode(CreateSeqStmt);
539554
sequence->seqname=pstrdup(constraint->name);
540555
sequence->options=NIL;
@@ -543,12 +558,6 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
543558
sequence->seqname,stmt->relname,column->colname);
544559

545560
ilist=lcons(sequence,NIL);
546-
547-
constraint=makeNode(Constraint);
548-
constraint->contype=CONSTR_UNIQUE;
549-
constraint->name=makeTableName(stmt->relname,column->colname,"key",NULL);
550-
551-
column->constraints=lappend(column->constraints,constraint);
552561
}
553562

554563
if (column->constraints!=NIL)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp