aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/analyze.c
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/analyze.c
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/analyze.c')
-rw-r--r--src/backend/parser/analyze.c29
1 files changed, 25 insertions, 4 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);
}