Re: "current directory" in a server error message

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: "current directory" in a server error message
Date: 2023-03-16 04:02:05
Message-ID: CALj2ACXywqz2RfRQW1k6KdKmFjfCcOq1EWX2BnzqCPzJeNyaaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 16, 2023 at 7:47 AM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
>
> Hello.
>
> When I ran pg_ls_dir('..'), the error message I received was somewhat
> difficult to understand.
>
> postgres=> select * from pg_ls_dir('..');
> ERROR: path must be in or below the current directory
>
> As far as I know the concept of a "current directory" doesn't apply to
> the server side. In fact, the function comment for
> convert_and_check_filename explicitly states that:
>
> > * Filename may be absolute or relative to the DataDir
>
> Thus I think that the message should read "path must be in or below
> the data directory" instead.
>
> What do you think about making this change?

Well yes. As far as postgres processes are concerned their working
directory is set to data directory by the postmaster in
ChangeToDataDir() and all the children will inherit that setting. So,
I see nothing wrong in being explicit about it in the error messages.

BTW, adminpack too has the same error message.

FWIW, here are the steps to generate the error:
create role foo with nosuperuser;
grant execute on function pg_ls_dir(text) to foo;
set role foo;
select * from pg_ls_dir('..');

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2023-03-16 04:18:07 Re: Initial Schema Sync for Logical Replication
Previous Message Andres Freund 2023-03-16 03:55:33 Re: meson documentation build open issues