Re: BUG #17549: wrong index scan plan with RLS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: 875941708(at)qq(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17549: wrong index scan plan with RLS
Date: 2022-07-13 14:27:39
Message-ID: 2221347.1657722459@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message hubert depesz lubaczewski 2022-07-14 11:51:55 Excessive number of replication slots for 12->14 logical replication
Previous Message Juan José Santamaría Flecha 2022-07-13 13:08:06 Re: pg_ctl cannot find postgresql.conf