pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix error handling in pg_flush_data() and FilePrefetch()
Date: Sat, 31 Oct 2026 09:48:14 +0000
Message-ID: <E1xN5h8-00000001W7P-2bap@gemulon.postgresql.org> (raw)

Fix error handling in pg_flush_data() and FilePrefetch()

posix_fadvise() returns an error code directly instead of setting
errno. However, pg_flush_data() uses %m and errcode_for_file_access()
to report errors without setting errno, potentially reporting an
unrelated error. Fix this by assigning the returned error code to
errno before reporting the error.

FilePrefetch() is documented to return an errno error code on failure,
but it returns -1 when FileAccess() fails. Fix this by returning errno
instead.

The first bug one only affects a warning, and the second doesn't have
any effect because the only existing caller ignores the return value.
So these are pretty harmless bugs, but let's be tidy.

Author: Chao Li <lic@highgo.com>
Discussion: https://www.postgresql.org/message-id/F1916C7A-F152-4AF3-87A9-40492D8B3670@gmail.com
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1cdfea37c268d41b47e1cf968103cb9866feec4d

Modified Files
--------------
src/backend/storage/file/fd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1xN5h8-00000001W7P-2bap@gemulon.postgresql.org>
Permalink:  ../E1xN5h8-00000001W7P-2bap@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xN5h8-00000001W7P-2bap@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Fix error handling in pg_flush_data() and FilePrefetch()
  In-Reply-To: <E1xN5h8-00000001W7P-2bap@gemulon.postgresql.org>
  References: <E1xN5h8-00000001W7P-2bap@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox