PG Bug reporting form <noreply@postgresql.org> writes:
> I guess I found a memory leak problem when OPERATOR FAMILY use LANGUAGE
> SQL function.
> ** Problem **
> I build postgresql with tag REL_15_3, and run following SQL.
> --
> CREATE OR REPLACE FUNCTION pg_catalog.text_cmp_bpchar(text, bpchar)
> RETURNS int4
> AS'select pg_catalog.bttextcmp($1, $2::text)'
> LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE;
> ALTER OPERATOR FAMILY text_ops USING btree ADD
> OPERATOR 3 =(bpchar, bpchar),
> FUNCTION 1 pg_catalog.text_cmp_bpchar(text, bpchar);
Don't do that. Btree expects comparison support functions not to leak
memory. There's zero interest in relaxing that requirement, and also
zero interest in making generic SQL-language functions meet it.
regards, tom lane