Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jB2af-0001Yk-6X for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 20:32:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jB2Zf-0001wg-Mv for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 20:30:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jB2Zf-0001wZ-AV for pgsql-hackers@lists.postgresql.org; Sun, 08 Mar 2020 20:30:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jB2ZZ-0002GD-7Y for pgsql-hackers@postgresql.org; Sun, 08 Mar 2020 20:30:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 028KUiMB008035; Sun, 8 Mar 2020 16:30:44 -0400 From: Tom Lane To: Justin Pryzby cc: pgsql-hackers@postgresql.org, Fabien COELHO , Alvaro Herrera , David Steele , "Bossart, Nathan" , Thomas Munro Subject: Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction In-reply-to: <5679.1583696409@sss.pgh.pa.us> References: <20200308173103.GC1357@telsasoft.com> <27334.1583692669@sss.pgh.pa.us> <20200308191456.GD1357@telsasoft.com> <5679.1583696409@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 08 Mar 2020 15:40:09 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8033.1583699444.1@sss.pgh.pa.us> Date: Sun, 08 Mar 2020 16:30:44 -0400 Message-ID: <8034.1583699444@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > I've just finished scanning the source code and concluding that all > of these functions are similarly broken: > pg_ls_dir > pg_ls_dir_files > pg_tablespace_databases > pg_logdir_ls_internal > pg_timezone_names > pgrowlocks BTW, another thing I noticed while looking around is that some of the functions using SRF_RETURN_DONE() think they should clean up memory beforehand. This is a waste of code/cycles, as long as the memory was properly allocated in funcctx->multi_call_memory_ctx, because funcapi.c takes care of deleting that context. We should probably document that *any* manual cleanup before SRF_RETURN_DONE() is an antipattern. If you have to have cleanup, it needs to be done via RegisterExprContextCallback instead. regards, tom lane