pgsql: Fix fd.c to preserve errno where needed.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix fd.c to preserve errno where needed.
Date: 2013-05-16 19:05:31
Message-ID: E1Ud3UZ-00023y-Uv@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix fd.c to preserve errno where needed.

PathNameOpenFile failed to ensure that the correct value of errno was
returned to its caller after a failure (because it incorrectly supposed
that free() can never change errno). In some cases this would result
in a user-visible failure because an expected ENOENT errno was replaced
with something else. Bogus EINVAL failures have been observed on OS X,
for example.

There were also a couple of places that could mangle an important value
of errno if FDDEBUG was defined. While the usefulness of that debug
support is highly debatable, we might as well make it safe to use,
so add errno save/restore logic to the DO_DB macro.

Per bug #8167 from Nelson Minar, diagnosed by RhodiumToad.
Back-patch to all supported branches.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/6563fb2b45146852601e63828308fe04fb03b9e9

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

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2013-05-16 19:05:32 pgsql: Fix fd.c to preserve errno where needed.
Previous Message Tom Lane 2013-05-16 16:30:45 pgsql: Fix some uses of "the quick brown fox".