public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bruce Momjian <[email protected]>
To: Wei Sun <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Add lasterrno setting for dir_existsfile()
Date: Fri, 12 Aug 2022 18:22:01 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Mon, Jan 10, 2022 at 12:19:28AM +0800, Wei Sun wrote:
> Hi,
>
> Some time ago,the following patch clean up error handling in pg_basebackup's
> walmethods.c.
> https://github.com/postgres/postgres/commit/248c3a9
>
> This patch keep the error state in the DirectoryMethodData struct,
> in most functions, the lasterrno is set correctly, but in function
> dir_existsfile(),
> the lasterrno is not set when the file fails to open.
>
> If this is a correction omission, I think this patch can fix this.
>
> Cheers
> diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c
> index f74bd13..35cf5a8 100644
> --- a/src/bin/pg_basebackup/walmethods.c
> +++ b/src/bin/pg_basebackup/walmethods.c
> @@ -580,7 +580,10 @@ dir_existsfile(const char *pathname)
>
> fd = open(tmppath, O_RDONLY | PG_BINARY, 0);
> if (fd < 0)
> + {
> + dir_data->lasterrno = errno;
> return false;
> + }
> close(fd);
> return true;
> }
Looking at this, the function is used to check if something exists, and
return a boolean. I am not sure it is helpful to also return a ENOENT in
the lasterrno status field. It might be useful to set lasterrno if the
open fails and it is _not_ ENOENT.
--
Bruce Momjian <[email protected]> https://momjian.us
EDB https://enterprisedb.com
Indecision is a decision. Inaction is an action. Mark Batterson
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Add lasterrno setting for dir_existsfile()
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox