1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Sequences are now based on int8, not int4, arithmetic. SERIAL pseudo-type

has an alias SERIAL4 and a sister SERIAL8.  SERIAL8 is just the same
except the created column is type int8 not int4.
initdb forced.  Note this also breaks any chance of pg_upgrade from 7.1,
unless we hack up pg_upgrade to drop and recreate sequences.  (Which is
not out of the question, but I don't wanna do it.)
This commit is contained in:
Tom Lane
2001-08-16 20:38:56 +00:00
parent bcb0ccf5be
commit d4f4b971a4
21 changed files with 254 additions and 182 deletions

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.194 2001/08/11 00:02:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.195 2001/08/16 20:38:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -702,6 +702,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
*pkey = NULL;
IndexElem *iparam;
bool saw_nullable;
bool is_serial;
q = makeNode(Query);
q->commandType = CMD_UTILITY;
@@ -723,10 +724,25 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
column = (ColumnDef *) element;
columns = lappend(columns, column);
/* Check for SERIAL pseudo-types */
is_serial = false;
if (strcmp(column->typename->name, "serial") == 0 ||
strcmp(column->typename->name, "serial4") == 0)
{
is_serial = true;
column->typename->name = pstrdup("int4");
}
else if (strcmp(column->typename->name, "serial8") == 0)
{
is_serial = true;
column->typename->name = pstrdup("int8");
}
/* Do necessary work on the column type declaration */
transformColumnType(pstate, column);
/* Special case SERIAL type? */
if (column->is_sequence)
/* Special actions for SERIAL pseudo-types */
if (is_serial)
{
char *sname;
char *qstring;
@@ -778,13 +794,18 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
column->constraints = lappend(column->constraints,
constraint);
/*
* Build a CREATE SEQUENCE command to create the
* sequence object, and add it to the list of things
* to be done before this CREATE TABLE.
*/
sequence = makeNode(CreateSeqStmt);
sequence->seqname = pstrdup(sname);
sequence->istemp = stmt->istemp;
sequence->options = NIL;
elog(NOTICE, "CREATE TABLE will create implicit sequence '%s' for SERIAL column '%s.%s'",
sequence->seqname, stmt->relname, column->colname);
sequence->seqname, stmt->relname, column->colname);
blist = lappend(blist, sequence);
}

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.245 2001/08/15 18:42:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.246 2001/08/16 20:38:53 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -354,7 +354,7 @@ static void doNegateFloat(Value *v);
NEW, NOCREATEDB, NOCREATEUSER, NONE, NOTHING, NOTIFY, NOTNULL,
OFFSET, OIDS, OPERATOR, OWNER, PASSWORD, PROCEDURAL,
REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT,
SEQUENCE, SETOF, SHARE, SHOW, START, STATEMENT,
STATISTICS, STDIN, STDOUT, SYSID,
TEMP, TEMPLATE, TOAST, TRUNCATE, TRUSTED,
UNLISTEN, UNTIL, VACUUM, VALID, VERBOSE, VERSION
@@ -1249,22 +1249,6 @@ columnDef: ColId Typename ColQualList opt_collate
n->typename = $2;
n->constraints = $3;
if ($4 != NULL)
elog(NOTICE,"CREATE TABLE/COLLATE %s not yet implemented"
"; clause ignored", $4);
$$ = (Node *)n;
}
| ColId SERIAL ColQualList opt_collate
{
ColumnDef *n = makeNode(ColumnDef);
n->colname = $1;
n->typename = makeNode(TypeName);
n->typename->name = xlateSqlType("integer");
n->typename->typmod = -1;
n->is_sequence = TRUE;
n->constraints = $3;
if ($4 != NULL)
elog(NOTICE,"CREATE TABLE/COLLATE %s not yet implemented"
"; clause ignored", $4);
@@ -1630,7 +1614,7 @@ OptSeqList: OptSeqList OptSeqElem
| { $$ = NIL; }
;
OptSeqElem: CACHE IntegerOnly
OptSeqElem: CACHE NumericOnly
{
$$ = makeNode(DefElem);
$$->defname = "cache";
@@ -1642,25 +1626,25 @@ OptSeqElem: CACHE IntegerOnly
$$->defname = "cycle";
$$->arg = (Node *)NULL;
}
| INCREMENT IntegerOnly
| INCREMENT NumericOnly
{
$$ = makeNode(DefElem);
$$->defname = "increment";
$$->arg = (Node *)$2;
}
| MAXVALUE IntegerOnly
| MAXVALUE NumericOnly
{
$$ = makeNode(DefElem);
$$->defname = "maxvalue";
$$->arg = (Node *)$2;
}
| MINVALUE IntegerOnly
| MINVALUE NumericOnly
{
$$ = makeNode(DefElem);
$$->defname = "minvalue";
$$->arg = (Node *)$2;
}
| START IntegerOnly
| START NumericOnly
{
$$ = makeNode(DefElem);
$$->defname = "start";
@@ -5593,7 +5577,6 @@ ColId: IDENT { $$ = $1; }
| NATIONAL { $$ = "national"; }
| NONE { $$ = "none"; }
| PATH_P { $$ = "path"; }
| SERIAL { $$ = "serial"; }
| TIME { $$ = "time"; }
| TIMESTAMP { $$ = "timestamp"; }
;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.95 2001/08/15 18:42:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.96 2001/08/16 20:38:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -228,7 +228,6 @@ static ScanKeyword ScanKeywords[] = {
{"second", SECOND_P},
{"select", SELECT},
{"sequence", SEQUENCE},
{"serial", SERIAL},
{"serializable", SERIALIZABLE},
{"session", SESSION},
{"session_user", SESSION_USER},