Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhMH7-0007ff-U8 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Aug 2017 20:47:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dhMH7-0004Au-Gy for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Aug 2017 20:47:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dhMFZ-0007jw-Nt; Mon, 14 Aug 2017 20:46:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dhMFV-0000I2-Ov; Mon, 14 Aug 2017 20:46:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v7EKk5AY010718; Mon, 14 Aug 2017 16:46:05 -0400 From: Tom Lane To: Alexander Korotkov cc: Mark Rofail , Alvaro Herrera , pgsql-hackers , Robert Haas , David Steele , Stephen Frost , pgsql-hackers-owner@postgresql.org, Erik Rijkers Subject: Re: GSoC 2017: Foreign Key Arrays In-reply-to: References: <17185.1501392410@sss.pgh.pa.us> <20170731151805.nonu6qwv54ca4qvv@alvherre.pgsql> Comments: In-reply-to Alexander Korotkov message dated "Mon, 14 Aug 2017 23:35:22 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10716.1502743565.1@sss.pgh.pa.us> Date: Mon, 14 Aug 2017 16:46:05 -0400 Message-ID: <10717.1502743565@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Alexander Korotkov writes: > On Mon, Aug 14, 2017 at 2:09 PM, Mark Rofail wrote: >> I think we should cast the operands in the RI queries fired as follows >> 1. we get the array type from the right operand >> 2. compare the two array type and see which type is more "general" (as to >> which should be cast to which, int2 should be cast to int4, since casting >> int4 to int2 could lead to data loss). This can be done by seeing which Oid >> is larger numerically since, coincidentally, they are declared in this way >> in pg_type.h. > I'm not sure numerical comparison of Oids is a good idea. I absolutely, positively guarantee that a patch written that way will be rejected. > Should we instead use logic similar to select_common_type() and underlying > functions? Right. What we typically do in cases like this is check to see if there is an implicit coercion available in one direction but not the other. I don't know if you can use select_common_type() directly, but it would be worth looking at. Also, given that the context here is RI constraints, what you're really worried about is whether the referenced column's uniqueness constraint is associated with compatible operators, so looking into its operator class for relevant operators might be the right way to think about it. I wrote something just very recently that touches on that ... ah, here it is: https://www.postgresql.org/message-id/13220.1502376894@sss.pgh.pa.us regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers