Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 93FAD37EB72 for ; Sun, 15 Jul 2012 18:24:06 -0300 (ADT) Received: from mail-qc0-f174.google.com ([209.85.216.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SqWIM-0007oY-LT for pgsql-bugs@postgresql.org; Sun, 15 Jul 2012 21:24:05 +0000 Received: by qcro28 with SMTP id o28so3015706qcr.19 for ; Sun, 15 Jul 2012 14:23:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent:x-gm-message-state; bh=5m4T3TfVPucrS7xr8QH/vS8L2HeQE/NHMSBQ5kBIc/o=; b=FqwvR3OMP0/YmM3oRplo7wZVPabw/W6/DxooDGYEMwKSwOy0/SQnwgAA9XeX7V/dkM LSI3WY6Ztv4w5+oFWPv++Y4iXXwhwfuIyfVD5Glvm3HBKIIaGUH8YyRAg386eOEfa+bC /ufom3QKDrSlSvrJPUnM5j10xkHxyo5C424xsXXzh3yZWywruvKuuTf3DhMiERow7N8t G9DLsOL2jwM2QvvT/CyO/yiu0lXUqqs0b0ZUfHPlSysasKtBwtL0C4yycWt2pR+095Jt VqJaur4/N019GJKT7cLLg+7MpCEVxh+B4FPBD2BQaVW8l90kgLD/Qcgh75HnCS6Q6iQB bdGw== Received: by 10.229.135.194 with SMTP id o2mr4873053qct.125.1342387428945; Sun, 15 Jul 2012 14:23:48 -0700 (PDT) Received: from tornado.leadboat.com (ip68-105-236-221.hr.hr.cox.net. [68.105.236.221]) by mx.google.com with ESMTPS id z9sm20177814qae.15.2012.07.15.14.23.46 (version=SSLv3 cipher=OTHER); Sun, 15 Jul 2012 14:23:47 -0700 (PDT) Date: Sun, 15 Jul 2012 17:23:44 -0400 From: Noah Misch To: Amit Kapila Cc: miroslav.sulc@fordfrog.com, pgsql-bugs@postgresql.org Subject: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table Message-ID: <20120715212344.GA7475@tornado.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Gm-Message-State: ALoCoQm0wkioht92wDEswg1qAgCC8T1dkd56U5qNJeJ4ZRjWnpo9bkQi2pJAb4haz0GvjfobfNBi X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201207/114 X-Sequence-Number: 33590 On Mon, Jul 02, 2012 at 04:16:31PM +0530, Amit Kapila wrote: > > From: pgsql-bugs-owner@postgresql.org [mailto:pgsql-bugs-owner@postgresql.org] On Behalf Of miroslav.sulc@fordfrog.com > > Sent: Saturday, June 30, 2012 4:28 PM > > test=# create table test_constraints (id int, val1 varchar, val2 int, unique > > (val1, val2)); > > NOTICE: CREATE TABLE / UNIQUE will create implicit index > > "test_constraints_val1_val2_key" for table "test_constraints" > > CREATE TABLE > > test=# create table test_constraints_inh () inherits (test_constraints); > > CREATE TABLE > > test=# alter table only test_constraints drop constraint > > test_constraints_val1_val2_key; > > ERROR: constraint "test_constraints_val1_val2_key" of relation > > "test_constraints_inh" does not exist > > postgresql tries to drop the constraint even from descendant table though > > "only" is specified. ONLY shouldn't be necessary, either. > In function ATExecDropConstraint(), for the constarint "test_constraints_val1_val2_key" con->connoinherit is false, > due to which it tries to drop the constrint from child table as well. > I have checked that from function index_constraint_create() when it calls function CreateConstraintEntry(), the flag for noinherit passed is false. > I think this is the reason of failure for the same. Agreed. The other non-CHECK callers also get this wrong: [local] regression=# select contype,connoinherit,count(*) from pg_constraint group by 1,2; contype | connoinherit | count ---------+--------------+------- p | f | 7 x | f | 2 c | f | 17 f | f | 5 One can construct similar bugs around dropping foreign key and exclusion constraints. Though it may be irrelevant for command semantics, additionally using connoinherit = 't' for contype = 't' (CONSTRAINT_TRIGGER) would more-accurately represent the nature of those constraints. Care to prepare a patch with a test case addition? Thanks, nm