提交 4d3482a7 编写于 作者: T Tom Lane

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 bug
report from Patric Bechtel.  This time I actually looked through the Olson
timezone database to find the largest offsets used anywhere.  The winners
are 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 #define
symbols controlling this, so make some ... and also remove an obsolete
comment that didn't get fixed the last time.

Back-patch to all supported branches.
上级 dd957a5b
......@@ -2571,9 +2571,6 @@ DecodeNumberField(int len, char *str, int fmask,
* Return 0 if okay (and set *tzp), a DTERR code if not okay.
*
* NB: this must *not* ereport on failure; see commands/variable.c.
*
* Note: we allow timezone offsets up to 13:59. There are places that
* use +1300 summer time.
*/
static int
DecodeTimezone(char *str, int *tzp)
......@@ -2618,7 +2615,8 @@ DecodeTimezone(char *str, int *tzp)
else
min = 0;
if (hr < 0 || hr > 14)
/* Range-check the values; see notes in utils/timestamp.h */
if (hr < 0 || hr > MAX_TZDISP_HOUR)
return DTERR_TZDISP_OVERFLOW;
if (min < 0 || min >= 60)
return DTERR_TZDISP_OVERFLOW;
......
......@@ -89,6 +89,16 @@ typedef struct
#define USECS_PER_SEC INT64CONST(1000000)
#endif
/*
* We allow numeric timezone offsets up to 15:59:59 either way from Greenwich.
* Currently, the record holders for wackiest offsets in actual use are zones
* Asia/Manila, at -15:56:00 until 1844, and America/Metlakatla, at +15:13:42
* until 1867. If we were to reject such values we would fail to dump and
* restore old timestamptz values with these zone settings.
*/
#define MAX_TZDISP_HOUR 15 /* maximum allowed hour part */
#define TZDISP_LIMIT ((MAX_TZDISP_HOUR + 1) * SECS_PER_HOUR)
/*
* Macros for fmgr-callable functions.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册