From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net> |
Cc: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, David Steele <david(at)pgmasters(dot)net>, pgsql-hackers(at)postgresql(dot)org, "Bossart, Nathan" <bossartn(at)amazon(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Subject: | Re: pg_ls_tmpdir to show directories and shared filesets (and pg_ls_*) |
Date: | 2020-12-23 19:17:10 |
Message-ID: | 20201223191710.GR30237@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Nov 23, 2020 at 04:14:18PM -0500, Tom Lane wrote:
> * I don't think it's okay to change the existing signatures of
> pg_ls_logdir() et al. Even if you can make an argument that it's
> not too harmful to add more output columns, replacing pg_stat_file's
> isdir output with something of a different name and datatype is most
> surely not OK --- there is no possible way that doesn't break existing
> user queries.
>
> I think possibly a more acceptable approach is to leave these functions
> alone but add documentation explaining how to get the additional info.
> You could say things along the lines of "pg_ls_waldir() is the same as
> pg_ls_dir_metadata('pg_wal') except for showing fewer columns."
On Mon, Nov 23, 2020 at 06:06:19PM -0500, Tom Lane wrote:
> I'm mostly concerned about removing the isdir output of pg_stat_file().
> Maybe we could compromise to the extent of keeping that, allowing it
> to be partially duplicative of a file-type-code output column.
On Tue, Nov 24, 2020 at 11:53:22AM -0500, Stephen Frost wrote:
> I don't have any particular issue with keeping isdir as a convenience
> column. I agree it'll now be a bit duplicative but that seems alright.
Maybe we should do what Tom said, and leave pg_ls_* unchanged, but also mark
them as deprecated in favour of:
| pg_ls_dir_metadata(dir), dir={'pg_wal/archive_status', 'log', 'pg_wal', 'base/pgsql_tmp'}
However, pg_ls_tmpdir is special since it handles tablespace tmpdirs, which it
seems is not trivial to get from sql:
+SELECT * FROM (SELECT DISTINCT COALESCE(NULLIF(pg_tablespace_location(b.oid),'')||suffix, 'base/pgsql_tmp') AS dir
+FROM pg_tablespace b, pg_control_system() pcs,
+LATERAL format('/PG_%s_%s', left(current_setting('server_version_num'), 2), pcs.catalog_version_no) AS suffix) AS dir,
+LATERAL pg_ls_dir_recurse(dir) AS a;
For context, the line of reasoning that led me to this patch series was
something like this:
0) Why can't I list shared tempfiles (dirs) using pg_ls_tmpdir() ?
1) Implement recursion for pg_ls_tmpdir();
2) Eventually realize that it's silly to implement a function to recurse into
one particular directory when no general feature exists;
3) Implement generic facility;
> * I noticed that you did s/stat/lstat/. That's fine on Unix systems,
> but it won't have any effect on Windows systems (cf bed90759f),
> which means that we'll have to document a platform-specific behavioral
> difference. Do we want to go there?
>
> Maybe this patch needs to wait on somebody fixing our lack of real lstat() on Windows.
I think only the "top" patches depend on lstat (for the "type" column and
recursion, to avoid loops). The initial patches are independently useful, and
resolve the original issue of hiding tmpdirs. I've rebased and re-arranged the
patches to reflect this.
--
Justin
Attachment | Content-Type | Size |
---|---|---|
v26-0001-Document-historic-behavior-of-links-to-directori.patch | text/x-diff | 1.1 KB |
v26-0002-pg_stat_file-and-pg_ls_dir_-to-use-lstat.patch | text/x-diff | 2.3 KB |
v26-0003-Add-tests-on-pg_ls_dir-before-changing-it.patch | text/x-diff | 2.3 KB |
v26-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch | text/x-diff | 19.1 KB |
v26-0005-pg_ls_tmpdir-to-show-directories-and-isdir-argum.patch | text/x-diff | 6.3 KB |
v26-0006-pg_ls_-dir-to-show-directories-and-isdir-column.patch | text/x-diff | 9.1 KB |
v26-0007-pg_ls_logdir-to-ignore-error-if-initial-top-dir-.patch | text/x-diff | 3.1 KB |
v26-0008-pg_ls_-dir-to-return-all-the-metadata-from-pg_st.patch | text/x-diff | 17.6 KB |
v26-0009-pg_ls_-pg_stat_file-to-show-file-type.patch | text/x-diff | 21.5 KB |
v26-0010-Preserve-pg_stat_file-isdir.patch | text/x-diff | 4.5 KB |
v26-0011-Add-recursion-option-in-pg_ls_dir_files.patch | text/x-diff | 16.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2020-12-23 19:27:32 | Re: pg_ls_tmpdir to show directories and shared filesets (and pg_ls_*) |
Previous Message | John Naylor | 2020-12-23 18:05:25 | Re: Perform COPY FROM encoding conversions in larger chunks |