supautils icon indicating copy to clipboard operation
supautils copied to clipboard

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

Open olirice opened this issue 2 years ago • 3 comments

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

  • if it is possible to enable creating operator families and operator classes using the postgres role
  • If possible, how much work would it be

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

olirice avatar Jan 18 '24 18:01 olirice

The company I work for maintains a Postgres extension that requires the ability to create operator families and classes. Can anyone at Supabase confirm whether this is possible?

freshtonic avatar Apr 10 '25 00:04 freshtonic

create operator is functional via native extensions. For example pgvector defines several operators for vector comparison

it is not currently supported as end-user activity

olirice avatar Apr 10 '25 16:04 olirice

👍 on this. I have a custom type that would really benefit from an operator class.

ebellani avatar Oct 28 '25 21:10 ebellani