public inbox for [email protected]
help / color / mirror / Atom feedFrom: Michael Paquier <[email protected]>
To: Postgres hackers <[email protected]>
Cc: Robert Haas <[email protected]>
Subject: Incorrect errno used in OpenWalSummaryFile()
Date: Mon, 2 Feb 2026 12:54:26 +0900
Message-ID: <[email protected]> (raw)
Hi all,
While looking at walsummary.c for a different thread, I have bumped
into this code:
OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok)
[...]
file = PathNameOpenFile(path, O_RDONLY);
if (file < 0 && (errno != EEXIST || !missing_ok))
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not open file \"%s\": %m", path)));
And it seems to me that this EEXIST should be an ENOENT? The top of
the function also documents that we want to handle an error when a
summary file does not exist. The comment makes sense to me, not the
code.
It's also worth noting that this function has two callers, both use
missing_ok = false, meaning that the errno check does not really
matter today. If someone plays with this code on HEAD or the
back-branches and decides to introduce a missing_ok=true call, it
could matter, so I'd rather not change this function signature.
This issue has been mentioned here as well, I've just bumped into it
independently a few hours ago:
https://www.postgresql.org/message-id/[email protected]
Regards,
--
Michael
diff --git a/src/backend/backup/walsummary.c b/src/backend/backup/walsummary.c
index 4ee510092f99..4cd1824fbc6b 100644
--- a/src/backend/backup/walsummary.c
+++ b/src/backend/backup/walsummary.c
@@ -214,7 +214,7 @@ OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok)
LSN_FORMAT_ARGS(ws->end_lsn));
file = PathNameOpenFile(path, O_RDONLY);
- if (file < 0 && (errno != EEXIST || !missing_ok))
+ if (file < 0 && (errno != ENOENT || !missing_ok))
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not open file \"%s\": %m", path)));
Attachments:
[text/plain] wal-summary-errno.patch (563B, ../[email protected]/2-wal-summary-errno.patch)
download | inline diff:
diff --git a/src/backend/backup/walsummary.c b/src/backend/backup/walsummary.c
index 4ee510092f99..4cd1824fbc6b 100644
--- a/src/backend/backup/walsummary.c
+++ b/src/backend/backup/walsummary.c
@@ -214,7 +214,7 @@ OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok)
LSN_FORMAT_ARGS(ws->end_lsn));
file = PathNameOpenFile(path, O_RDONLY);
- if (file < 0 && (errno != EEXIST || !missing_ok))
+ if (file < 0 && (errno != ENOENT || !missing_ok))
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not open file \"%s\": %m", path)));
[application/pgp-signature] signature.asc (833B, ../[email protected]/3-signature.asc)
download
view thread (3+ 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], [email protected]
Subject: Re: Incorrect errno used in OpenWalSummaryFile()
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