Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pyv67-0006U0-KH for pgsql-bugs@arkaria.postgresql.org; Tue, 16 May 2023 13:52:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pyv65-0006AF-Db for pgsql-bugs@arkaria.postgresql.org; Tue, 16 May 2023 13:52:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pyv65-0006A5-4j for pgsql-bugs@lists.postgresql.org; Tue, 16 May 2023 13:52:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pyv62-0008Fz-DT for pgsql-bugs@lists.postgresql.org; Tue, 16 May 2023 13:52:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 34GDq8qP2591315; Tue, 16 May 2023 09:52:09 -0400 From: Tom Lane To: hu_yajun@qq.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17936: Memory Leak when OPERATOR FAMILY use LANGUAGE SQL function In-reply-to: <17936-ccbf22f31c04b6cf@postgresql.org> References: <17936-ccbf22f31c04b6cf@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 16 May 2023 13:16:43 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2591313.1684245128.1@sss.pgh.pa.us> Date: Tue, 16 May 2023 09:52:08 -0400 Message-ID: <2591314.1684245128@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form 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