pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Derek Hans <derek.hans@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: GIST/GIN index not used with Row Level Security
Date: Tue, 13 Aug 2019 15:48:36 -0400
Message-ID: <14241.1565725716@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGrP7a3JcEorwM98OGn7s-TZ1os8rubCqeEXLgqeZrvX4LfwvQ@mail.gmail.com>
References: <CAGrP7a2t+JbeuxpQY+RSvNe4fr3+==UmyimwV0GCD+wcrSSb=w@mail.gmail.com>
	<12552.1565723566@sss.pgh.pa.us>
	<CAGrP7a3JcEorwM98OGn7s-TZ1os8rubCqeEXLgqeZrvX4LfwvQ@mail.gmail.com>

Derek Hans <derek.hans@gmail.com> writes:
>> However, wild-guess time: it might be that without access to the
>> table statistics, the "search like '%yo'" condition is estimated
>> to be too unselective to make an indexscan profitable.  And putting
>> RLS in the way would disable that access if the ~~ operator is not
>> marked leakproof, which it isn't.

> I didn't realize you could set access to table statistics. How do I enable
> this access for this user?

You don't --- there's a hard-wired restriction against applying leaky
operators to the table statistics, because they might leak values that
the current user isn't supposed to be able to see.  Overriding that
would pretty much destroy the value of RLS.

It's possible you could get away with marking ~~ (textlike) as leakproof.
The default marking is based on the assumption that textlike might throw
errors based on its RHS input not being a valid pattern ... but I think
the only such error is "LIKE pattern must not end with escape character",
and maybe that's not a big enough leak to concern you.

> If that's not possible, it sounds like it
> effectively blocks the use of GIN/GIST indexes when RLS is in use.

There's a whole lot of daylight between "it doesn't pick an indexscan in
this one example" and "it effectively blocks the use of GIN/GIST".

			regards, tom lane





view thread (12+ messages)  latest in thread

Message-ID: <14241.1565725716@sss.pgh.pa.us>
Permalink:  ../14241.1565725716@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14241.1565725716@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, derek.hans@gmail.com
  Subject: Re: GIST/GIN index not used with Row Level Security
  In-Reply-To: <14241.1565725716@sss.pgh.pa.us>
  References: <CAGrP7a2t+JbeuxpQY+RSvNe4fr3+==UmyimwV0GCD+wcrSSb=w@mail.gmail.com> <12552.1565723566@sss.pgh.pa.us> <CAGrP7a3JcEorwM98OGn7s-TZ1os8rubCqeEXLgqeZrvX4LfwvQ@mail.gmail.com> <14241.1565725716@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