From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: poliv78@gmail.com
Subject: BUG #18676: Execute function while selecting from table with partial index using this function.
Date: Mon, 28 Oct 2024 14:58:34 +0000
Message-ID: <18676-383b0d2b6dc65bf6@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18676
Logged by: Yevhen Polyvoda
Email address: poliv78@gmail.com
PostgreSQL version: 17.0
Operating system: macos Sequoia 15.0
Description:
Please run the script below. It creates sample table with partial index
using IMMUTABLE function.
I think when table is changing - index in changing and thus function used in
WHERE cluse can be run.
But it is not supposed to be run on just simple SELECT from table without
even condition to use this index.
---------------------------------------------------
CREATE TABLE IF NOT EXISTS public.test_table
(
id integer NOT NULL
);
CREATE OR REPLACE FUNCTION public.test_function(
)
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
IMMUTABLE PARALLEL UNSAFE
AS $BODY$
DECLARE
BEGIN
raise notice 'test';
RETURN 1;
END
$BODY$;
REVOKE ALL ON FUNCTION public.test_function() FROM PUBLIC;
CREATE INDEX IF NOT EXISTS test_idx
ON public.test_table USING btree
(id)
WHERE id = public.test_function();
create role test_role LOGIN PASSWORD 'test';
------------------------------------------------
set role = 'test_role';
select * from public.test_table;
we will get permission denied because while selecting somehow function
public.test_function() runs.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, poliv78@gmail.com
Subject: Re: BUG #18676: Execute function while selecting from table with partial index using this function.
In-Reply-To: <18676-383b0d2b6dc65bf6@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox