Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plaRW-000104-5s for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Apr 2023 19:11:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1plaRU-0002rV-NU for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Apr 2023 19:11:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plaRU-0002rM-Dx for pgsql-hackers@lists.postgresql.org; Sun, 09 Apr 2023 19:11:12 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plaRO-0007Zv-SP for pgsql-hackers@lists.postgresql.org; Sun, 09 Apr 2023 19:11:11 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CFCC55C0073; Sun, 9 Apr 2023 15:11:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 09 Apr 2023 15:11:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1681067465; x= 1681153865; bh=XtjQ8iUDicFAoDEGOKqo53W+tEDh1b4DAKuXOLomWnU=; b=Y Xw2bqPhp0sPZW/Mf03Cc4L2Y4vhpElLgurZ8nKT6HPbh1AIfWWBtGXJDZ3tEubXn tybeRIrocjRXGCbT0ZkU4HniwAPkQEqVC4+iTveVjeHel/sO80bcSf7rxR9mU7/O LDRZ0zpqdHxrFPWkLtWrmWcISowi59c3i6Dzdfy8tx3KKsiGziswIKEmXW6fFQWQ ljbqXOXBqQ/acLvrl39mdweLF5zfX3hJR7vramcWXgJSyVsXszAy+xN5no3QTsE8 H8g+dxlC0skAUYQEwEF8GM63HT6MdpKA24npuQhc3Th8lqAlLtOMOYBGEqE5wWv1 0idW1WXo4rfVJzB0H4MGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdektddgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeej keffgfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghl vhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 9 Apr 2023 15:11:04 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id BB216DB6; Sun, 9 Apr 2023 21:11:01 +0200 (CEST) Date: Sun, 9 Apr 2023 21:11:01 +0200 From: Alvaro Herrera To: Tom Lane Cc: Andres Freund , Justin Pryzby , Peter Eisentraut , pgsql-hackers@lists.postgresql.org Subject: Re: cataloguing NOT NULL constraints Message-ID: <20230409191101.po3bjtxdvm562f4o@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3801207.1681057430@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Apr-09, Tom Lane wrote: > In the new dispensation, pg_dump omits the NOT NULL clauses. > Great, you say, that makes the output more like what the user wrote. > I'm not so sure. This means that the ALTER TABLE will be compelled > to perform a full-table scan to verify that there are no nulls in the > already-loaded data before it can add the missing NOT NULL constraint. Yeah, I agree that this unintended consequence isn't very palatable. I think the other pg_upgrade problem is easily fixed (haven't tried yet), but having to rethink the pg_dump representation would likely take longer than we'd like. > I'm inclined to think that this idea of suppressing the implied > NOT NULL from PRIMARY KEY is a nonstarter and we should just > go ahead and make such a constraint. Another idea could be for > pg_dump to emit the NOT NULL, load data, do the ALTER ADD PRIMARY > KEY, and then ALTER DROP NOT NULL. I like that second idea, yeah. It might be tough to make it work, but I'll try. > In any case, I wonder whether that's the sort of redesign we should > be doing post-feature-freeze. It might be best to revert and try > again in v17. Yeah, sounds like reverting for now and retrying in v17 with the discussed changes might be better. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "La espina, desde que nace, ya pincha" (Proverbio africano)