Thread: The notorious to_char bug

The notorious to_char bug

From
greg@turnstep.com
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(From the SQL list:)

> And we know it is a bug:

>  * to_char(0,'FM999.99') returns a period, to_char(1,'FM999.99') does not

I took a look at this bug a week ago, and noticed that inside of the file 
src/backend/utils/adt/formatting.c
we are specifically causing the above behavior, perhaps in an effort to 
mimic Oracle's implementation of it. Unless I am missing something, it 
seems that we can simply take out the hack inside of the above file, 
or mark the bug as solved...

Search for the strings "terrible" and "terible" to find the spots 
inside of formatting.c

Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200209180909

-----BEGIN PGP SIGNATURE-----

iD8DBQE9iIDvvJuQZxSWSsgRAqRLAJ9gV8oTnMFTsSmQzMdKppNlWW/TvACgvDu2
f0TDVbi//F5jwZn7K9+9wLE=
=TIs7
-----END PGP SIGNATURE-----




Re: The notorious to_char bug

From
Tom Lane
Date:
greg@turnstep.com writes:
> (From the SQL list:)

>> And we know it is a bug:
>> * to_char(0,'FM999.99') returns a period, to_char(1,'FM999.99') does not

> I took a look at this bug a week ago, and noticed that inside of the file 
> src/backend/utils/adt/formatting.c
> we are specifically causing the above behavior, perhaps in an effort to 
> mimic Oracle's implementation of it.

Hm.  Can anyone try these cases on Oracle?  If the code goes out of its
way to have this odd behavior, maybe it's because Oracle does too.
        regards, tom lane


Re: The notorious to_char bug

From
"Jonah H. Harris"
Date:
Oracle 8.1.7.2

SQL> SELECT to_char(0,'FM999.99') AS tst_char FROM dual;

TST_CHA
-------
0.

SQL> SELECT to_char(1,'FM999.99') AS tst_char FROM dual;

TST_CHA
-------
1.


-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Tom Lane
Sent: Wednesday, September 18, 2002 9:12 AM
To: greg@turnstep.com
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] The notorious to_char bug


greg@turnstep.com writes:
> (From the SQL list:)

>> And we know it is a bug:
>> * to_char(0,'FM999.99') returns a period, to_char(1,'FM999.99') does not

> I took a look at this bug a week ago, and noticed that inside of the file
> src/backend/utils/adt/formatting.c
> we are specifically causing the above behavior, perhaps in an effort to
> mimic Oracle's implementation of it.

Hm.  Can anyone try these cases on Oracle?  If the code goes out of its
way to have this odd behavior, maybe it's because Oracle does too.
        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly