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 1uSgbz-00Bhbc-MD for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Jun 2025 18:37:15 +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 1uSgbx-003f8Z-GB for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Jun 2025 18:37:14 +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 1uSgbx-003f8Q-7t for pgsql-bugs@lists.postgresql.org; Fri, 20 Jun 2025 18:37:13 +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.96) (envelope-from ) id 1uSgbv-0036Io-2u for pgsql-bugs@lists.postgresql.org; Fri, 20 Jun 2025 18:37:12 +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 55KIbA9O2145179; Fri, 20 Jun 2025 14:37:10 -0400 From: Tom Lane To: brandystodd@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions In-reply-to: <18965-89456ea7e640a053@postgresql.org> References: <18965-89456ea7e640a053@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 20 Jun 2025 17:42:06 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2145177.1750444630.1@sss.pgh.pa.us> Date: Fri, 20 Jun 2025 14:37:10 -0400 Message-ID: <2145178.1750444630@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > CREATE OR REPLACE FUNCTION raise( > IN i_msg text > ) > RETURNS text AS $$ > BEGIN > RAISE EXCEPTION '%', i_msg; > RETURN ''::text; > END;$$ > LANGUAGE PLPGSQL > IMMUTABLE STRICT; I think the fundamental problem you're having is that you marked this function IMMUTABLE, which gives the planner license to pre-evaluate it. It had better be VOLATILE to discourage advance evaluation. https://www.postgresql.org/docs/current/xfunc-volatility.html regards, tom lane