pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #8582: field serial getted incorrect value from automaticaly created its sequence
5+ messages / 4 participants
[nested] [flat]
* BUG #8582: field serial getted incorrect value from automaticaly created its sequence
@ 2013-11-07 07:35 evgeniy.skomorokhov@gmail.com
0 siblings, 1 reply; 5+ messages in thread
From: evgeniy.skomorokhov@gmail.com @ 2013-11-07 07:35 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 8582
Logged by: Evgeniy Skomorokhov
Email address: evgeniy.skomorokhov@gmail.com
PostgreSQL version: 9.2.4
Operating system: ubuntu precise 12.04
Description:
Automaticaly created sequence takes values from the range [1;
9223372036854775807] but max value of field which will be filled from
sequence - max of type integer (2147483647).
In PostgreSQL we can set field type "serial" during creting table like:
CREATE TABLE test1(
id serial
);
Then we get table and sequence structure like
/*
NOTICE: CREATE TABLE will create implicit sequence "test1_id_seq" for
serial column "test1.id"
-- Created structures test1 and test1_id_seq:
CREATE TABLE test1
(
id serial NOT NULL
)
WITH (
OIDS=FALSE
);
ALTER TABLE test1
OWNER TO gis;
CREATE SEQUENCE test1_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE test1_id_seq
OWNER TO gis;
*/
And when we insert values to table we can get exception "ERROR: integer out
of range"
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #8582: field serial getted incorrect value from automaticaly created its sequence
@ 2013-11-07 18:41 Tom Lane <tgl@sss.pgh.pa.us>
parent: evgeniy.skomorokhov@gmail.com
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2013-11-07 18:41 UTC (permalink / raw)
To: evgeniy.skomorokhov@gmail.com; +Cc: pgsql-bugs
evgeniy.skomorokhov@gmail.com writes:
> Automaticaly created sequence takes values from the range [1;
> 9223372036854775807] but max value of field which will be filled from
> sequence - max of type integer (2147483647).
If you want a bigint column, use "bigserial". Not everybody wants
to take that space penalty, though.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #8582: field serial getted incorrect value from automaticaly created its sequence
@ 2013-11-07 18:55 John R Pierce <pierce@hogranch.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: John R Pierce @ 2013-11-07 18:55 UTC (permalink / raw)
To: pgsql-bugs
On 11/7/2013 10:41 AM, Tom Lane wrote:
> evgeniy.skomorokhov@gmail.com writes:
>> >Automaticaly created sequence takes values ​​from the range [1;
>> >9223372036854775807] but max value of field which will be filled from
>> >sequence - max of type integer (2147483647).
> If you want a bigint column, use "bigserial". Not everybody wants
> to take that space penalty, though.
I think he's suggesting that a sequence generated from a regular serial
probably shouldn't have that 63 bit max_value
--
john r pierce 37N 122W
somewhere on the middle of the left coast
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #8582: field serial getted incorrect value from automaticaly created its sequence
@ 2013-11-07 19:16 David Johnston <polobo@yahoo.com>
parent: John R Pierce <pierce@hogranch.com>
0 siblings, 1 reply; 5+ messages in thread
From: David Johnston @ 2013-11-07 19:16 UTC (permalink / raw)
To: pgsql-bugs
John R Pierce wrote
> On 11/7/2013 10:41 AM, Tom Lane wrote:
>>
> evgeniy.skomorokhov@
> writes:
>>> >Automaticaly created sequence takes values ​​from the range [1;
>>> >9223372036854775807] but max value of field which will be filled from
>>> >sequence - max of type integer (2147483647).
>> If you want a bigint column, use "bigserial". Not everybody wants
>> to take that space penalty, though.
>
>
> I think he's suggesting that a sequence generated from a regular serial
> probably shouldn't have that 63 bit max_value
The main advantage of the current behavior is if you hit the limit for an
integer you can alter the column type to bigint without having to mess
around with the associated sequence. If the sequence was upper-bound
limited that same conditions that caused the out-of-range error will just
generate a different kind of error (not sure which one if the sequence is
exhausted).
Its definitely not a "bug" whether you believe the behavior should be
changed or not. A sequence is de-coupled from any particular type. Maybe
if there were short, normal, and big sequences with matching performance
improvements it would matter but having only a single sequence
implementation makes the current behavior/defaults reasonable for normal
usage.
I am curious why this even came up. This seems to be the kind of thing most
people would be oblivious to.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-8582-field-serial-getted-incorrect-value-from-automatica...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Re: BUG #8582: field serial getted incorrect value from automaticaly created its sequence
@ 2013-11-07 20:18 John R Pierce <pierce@hogranch.com>
parent: David Johnston <polobo@yahoo.com>
0 siblings, 0 replies; 5+ messages in thread
From: John R Pierce @ 2013-11-07 20:18 UTC (permalink / raw)
To: pgsql-bugs
On 11/7/2013 11:16 AM, David Johnston wrote:
> If the sequence was upper-bound
> limited that same conditions that caused the out-of-range error will just
> generate a different kind of error (not sure which one if the sequence is
> exhausted).
indeed. and being curious myself, the error is...
ERROR: nextval: reached maximum value of sequence "t_id_seq" (20)
--
john r pierce 37N 122W
somewhere on the middle of the left coast
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2013-11-07 20:18 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-11-07 07:35 BUG #8582: field serial getted incorrect value from automaticaly created its sequence evgeniy.skomorokhov@gmail.com
2013-11-07 18:41 ` Tom Lane <tgl@sss.pgh.pa.us>
2013-11-07 18:55 ` John R Pierce <pierce@hogranch.com>
2013-11-07 19:16 ` David Johnston <polobo@yahoo.com>
2013-11-07 20:18 ` John R Pierce <pierce@hogranch.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