Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 58237125103 for ; Tue, 15 May 2012 09:25:22 -0300 (ADT) Received: from [213.9.93.70] (helo=mail.piware.de) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SUGoa-0002W9-97 for pgsql-bugs@postgresql.org; Tue, 15 May 2012 12:25:22 +0000 Received: from localhost.localdomain (p549B18E4.dip.t-dialin.net [84.155.24.228]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Martin Pitt (ThinkPad)", Issuer "piware CA" (verified OK)) by mail.piware.de (Postfix) with ESMTPS id 2DCA1FB921 for ; Tue, 15 May 2012 14:21:18 +0200 (CEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 78D32203D8; Tue, 15 May 2012 14:25:00 +0200 (CEST) Date: Tue, 15 May 2012 14:25:00 +0200 From: Martin Pitt To: PostgreSQL Bugs Subject: 9.2beta1 regression: pg_restore --data-only does not set sequence values any more Message-ID: <20120515122500.GD3041@piware.de> Mail-Followup-To: PostgreSQL Bugs MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="96YOpH+ONegL0A3E" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Host-Lookup-Failed: Reverse DNS lookup failed for 213.9.93.70 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201205/85 X-Sequence-Number: 33056 --96YOpH+ONegL0A3E Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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:=20 * Create a db and sequence: $ createdb test $ psql test -c "CREATE SEQUENCE odd10 INCREMENT BY 2 MINVALUE 1 MAXVALUE = 10 CYCLE" CREATE SEQUENCE =20 * 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: =20 $ dropdb test * Restore DB: $ psql template1 < /tmp/schema=20 $ pg_restore --data-only -d postgres /tmp/test.dump=20 * 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 --=20 Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) --96YOpH+ONegL0A3E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJPskscAAoJEPmIJawmtHufq10P/RoQ0Jhwr8UflBaIprKEJKW8 TNY44UXi3l1ynqvVIt1F+5FLbf8mkUTZDRVpJo0Fwp/47YnaGPx/PMqOB4v629Tu K39dIVsk/V8n0GnSt8PRIjX7Z/UMHvbIuNVk8rRBF5EIf2cJzFwOsEZEmCr1Ms9s dNEcprP6I71faf5DRRbjPy5OLcOuH0/b8mqn5055umfnWkgz9e8yLo/AqY0LpvOJ t2D27yz1ZMC3ZY8x/Kw0UUDT9khFTKkML5ql60kdeZi+I0wy6OuMbAHgqDwMtRmW KwY26MBWa2h5DjUc7qKddjaPXf8nZHHPRScdbUXa2shJuD2dQgZk/tfxNpFzRBWQ HHGHaUiCNuzAlWY4G2TrpnRwt5nxeCD1kAhZUXFKq82yM+DzSaKgdVoqGD+rcnoH sLcZcHWvoKOghKPNmyUvT5FDsERR0RKEHzrhhxOl+KYtoZt8cm9mTvwQtFQ5zNJw a2WZYlxdOR/OJFajhaMYc0k6NQBZOU8zgoC77c2t4vxDvAlKAwhTD7lq90qu+Uzr O93e6Kqw5vQIhUMq85Fkp4p7OuRiTp7Mq3AmhXlVyjMzVoYFrI6N4T/doh3d6N6L I/iZXHdKCNt8O5mckBUcZPpYw1qLvcFeeP3FIPHSQ1FImw+QDqfeJCvApamMYs8N z+9P9chi3aTn7iTEVyMH =0Hgu -----END PGP SIGNATURE----- --96YOpH+ONegL0A3E--