Problem with zero year
От | Bruce Momjian |
---|---|
Тема | Problem with zero year |
Дата | |
Msg-id | 200903171457.n2HEvqJ20005@momjian.us обсуждение исходный текст |
Ответы |
Re: Problem with zero year
|
Список | pgsql-hackers |
We added the following commit in 8.4: /src/backend/utils/adt/datetime.c tgl Reject year zeroduring datetime input, except when it's a 2-digit year (then it means 2000 AD). Formerly we silently interpreted thisas 1 BC, which at best is unwarranted familiarity with the implementation. It's barely possible that some app somewhereexpects the old behavior, though, so we won't back-patch this into existing release branches. The problem is that the 2-digit year check is for <=2 digits, not exactly two digits: /* * When processing a year field, mark it for adjustment if it's only one * or two digits. */ if (*tmask ==DTK_M(YEAR)) *is2digits = (flen <= 2); This leads to some unexpected outputs: test=> select '1-1-0'::date; date------------ 2000-01-01 test=> select '1-1-0 BC'::date;ERROR: date/time field value out of range: "1-1-0 BC"LINE 1: select '1-1-0 BC'::date; ^ test=> select '1-1-0 AD'::date; date------------ 2000-01-01 test=> select '1-1-000'::date;ERROR: date/time field value out of range: "1-1-000"LINE 1: select '1-1-000'::date; I think the BC part is fine because that can't possibily be 2000 AD, but having '0' interpreted as 2000 seems counter to the commit message text; should the assignment be changed to: if (*tmask == DTK_M(YEAR)) *is2digits = (flen == 2); -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
В списке pgsql-hackers по дате отправления: