Re: timestamptz parsing bug?

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamptz parsing bug?
Date: 2011-08-29 17:40:07
Message-ID: CAEZATCX893NNUzhtBz7-+SA3mLLNrbV5M4s1twygV86Zu6nX5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29 August 2011 15:40, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
> Why do we parse this as a correct timestamptz literal:
>
>    2011-08-29T09:11:14.123 CDT
>
> but not this:
>
>    2011-08-29T09:11:14.123 America/Chicago
>
> Replace the ISO-8601 style T between the date and time parts of the latter
> with a space and the parser is happy again.
>
>
> cheers
>
> andrew
>

Funny, I've just recently been looking at this code.

I think that the issue is in the DTK_TIME handling code in DecodeDateTime().

For this input string the "T" is recognised as the start of an ISO
time, and the ptype variable is set to DTK_TIME. The next field is a
DTK_TIME, however, when it is handled it doesn't reset the ptype
variable.

When it gets to the timezone "America/Chicago" at the end, this is
handled in the DTK_DATE case, because of the "/". But because ptype is
still set, it is expecting this to be an ISO time, so it errors out.

The attached patch seems to fix it. Could probably use a new
regression test though.

Regards,
Dean

Attachment Content-Type Size
datetime.patch application/octet-stream 690 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message hubert depesz lubaczewski 2011-08-29 17:49:24 Re: [GENERAL] pg_upgrade problem
Previous Message Greg Stark 2011-08-29 17:34:12 Re: spinlocks on HP-UX