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 1jDWrG-0002R3-3m for pgsql-hackers@arkaria.postgresql.org; Sun, 15 Mar 2020 17:15:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDWrE-0003uL-UI for pgsql-hackers@arkaria.postgresql.org; Sun, 15 Mar 2020 17:15:24 +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 1jDWrE-0003uD-Hm for pgsql-hackers@lists.postgresql.org; Sun, 15 Mar 2020 17:15:24 +0000 Received: from courriel.mines-paristech.fr ([77.158.173.149] 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 1jDWr6-0007gl-TU for pgsql-hackers@postgresql.org; Sun, 15 Mar 2020 17:15:19 +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 AD0BB55E3B; Sun, 15 Mar 2020 18:15:04 +0100 (CET) Received: from pseudo (126.237.219.88.rev.sfr.net [88.219.237.126]) (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 39F6A201B5; Sun, 15 Mar 2020 18:15:04 +0100 (CET) Date: Sun, 15 Mar 2020 18:15:02 +0100 (CET) From: Fabien COELHO X-X-Sender: fabien@pseudo To: Justin Pryzby 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_*) In-Reply-To: <20200313131232.GO29065@telsasoft.com> Message-ID: 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> <20200313131232.GO29065@telsasoft.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="2056645051-1912256913-1584276379=:12715" Content-ID: X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrudefuddgtdefucetufdoteggodetrfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeffhffvufgjkfhffgggtgesmhdtreertderjeenucfhrhhomhephfgrsghivghnucevqffgnffjqfcuoegtohgvlhhhohestghrihdrvghnshhmphdrfhhrqeenucfkphepkeekrddvudelrddvfeejrdduvdeinecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --2056645051-1912256913-1584276379=:12715 Content-Type: text/plain; FORMAT=flowed; CHARSET=UTF-8 Content-Transfer-Encoding: 8BIT Content-ID: Hello Justin, Some feedback on v10: All patches apply cleanly, one on top of the previous. I really wish there would be less than 9 patches… * v10.1 doc change: ok * v10.2 doc change: ok, not sure why it is not merged with previous * v10.3 test add: could be merge with both previous Tests seem a little contrived. I'm wondering whether something more straightforward could be proposed. For instance, once the tablespace is just created but not used yet, probably we do know that the tmp file exists and is empty? * v10.4 at least, some code! Compiles, make check ok. pg_ls_dir_files: I'm fine with the flag approach given the number of switches and the internal nature of the function. I'm not sure of the "FLAG_" prefix which seems too generic, even if it is local. I'd suggest "LS_DIR_*", maybe, as a more specific prefix. ISTM that Pg style requires spaces around operators. I'd suggest some parenthesis would help as well, eg: "flags&FLAG_MISSING_OK" -> "(flags & FLAG_MISSING_OK)" and other instances. About: if (S_ISDIR(attrib.st_mode)) { if (flags&FLAG_SKIP_DIRS) continue; } and similars, why not the simpler: if (S_ISDIR(attrib.st_mode) && (flags & FLAG_SKIP_DIRS)) continue; Especially that it is done like that in previous cases. Maybe I'd create defines for long and common flag specs, eg: #define ..._LS_SIMPLE (FLAG_SKIP_DIRS|FLAG_SKIP_HIDDEN|FLAG_SKIP_SPECIAL|FLAG_METADATA) No attempt at recursing. I'm not sure about these asserts: /* isdir depends on metadata */ Assert(!(flags&FLAG_ISDIR) || (flags&FLAG_METADATA)); Hmmm. Why? /* Unreasonable to show isdir and skip dirs */ Assert(!(flags&FLAG_ISDIR) || !(flags&FLAG_SKIP_DIRS)); Hmmm. Why would I prevent that, even if it has little sense, it should work. I do not see having false on the isdir column as an actual issue. * v10.5 add is_dir column, a few tests & doc. Ok. * v10.6 behavior change for existing functions, always show isdir column, and removal of IS_DIR flag. I'm unsure why the features are removed, some use case may benefit from the more complete function? Maybe flags defs should not be changed anyway? I do not like much the "if (...) /* empty */;" code. Maybe it could be caught more cleanly later in the conditional structure. * v10.7 adds "pg_ls_dir_recurse" function Using sql recurse to possibly to implement the feature is pretty elegant and limits open directories to one at a time, which is pretty neat. Doc looks incomplete and the example is very contrived and badly indented. The function definition does not follow the style around: uppercase whereas all others are lowercase, "" instead of '', no "as"… I do not understand why oid 8511 is given to the new function. I do not understand why UNION ALL and not UNION. I would have put the definition after "pg_ls_dir_metadata" definition. pg_ls_dir_metadata seems defined as (text,bool,bool) but called as (text,bool,bool,bool). Maybe a better alias could be given instead of x? There are no tests for the new function. I'm not sure it would work. * v10.8 change flags & add test on pg_ls_logdir(). I'm unsure why it is done at this stage. * v10.9 change some ls functions and fix patch 10.7 issue I'm unsure why it is done at this stage. "make check" ok. -- Fabien. --2056645051-1912256913-1584276379=:12715--