pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martin Pitt <mpitt@debian.org>
To: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: 9.2beta1 regression: pg_restore --data-only does not set sequence values any more
Date: Tue, 15 May 2012 14:25:00 +0200
Message-ID: <20120515122500.GD3041@piware.de> (raw)

Hello all,

while packaging 9.2 beta 1 for Debian/Ubuntu the postgresql-common
test suite noticed a regression: It seems that pg_restore --data-only
now skips the current value of sequences, so that in the upgraded
database the sequence counter is back to the default. This can lead to
rather serious data errors.

Reproducer: 

 * Create a db and sequence:

  $ createdb test
  $ psql test -c "CREATE SEQUENCE odd10 INCREMENT BY 2 MINVALUE 1 MAXVALUE 10 CYCLE"
  CREATE SEQUENCE
 
 * Advance it two steps:

   $ psql --cluster 9.2/main -Atc "SELECT nextval('odd10')" test
   1
   $ psql --cluster 9.2/main -Atc "SELECT nextval('odd10')" test
   3

 * Dump schema and "test" data:

   $ pg_dumpall -s > /tmp/schema
   $ pg_dump -Fc test > /tmp/test.dump

 * Drop db:
 
   $ dropdb test

 * Restore DB:

   $ psql template1 < /tmp/schema 
   $ pg_restore --data-only -d postgres /tmp/test.dump 

 * Check the counter:

   $ psql -Atc "SELECT nextval('odd10')" test
   1

This is wrong, it should be "5", from the original database. This
worked all the way up to 9.1.


With "pg_restore /tmp/test.dump" (i. e. a full dump), you see

   SELECT pg_catalog.setval('odd10', 3, true);

in the dump, but it is not present in the output of
"pg_restore --data-only /tmp/test.dump". However, when I use the 9.1
version, it works:

   $ /usr/lib/postgresql/9.1/bin/pg_restore --data-only  /tmp/test.dump  | grep setval
   SELECT pg_catalog.setval('odd10', 3, true);

Thanks!

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

Attachments:

  signature.asc (application/pgp-signature, 835B) download

view thread (6+ messages)  latest in thread

Message-ID: <20120515122500.GD3041@piware.de>
Permalink:  ../20120515122500.GD3041@piware.de/
Also on:    postgresql.org/message-id/20120515122500.GD3041@piware.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: mpitt@debian.org
  Subject: Re: 9.2beta1 regression: pg_restore --data-only does not set sequence values any more
  In-Reply-To: <20120515122500.GD3041@piware.de>
  References: <20120515122500.GD3041@piware.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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