Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rmnjL-009vmj-3Y for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Mar 2024 04:39:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rmnjJ-002Tj0-DW for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Mar 2024 04:39:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rmnjJ-002Tis-59 for pgsql-bugs@lists.postgresql.org; Wed, 20 Mar 2024 04:39:09 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rmnjF-005ROo-Up for pgsql-bugs@lists.postgresql.org; Wed, 20 Mar 2024 04:39:08 +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 42K4d5BZ4112888; Wed, 20 Mar 2024 00:39:05 -0400 From: Tom Lane To: David Rowley cc: Sawyer Knoblich , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18399: Query plan optimization results in runtime error when hoisting cast from inside subquery In-reply-to: References: <18399-17778030a1971177@postgresql.org> <3877106.1710863246@sss.pgh.pa.us> <4085750.1710895021@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Wed, 20 Mar 2024 17:08:49 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4112886.1710909545.1@sss.pgh.pa.us> Date: Wed, 20 Mar 2024 00:39:05 -0400 Message-ID: <4112887.1710909545@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > There are quite a lot of things which would have to be restricted, > much more than you might think. Any conditions which could cause an > error would have to be evaluated last in a WHERE clause and that might > result in being unable to use indexes because some other (possibly > unindexed) expression would need to be evaluated first. That particular aspect might not be too awful, because there's already a good deal of pressure for index opclass members to not fail --- certainly I'd expect that all standard btree comparison functions could be marked non-failing. (Let us slide quietly past the question of exactly how strong the guarantee should be; for example any function that takes toastable argument types is potentially at risk of OOM, but do you really want to exclude numeric_eq and texteq from the set of safe operations? See also past discussions on how strict we should be about the related concept of leakproofness.) In any case I agree with your larger point that ordering things such that potentially-failing tests are always done last would be a performance disaster, even if it's possible at all. regards, tom lane