Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1 - Mailing list pgsql-bugs

From Brendan Jurd
Subject Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1
Date
Msg-id 37ed240d0906212339i4073945cufc4cd7473644975e@mail.gmail.com
Whole thread Raw
In response to Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1  (Jeremy Ford <jeremford@gmail.com>)
Responses Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1
List pgsql-bugs
2009/6/22 Jeremy Ford <jeremford@gmail.com>:
> Oracle 9i:
> =A0YEAR MONTH METHOD1=A0=A0=A0=A0 METHOD2
>
> =A02009 03=A0=A0 1/03/2009=A0=A0 1/03/2009
>
> Oracle 10g:
> YEAR=A0=A0=A0=A0=A0 MONTH=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ME=
THOD1=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 METHOD2
>
> =A02009=A0=A0=A0=A0=A0 03=A0=A0=A0=A0=A0=A0=A0=A0=A0 1/03/2009=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 1/03/2009
>

Hi Jeremy,

The query you used above might not tell us the whole story, because
you also have calls to to_char() in there (which is where those
leading spaces are coming from), and I have no idea whether Oracle's
to_char() also adds those leading spaces.

It would be very helpful if you'd test the following against Oracle
and let us know what you get back, just to totally rule out any
interference from to_char():

SELECT to_date(' 2009 03', 'YYYYMM') as nospace;
SELECT to_date(' 2009 03', 'YYYY MM') as monthspace;
SELECT to_date(' 2009 03', ' YYYY MM') as bothspaces;
SELECT to_date(' 2009 03', '  YYYY MM') as extraspace;
SELECT to_date('2009 03', ' YYYY MM') as bogusspace;

> On Sat, Jun 20, 2009 at 2:03 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> My feeling about it is that we usually try to match Oracle's behavior
>> for to_date/to_char, so the $64 question is whether Oracle allows a
>> leading space in these same cases. =A0Anyone have it handy to test?

If it turns out that Oracle does ignore leading spaces, we might want
to just add a special case in the input string scanner to skip over
any whitespace at the beginning of the string before we begin
processing in earnest.

Depending on the results from the test cases I posted above, we might
want to do something similar for the format string also.

Cheers,
BJ

pgsql-bugs by date:

Previous
From: Jeremy Ford
Date:
Subject: Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1
Next
From: Dave Page
Date:
Subject: Re: BUG #4785: Installation fails