summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-02-25 19:41:23 +0000
committerBruce Momjian <bruce@momjian.us>2004-02-25 19:41:23 +0000
commitc672aa823bdc02831ae60f403b2069107de675f7 (patch)
tree0d5566d0df4056250b3a7d74d21a7d69b58f28b2 /src/backend/utils
parent5ada9ef088ae0151a2f6efe48203100ef5b51113 (diff)
downloadpostgresql-c672aa823bdc02831ae60f403b2069107de675f7.tar.gz
For application to HEAD, following community review.
* Changes incorrect CYGWIN defines to __CYGWIN__ * Some localtime returns NULL checks (when unchecked cause SEGVs under Win32 regression tests) * Rationalized CreateSharedMemoryAndSemaphores and AttachSharedMemoryAndSemaphores (Bruce, I finally remembered to do it); requires attention. Claudio Natoli
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/datetime.c14
-rw-r--r--src/backend/utils/cache/relcache.c6
2 files changed, 16 insertions, 4 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 5fa4be73c4..5f340dd2a1 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.124 2004/01/19 19:04:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.125 2004/02/25 19:41:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1611,6 +1611,10 @@ DetermineLocalTimeZone(struct tm * tm)
* and reassemble to get a representation of local time.
*/
tx = localtime(&mytime);
+ if (!tx)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
+ errmsg("timestamp out of range")));
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
UNIX_EPOCH_JDATE;
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
@@ -1632,6 +1636,10 @@ DetermineLocalTimeZone(struct tm * tm)
mysec += delta1;
mytime = (time_t) mysec;
tx = localtime(&mytime);
+ if (!tx)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
+ errmsg("timestamp out of range")));
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
UNIX_EPOCH_JDATE;
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
@@ -1653,6 +1661,10 @@ DetermineLocalTimeZone(struct tm * tm)
mysec += (delta2 - delta1);
mytime = (time_t) mysec;
tx = localtime(&mytime);
+ if (!tx)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
+ errmsg("timestamp out of range")));
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
UNIX_EPOCH_JDATE;
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8561cff549..ac0ee1a5e5 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.197 2004/02/10 01:55:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.198 2004/02/25 19:41:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3266,13 +3266,13 @@ write_relcache_init_file(void)
* OK, rename the temp file to its final name, deleting any
* previously-existing init file.
*/
-#if defined(WIN32) || defined(CYGWIN)
+#if defined(WIN32) || defined(__CYGWIN__)
rename(tempfilename, finalfilename);
LWLockRelease(RelCacheInitLock);
#else
{
char finalfilename_new[MAXPGPATH];
-
+
snprintf(finalfilename_new, sizeof(finalfilename_new), "%s.new", finalfilename);
rename(tempfilename, finalfilename_new);
LWLockRelease(RelCacheInitLock);