pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #3668: type error in serial
3+ messages / 3 participants
[nested] [flat]

* BUG #3668: type error in serial
@ 2007-10-10 19:02  Eric Weimer <eweimer@thelocalphonecompany.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Eric Weimer @ 2007-10-10 19:02 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      3668
Logged by:          Eric Weimer
Email address:      eweimer@thelocalphonecompany.net
PostgreSQL version: 8.1
Operating system:   Linux
Description:        type error in serial
Details: 

Creating a table with a column of type serial causes the creation of a
sequence tied as the default value for the column.
The actual type of the column is integer, however the sequence created is of
type bigint. If the sequence is created as a bigint, then the column should
also be defined as bigint. 

Example:
dev=# create temp table testing (id serial);
NOTICE:  CREATE TABLE will create implicit sequence "testing_id_seq" for
serial column "testing.id"
CREATE TABLE
dev=# \d testing_id_seq
Sequence "pg_temp_1.testing_id_seq"
    Column     |  Type   
---------------+---------
 sequence_name | name
 last_value    | bigint
 increment_by  | bigint
 max_value     | bigint
 min_value     | bigint
 cache_value   | bigint
 log_cnt       | bigint
 is_cycled     | boolean
 is_called     | boolean

dev=# \d testing
                        Table "pg_temp_1.testing"
 Column |  Type   |                      Modifiers                       
--------+---------+------------------------------------------------------
 id     | integer | not null default nextval('testing_id_seq'::regclass)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #3668: type error in serial
@ 2007-10-10 21:32  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Eric Weimer <eweimer@thelocalphonecompany.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2007-10-10 21:32 UTC (permalink / raw)
  To: Eric Weimer <eweimer@thelocalphonecompany.net>; +Cc: pgsql-bugs

"Eric Weimer" <eweimer@thelocalphonecompany.net> writes:
> Creating a table with a column of type serial causes the creation of a
> sequence tied as the default value for the column.
> The actual type of the column is integer, however the sequence created is of
> type bigint. If the sequence is created as a bigint, then the column should
> also be defined as bigint. 

This is not a bug, primarily because we have only one size of sequence.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #3668: type error in serial
@ 2012-08-29 23:38  Dave Johansen <davejohansen@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Dave Johansen @ 2012-08-29 23:38 UTC (permalink / raw)
  To: pgsql-bugs

On Wednesday, October 10, 2007 2:32:17 PM UTC-7, Tom Lane wrote:
> "Eric Weimer" <eweimer@thelocalphonecompany.net> writes:
> > Creating a table with a column of type serial causes the creation of a
> > sequence tied as the default value for the column.
> > The actual type of the column is integer, however the sequence created is of
> > type bigint. If the sequence is created as a bigint, then the column should
> > also be defined as bigint. 
> 
> This is not a bug, primarily because we have only one size of sequence.
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

I believe that the SERIAL type should set the MAXVALUE appropriately (that of a 32 bit number) because then it could give an error like "reached maximum value of sequence" rather than having people beating their heads against the wall because they can't figure out why they're getting an error of "integer out of range". That seems like a relatively minor change that could save people a LOT of headache.

Dave




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2012-08-29 23:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-10-10 19:02 BUG #3668: type error in serial Eric Weimer <eweimer@thelocalphonecompany.net>
2007-10-10 21:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-08-29 23:38   ` Dave Johansen <davejohansen@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox