Thread: Timestamp parsing with blanked time part

Timestamp parsing with blanked time part

From
Ireneusz Pluta
Date:
Hi,

consider the following:

select quote_literal(blank_hms) as "quote_literal(blank_hms)", blank_hms::timestamp as
"blank_hms::timestamp" from (select unnest(array['2011-07-22 :', '2011-07-22 : ', '2011-07-22 : :
']::text[]) as blank_hms) a; select version();

  quote_literal(blank_hms) | blank_hms::timestamp
--------------------------+----------------------
  '2011-07-22 :'           | 2011-07-22 00:00:00
  '2011-07-22 : '          | 2011-07-22 00:00:00
  '2011-07-22 : : '        | 2011-07-22 00:00:00
(3 rows)

Time: 0.264 ms
                                                      version
------------------------------------------------------------------------------------------------------------------
  PostgreSQL 9.0.3 on x86_64-manual_install-freebsd8.x, compiled by GCC cc (GCC) 4.2.1 20070719
[FreeBSD], 64-bit
(1 row)

The result is what might be expected by the common sense means.

Howewer, the input format of the example datetime strings is definitely wrong as far as I guess.
Some other datetime parsers reject it, the Perl DateTime::Format::Pg is an example.

Is this case a subject of eventual corrections in the future versions of postgres and it would start
emit errors then?

Thanks
Irek.

Re: Timestamp parsing with blanked time part

From
Tom Lane
Date:
Ireneusz Pluta <ipluta@wp.pl> writes:
> [ Postgres accepts timestamp input of the form '2011-07-22 :' ]
> Some other datetime parsers reject it, the Perl DateTime::Format::Pg is an example.

> Is this case a subject of eventual corrections in the future versions of postgres and it would start emit errors
then?

No, it isn't.  If we tightened that up, it would inevitably break
somebody else's application.  And who's to say that DateTime::Format
is the best authority on what should be considered valid?

            regards, tom lane