Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4LnC-0003tP-C6 for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Apr 2018 07:28:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4LnA-0008Gb-7W for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Apr 2018 07:28:12 +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.89) (envelope-from ) id 1f4Ln9-0008GR-Pl for pgsql-hackers@lists.postgresql.org; Fri, 06 Apr 2018 07:28:12 +0000 Received: from forward2p.cmail.yandex.net ([77.88.31.17]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4Ln5-0005Sf-L4 for pgsql-hackers@postgresql.org; Fri, 06 Apr 2018 07:28:10 +0000 Received: from mxback3j.mail.yandex.net (mxback3j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10c]) by forward2p.cmail.yandex.net (Yandex) with ESMTP id 86CC22196A; Fri, 6 Apr 2018 10:28:03 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback3j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id B9iE4jcxLF-S0486D9M; Fri, 06 Apr 2018 10:28:02 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zsrv.org; s=mail; t=1522999682; bh=WqQGH9d0EqZSuQu0+BSfgLIfJRfjsrUkGIfTiQhKEIw=; h=From:To:Cc:In-Reply-To:References:Subject:Message-Id:Date; b=h0SwWo5jLiaRyadNsfCqKwHLCqQ6jU03Nn/eWW4/Z0RrCIwb/In2iB6h9LQgucFib wHG/8YhJbnw41eE7yUvkipOL57Fkuh8zs83PbwZqZC2cgnHhrmdBYPiwbXavNrelUJ Y+AvLClVUk7qg65JfBrHhAloIB0w1E2lmSrIWzqc= Authentication-Results: mxback3j.mail.yandex.net; dkim=pass header.i=@zsrv.org Received: by web16g.yandex.ru with HTTP; Fri, 06 Apr 2018 10:28:00 +0300 From: Sergei Kornilov To: Peter Eisentraut , Tom Lane , Stephen Frost Cc: Robert Haas , "pgsql-hackers@postgresql.org" In-Reply-To: References: <81911511895540@web58j.yandex.ru> <20171129152135.GN4628@tamriel.snowman.net> <9878.1511970441@sss.pgh.pa.us> <370481511970756@web3j.yandex.ru> Subject: Re: using index or check in ALTER TABLE SET NOT NULL MIME-Version: 1.0 Message-Id: <3796271522999680@web16g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 06 Apr 2018 10:28:00 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, Peter! I agree my patch seems as strange workaround. And better will be SET NOT NULL NOT VALID feature. But this change is very complicated for me For now my patch is small, simple and provides way for users. regards, Sergei 06.04.2018, 06:29, "Peter Eisentraut" : > On 11/29/17 10:52, Sergei Kornilov wrote: >>  My target problem of adding NOT NULL to big relation without long downtime can be done with ADD CONSTRAINT NOT VALID, VALIDATE it in second transaction, then SET NOT NULL by my patch and drop unneeded constraint. > > It seems to me that this is a workaround for not properly cataloguing > NOT NULL constraints. If we fixed that, you could do SET NOT NULL NOT > VALID and go from there. Maybe we should look again into fixing that. > That would solve so many problems. > > -- > Peter Eisentraut http://www.2ndQuadrant.com/ > PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services