diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-02-17 02:09:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-02-17 02:09:32 +0000 |
commit | cd004067742ee16ee63e55abfb4acbd5f09fbaab (patch) | |
tree | 62995d45f55faf5f5cdddc791d4d83d3de495b03 /src/backend/utils/adt/date.c | |
parent | ee7a6770f607e9e7f0e1b29dc25a7b7d63cb7940 (diff) |
Replace time_t with pg_time_t (same values, but always int64) in on-disk
data structures and backend internal APIs. This solves problems we've seen
recently with inconsistent layout of pg_control between machines that have
32-bit time_t and those that have already migrated to 64-bit time_t. Also,
we can get out from under the problem that Windows' Unix-API emulation is not
consistent about the width of time_t.
There are a few remaining places where local time_t variables are used to hold
the current or recent result of time(NULL). I didn't bother changing these
since they do not affect any cross-module APIs and surely all platforms will
have 64-bit time_t before overflow becomes an actual risk. time_t should
be avoided for anything visible to extension modules, however.
Diffstat (limited to 'src/backend/utils/adt/date.c')
-rw-r--r-- | src/backend/utils/adt/date.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index bec5e373964..70f60c94622 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.138 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.139 2008/02/17 02:09:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -945,8 +945,10 @@ tm2time(struct pg_tm * tm, fsec_t fsec, TimeADT *result) /* time2tm() * Convert time data type to POSIX time structure. - * For dates within the system-supported time_t range, convert to the - * local time zone. If out of this range, leave as GMT. - tgl 97/05/27 + * + * For dates within the range of pg_time_t, convert to the local time zone. + * If out of this range, leave as UTC (in practice that could only happen + * if pg_time_t is just 32 bits) - thomas 97/05/27 */ static int time2tm(TimeADT time, struct pg_tm * tm, fsec_t *fsec) @@ -2466,10 +2468,9 @@ timetz_zone(PG_FUNCTION_ARGS) if (tzp) { /* Get the offset-from-GMT that is valid today for the selected zone */ - pg_time_t now; + pg_time_t now = (pg_time_t) time(NULL); struct pg_tm *tm; - now = time(NULL); tm = pg_localtime(&now, tzp); tz = -tm->tm_gmtoff; } |