aboutsummaryrefslogtreecommitdiff
path: root/contrib/spi/autoinc.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 /contrib/spi/autoinc.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 'contrib/spi/autoinc.c')
-rw-r--r--contrib/spi/autoinc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c
index 8592ea7ed9b..92d3e97c220 100644
--- a/contrib/spi/autoinc.c
+++ b/contrib/spi/autoinc.c
@@ -79,8 +79,13 @@ autoinc(PG_FUNCTION_ARGS)
seqname = DirectFunctionCall1(textin,
CStringGetDatum(args[i]));
newvals[chnattrs] = DirectFunctionCall1(nextval, seqname);
+ /* nextval now returns int64; coerce down to int32 */
+ newvals[chnattrs] = Int32GetDatum((int32) DatumGetInt64(newvals[chnattrs]));
if (DatumGetInt32(newvals[chnattrs]) == 0)
+ {
newvals[chnattrs] = DirectFunctionCall1(nextval, seqname);
+ newvals[chnattrs] = Int32GetDatum((int32) DatumGetInt64(newvals[chnattrs]));
+ }
pfree(DatumGetTextP(seqname));
chnattrs++;
i++;