supabase / supautils

PostgreSQL extension that secures a cluster on a cloud environment
https://supabase.github.io/supautils
Apache License 2.0
59 stars 13 forks source link

Allow `postgres` role to `create operator class` and `create operator family` #72

Open olirice opened 9 months ago

olirice commented 9 months ago

Feature request

A user is requesting the ability to create operator class and create operator family so they can bring a bit of a DSL-y experience to their project complete with custom operators that can leverage indexes.

Repro case

CREATE OR REPLACE FUNCTION integer_compare(a integer, b integer) RETURNS boolean AS $$
BEGIN
    RETURN a > b;
END;
$$ LANGUAGE plpgsql;

CREATE OPERATOR @@ (
    LEFTARG = integer,
    RIGHTARG = integer,
    PROCEDURE = integer_compare,
    RETURNS = boolean
);

CREATE OPERATOR FAMILY integer_family USING btree;

CREATE OPERATOR CLASS integer_ops FOR TYPE integer USING btree FAMILY integer_family AS
    OPERATOR 1 @@ (integer, integer);

Currently this will fail on

CREATE OPERATOR FAMILY integer_family USING btree;

with

ERROR:  42501: must be superuser to create an operator family

The existing postgres permissions system does not have a dedicated role for these capabilities.

This task is to evaluate

Given how niche the request is, unless it only requires an extremely straightforward and safe change we should not implement this feature.