Re: to_date_valid()

Поиск
Список
Период
Сортировка
Искать
От
Peter Eisentraut
Тема
Re: to_date_valid()
Дата
Msg-id
7fde7a91-0ad3-33ac-c348-cf58e4638464@2ndquadrant.com
Ответ на
Re: to_date_valid() (Andreas 'ads' Scherbaum)
Список
Дерево обсуждения
to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Amit Kapila <amit.kapila16@gmail.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Euler Taveira <euler@timbira.com.br>
Re: to_date_valid() Jaime Casanova <jaime.casanova@2ndquadrant.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Andreas Karlsson <andreas@proxel.se>
Re: to_date_valid() Pavel Stehule <pavel.stehule@gmail.com>
Re: to_date_valid() Andreas Karlsson <andreas@proxel.se>
Re: to_date_valid() Albe Laurenz <laurenz.albe@wien.gv.at>
Re: to_date_valid() Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: to_date_valid() "Joshua D. Drake" <jd@commandprompt.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Artur Zakirov <a.zakirov@postgrespro.ru>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Artur Zakirov <a.zakirov@postgrespro.ru>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: to_date_valid() Tom Lane <tgl@sss.pgh.pa.us>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: to_date_valid() Craig Ringer <craig@2ndquadrant.com>
Re: to_date_valid() Pavel Stehule <pavel.stehule@gmail.com>
Re: to_date_valid() Pavel Stehule <pavel.stehule@gmail.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Pavel Stehule <pavel.stehule@gmail.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() Pavel Stehule <pavel.stehule@gmail.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() "David G. Johnston" <david.g.johnston@gmail.com>
Re: to_date_valid() Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: to_date_valid() "David G. Johnston" <david.g.johnston@gmail.com>
Re: to_date_valid() Bruce Momjian <bruce@momjian.us>
Re: to_date_valid() Pavel Stehule <pavel.stehule@gmail.com>
Re: to_date_valid() Gavin Flower <GavinFlower@archidevsys.co.nz>
On 8/15/16 7:33 AM, Andreas 'ads' Scherbaum wrote:
> postgres=# SELECT to_date('2011 12  18', 'YYYY MM   DD');
>    to_date
> ------------
>   2011-12-08
> (1 row)
> 
> 
> That is from the regression tests, and obviously handles the date 
> transformation wrong. My attempt catches this, because I compare the 
> date with the input date, and do not rely on a valid date only.

It's debatable what is correct here.

Using to_number, the behavior appears to be that a space in the pattern
ignores one character.  For example:

test=# select to_number('123 456', '999 999');to_number
-----------   123456

test=# select to_number('123 456', '999  999');to_number
-----------    12356

Considering that, the above to_date result is not incorrect.

So just squashing the spaces and converting the value back is not a
correct approach to detecting overflow.

I think using ValidateDate() was the right idea.  That is what we use
for checking date validity everywhere else.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


В списке pgsql-hackers по дате отправления
От: Tom Lane
Дата:
Сообщение: Re: ICU integration
От: Masahiko Sawada
Дата:
FAQ