Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id CD4E31337B54 for ; Sun, 10 Apr 2011 18:39:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 86277-01 for ; Sun, 10 Apr 2011 21:38:54 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vx0-f174.google.com (mail-vx0-f174.google.com [209.85.220.174]) by mail.postgresql.org (Postfix) with ESMTP id 4DDF6133740B for ; Sun, 10 Apr 2011 18:38:53 -0300 (ADT) Received: by vxi39 with SMTP id 39so3757336vxi.19 for ; Sun, 10 Apr 2011 14:38:53 -0700 (PDT) Received: by 10.52.177.195 with SMTP id cs3mr3136083vdc.57.1302471533096; Sun, 10 Apr 2011 14:38:53 -0700 (PDT) Received: from tornado.leadboat.com (adsl-242-203-69.rmo.bellsouth.net [74.242.203.69]) by mx.google.com with ESMTPS id n5sm1056641vcs.10.2011.04.10.14.38.51 (version=SSLv3 cipher=OTHER); Sun, 10 Apr 2011 14:38:52 -0700 (PDT) Date: Sun, 10 Apr 2011 17:38:49 -0400 From: Noah Misch To: Robert Haas Cc: Naoya Anzai , pgsql-hackers@postgresql.org Subject: Re: BUG #5856: pg_attribute.attinhcount is not correct. Message-ID: <20110410213849.GA10105@tornado.leadboat.com> References: <201101311142.p0VBgVGd019556@wwwmaster.postgresql.org> <20110331100649.GA7286@tornado.gateway.2wire.net> <20110401045629.GA9314@tornado.gateway.2wire.net> <20110410103636.GC10697@tornado.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201104/607 X-Sequence-Number: 185810 On Sun, Apr 10, 2011 at 11:19:26AM -0400, Robert Haas wrote: > On Sun, Apr 10, 2011 at 6:36 AM, Noah Misch wrote: > > On Sun, Apr 03, 2011 at 09:53:57PM -0400, Robert Haas wrote: > >> On Fri, Apr 1, 2011 at 12:56 AM, Noah Misch wrote: > >> > On Thu, Mar 31, 2011 at 11:11:49AM -0400, Robert Haas wrote: > >> >> On Thu, Mar 31, 2011 at 6:06 AM, Noah Misch wrote: > >> >> > The best way I can see is to make ATExecAddColumn more like ATExecDropColumn, > >> >> > ATAddCheckConstraint, and ATExecDropConstraint. ?Namely, recurse at Exec-time > >> >> > rather than Prep-time, and cease recursing when we satisfy the ADD COLUMN with a > >> >> > merge. ?Did you have something else in mind? > >> >> > >> >> I had exactly what you just said in mind. > >> > > >> > Patch attached, then. > >> > >> Committed. > > > > Thanks. ?This turns out to have caused that TOAST creation regression: > > > > On Fri, Apr 08, 2011 at 08:12:19PM -0400, Noah Misch wrote: > > [pg_upgrade/typed table business] > >> I also tested a regular dump+reload of the regression database, and a pg_upgrade > >> of the same. ?The latter failed further along, due (indirectly) to this failure > >> to create a TOAST table: > >> > >> ? create table p (); > >> ? create table ch () inherits (p); > >> ? alter table p add column a text; > >> ? select oid::regclass,reltoastrelid from pg_class where oid::regclass IN ('p','ch'); > >> ? insert into ch values (repeat('x', 1000000)); > >> > >> If I "drop table a_star cascade" in the regression database before attempting > >> pg_upgrade, it completes cleanly. > > > > Since ATExecAddColumn now handles the recursion, child table work queue entries > > no longer have AT_PASS_ADD_COL subcommands. ?Consequently, this heuristic in > > ATRewriteCatalogs skips over them: > > > > ? ? ? ? ? ? ? ?if (tab->relkind == RELKIND_RELATION && > > ? ? ? ? ? ? ? ? ? ? ? ?(tab->subcmds[AT_PASS_ADD_COL] || > > ? ? ? ? ? ? ? ? ? ? ? ? tab->subcmds[AT_PASS_ALTER_TYPE] || > > ? ? ? ? ? ? ? ? ? ? ? ? tab->subcmds[AT_PASS_COL_ATTRS])) > > ? ? ? ? ? ? ? ? ? ? ? ?AlterTableCreateToastTable(tab->relid, (Datum) 0); > > > > SET STORAGE uses AT_PASS_MISC, so this test case also omits a TOAST table: > > > > ?set client_min_messages = debug1; -- display toast creation > > ?create table t (a text); -- makes toast > > ?alter table t alter a set storage plain; > > ?alter table t add b int default 0; -- rewrite the table - no toast > > ?alter table t alter a set storage extended; -- no toast added? > > ?insert into t (a) values (repeat('x', 1000000)); -- fails > > Checking my understanding here, the first of these is a regression > introduced by the patch for $SUBJECT, but the second one is a > pre-existing bug. Is that right? The patch for $SUBJECT just introduced the first regression; commit 04e17bae50a73af524731fa11210d5c3f7d8e1f9 introduced the second regression near the beginning of the 9.1 development cycle.