Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 9BAEC5377DB; Tue, 29 May 2012 19:05:46 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SZUXt-00077w-DZ; Tue, 29 May 2012 22:05:45 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q4TM5POW000427; Tue, 29 May 2012 18:05:25 -0400 (EDT) To: Andrew Dunstan cc: Martin Pitt , PostgreSQL Bugs , PostgreSQL-development Subject: Re: [HACKERS] Re: 9.2beta1 regression: pg_restore --data-only does not set sequence values any more In-reply-to: <4FBFCDC7.8070209@dunslane.net> References: <20120515122500.GD3041@piware.de> <23209.1337173706@sss.pgh.pa.us> <4FBA9096.30107@dunslane.net> <4FBFCDC7.8070209@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Fri, 25 May 2012 14:21:59 -0400" Date: Tue, 29 May 2012 18:05:25 -0400 Message-ID: <426.1338329125@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/218 X-Sequence-Number: 33189 Andrew Dunstan writes: >>> Martin Pitt > writes: >>>> 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. > It turns out there were some infelicities with pg_dump as well as with > pg_restore. > I think the attached patch does the right thing. I'll keep testing - > I'll be happier if other people bang on it too. After looking this over, I think the original patch was just fundamentally wrong and needs to be largely rewritten. The basic error was in saying that the existing options --schema-only and --data-only were equivalent to particular cases of --section, which they are not. The proposed new patch does not make this better; it just makes the logic even more spaghetti-ish. I think what we need is to rip all that out and treat --section as being a new option that's not tied to the old ones in any way, but is an entirely orthogonal filter. The right place to implement it (for either pg_dump or pg_restore) is in the TOC-scanning loops in pg_backup_archiver.c, which can track which section they are in fairly easily (probably define it as being the current item's section unless that's SECTION_NONE, in which case use the previous section value). BTW, I'm thinking we could make that code simpler and faster if the _tocEntryRequired logic were done only once in an initial pass, and then we stored the teReqs result into a work field in the TocEntry struct for use in later passes. Andrew told me off-list that he would be unavailable due to travel for awhile, so I will have a go at fixing this. regards, tom lane