aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablespace.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-01-29 20:04:08 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2014-01-29 20:04:08 -0500
commitaf259c691f13bafe4977f61adf10d81c7ece6c69 (patch)
treeb04ec18e93399b404d05201234b7d296197f9509 /src/backend/commands/tablespace.c
parent1b384aff158a840fed4e9f4f366ba8d7c6ed42fb (diff)
downloadpostgresql-af259c691f13bafe4977f61adf10d81c7ece6c69.tar.gz
postgresql-af259c691f13bafe4977f61adf10d81c7ece6c69.zip
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.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 22b489a9204..c80821e2d57 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -769,10 +769,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);