aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-08-16 20:38:56 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-08-16 20:38:56 +0000
commitd4f4b971a4eb7992add4e70752aa9d0936c43dcc (patch)
tree59ef607b44a6bedc3eeb9b06cc77850649ca7ae0 /src/backend/parser
parentbcb0ccf5be9ef9e1a76968e773cb2bd11565ef9c (diff)
downloadpostgresql-d4f4b971a4eb7992add4e70752aa9d0936c43dcc.tar.gz
postgresql-d4f4b971a4eb7992add4e70752aa9d0936c43dcc.zip
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.)
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/analyze.c29
-rw-r--r--src/backend/parser/gram.y31
-rw-r--r--src/backend/parser/keywords.c3
3 files changed, 33 insertions, 30 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index c4c0aa1a875..7604d42a039 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -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);
}
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 57242a5978a..6cd7f064803 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -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
@@ -1255,22 +1255,6 @@ columnDef: ColId Typename ColQualList opt_collate
$$ = (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);
-
- $$ = (Node *)n;
- }
;
ColQualList: ColQualList ColConstraint { $$ = lappend($1, $2); }
@@ -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"; }
;
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index 3fb39c0821e..5c1427da03e 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -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},