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 1mhgTw-0004vi-L8 for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Nov 2021 23:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mhgTv-00080g-Jk for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Nov 2021 23:12:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mhgTu-00080W-TH for pgsql-bugs@lists.postgresql.org; Mon, 01 Nov 2021 23:12:47 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mhgTs-0007td-1k for pgsql-bugs@lists.postgresql.org; Mon, 01 Nov 2021 23:12:46 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 746465C01A8; Mon, 1 Nov 2021 19:12:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 01 Nov 2021 19:12:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=KB8KDKTEV2EjHBSk1gepJ/rlbRKWNPNS0xE+kLtCAAM=; b=GNoTRgwP Ww3xRoJ6J2X4Jh+g96jT3evV3+cLVdAmxVEcgGQ4zel5Px3Mjnp0JuzVDrDpSsjU IrMQMNHffChRkT/f7XkaLwhGBGN0JMPdCv5e7wVzVLnusv+rM2spI9nGaVec31ot L7FezSzBhxgOi7w8Uyi+hUrBqi0D5ugZv5rwf5UYxPOH1Ekr112aeXqL3LTtmMX7 WQl6rMWzXug0RQnc6L8U3eDBwscydFC8Zb8PdTOjMatLXeZjJmx1Zldr8WJs2MIo kf1p8X36Ze7+4nONGD1W2w8i5A9Mu4gcQhpxGM5N/6TSu6riCkuEgOP4AU0psZUq 6f9RJJ7dFSuEOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvdehgedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugfgjgesthekre dttddtjeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgv segrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepudejveejffejve duudetvdekieeuiedtvdeileefkeevjedufeeguedvjefhueelnecuffhomhgrihhnpegv nhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Nov 2021 19:12:42 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 964A02A0804; Mon, 1 Nov 2021 20:12:39 -0300 (-03) Date: Mon, 1 Nov 2021 20:12:39 -0300 From: Alvaro Herrera To: Tom Lane Cc: marcus@cockroachlabs.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17261: FK ON UPDATE CASCADE can break referential integrity with columns of different types Message-ID: <202111012312.6uzrqejsrg5j@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1311165.1635803989@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Nov-01, Tom Lane wrote: > PG Bug reporting form writes: > > It is possible to break foreign key referential integrity when the FK > > columns have different types and updates are cascaded from the parent > > relation to the child relation. > > I'm not really sure what you'd consider such an FK relationship to mean. > I can't get too excited about it when there doesn't seem to be a well > defined semantics for it. Yeah, I was thinking that a possible fix might be to reject the creation of such an FK, but I'm not sure what would be a good test to determine acceptability. It's not as easy as rejecting different typmods, in general: for example, rejecting FKs of varchars because their max lengths are different would be inappropriate. For numeric perhaps we could get away with saying that the referencing column must have a scale that's at least as large as the referenced column. But I wouldn't want to get in the business of having type-specific rules for this, because that seems messy and overcomplicated for little useful gain. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/