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 1p65kw-00007u-DA for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Dec 2022 08:07:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p65kv-0006ZX-8W for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Dec 2022 08:07:45 +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 1p65ku-0006ZO-W1 for pgsql-bugs@lists.postgresql.org; Fri, 16 Dec 2022 08:07:44 +0000 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p65kr-0001ot-Qv for pgsql-bugs@lists.postgresql.org; Fri, 16 Dec 2022 08:07:43 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 22C1D2B0599F; Fri, 16 Dec 2022 03:07:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 16 Dec 2022 03:07:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :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=1671178058; x= 1671185258; bh=NADgWbWvobzAqGeS89FPqCxn9fgfecJToYR9XXHzluE=; b=P XOqwgSXdZpgS6UQsWoGi0wWnBsxbKOtnwQOE7bO1OZwbKcbtQCFhpqvhsEviTc9t Q0wfgtN3PQVbHsA/4RA2Fpw2EFqqJx+NhxbtK3hXxXyzg5PfhShyLQxJ5/UErLQU vQnFuN80YFYO0t1vAgV++LUrvdJiG8Z69bqRdCyeKUhwVwwOAccNMUCTPu3ALT49 I/6qXCpXJdZ+KOP9s9foUAKIguIInAFcL1t4nBnlcUcs+qZTMYm2RRMnbxXz6Wrr AzufkTFZdFoHCc+aw8zVSHmOz5NIyj1MbFF6FyxWpAbpbfQW2kArqhlHurobv/8/ cRGck9jy3M8F8GWCneVEQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeigdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnth gvrhhprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeehleffgeegudejteei hfelteduvdeifffhffdvjedvffegjeekudeludehudeifeenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghu thesvghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 16 Dec 2022 03:07:37 -0500 (EST) Message-ID: <173834de-18a1-4a9c-5e15-9b22e56c4293@enterprisedb.com> Date: Fri, 16 Dec 2022 09:07:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: BUG #17720: pg_dump creates a dump with primary key that cannot be restored, when specifying 'using index ...' Content-Language: en-US To: Tom Lane , Daniel Gustafsson Cc: "David G. Johnston" , "zedaardv@drizzle.com" , "pgsql-bugs@lists.postgresql.org" References: <17720-dab8ee0fa85d316d@postgresql.org> <9C039DE3-EFBD-4D65-B4CF-90D8148B7B4C@yesql.se> <2684951.1671032222@sss.pgh.pa.us> <20CD10FD-A9C2-47D0-9A75-B86532BC058E@yesql.se> <3039077.1671060472@sss.pgh.pa.us> From: Peter Eisentraut In-Reply-To: <3039077.1671060472@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 15.12.22 00:27, Tom Lane wrote: > Daniel Gustafsson writes: >> The attached prohibits the use of NULLS NOT DISTINCT for backing primary key >> constraints but allow them for unique constraints. Is this along the lines of >> what you had in mind? > > Needs more than zero comments in the code, and why bother testing > is_alter_table in index_check_primary_key? We're disallowing > this case across-the-board, no matter how you get to it. > > I'll defer to Peter on whether this is in fact the right way to go, > or we should relax the syntax restriction as David suggests. My first instinct was to just fix pg_dump to not dump syntax that can't be loaded in. It shouldn't matter what null treatment the underlying unique index has, since the primary key can't have nulls anyway, so either type of index should be acceptable. But then we'd need to think through a bunch of possible ALTER behaviors. For example, if we just change pg_dump and leave the index as is, a subsequent dump and restore would lose the original null treatment flag. What if someone then wants to re-detach the constraint from the index? (Does that exist now? Maybe not, but it could.) What should happen then? This could all be worked out, I think, but it would need more thought. In short, I think preventing the ALTER command, as proposed in this patch, seems like a good solution for the moment. Additional work to enable some of this could follow later independently.