Re: [HACKERS] Bug in to_timestamp().
Artur Zakirov <a.zakirov@postgrespro.ru>
From: Arthur Zakirov <a.zakirov@postgrespro.ru>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, amul sul <sulamul@gmail.com>, Pavel Stehule <pavel.stehule@gmail.com>, Robert Haas <robertmhaas@gmail.com>, "David G. Johnston" <david.g.johnston@gmail.com>, Alex Ignatov <a.ignatov@postgrespro.ru>, Bruce Momjian <bruce@momjian.us>, amul sul <sul_amul@yahoo.co.in>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-01-12T12:58:49Z
Lists: pgsql-hackers
Attachments
- 0001-to-timestamp-format-checking-v9.patch (text/plain) patch v9-0001
Hello,
On Fri, Jan 12, 2018 at 02:48:40PM +1300, Thomas Munro wrote:
>
> I'm guessing that commit 11b623dd0a2c385719ebbbdd42dd4ec395dcdc9d had
> something to do with the following failure, when your patch is
> applied:
>
> horology ... FAILED
>
Thank you a lot for pointing on that.
It seems to me that it happens because the patch eats minus sign "-" before "05". And it is wrong to do that.
I attached new version of the patch. Now (expected output):
=# SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZH');
to_timestamp
------------------------
2011-12-18 20:38:00+04
But these queries may confuse:
=# SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZH');
to_timestamp
------------------------
2011-12-18 10:38:00+04
=# SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI -TZH');
to_timestamp
------------------------
2011-12-18 10:38:00+04
And these queries don't work anymore using new version of the patch:
=# SELECT to_timestamp('2000 + JUN', 'YYYY MON');
ERROR: invalid value "+ J" for "MON"
DETAIL: The given value did not match any of the allowed values for this field.
=# SELECT to_timestamp('2000 + JUN', 'YYYY MON');
ERROR: invalid value "+ " for "MON"
DETAIL: The given value did not match any of the allowed values for this field.
Other queries mentioned in the thread work as before.
Any thoughts? If someone has better approach, feel free to share it.
--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
Commits
-
Improve behavior of to_timestamp()/to_date() functions
- cf984672427e 12.0 landed
-
Implement TZH and TZM timestamp format patterns
- 11b623dd0a2c 11.0 cited
-
as attache of this mail is patch (to the main tree) with to_char's
- b866d2e2d794 7.1.1 cited