66 * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
77 *
88 * IDENTIFICATION
9- * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.71 2010/04/09 11:49:51 mha Exp $
9+ * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.72 2010/04/15 18:46:45 tgl Exp $
1010 *
1111 *-------------------------------------------------------------------------
1212 */
@@ -498,8 +498,10 @@ identify_system_timezone(void)
498498if (std_zone_name [0 ]== '\0' )
499499{
500500ereport (LOG ,
501- (errmsg ("could not determine system time zone, defaulting to \"%s\"" ,"GMT" ),
502- errhint ("You can specify the correct timezone in postgresql.conf." )));
501+ (errmsg ("could not determine system time zone" ),
502+ errdetail ("The PostgreSQL time zone will be set to \"%s\"." ,
503+ "GMT" ),
504+ errhint ("You can specify the correct timezone in postgresql.conf." )));
503505return NULL ;/* go to GMT */
504506}
505507
@@ -533,9 +535,10 @@ identify_system_timezone(void)
533535 (- std_ofs > 0 ) ?"+" :"" ,- std_ofs /3600 );
534536
535537ereport (LOG ,
536- (errmsg ("could not recognize system timezone, defaulting to \"%s\"" ,
537- resultbuf ),
538- errhint ("You can specify the correct timezone in postgresql.conf." )));
538+ (errmsg ("could not recognize system time zone" ),
539+ errdetail ("The PostgreSQL time zone will be set to \"%s\"." ,
540+ resultbuf ),
541+ errhint ("You can specify the correct timezone in postgresql.conf." )));
539542return resultbuf ;
540543}
541544
@@ -1076,9 +1079,12 @@ identify_system_timezone(void)
10761079
10771080if (!tm )
10781081{
1079- ereport (WARNING ,
1080- (errmsg_internal ("could not determine current date/time: localtime failed" )));
1081- return NULL ;
1082+ ereport (LOG ,
1083+ (errmsg ("could not identify system time zone: localtime() failed" ),
1084+ errdetail ("The PostgreSQL time zone will be set to \"%s\"." ,
1085+ "GMT" ),
1086+ errhint ("You can specify the correct timezone in postgresql.conf." )));
1087+ return NULL ;/* go to GMT */
10821088}
10831089
10841090memset (tzname ,0 ,sizeof (tzname ));
@@ -1089,7 +1095,7 @@ identify_system_timezone(void)
10891095if (strcmp (tzname ,win32_tzmap [i ].stdname )== 0 ||
10901096strcmp (tzname ,win32_tzmap [i ].dstname )== 0 )
10911097{
1092- elog (DEBUG4 ,"TZ \"%s\" matchesWindows timezone \"%s\"" ,
1098+ elog (DEBUG4 ,"TZ \"%s\" matchessystem time zone \"%s\"" ,
10931099win32_tzmap [i ].pgtzname ,tzname );
10941100return win32_tzmap [i ].pgtzname ;
10951101}
@@ -1107,9 +1113,13 @@ identify_system_timezone(void)
11071113KEY_READ ,
11081114& rootKey )!= ERROR_SUCCESS )
11091115{
1110- ereport (WARNING ,
1111- (errmsg_internal ("could not open registry key to identify Windows timezone: %i" , (int )GetLastError ())));
1112- return NULL ;
1116+ ereport (LOG ,
1117+ (errmsg ("could not open registry key to identify system time zone: %i" ,
1118+ (int )GetLastError ()),
1119+ errdetail ("The PostgreSQL time zone will be set to \"%s\"." ,
1120+ "GMT" ),
1121+ errhint ("You can specify the correct timezone in postgresql.conf." )));
1122+ return NULL ;/* go to GMT */
11131123}
11141124
11151125for (idx = 0 ;;idx ++ )
@@ -1134,24 +1144,24 @@ identify_system_timezone(void)
11341144{
11351145if (r == ERROR_NO_MORE_ITEMS )
11361146break ;
1137- ereport (WARNING ,
1138- (errmsg_internal ("could not enumerate registry subkeys to identifyWindows timezone : %i" , (int )r )));
1147+ ereport (LOG ,
1148+ (errmsg_internal ("could not enumerate registry subkeys to identifysystem time zone : %i" , (int )r )));
11391149break ;
11401150}
11411151
11421152if ((r = RegOpenKeyEx (rootKey ,keyname ,0 ,KEY_READ ,& key ))!= ERROR_SUCCESS )
11431153{
1144- ereport (WARNING ,
1145- (errmsg_internal ("could not open registry subkey to identifyWindows timezone : %i" , (int )r )));
1154+ ereport (LOG ,
1155+ (errmsg_internal ("could not open registry subkey to identifysystem time zone : %i" , (int )r )));
11461156break ;
11471157}
11481158
11491159memset (zonename ,0 ,sizeof (zonename ));
11501160namesize = sizeof (zonename );
11511161if ((r = RegQueryValueEx (key ,"Std" ,NULL ,NULL ,zonename ,& namesize ))!= ERROR_SUCCESS )
11521162{
1153- ereport (WARNING ,
1154- (errmsg_internal ("could not query value for' std' to identifyWindows timezone \"%s\": %i" ,
1163+ ereport (LOG ,
1164+ (errmsg_internal ("could not query value forkey \" std\" to identifysystem time zone \"%s\": %i" ,
11551165keyname , (int )r )));
11561166RegCloseKey (key );
11571167continue ;/* Proceed to look at the next timezone */
@@ -1167,8 +1177,8 @@ identify_system_timezone(void)
11671177namesize = sizeof (zonename );
11681178if ((r = RegQueryValueEx (key ,"Dlt" ,NULL ,NULL ,zonename ,& namesize ))!= ERROR_SUCCESS )
11691179{
1170- ereport (WARNING ,
1171- (errmsg_internal ("could not query value for' dlt' to identifyWindows timezone \"%s\": %i" ,
1180+ ereport (LOG ,
1181+ (errmsg_internal ("could not query value forkey \" dlt\" to identifysystem time zone \"%s\": %i" ,
11721182keyname , (int )r )));
11731183RegCloseKey (key );
11741184continue ;/* Proceed to look at the next timezone */
@@ -1194,17 +1204,20 @@ identify_system_timezone(void)
11941204if (strcmp (localtzname ,win32_tzmap [i ].stdname )== 0 ||
11951205strcmp (localtzname ,win32_tzmap [i ].dstname )== 0 )
11961206{
1197- elog (DEBUG4 ,"TZ \"%s\" matches localizedWindows timezone \"%s\" (\"%s\")" ,
1207+ elog (DEBUG4 ,"TZ \"%s\" matches localizedsystem time zone \"%s\" (\"%s\")" ,
11981208win32_tzmap [i ].pgtzname ,tzname ,localtzname );
11991209return win32_tzmap [i ].pgtzname ;
12001210}
12011211}
12021212}
12031213
1204- ereport (WARNING ,
1205- (errmsg ("could not find a match for Windows timezone \"%s\"" ,
1206- tzname )));
1207- return NULL ;
1214+ ereport (LOG ,
1215+ (errmsg ("could not find a match for system time zone \"%s\"" ,
1216+ tzname ),
1217+ errdetail ("The PostgreSQL time zone will be set to \"%s\"." ,
1218+ "GMT" ),
1219+ errhint ("You can specify the correct timezone in postgresql.conf." )));
1220+ return NULL ;/* go to GMT */
12081221}
12091222#endif /* WIN32 */
12101223
@@ -1390,7 +1403,7 @@ select_default_timezone(void)
13901403return def_tz ;
13911404
13921405ereport (FATAL ,
1393- (errmsg ("could not select a suitable defaulttimezone " ),
1406+ (errmsg ("could not select a suitable defaulttime zone " ),
13941407errdetail ("It appears that your GMT time zone uses leap seconds. PostgreSQL does not support leap seconds." )));
13951408return NULL ;/* keep compiler quiet */
13961409}
@@ -1414,7 +1427,7 @@ pg_timezone_pre_initialize(void)
14141427 * seems OK to just use the "lastditch" case provided by tzparse().
14151428 */
14161429if (tzparse ("GMT" ,& gmt_timezone_data .state , TRUE)!= 0 )
1417- elog (FATAL ,"could not initialize GMTtimezone " );
1430+ elog (FATAL ,"could not initialize GMTtime zone " );
14181431strcpy (gmt_timezone_data .TZname ,"GMT" );
14191432gmt_timezone = & gmt_timezone_data ;
14201433}
@@ -1541,7 +1554,7 @@ pg_tzenumerate_next(pg_tzenum *dir)
15411554/* Step into the subdirectory */
15421555if (dir -> depth >=MAX_TZDIR_DEPTH - 1 )
15431556ereport (ERROR ,
1544- (errmsg ("timezone directory stack overflow" )));
1557+ (errmsg_internal ("timezone directory stack overflow" )));
15451558dir -> depth ++ ;
15461559dir -> dirname [dir -> depth ]= pstrdup (fullname );
15471560dir -> dirdesc [dir -> depth ]= AllocateDir (fullname );