Re: New to_timestamp implementation is pretty strict

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: New to_timestamp implementation is pretty strict
Дата
Msg-id 49343111.8070300@enterprisedb.com
обсуждение исходный текст
Ответ на Re: New to_timestamp implementation is pretty strict  ("Robert Haas" <robertmhaas@gmail.com>)
Ответы Re: New to_timestamp implementation is pretty strict  ("Robert Haas" <robertmhaas@gmail.com>)
Список pgsql-hackers
Robert Haas wrote:
> On Mon, Dec 1, 2008 at 10:33 AM, Greg Stark <stark@enterprisedb.com> wrote:
>> How would you parse an input format of just 'SS' ? is there something
>> ambiguous about '3' ? I don't see anything "bad" about using %d to
>> output an integer number of seconds.
> 
> +1.
> 
> It seems to me that it's pretty silly to say that we "know" that the 2
> in "01:2:03" is intended to mean 02, but we are somehow confused about
> whether the 3 in "01:02:3" is intended to mean 03 or 30.

Yep. It's a fair argument that we shouldn't accept either, but the 
inconsistency is just wrong. I've committed a patch fixing the 
inconsistency, by allowing "01:02:3".

Now whether we should forbid both, my opinion is that we shouldn't; that 
would just unnecessarily brake old applications, and I don't think 
there's much danger of ambiguity in what "01:2:03" means.

For better or worse, we also allow these more questionable inputs:

postgres=# SELECT to_timestamp('2008/-3/01', 'YYYY/MM/DD');      to_timestamp
------------------------ 2007-09-01 00:00:00+03
(1 row)

postgres=# SELECT to_timestamp('2008--3-01', 'YYYY-MM-DD');      to_timestamp
------------------------ 2007-09-01 00:00:00+03
(1 row)

postgres=# SELECT to_timestamp('2008-03', 'YYYY-MM-DD');      to_timestamp
------------------------ 2008-03-01 00:00:00+02
(1 row)

postgres=# SELECT to_timestamp('2008-03-04-foobar', 'YYYY-MM-DD');      to_timestamp
------------------------ 2008-03-04 00:00:00+02
(1 row)

The argument for rejecting these is stronger, IMHO, but given that we 
allowed these in previous releases as well, I don't think we try to 
forbid them either.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


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

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Simple postgresql.conf wizard
Следующее
От: "Vignesh Raaj"
Дата:
Сообщение: Reg: Nested query