aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/tzparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/misc/tzparser.c')
-rw-r--r--src/backend/utils/misc/tzparser.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/backend/utils/misc/tzparser.c b/src/backend/utils/misc/tzparser.c
index f7d6c84514e..cc688dcaba1 100644
--- a/src/backend/utils/misc/tzparser.c
+++ b/src/backend/utils/misc/tzparser.c
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/tzparser.c,v 1.7 2009/01/01 17:23:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/tzparser.c,v 1.8 2009/05/02 22:02:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -326,12 +326,41 @@ ParseTzFile(const char *filename, int depth,
tzFile = AllocateFile(file_path, "r");
if (!tzFile)
{
- /* at level 0, if file doesn't exist, guc.c's complaint is enough */
+ /*
+ * Check to see if the problem is not the filename but the directory.
+ * This is worth troubling over because if the installation share/
+ * directory is missing or unreadable, this is likely to be the first
+ * place we notice a problem during postmaster startup.
+ */
+ int save_errno = errno;
+ DIR *tzdir;
+
+ snprintf(file_path, sizeof(file_path), "%s/timezonesets",
+ share_path);
+ tzdir = AllocateDir(file_path);
+ if (tzdir == NULL)
+ {
+ ereport(tz_elevel,
+ (errcode_for_file_access(),
+ errmsg("could not open directory \"%s\": %m",
+ file_path),
+ errhint("This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
+ my_exec_path)));
+ return -1;
+ }
+ FreeDir(tzdir);
+ errno = save_errno;
+
+ /*
+ * otherwise, if file doesn't exist and it's level 0, guc.c's
+ * complaint is enough
+ */
if (errno != ENOENT || depth > 0)
ereport(tz_elevel,
(errcode_for_file_access(),
errmsg("could not read time zone file \"%s\": %m",
filename)));
+
return -1;
}