pgsql: Make to_timestamp() and to_date() range-check fields of their in

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Make to_timestamp() and to_date() range-check fields of their in
Дата
Msg-id E1bpJif-0003Ca-OG@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Make to_timestamp() and to_date() range-check fields of their input.

Historically, something like to_date('2009-06-40','YYYY-MM-DD') would
return '2009-07-10' because there was no prohibition on out-of-range
month or day numbers.  This has been widely panned, and it also turns
out that Oracle throws an error in such cases.  Since these functions
are nominally Oracle-compatibility features, let's change that.

There's no particular restriction on year (modulo the fact that the
scanner may not believe that more than 4 digits are year digits,
a matter to be addressed separately if at all).  But we now check month,
day, hour, minute, second, and fractional-second fields, as well as
day-of-year and second-of-day fields if those are used.

Currently, no checks are made on ISO-8601-style week numbers or day
numbers; it's not very clear what the appropriate rules would be there,
and they're probably so little used that it's not worth sweating over.

Artur Zakirov, reviewed by Amul Sul, further adjustments by me

Discussion: <1873520224.1784572.1465833145330.JavaMail.yahoo@mail.yahoo.com>
See-Also: <57786490.9010201@wars-nicht.de>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/d3cd36a133d96ad5578b6c10279b55fd5b538093

Modified Files
--------------
doc/src/sgml/func.sgml                 | 85 +++++++++++++++++-------------
src/backend/utils/adt/formatting.c     | 94 +++++++++++++++++++++++----------
src/test/regress/expected/horology.out | 96 +++++++++++++++++++++++++++++++++-
src/test/regress/sql/horology.sql      | 30 ++++++++++-
4 files changed, 239 insertions(+), 66 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Remove dead line of code
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Rationalize format-picture caching logic in formatting.c.