Re: BUG #17936: Memory Leak when OPERATOR FAMILY use LANGUAGE SQL function - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17936: Memory Leak when OPERATOR FAMILY use LANGUAGE SQL function
Date
Msg-id 2591314.1684245128@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17936: Memory Leak when OPERATOR FAMILY use LANGUAGE SQL function  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Memory leak on subquery as scalar operand
Next
From: Tom Lane
Date:
Subject: Re: BUG #17935: Incorrect memory access in fuzzystrmatch/difference()