Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4nYC-007THC-9o for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Apr 2025 21:10:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u4nYA-00H52w-D2 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Apr 2025 21:10:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4nY9-00H52n-Tb for pgsql-hackers@lists.postgresql.org; Tue, 15 Apr 2025 21:10:34 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u4nY8-000Fxu-2D for pgsql-hackers@lists.postgresql.org; Tue, 15 Apr 2025 21:10:33 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id A4B881140419; Tue, 15 Apr 2025 17:10:31 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Tue, 15 Apr 2025 17:10:31 -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:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1744751431; x=1744837831; bh=/ cxqjzn9C+YB7m1RtbWN+OfTEPeUNuD8xPqHalxqZhw=; b=UxQz/V6E8Gi2+/JOU LMJy2ZIB3jcsqHMHfLVxhUSVbkf/Qk/owW1xj5M2BwzpPczCSGb/UrnzpQZM5Z/x IeMYaNFOFjxfcS/AZg/MPk2EHuFqvvWv4GLvQK0y33Kevhht8xgZ7vp04y30Q//Y U5GQ9kWawc7Xeye/VSkhvtcT8lAs+rAt0lKnXHKpu3ZFORNAi9AznPaLKPOY1rYE PPDfNjqXUZHwmWK+trHNndgtcMQbLSeqK9D+7fHbI9htniRr/ZUEmF0OOssAXyDG wzs8StkFI7rH7jo1AggTdbbn8xTp/+Ozsz+abTKAMqya+sdJRKlSHIFUqJeC4OQY oI2Cw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvvdegheefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddt jeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffeh fffhjeejhffgieeuueekjeekfffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvg hrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsg gprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehjihgrnhdr uhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhnughrfi grnhhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshes lhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepthhglhesshhssh drphhghhdrphgrrdhush X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Apr 2025 17:10:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1744751426; bh=9ujQnVs9CKSWQrdBczyx6sPn+Uc0ms4LiRwXeQ5ISXQ=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=iPM2ymD2KJFWLttIG+8m+1fxCajiSbXMzJjrIHCANrwEvob7OgObQ2x+wOlb8ElUj +YRXeEigTjaroAn7y1IPrCh1ff8Q3AnPxwXttUO03u8FCZeOJco7n2/gg0CuT/jIiQ AOm19KxJMoUcX+IjAzWqXhgXktCqnZNezu8eO0VIj0LWzrLAwtCpp0Xq1LEgMPM+pJ 03IJn3M1KiOvAUwh0WLdh6IgEMcmBacz787WTjJED9YIpWJycYIVm0vhmR589nbnNa xo/DSQrhBgSW7ezxS+uDnLIW3EAyArkQllZBvkyH/2/E5yPA3PFd539XEMP0ZosUIl O0n8+IcE7WXkQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id D08178F; Tue, 15 Apr 2025 23:10:26 +0200 (CEST) Date: Tue, 15 Apr 2025 23:10:26 +0200 From: Alvaro Herrera To: Tom Lane Cc: Tender Wang , jian he , Pg Hackers Subject: Re: not null constraints, again Message-ID: <202504152110.gr3ga55h55q6@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1719550.1744746674@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Apr-15, Tom Lane wrote: > +1. Fundamentally the problem here is that pg_restore needs > > ALTER TABLE ONLY foo ADD PRIMARY KEY > > to not recurse to child tables at all. It is expecting this command > to acquire a lock on foo and nothing else; and it has already taken > care of making foo's PK column(s) NOT NULL, so there is no reason we > should have to examine the children. Right. > Looking at the patch itself, it doesn't seem like the got_children > flag is accomplishing anything; I guess that was leftover from an > earlier version? You could declare "List *children" inside the > block where it's used, too. Basically, this patch is just moving > the check-the-children logic from one place to another. Ah yes, I forgot to set got_children when reading the children list. This happens within the loop for columns, so the idea is to obtain that list just once instead of once per column. I don't think there's any ill effect from doing it multiple times, but it's wasted work and that's what led me to adding got_children. I'll add the assignment. > Also I find the comments still a bit confusing, but maybe that's > on me. I'll review tomorrow morning, maybe I can find some improvements for them. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "La conclusión que podemos sacar de esos estudios es que no podemos sacar ninguna conclusión de ellos" (Tanenbaum)