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 1riFOT-00FyeX-9f for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2024 15:10:49 +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 1riFOR-006AYJ-BL for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2024 15:10:47 +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 1riFOQ-006AYB-2D for pgsql-hackers@lists.postgresql.org; Thu, 07 Mar 2024 15:10:47 +0000 Received: from fout2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1riFOK-003KXZ-Ms for pgsql-hackers@postgresql.org; Thu, 07 Mar 2024 15:10:45 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id A7BC5138010E; Thu, 7 Mar 2024 10:10:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 07 Mar 2024 10:10:40 -0500 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1709824240; x= 1709910640; bh=8ZvntDINpTqyLpacRRuncLK8op1vdgAPSnVw6bCv5/w=; b=D qfsJZFbAjmgdG7MBPf6+eQQUc7bzeKeWhe5kjozPMGlRGMpG50TjP2OEL3esFVOY SFaqlfr9oKS7N5qfrvue8APDwHQ/+YUVB1DVSSuAmy2k9nR8CEVs3svR5XAYChzB SPTCKfSFugR0ONLIF6aYufQbOsVO7clhrwKY/9gZI2OBh/Nxxd41Imky6/Qkfd0u SlBuF1kOakVJ4VHuEJn182r3qglyikx6HWk8RCxVb1jzlG4ueRK0tvi/uebwvwNx VHTH5V5PSEHGJRjft+t7FnX3boK6fo5ES6jSpyFM0CQnsTMZxRLHrNZ2WD4cnMmk KJDXH+LamD9ZfjPPXB1bA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrieefgdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Mar 2024 10:10:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1709824238; bh=P4arx+mKlg4kvUOL+FwJjeVJaDlYzsqnJfKAbZ6wMVI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=NcAZrZ9MDnrfXinvSeGcm5vtexINg5rJwIp/7rxIPDqzY7glg+aGoIOG0Ze7aTRBm G7hXhpWSJ4pD26R3aFPFI7XpkS8Qn8Jm66p7RabhhDdDuwMR8WfqNrkazNsDAAumT0 n8vurjfxqcfpE6q5aJJGa3ytgqu9/qN1h0KhcQWpYBviv4R/dskS7i/COmF3VYH0T4 5MJJJ9bvbsfNupOXrgHgJJOEB7uuredsAMoHe/0Z8IciZg5td8oV7qG9Flmuf3GzSS P0pmCFWfR0k9553tYwQOvXyqTVMea/br1Uo1Vk+WniB/n2wYcL9Tgn8zT4w+K59pJt wYGXPYDfEEPUg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 0A1E2D84; Thu, 7 Mar 2024 16:10:38 +0100 (CET) Date: Thu, 7 Mar 2024 16:10:38 +0100 From: Alvaro Herrera To: Dean Rasheed Cc: Aleksander Alekseev , PostgreSQL-development , Amul Sul , vignesh C Subject: Re: Dump-restore loosing 'attnotnull' bit for DEFERRABLE PRIMARY KEY column(s). Message-ID: <202403071510.nhy6pdq66zuo@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Mar-07, Dean Rasheed wrote: > On Thu, 7 Mar 2024 at 13:00, Alvaro Herrera wrote: > > > > So I think the original developers of REPLICA IDENTITY had the right > > idea here (commit 07cacba983ef), and we mustn't change this aspect, > > because it'll lead to data corruption in replication. Using a deferred > > PK for DDL considerations seems OK, but it seems certain that for actual > > data replication it's going to be a disaster. > > Yes, that makes sense. If I understand correctly though, the > replication code uses relation->rd_replidindex (not > relation->rd_pkindex), although sometimes it's the same thing. So can > we get away with making sure that RelationGetIndexList() doesn't set > relation->rd_replidindex to a deferrable PK, while still allowing > relation->rd_pkindex to be one? Well, not really, because the logical replication code for some reason uses GetRelationIdentityOrPK(), which falls back to rd->pk_index (via RelationGetPrimaryKeyIndex) if rd_replindex is not set. Maybe we can add a flag RelationData->rd_ispkdeferred, so that RelationGetPrimaryKeyIndex returned InvalidOid for deferrable PKs; then logical replication would continue to not know about this PK, which perhaps is what we want. I'll do some testing with this. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/