Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZAfPi-0000ic-0I for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Jul 2015 14:24:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZAfPg-0007Xz-Fn for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Jul 2015 14:24:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZAfHg-0001a0-BT for pgsql-bugs@postgresql.org; Thu, 02 Jul 2015 14:16:12 +0000 Received: from mail-wi0-f174.google.com ([209.85.212.174]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZAfHc-0007Ol-FJ for pgsql-bugs@postgresql.org; Thu, 02 Jul 2015 14:16:10 +0000 Received: by wicgi11 with SMTP id gi11so75198824wic.0 for ; Thu, 02 Jul 2015 07:16:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=elDWW0QFgvaaqVT8la2IxQNkOqdSBlQhM8j8nyfnG/c=; b=Me+k5eM+OLLzGnw3XAiGzts8LzswGhEaUYVV0dNj9vgoOQskAi5h/gGDi5aYL/M8kz 08pSQwHFWHnmW8rjeSE5WZ5IyJXOJa9Rq4S+MMkRPj7jLnuRztrS2IvomCddWa3A2hkR 1X8fBday5dooCvxEvuD8e0KQ+l3OhY7V6yKK9qJXGb6Q5VnTzg1rcp/zVQUJeLlUdGs6 sRvUGqzv9nCa6s0nE5fiF3uIxly5HFa9DXUch+6gwKFEnc5AKM3A3n9OMVbx7A514eMP N0O9tTjg25o9hb5/ChR+9WQDP4L1Q+ofI6l+Y5Nnv74DVsKgoEeo/pSDrfcIbCpNiKNg 04lA== X-Gm-Message-State: ALoCoQmRTAvGW8VEsIP0QxYOom93skrIUQMBVBwMWVsRwD0h/9EAn9x54OabZTKXHBzN7vtuTPKn X-Received: by 10.194.178.201 with SMTP id da9mr15762815wjc.139.1435846566719; Thu, 02 Jul 2015 07:16:06 -0700 (PDT) Received: from ?IPv6:2a00:1028:9941:52fa:e839:df84:99ef:ce5d? (dynamic-2a00-1028-9941-52fa-e839-df84-99ef-ce5d.ipv6.broadband.iol.cz. [2a00:1028:9941:52fa:e839:df84:99ef:ce5d]) by mx.google.com with ESMTPSA id p2sm8899329wix.11.2015.07.02.07.16.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 07:16:05 -0700 (PDT) Message-ID: <559547A2.2000204@2ndquadrant.com> Date: Thu, 02 Jul 2015 16:16:02 +0200 From: Petr Jelinek User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Michael Paquier , Tom Lane CC: xi@resolvent.net, PostgreSQL mailing lists , PostgreSQL-development Subject: Re: BUG #13126: table constraint loses its comment References: <20150422154850.5198.26685@wrigleys.postgresql.org> <8519.1429995948@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2015-05-27 15:10, Michael Paquier wrote: > On Wed, Apr 29, 2015 at 1:30 PM, Michael Paquier > wrote: >> On Sun, Apr 26, 2015 at 6:05 AM, Tom Lane wrote: >>> xi@resolvent.net writes: >>>> In some circumstances, the comment on a table constraint disappears. Here >>>> is an example: >>> >>> Hm, yeah. The problem is that ATExecAlterColumnType() rebuilds all the >>> affected indexes from scratch, and it isn't doing anything about copying >>> their comments to the new objects (either comments on the constraints, or >>> comments directly on the indexes). >>> >>> The least painful way to fix it might be to charter ATPostAlterTypeCleanup >>> to create COMMENT commands and add those to the appropriate work queue, >>> rather than complicating the data structure initially emitted by >>> ATExecAlterColumnType. But it'd still be a fair amount of new code I'm >>> afraid. >>> >>> Not planning to fix this personally, but maybe someone else would like to >>> take it up. >> >> In order to fix this, an idea would be to add a new routine in >> ruleutils.c that generates the COMMENT query string, and then call it >> directly from tablecmds.c. On master, I imagine that we could even add >> some SQL interface if there is some need. >> Thoughts? > > After looking at this problem, I noticed that the test case given > above does not cover everything: primary key indexes, constraints > (CHECK for example) and indexes alone have also their comments removed > after ALTER TABLE when those objects are re-created. I finished with > the patch attached to fix everything, patch that includes a set of > regression tests covering all the code paths added. > I was going through the code and have few comments: - Why do you change the return value of TryReuseIndex? Can't we use reuse the same OidIsValid(stmt->oldNode) check that ATExecAddIndex is doing instead? - I think the changes to ATPostAlterTypeParse should follow more closely the coding of transformTableLikeClause - namely use the idxcomment - Also the changes to ATPostAlterTypeParse move the code somewhat uncomfortably over the 80 char width, I don't really see a way to fix that except for moving some of the nesting out to another function. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs