Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd0ff9c

Browse files
committed
Expand the allowed range of timezone offsets to +/-15:59:59 from Greenwich.
We used to only allow offsets less than +/-13 hours, then it was +/14,then it was +/-15. That's still not good enough though, as per today's bugreport from Patric Bechtel. This time I actually looked through the Olsontimezone database to find the largest offsets used anywhere. The winnersare Asia/Manila, at -15:56:00 until 1844, and America/Metlakatla, at+15:13:42 until 1867. So we'd better allow offsets less than +/-16 hours.Given the history, we are way overdue to have some greppable #definesymbols controlling this, so make some ... and also remove an obsoletecomment that didn't get fixed the last time.Back-patch to all supported branches.
1 parent07ab138 commitcd0ff9c

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

‎src/backend/utils/adt/date.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,9 +1956,8 @@ timetz_recv(PG_FUNCTION_ARGS)
19561956

19571957
result->zone=pq_getmsgint(buf,sizeof(result->zone));
19581958

1959-
/* we allow GMT displacements up to 14:59:59, cf DecodeTimezone() */
1960-
if (result->zone <=-15*SECS_PER_HOUR||
1961-
result->zone >=15*SECS_PER_HOUR)
1959+
/* Check for sane GMT displacement; see notes in datatype/timestamp.h */
1960+
if (result->zone <=-TZDISP_LIMIT||result->zone >=TZDISP_LIMIT)
19621961
ereport(ERROR,
19631962
(errcode(ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE),
19641963
errmsg("time zone displacement out of range")));

‎src/backend/utils/adt/datetime.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,9 +2698,6 @@ DecodeNumberField(int len, char *str, int fmask,
26982698
* Return 0 if okay (and set *tzp), a DTERR code if not okay.
26992699
*
27002700
* NB: this must *not* ereport on failure; see commands/variable.c.
2701-
*
2702-
* Note: we allow timezone offsets up to 13:59. There are places that
2703-
* use +1300 summer time.
27042701
*/
27052702
staticint
27062703
DecodeTimezone(char*str,int*tzp)
@@ -2745,7 +2742,8 @@ DecodeTimezone(char *str, int *tzp)
27452742
else
27462743
min=0;
27472744

2748-
if (hr<0||hr>14)
2745+
/* Range-check the values; see notes in datatype/timestamp.h */
2746+
if (hr<0||hr>MAX_TZDISP_HOUR)
27492747
returnDTERR_TZDISP_OVERFLOW;
27502748
if (min<0||min >=MINS_PER_HOUR)
27512749
returnDTERR_TZDISP_OVERFLOW;

‎src/include/datatype/timestamp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ typedef struct
105105
#defineUSECS_PER_MINUTE INT64CONST(60000000)
106106
#defineUSECS_PER_SECINT64CONST(1000000)
107107

108+
/*
109+
* We allow numeric timezone offsets up to 15:59:59 either way from Greenwich.
110+
* Currently, the record holders for wackiest offsets in actual use are zones
111+
* Asia/Manila, at -15:56:00 until 1844, and America/Metlakatla, at +15:13:42
112+
* until 1867. If we were to reject such values we would fail to dump and
113+
* restore old timestamptz values with these zone settings.
114+
*/
115+
#defineMAX_TZDISP_HOUR15/* maximum allowed hour part */
116+
#defineTZDISP_LIMIT((MAX_TZDISP_HOUR + 1) * SECS_PER_HOUR)
117+
108118
/*
109119
* DT_NOBEGIN represents timestamp -infinity; DT_NOEND represents +infinity
110120
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp