FeatureFuel
1

Leakproof enum equality and like/ilike, so RLS queries can use their indexes

Source: supabase/supabase#54373 · opened by @martijn00
Under RLS, Postgres only uses a filter as an index condition (or evaluates it before the policies) when its operator function is LEAKPROOF. Two common filters aren't, and on Supabase the project can't change that, because ALTER FUNCTION ... LEAKPROOF needs a superuser: • Enum equality. enum_eq (and enum_ne, enum_lt, ...) has no proleakproof in src/include/catalog/pg_proc.dat, while texteq does. On an RLS table, where status = 'open' with an index on (organization_id, status) reads every row of the organization and filters after the policies. • like and ilike. textlike and texticlike aren't leakproof, so a pg_trgm index never serves ?name=ilike.*foo* from PostgREST, or a search in a security invoker function, for a user subject to RLS. The same mechanism is behind supabase/storage#1678 (lower(name) in storage.search). Workarounds today • Store status values as text with a check constraint instead of an enum, which loses the type. • M…

No pledges yet. Be the first to back this.

Make a pledge

Pledge your monetary support if this feature is added.

$

Comments

No comments yet.

Replying to

Add a comment

What do you think about this feature request?


Similar requests