Re: pg_ls_tmpdir to show directories and shared filesets (and pg_ls_*)

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: 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>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: pg_ls_tmpdir to show directories and shared filesets (and pg_ls_*)
Date: 2020-03-17 09:21:48
Message-ID: alpine.DEB.2.21.2003170828250.17584@pseudo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


About v13, seens as one patch:

Function "pg_ls_dir_metadata" documentation suggests a variable number of
arguments with brackets, but parameters are really mandatory.

postgres=# SELECT pg_ls_dir_metadata('.');
ERROR: function pg_ls_dir_metadata(unknown) does not exist
LINE 1: SELECT pg_ls_dir_metadata('.');
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
postgres=# SELECT pg_ls_dir_metadata('.', true, true);

The example in the documentation could be better indented. Also, ISTM that
there are two implicit laterals (format & pg_ls_dir_recurse) that I would
make explicit. I'd use the pcs alias explicitely. I'd use meaningful
aliases (eg ts instead of b, …).

On reflection, I think that a boolean "isdir" column is a bad idea because
it is not extensible. I'd propose to switch to the standard "ls" approach
of providing the type as one character: '-' for regular, 'd' for
directory, 'l' for link, 's' for socket, 'c' for character special…

ISTM that "lstat" is not available on windows, which suggests to call
"stat" always, and then "lstat" on un*x and pg ports stuff on win.

I'm wondering about the restriction on directories only. Why should it not
work on a file? Can it be easily extended to work on a simple file? If so,
it could be just "pg_ls".

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2020-03-17 09:26:57 Re: Missing errcode() in ereport
Previous Message Amit Kapila 2020-03-17 08:59:47 Re: Missing errcode() in ereport