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 1m8Szo-00066M-BL for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jul 2021 19:44:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8Szm-0003qg-P6 for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jul 2021 19:44:06 +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 1m8Szm-0003qY-I8 for pgsql-bugs@lists.postgresql.org; Tue, 27 Jul 2021 19:44:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8Szc-0008NY-BY for pgsql-bugs@lists.postgresql.org; Tue, 27 Jul 2021 19:44:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 16RJhq99455835; Tue, 27 Jul 2021 15:43:52 -0400 From: Tom Lane To: Alexander Korotkov cc: Alvaro Herrera , Neil Chen , Alexander Law , PostgreSQL mailing lists , Paul A Jungwirth Subject: Re: BUG #17066: Cache lookup failed when null (unknown) is passed as anycompatiblemultirange In-reply-to: References: <202106221342.lab2x5tvhcbs@alvherre.pgsql> <2549561.1624491310@sss.pgh.pa.us> <640279.1626818095@sss.pgh.pa.us> <703769.1626879831@sss.pgh.pa.us> Comments: In-reply-to Alexander Korotkov message dated "Tue, 27 Jul 2021 18:31:05 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <455833.1627415032.1@sss.pgh.pa.us> Date: Tue, 27 Jul 2021 15:43:52 -0400 Message-ID: <455834.1627415032@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Korotkov writes: > On Wed, Jul 21, 2021 at 6:03 PM Tom Lane wrote: >> That's too bad, because IMO it'd be way more helpful to say >> ERROR: arguments declared "anyelement" are not all alike >> DETAIL: integer versus numeric >> which is what enforce_generic_type_consistency would say if it >> were reached. Similarly, the other error cases in that code >> are far more specific and thus more helpful than simply reporting >> that there's no matching function. >> >> I'm tempted to propose that, if there is only one possible match >> but check_generic_type_consistency rejects it, then >> function/operator lookup should return that OID anyway, allowing >> enforce_generic_type_consistency to throw the appropriate error. >> This would obviously not help when there are multiple polymorphic >> functions having the same name and number of arguments, but that >> strikes me as a very unusual corner case. > I spend some time thinking about this. I'm actually not sure this > approach is really correct. If there is only one polymorphic > candidate, it's still possible that the user means non-polymorphic > function with exactly matching arguments, which is simply doesn't > exist. I don't particularly buy that reasoning. Certainly the true cause of the error could be that the user mistyped the function name, or meant to refer to something that's not in the search_path, or forgot to load the function into this particular database, etc etc. But we have to act on the basis of the information we have, and that is the function(s) we see. If we let possibilities like these paralyze us, we'll never be able to issue useful error messages at all. I don't deny that what I'm proposing above is a bit weird and non-orthogonal; there may be a better way to do it. But the existing code structure where check_generic_type_consistency silently returns a boolean just isn't very conducive to giving a good error message. We have a lot more information available to give, if we choose to give it. Possibly we should think in terms of rewriting enforce_generic_type_consistency's messages so that they are errdetail() messages with a common primary message that's still some variation of "there's no matching function". regards, tom lane