Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id DA5971EA2927 for ; Sat, 9 Jun 2012 03:57:41 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SdFc7-0000xv-4O for pgsql-bugs@postgresql.org; Sat, 09 Jun 2012 06:57:41 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SdFbu-0005QC-L6 for pgsql-bugs@postgresql.org; Sat, 09 Jun 2012 06:57:22 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1SdFbu-0006NI-A6 for pgsql-bugs@postgresql.org; Sat, 09 Jun 2012 06:57:22 +0000 Date: Sat, 09 Jun 2012 06:57:22 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6682: pg_dump and sequence values of serial columns for extension configuration tables To: pgsql-bugs@postgresql.org From: phb.emaj@free.fr X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/80 X-Sequence-Number: 33307 The following bug has been logged on the website: Bug reference: 6682 Logged by: Philippe BEAUDOIN Email address: phb.emaj@free.fr PostgreSQL version: 9.1.4 Operating system: Linux Description: = When a table is registered as an extension configuration table and contains a serial column, the current value of the sequence associated to this serial column is not dumped by pg_dump. Here is a test case to easily reproduce this issue. Just copy/paste and adjust initial parameters. #!/bin/sh export PGINST=3D/usr/local/pg913 export PGBIN=3D$PGINST/bin export PGEXT=3D$PGINST/share/postgresql/extension export PGHOST=3Dlocalhost export PGPORT=3D5913 export PGUSER=3Dpostgres export PGDATABASE=3Dphb echo "-----------------------------------------------------------------------" echo " Issue: pg_dump doesn't record sequence values of serial columns for " echo " tables registered by pg_extension_config_dump()" echo "-----------------------------------------------------------------------" echo Connection parameters: $PGHOST - $PGPORT - $PGUSER - $PGDATABASE # Build the extension control file cat >$PGINST/share/postgresql/extension/phb.control <$PGEXT/phb--1.0.0.sql < Create the extension" $PGBIN/psql -ac "create extension phb;" $PGBIN/psql -ac "\dx+ phb" echo "--> Use the extension and look at the impact" $PGBIN/psql -ac "insert into phb.tbl1 (col2) values (1),(2),(3);" $PGBIN/psql -ac "select setval('phb.seq1',10);" $PGBIN/psql -ac "select * from phb.tbl1;" $PGBIN/psql -ac "select * from phb.tbl1_col1_seq;" $PGBIN/psql -ac "select * from phb.seq1;" echo "--> OK, now dump the phb database" $PGBIN/pg_dump -Fp -f phb.dump echo "--> Cleanup and recreate the database" $PGBIN/psql template1 -ac "drop database phb;" $PGBIN/psql template1 -ac "create database phb;" echo "--> Restore the phb database" $PGBIN/psql -f phb.dump echo "--> Look at the result: the sequences start values equal 1 !!! " $PGBIN/psql -ac "\dx+ phb" $PGBIN/psql -ac "select * from phb.tbl1;" $PGBIN/psql -ac "select * from phb.tbl1_col1_seq;" $PGBIN/psql -ac "select * from phb.seq1;" echo "--> Of course inserting a new row results in duplicate key errors" $PGBIN/psql -ac "insert into phb.tbl1 (col2) values (4);" echo "--> And sequences cannot be registered as 'content to be dumped'" $PGBIN/psql -ac "select pg_catalog.pg_extension_config_dump('tbl1_col1_seq','');" $PGBIN/psql -ac "select pg_catalog.pg_extension_config_dump('seq1','');" # cleanup the environment $PGBIN/psql template1 -ac "drop database phb;" rm $PGINST/share/postgresql/extension/phb* rm phb.dump