Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E63B81337BBA for ; Thu, 31 Mar 2011 09:35:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 17352-03 for ; Thu, 31 Mar 2011 12:35:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from dd2030.kasserver.com (dd2030.kasserver.com [85.13.128.37]) by mail.postgresql.org (Postfix) with ESMTP id 3506D1337B2F for ; Thu, 31 Mar 2011 09:35:45 -0300 (ADT) Received: from [172.26.14.62] (exit.credativ.com [87.139.82.80]) by dd2030.kasserver.com (Postfix) with ESMTPA id E8667E00AB; Thu, 31 Mar 2011 14:35:44 +0200 (CEST) Date: Thu, 31 Mar 2011 14:35:43 +0200 From: Bernd Helmle To: Noah Misch , Robert Haas cc: Naoya Anzai , pgsql-hackers@postgresql.org Subject: Re: BUG #5856: pg_attribute.attinhcount is not correct. Message-ID: <6CF92001890CDD19DB8DDEED@[172.26.14.62]> In-Reply-To: <20110331100649.GA7286@tornado.gateway.2wire.net> References: <201101311142.p0VBgVGd019556@wwwmaster.postgresql.org> <20110331100649.GA7286@tornado.gateway.2wire.net> X-Mailer: Mulberry/4.0.8 (Mac OS X) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, MIME_QP_LONG_LINE=0.001 X-Spam-Level: X-Archive-Number: 201103/1879 X-Sequence-Number: 185129 --On 31. M=C3=A4rz 2011 06:06:49 -0400 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? > > Incidentally, when we satisfy an ADD COLUMN with a merge, we do not check or > update attnotnull: > > create table parent(); > create table child(c1 text) inherits (parent); > alter table parent add column c1 text not null; > \d child > > We could either update attnotnull (and schedule a phase-3 scan of the table) > or throw an error. For ALTER TABLE ... INHERIT, we throw the error. For > CREATE TABLE ... INHERITS, we add the NOT NULL (and no scan is needed). I'd > weakly lean toward throwing the error. Opinions? Hmm this looks like the same kind of problem i'm currently faced with when=20 working on tracking inheritance counters for NOT NULL constraint at the moment=20 (see=20 =20 for a heavy WIP patch). It currently recurses and seems to do the right thing=20 (tm) for your example above, but i'm far from being certain that the way i'm=20 undertaking here is correct. It indeed discovered a bug i had in my recursion=20 code... --=20 Thanks Bernd