Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jImmi-0005pA-Of for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2020 05:16:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jImmh-0004kI-Di for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2020 05:16:27 +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 1jImmh-0004iu-6s for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2020 05:16:27 +0000 Received: from courriel-2.mines-paristech.fr ([77.158.173.19] helo=antispam-1.ensmp.fr) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jImmc-0001XQ-LK for pgsql-hackers@postgresql.org; Mon, 30 Mar 2020 05:16:26 +0000 Received: from smtp-5.mines-paristech.fr (smtp.mines-paristech.fr [77.158.173.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by antispam-1.ensmp.fr (antispam.mines-paristech.fr) with ESMTPS id 21C69578B3; Mon, 30 Mar 2020 07:16:19 +0200 (CEST) Received: from pseudo (11.237.219.88.rev.sfr.net [88.219.237.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-5.mines-paristech.fr (Postfix) with ESMTPSA id 9DD6F20146; Mon, 30 Mar 2020 07:16:18 +0200 (CEST) Date: Mon, 30 Mar 2020 07:16:17 +0200 (CEST) From: Fabien COELHO X-X-Sender: fabien@pseudo To: Justin Pryzby cc: Tom Lane , pgsql-hackers@postgresql.org, 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: <20200329201215.GM20103@telsasoft.com> Message-ID: References: <20200312121156.GB29065@telsasoft.com> <20200316155306.GM26184@telsasoft.com> <3061.1584409130@sss.pgh.pa.us> <20200317020017.GT26184@telsasoft.com> <24244.1585415634@sss.pgh.pa.us> <20200328183904.GI20103@telsasoft.com> <28906.1585422475@sss.pgh.pa.us> <27064.1585499825@sss.pgh.pa.us> <20200329171415.GL20103@telsasoft.com> <29512.1585502524@sss.pgh.pa.us> <20200329201215.GM20103@telsasoft.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrudeigedgleegucetufdoteggodetrfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeffhffvufgjkfhffgggtgesthdtredttdervdenucfhrhhomhephfgrsghivghnucevqffgnffjqfcuoegtohgvlhhhohestghrihdrvghnshhmphdrfhhrqeenucfkphepkeekrddvudelrddvfeejrdduudenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Justin, >> Well, the following comment says "ignore anything but regular files", >> so I'm supposing that that is the behavior that we actually want here >> and failed to implement correctly. There might be scope for >> additional directory-reading functions, but I'd think you'd want >> more information (such as the file type) returned from anything >> that doesn't act this way. > > Maybe pg_stat_file() deserves similar attention ? Right now, it'll fail on a > broken link. If we changed it to lstat(), then it'd work, but it'd also show > metadata for the *link* rather than its target. Yep. I think this traditional answer is the rational answer. As I wrote about an earlier version of the patch, ISTM that instead of reinventing, extending, adapting various ls variants (with/without metadata, which show only files, which shows target of links, which shows directory, etc.) we would just need *one* postgres "ls" implementation which would be like "ls -la arg" (returns file type, dates), and then everything else is a wrapper around that with appropriate filtering that can be done at the SQL level, like you started with recurse. It would reduce the amount of C code and I find the SQL-level approach quite elegant. -- Fabien.