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 1jIbdY-0007Dk-4P for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Mar 2020 17:22:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jIbdW-0006sA-Q2 for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Mar 2020 17:22:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jIbdW-0006s3-H7 for pgsql-hackers@lists.postgresql.org; Sun, 29 Mar 2020 17:22:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIbdT-00056c-HF for pgsql-hackers@postgresql.org; Sun, 29 Mar 2020 17:22:14 +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 02THM4dZ029513; Sun, 29 Mar 2020 13:22:04 -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: <20200329171415.GL20103@telsasoft.com> References: <20200311111921.GQ29065@telsasoft.com> <21724.1583955158@sss.pgh.pa.us> <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> Comments: In-reply-to Justin Pryzby message dated "Sun, 29 Mar 2020 12:14:15 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29511.1585502524.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Mar 2020 13:22:04 -0400 Message-ID: <29512.1585502524@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby writes: > On Sun, Mar 29, 2020 at 12:37:05PM -0400, Tom Lane wrote: >> After looking at the callers of pg_ls_dir_files, and noticing that >> it's already defined to ignore anything that's not a regular file, >> I think switching to lstat makes sense. > Yea, only pg_ls_dir() shows special file types (and currently the others= even > hide dirs). > The essence of your patch is to ignore ENOENT, but you also changed to u= se > lstat(), which seems unrelated. That means we'll now hide (non-broken) > symlinks. Is that intentional/needed ? 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. In practice, since these directories shouldn't contain symlinks, it's likely moot. The only place in PG data directories where we actually expect symlinks is pg_tablespace ... and that contains symlinks to directories, so that this function would ignore them anyway. regards, tom lane