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 1jCk7M-0000KR-4X for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2020 13:12:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jCk7K-0004xR-RL for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2020 13:12:46 +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 1jCk7K-0004xJ-CI for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2020 13:12:46 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jCk7B-0001SC-Cx for pgsql-hackers@postgresql.org; Fri, 13 Mar 2020 13:12:45 +0000 Received: by mail-qt1-x843.google.com with SMTP id t13so7346396qtn.13 for ; Fri, 13 Mar 2020 06:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=doc6Gb6mywc9w9aXCnrOR6Fuc2fEACxegEB1MKPPTp4=; b=h0N6iTcN+UMMrGqW2iW/JagEYNHF9cmzdWVp7qKoIMNzayU3D4lf/RG/2cgn6qN0tj s24NjEV1HnztfjoJDSzoMLkS2Ub3eYeBcw4iE1q6ZW3XbRAvu5LhbiwS7mqHFduforlL 8LsWr9g20/BoN2nWvA0P1KniF/vBr2aIhuXqSuguaGSK+Ua/CfwLXLYTMIMEDz8mRgkM TL2Ulr2C3UN/+EZPrKixjMvWDwEcWJgdLJ1gb5auVzxkr4bUbzvRzcI9eM93AuYLfCfu q1GqqBIw+tJtLatzmL30q1/bkvnJPvP+E0E3Dnk70Qmj5R7/6cOaRXh3/ilRgsBD5kkQ qDGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=doc6Gb6mywc9w9aXCnrOR6Fuc2fEACxegEB1MKPPTp4=; b=L4lAd/oClGjFe4LEt4D6yRb+wNmpSaJZllGSYQeOzAh/nkFCg8H1Hm6b+7U2NWfSW7 qKyN1fvgCKfmUvelLtXgVfOKYpSAWg7B8/2Bf8MzyMP7mn7ZQIwObRBSCikylHrO5udj Hbvbnwsf8itumCUBTQaMrU14JeUypPv1i/OtT2zOGULrUD6EY284yQYUPJod1EGRaMiN tQ369d48FVv0wO0vIyYCHU7MVJ0ZKRQjoE3sgg2wssQcKiFvWlLdqQQjlwbfOpBQdU9M /DDT79/fzQG/nPoCA6np2hUalHA5hGFw6PsQ+9MLVZRim6CJ3r/UKr/KjAFzBHNBDI/8 oIdA== X-Gm-Message-State: ANhLgQ3OE8C3HkuwS5Jy7nLOt8n2b9wGugalW2vT8FNzC6sc0ta3RZMw 3jDv+Q7cGIeyAaI8xmMaE1e2mQ== X-Google-Smtp-Source: ADFU+vsx2GL8gQGzM/QGoPk8SFpCX61GkYIZhNsQVRWq8OBgsL0E6fZzPYUamWT3wudXcUUjCny80Q== X-Received: by 2002:ac8:7501:: with SMTP id u1mr12496511qtq.149.1584105155675; Fri, 13 Mar 2020 06:12:35 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id l60sm8389615qtd.35.2020.03.13.06.12.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Mar 2020 06:12:34 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id CA0BD800926; Fri, 13 Mar 2020 08:12:32 -0500 (CDT) Date: Fri, 13 Mar 2020 08:12:32 -0500 From: Justin Pryzby To: Fabien COELHO Cc: Alvaro Herrera , David Steele , pgsql-hackers@postgresql.org, "Bossart, Nathan" , Thomas Munro , Tom Lane Subject: Re: pg_ls_tmpdir to show directories and shared filesets (and pg_ls_*) Message-ID: <20200313131232.GO29065@telsasoft.com> References: <20200303200117.GI684@telsasoft.com> <20200303202313.GA28076@alvherre.pgsql> <20200305161838.GJ684@telsasoft.com> <20200306233507.GN684@telsasoft.com> <20200307214010.GB1357@telsasoft.com> <20200310183037.GA29065@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rCwQ2Y43eQY6RBgR" Content-Disposition: inline In-Reply-To: <20200310183037.GA29065@telsasoft.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --rCwQ2Y43eQY6RBgR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline @cfbot: rebased onto 085b6b6679e73b9b386f209b4d625c7bc60597c0 The merge conflict presents another opportunity to solicit comments on the new approach. Rather than making "recurse into tmpdir" the end goal: - add a function to show metadata of an arbitrary dir; - add isdir arguments to pg_ls_* functions (including pg_ls_tmpdir but not pg_ls_dir). - maybe add pg_ls_dir_recurse, which satisfies the original need; - retire pg_ls_dir (does this work with tuplestore?) - profit The alternative seems to be to go back to Alvaro's earlier proposal: - not only add "isdir", but also recurse; I think I would insist on adding a general function to recurse into any dir. And *optionally* change ps_ls_* to recurse (either by accepting an argument, or by making that a separate patch to debate). tuplestore is certainly better than keeping a stack/List of DIRs for this. On Tue, Mar 10, 2020 at 01:30:37PM -0500, Justin Pryzby wrote: > I took a step back, and I wondered whether we should add a generic function for > listing a dir with metadata, possibly instead of changing the existing > functions. Then one could do pg_ls_dir_metadata('pg_wal',false,false); > > Since pg8.1, we have pg_ls_dir() to show a list of files. Since pg10, we've > had pg_ls_logdir and pg_ls_waldir, which show not only file names but also > (some) metadata (size, mtime). And since pg12, we've had pg_ls_tmpfile and > pg_ls_archive_statusdir, which also show metadata. > > ...but there's no a function which lists the metadata of an directory other > than tmp, wal, log. > > One can do this: > |SELECT b.*, c.* FROM (SELECT 'base' a)a, LATERAL (SELECT a||'/'||pg_ls_dir(a.a)b)b, pg_stat_file(b)c; > ..but that's not as helpful as allowing: > |SELECT * FROM pg_ls_dir_metadata('.',true,true); > > There's also no function which recurses into an arbitrary directory, so it > seems shortsighted to provide a function to recursively list a tmpdir. > > Also, since pg_ls_dir_metadata indicates whether the path is a dir, one can > write a SQL function to show the dir recursively. It'd be trivial to plug in > wal/log/tmp (it seems like tmpdirs of other tablespace's are not entirely > trivial). > |SELECT * FROM pg_ls_dir_recurse('base/pgsql_tmp'); > > Also, on a neighboring thread[1], Tom indicated that the pg_ls_* functions > should enumerate all files during the initial call, which sounds like a bad > idea when recursively showing directories. If we add a function recursing into > a directory, we'd need to discuss all the flags to expose to it, like recurse, > ignore_errors, one_filesystem?, show_dotfiles (and eventually bikeshed all the > rest of the flags in find(1)). > > My initial patch [2] changed ls_tmpdir to show metadata columns including > is_dir, but not decend. It's pretty unfortunate if a function called > pg_ls_tmpdir hides shared filesets, so maybe it really is best to change that > (it's new in v12). > > I'm interested to in feedback on the alternative approach, as attached. The > final patch to include all the rest of columns shown by pg_stat_file() is more > of an idea/proposal and not sure if it'll be desirable. But pg_ls_tmpdir() is > essentially the same as my v1 patch. > > This is intended to be mostly independent of any fix to the WARNING I reported > [1]. Since my patch collapses pg_ls_dir into pg_ls_dir_files, we'd only need > to fix one place. I'm planning to eventually look into Tom's suggestion of > returning tuplestore to fix that, and maybe rebase this patchset on top of > that. > > -- > Justin > > [1] https://www.postgresql.org/message-id/flat/20200308173103.GC1357%40telsasoft.com > [2] https://www.postgresql.org/message-id/20191214224735.GA28433%40telsasoft.com --rCwQ2Y43eQY6RBgR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v10-0001-Document-historic-behavior-about-hiding-director.patch"