Unix Technical Forum

BUG #2290: Incorrect sequence increment after backup/restore

This is a discussion on BUG #2290: Incorrect sequence increment after backup/restore within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 2290 Logged by: Oleg Mamontov Email address: oleg@mamontov.net PostgreSQL version: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 09:47 AM
Oleg Mamontov
 
Posts: n/a
Default BUG #2290: Incorrect sequence increment after backup/restore


The following bug has been logged online:

Bug reference: 2290
Logged by: Oleg Mamontov
Email address: oleg@mamontov.net
PostgreSQL version: 8.0.x/8.1.x
Operating system: FreeBSD 4.x,5.x,6.x
Description: Incorrect sequence increment after backup/restore
Details:

If after CREATE TABLE with SERIAL column i'll change sequence increment to 2
or some other value (with ALTER SEQUENCE) then always work correctly (all
inserted rows will have values incremented by 2).
But after database backup/restore (with pg_dump) this ALTER will not
restored and all next inserted rows will have values incremented by 1
(default for SERIAL data type).
It's seems like a bug...
Changing increment value often used with replication (master database
inserts has odd values and slave database inserts has even) and other
situations.

Sorry for my poor English.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 09:47 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #2290: Incorrect sequence increment after backup/restore

"Oleg Mamontov" <oleg@mamontov.net> writes:
> If after CREATE TABLE with SERIAL column i'll change sequence increment to 2
> or some other value (with ALTER SEQUENCE) then always work correctly (all
> inserted rows will have values incremented by 2).


We currently consider that a serial column is a "black box" and you
should not mess with its underlying sequence directly. If you want
nondefault properties for the sequence, create it as an independent
sequence object and then just declare the column as "integer
default nextval('seq')".

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 09:48 AM
Bruce Momjian
 
Posts: n/a
Default Re: BUG #2290: Incorrect sequence increment after backup/restore

Tom Lane wrote:
> "Oleg Mamontov" <oleg@mamontov.net> writes:
> > If after CREATE TABLE with SERIAL column i'll change sequence increment to 2
> > or some other value (with ALTER SEQUENCE) then always work correctly (all
> > inserted rows will have values incremented by 2).

>
> We currently consider that a serial column is a "black box" and you
> should not mess with its underlying sequence directly. If you want
> nondefault properties for the sequence, create it as an independent
> sequence object and then just declare the column as "integer
> default nextval('seq')".


Added to TODO:

* %Disallow changing sequence characteristics like INCREMENT for
SERIAL columns

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 09:48 AM
Bruce Momjian
 
Posts: n/a
Default Re: BUG #2290: Incorrect sequence increment after backup/restore


Updated wording:

* %Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
does not dump the changes

---------------------------------------------------------------------------

Bruce Momjian wrote:
> Tom Lane wrote:
> > "Oleg Mamontov" <oleg@mamontov.net> writes:
> > > If after CREATE TABLE with SERIAL column i'll change sequence increment to 2
> > > or some other value (with ALTER SEQUENCE) then always work correctly (all
> > > inserted rows will have values incremented by 2).

> >
> > We currently consider that a serial column is a "black box" and you
> > should not mess with its underlying sequence directly. If you want
> > nondefault properties for the sequence, create it as an independent
> > sequence object and then just declare the column as "integer
> > default nextval('seq')".

>
> Added to TODO:
>
> * %Disallow changing sequence characteristics like INCREMENT for
> SERIAL columns
>
> --
> Bruce Momjian http://candle.pha.pa.us
> SRA OSS, Inc. http://www.sraoss.com
>
> + If your life is a hard drive, Christ can be your backup. +
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>


--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:43 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com