Commit f4c4f1ce authored by Bruce Momjian's avatar Bruce Momjian

>> Do you agree that using a hashtable for it in general is a good idea

>> assuming this sideeffect is removed, though?
>
>I have no problem with the hashtable, only with preloading it with
>everything.  What I'd like to see is that the table inherited at fork()
>contains just the data for the default timezone.  (At least in the
>normal case where that setting hasn't been changed since postmaster
>start.)

Here's a patch doing this. Changes score_timezone not to use pg_tzset(),
and thus not loading all the zones in the cache. The actual timezone
being picked will be set using set_global_timezone() which in turn calls
pg_tzset() and loads it in the cache.

Magnus Hagander
parent b4132fd0
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.32 2005/05/29 04:23:07 tgl Exp $ * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.33 2005/06/15 00:09:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -162,14 +162,19 @@ score_timezone(const char *tzname, struct tztry * tt) ...@@ -162,14 +162,19 @@ score_timezone(const char *tzname, struct tztry * tt)
struct tm *systm; struct tm *systm;
struct pg_tm *pgtm; struct pg_tm *pgtm;
char cbuf[TZ_STRLEN_MAX + 1]; char cbuf[TZ_STRLEN_MAX + 1];
pg_tz *tz; pg_tz tz;
tz = pg_tzset(tzname);
if (!tz) /* Load timezone directly. Don't use pg_tzset, because we don't want
return -1; /* can't handle the TZ name at all */ * all timezones loaded in the cache at startup. */
if (tzload(tzname, &tz.state) != 0) {
if (tzname[0] == ':' || tzparse(tzname, &tz.state, FALSE) != 0) {
return -1; /* can't handle the TZ name at all */
}
}
/* Reject if leap seconds involved */ /* Reject if leap seconds involved */
if (!tz_acceptable(tz)) if (!tz_acceptable(&tz))
{ {
elog(DEBUG4, "Reject TZ \"%s\": uses leap seconds", tzname); elog(DEBUG4, "Reject TZ \"%s\": uses leap seconds", tzname);
return -1; return -1;
...@@ -179,7 +184,7 @@ score_timezone(const char *tzname, struct tztry * tt) ...@@ -179,7 +184,7 @@ score_timezone(const char *tzname, struct tztry * tt)
for (i = 0; i < tt->n_test_times; i++) for (i = 0; i < tt->n_test_times; i++)
{ {
pgtt = (pg_time_t) (tt->test_times[i]); pgtt = (pg_time_t) (tt->test_times[i]);
pgtm = pg_localtime(&pgtt, tz); pgtm = pg_localtime(&pgtt, &tz);
if (!pgtm) if (!pgtm)
return -1; /* probably shouldn't happen */ return -1; /* probably shouldn't happen */
systm = localtime(&(tt->test_times[i])); systm = localtime(&(tt->test_times[i]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment