diff options
author | Tom Lane | 2014-01-30 01:03:57 +0000 |
---|---|---|
committer | Tom Lane | 2014-01-30 01:04:43 +0000 |
commit | 571addd729a400cece396d79696adcc63387e43b (patch) | |
tree | 5444989203f8b2633295a23cf8737c626ba10da6 /src/backend/commands/tablespace.c | |
parent | 120c5cc761e0d99a9a2f3349f4031850b0dbd5a0 (diff) |
Fix unsafe references to errno within error messaging logic.
Various places were supposing that errno could be expected to hold still
within an ereport() nest or similar contexts. This isn't true necessarily,
though in some cases it accidentally failed to fail depending on how the
compiler chanced to order the subexpressions. This class of thinko
explains recent reports of odd failures on clang-built versions, typically
missing or inappropriate HINT fields in messages.
Problem identified by Christian Kruse, who also submitted the patch this
commit is based on. (I fixed a few issues in his patch and found a couple
of additional places with the same disease.)
Back-patch as appropriate to all supported branches.
Diffstat (limited to 'src/backend/commands/tablespace.c')
-rw-r--r-- | src/backend/commands/tablespace.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index d73e5e826dc..60fd939175f 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -782,10 +782,14 @@ remove_symlink: else { if (unlink(linkloc) < 0) - ereport(redo ? LOG : (errno == ENOENT ? WARNING : ERROR), + { + int saved_errno = errno; + + ereport(redo ? LOG : (saved_errno == ENOENT ? WARNING : ERROR), (errcode_for_file_access(), errmsg("could not remove symbolic link \"%s\": %m", linkloc))); + } } pfree(linkloc_with_version_dir); |