bug in create table with serial

Started by Cristóvão Dalla Costaover 23 years ago3 messagesbugs
Jump to latest
#1Cristóvão Dalla Costa
cbraga@bsi.com.br

In PostgreSQL 7.3b2, if I create a table like so:

create table customers (id serial primary key);

The id field will be created of type 32 bit integer, yet the upper limit
for the sequence will be relative to a 64 bit integer.

\d customers
Table "public.customers"
Column | Type | Modifiers
-------------+--------------+-----------------------------------------------------------
id | integer | not null default
nextval('public.customers_id_seq'::text)

shop-devel=# select * from customers_id_seq;
-[ RECORD 1 ]-+--------------------
sequence_name | customers_id_seq
last_value | 1
increment_by | 1
max_value | 9223372036854775807
min_value | 1
cache_value | 1
log_cnt | 1
is_cycled | f
is_called | f

shop-devel=# select version ();
version
---------------------------------------------------------------------
PostgreSQL 7.3b2 on i386-portbld-freebsd4.7, compiled by GCC 2.95.4

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Cristóvão Dalla Costa (#1)
Re: bug in create table with serial

=?ISO-8859-1?Q?Crist=F3v=E3o_Dalla_Costa?= <cbraga@bsi.com.br> writes:

In PostgreSQL 7.3b2, if I create a table like so:
create table customers (id serial primary key);

The id field will be created of type 32 bit integer, yet the upper limit
for the sequence will be relative to a 64 bit integer.

So?

AFAICS, you will get a failure when you reach 2^31 items. Whether the
failure is "can't fit the value into int4" or "reached sequence maximum"
doesn't seem very exciting to me ...

regards, tom lane

#3Kris Jurka
books@ejurka.com
In reply to: Tom Lane (#2)
Re: bug in create table with serial

On Wed, 16 Oct 2002, Tom Lane wrote:

=?ISO-8859-1?Q?Crist=F3v=E3o_Dalla_Costa?= <cbraga@bsi.com.br> writes:

In PostgreSQL 7.3b2, if I create a table like so:
create table customers (id serial primary key);

The id field will be created of type 32 bit integer, yet the upper limit
for the sequence will be relative to a 64 bit integer.

So?

AFAICS, you will get a failure when you reach 2^31 items. Whether the
failure is "can't fit the value into int4" or "reached sequence maximum"
doesn't seem very exciting to me ...

Unless of course the column's data type was int8.

Kris Jurka