Re: pg_ls_tmpdir()

From: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_ls_tmpdir()
Date: 2018-10-01 15:50:21
Message-ID: 69FD7E51-2B13-41FD-9438-17395C73F5BF@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 9/26/18, 3:36 PM, "Laurenz Albe" <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> The patch applies, builds without warning and passes "make check-world".

Thanks for the review!

> Since pgsql_tmp is only created when the first temp file is written,
> calling the function on a newly initdb'ed data directory fails with
>
> ERROR: could not open directory "base/pgsql_tmp": No such file or directory
>
> This should be fixed; it shouldn't be an error.

Done.

> Calling the function with a non-existing tablespace OID produces:
>
> ERROR: could not open directory "pg_tblspc/1665/PG_12_201809121/pgsql_tmp": No such file or directory
>
> Wouldn't it be better to have a check if the tablespace exists?

Done.

> About the code:
> The catversion bump shouldn't be part of the patch, it will
> rot too quickly. The committer is supposed to add it.

Removed.

> I think the idea to have such a function is fine, but I have two doubts:
>
> 1. Do we really need two functions, one without input argument
> to list the default tablespace?
> I think that anybody who uses with such a function whould
> be able to feed the OID of "pg_default".

That seems reasonable to me. I've removed the second version of the
function.

> 2. There already are functions "pg_ls_logdir" and "pg_ls_waldir",
> and I can imagine new requests, e.g. pg_ls_datafiles() to list the
> data files in a database directory.
>
> It may make sense to have a generic function like
>
> pg_ls_dir(dirname text, tablespace oid)
>
> instead. But maybe that's taking it too far...

There is an existing pg_ls_dir() function that appears to be available
only to superusers. IMO it's also nice to break out specific "safe"
directories like this for other roles (e.g. pg_monitor).

Nathan

Attachment Content-Type Size
tmpdir_patch_v2.patch application/octet-stream 6.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Wong 2018-10-01 15:52:23 Re: Odd 9.4, 9.3 buildfarm failure on s390x
Previous Message Justin Pryzby 2018-10-01 15:45:47 Re: buildfarm and git pull