From: Tom Lane <tgl@sss.pgh.pa.us>
To: 875941708@qq.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17549: wrong index scan plan with RLS
Date: Wed, 13 Jul 2022 10:27:39 -0400
Message-ID: <2221347.1657722459@sss.pgh.pa.us> (raw)
In-Reply-To: <17549-5114159516d34c2d@postgresql.org>
References: <17549-5114159516d34c2d@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> # for RLS user, index scan can only use column a, and filter by lower(b)
> set app.a=1;
> explain analyse select * from abc where a=1 and lower(b)='1234';
> Index Scan using abc_a_lower_idx on abc
> Index Cond: (a = 1)
> Filter: (lower(b) = '1234'::text)
AFAICS this is operating as designed. It's unsafe to apply the
non-leakproof condition until we've verified that the row has a = 1.
In the particular case shown here, it might be all right to do it,
but cases such as bitmap indexscans or lossy index opclasses could
result in live re-evaluations of the indexqual conditions at some
rows. So we can't safely allow lower(b) to become part of the
indexquals.
regards, tom lane
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: tgl@sss.pgh.pa.us, 875941708@qq.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17549: wrong index scan plan with RLS
In-Reply-To: <2221347.1657722459@sss.pgh.pa.us>
* 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