From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | brandystodd(at)gmail(dot)com |
Subject: | BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions |
Date: | 2025-06-20 17:42:06 |
Message-ID: | 18965-89456ea7e640a053@postgresql.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 18965
Logged by: Todd Brandys
Email address: brandystodd(at)gmail(dot)com
PostgreSQL version: 17.5
Operating system: Linux
Description:
In the circumstance where a function evaluation is performed within Boolean
expression, the evaluation seems to continue past a function returning a
TRUE value. Here is a very boiled down version of my code, but it results
in the same issue. In the first SELECT statement, I get the expected
result, a single row with a TRUE value. In the other two SELECT statements,
an EXCEPTION is thrown, which is unexpected.
CREATE OR REPLACE FUNCTION raise(
IN i_msg text
)
RETURNS text AS $$
BEGIN
RAISE EXCEPTION '%', i_msg;
RETURN ''::text;
END;$$
LANGUAGE PLPGSQL
IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION test( )
RETURNS boolean AS $$
SELECT TRUE; $$
LANGUAGE SQL
IMMUTABLE STRICT;
SELECT TRUE OR public.raise('this exception should not be
raised')::boolean;
SELECT pg_catalog.PG_HAS_ROLE('postgres', 'postgres', 'member')
OR public.raise('this exception should not be raised')::boolean;
SELECT public.test() OR public.raise('this exception should not be
raised')::boolean;
Again, I am using PostgreSQL 17.5, compiled from source. I have no
extensions installed in the database. Here is the configure script I used
to build the distribution:
export PYTHON=/var/lib/pgsql/venv/bin/python3
./configure \
--prefix=/usr/local/installed/postgresql-17.5 \
--enable-atomics --enable-largefile --with-llvm --with-perl
--with-readline --with-python \
--with-uuid=ossp --with-zlib --with-ssl=openssl --with-libxml
--with-libxslt
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-06-20 17:50:41 | Re: BUG #18959: Name collisions of expression indexes during parallel Index creations on a pratitioned table. |
Previous Message | Tom Lane | 2025-06-20 15:14:59 | Re: BUG #18963: Column confupdsetcols missing in pg_catalog.pg_constraint |