Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 0208819427CD for ; Mon, 28 Nov 2011 22:38:16 -0400 (AST) Received: from mail-vx0-f174.google.com ([209.85.220.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RVDaI-0000V6-9A for pgsql-admin@postgresql.org; Tue, 29 Nov 2011 02:38:14 +0000 Received: by vcbfk14 with SMTP id fk14so4245991vcb.19 for ; Mon, 28 Nov 2011 18:38:01 -0800 (PST) Received: by 10.52.66.205 with SMTP id h13mr6193026vdt.1.1322534280981; Mon, 28 Nov 2011 18:38:00 -0800 (PST) Received: from ayaki.localdomain (124-169-45-65.dyn.iinet.net.au. [124.169.45.65]) by mx.google.com with ESMTPS id a8sm12996633vdj.11.2011.11.28.18.37.57 (version=SSLv3 cipher=OTHER); Mon, 28 Nov 2011 18:37:59 -0800 (PST) Message-ID: <4ED44582.4080306@ringerc.id.au> Date: Tue, 29 Nov 2011 10:37:54 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Lukasz Brodziak CC: pgsql-admin@postgresql.org Subject: Re: Sequence "self" change - possible? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201111/135 X-Sequence-Number: 38729 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 happen. -- Craig Ringer