Unclear documentation of to_char()

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Unclear documentation of to_char()
Date: 2003-02-23 19:55:32
Message-ID: Pine.LNX.4.44.0302232038310.1618-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The documentation of to_char() is unclear regarding the meaning of the
various formatting patterns for plus and minus signs:

S negative value with minus sign (uses locale)
MI minus sign in specified position (if number < 0)
PL plus sign in specified position (if number > 0)
SG plus/minus sign in specified position

Here is what happens: (The quotes in the result are not actually part of
the function result.)

to_char(485.8, 'S9999.999') ' +485.800'
to_char(485.8, 'MI9999.999') ' 485.800'
to_char(485.8, 'PL9999.999') '+ 485.800'
to_char(485.8, 'SG9999.999') '+ 485.800'

to_char(-485.8, 'S9999.999') ' -485.800'
to_char(-485.8, 'MI9999.999') '- 485.800'
to_char(-485.8, 'PL9999.999') ' -485.800'
to_char(-485.8, 'SG9999.999') '- 485.800'

to_char(485.8, '9999.999S') ' 485.800+'
to_char(485.8, '9999.999PL') ' 485.800+'
to_char(485.8, '9999.999MI') ' 485.800 '
to_char(485.8, '9999.999SG') ' 485.800+'

to_char(-485.8, '9999.999S') ' 485.800-'
to_char(-485.8, '9999.999PL') ' -485.800 '
to_char(-485.8, '9999.999MI') ' 485.800-'
to_char(-485.8, '9999.999SG') ' 485.800-'

The SG seems to work okay, and the S could be considered okay if the
documentation were adjusted, but I suspect there are a few bugs in PL and
MI.

--
Peter Eisentraut peter_e(at)gmx(dot)net

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2003-02-23 20:00:12 Re: [HACKERS] loading libraries on Postmaster startup
Previous Message Dave Page 2003-02-23 19:52:57 Re: Linking to "current" docs