Skip site navigation (1) Skip section navigation (2)

Re: Sequence "self" change - possible?

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Lukasz Brodziak <lukasz(dot)brodziak(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Sequence "self" change - possible?
Date: 2011-11-29 02:37:54
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
On 11/28/2011 10:04 PM, Lukasz Brodziak wrote:
> Hello,
> Is it possible for sequence to decrement its value by itself? Or is it
> possible to see wether it was changed by someone. The thing is that on
> one of our clinet's DB sequence rolled back to the state from 8 months ago.

It shouldn't generally be possible, no. It'd have to be changed by a 
call to nextval(), setval() or the like, or a direct UPDATE to the 
underlying sequence pseudo-table.

Could someone have tried to restore a backup from 8 months ago? That'd 
result in a setval(...) call when pg_restore or psql (depending on 
backup format) tried to set the sequence position.

In your case, though, your next post mentions possible database 
corruption, so I'm wondering if this is related. If something's been 
scribbling over the database files, someone's half-restored an old 
file-level backup, or something similarly horrible then anything could 

Craig Ringer

In response to

pgsql-admin by date

Next:From: Craig RingerDate: 2011-11-29 02:42:22
Subject: Re: Database is in recovery mode.
Previous:From: Tom LaneDate: 2011-11-29 01:00:34
Subject: Re: Repeatable crash in pg_dump (with -d2 info)

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group