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 1p5U2R-0000UM-RM for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Dec 2022 15:51:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p5U2P-0004Ro-Ln for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Dec 2022 15:51:17 +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 1p5U2P-0004Rf-Dx for pgsql-bugs@lists.postgresql.org; Wed, 14 Dec 2022 15:51:17 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5U2M-0006I6-A3 for pgsql-bugs@lists.postgresql.org; Wed, 14 Dec 2022 15:51:16 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 8EABB2F5F56C for ; Wed, 14 Dec 2022 16:51:10 +0100 (CET) Received: from s980.loopia.se (unknown [172.22.191.5]) by s807.loopia.se (Postfix) with ESMTP id 7F70D2E283F3; Wed, 14 Dec 2022 16:51:10 +0100 (CET) Received: from s474.loopia.se (unknown [172.22.191.6]) by s980.loopia.se (Postfix) with ESMTP id 79E3C2201667; Wed, 14 Dec 2022 16:51:10 +0100 (CET) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from s981.loopia.se ([172.22.191.6]) by s474.loopia.se (s474.loopia.se [172.22.190.14]) (amavisd-new, port 10024) with LMTP id ILLEKkbhqUzv; Wed, 14 Dec 2022 16:51:10 +0100 (CET) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s981.loopia.se (Postfix) with ESMTPSA id 04DBE22B177C; Wed, 14 Dec 2022 16:51:09 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: BUG #17720: pg_dump creates a dump with primary key that cannot be restored, when specifying 'using index ...' From: Daniel Gustafsson In-Reply-To: <2684951.1671032222@sss.pgh.pa.us> Date: Wed, 14 Dec 2022 16:51:09 +0100 Cc: "David G. Johnston" , "zedaardv@drizzle.com" , "pgsql-bugs@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <36765FCD-2CE4-40C2-80D3-7A7076B68DB1@yesql.se> References: <17720-dab8ee0fa85d316d@postgresql.org> <9C039DE3-EFBD-4D65-B4CF-90D8148B7B4C@yesql.se> <2684951.1671032222@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3696.100.31) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 14 Dec 2022, at 16:37, Tom Lane wrote: >=20 > Daniel Gustafsson writes: >> On 14 Dec 2022, at 13:54, David G. Johnston = wrote: >>> There is a decent chance that the fix here is to prohibit doing what = you did here - a PK cannot contain nulls in any of its columns so indeed = choosing an index that specifies how nulls behave is non-sensical. That = said, it also doesn=E2=80=99t hurt so long as the column itself is = indeed not null. But extending the syntax doesn=E2=80=99t seem that = appealing. >=20 >> Even if we prohibit this, there is still the case of all existing = systems which >> can't be dumped. I wonder if the solution is to teach pg_dump to not = create >> NULLS NOT DISTINCT primary key constraints? The simple attached fix = creates a >> valid PK constraint on the above schema. >=20 > It doesn't make sense for pg_dump to editorialize on a schema that > we otherwise consider valid; people would rightfully complain that > dump/restore changed things. So we need to do both things: prohibit > adopting such an index as a PK constraint (but I guess it's okay > for plain unique constraints?), and adjust pg_dump to compensate > for the legacy case where it was already done. Agreed, I'll expand the patch. -- Daniel Gustafsson https://vmware.com/