Re: monetary bug

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Mike Mascari <mascarm(at)mascari(dot)com>, Mahmoud Taghizadeh <m_taghi(at)yahoo(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: monetary bug
Date: 2004-08-23 10:45:36
Message-ID: 20040823104535.GB17568@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Aug 22, 2004 at 04:07:17PM -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Tom Lane wrote:
> >> We keep hoping someone will step up to the plate and rewrite it,
> >> instead. Per previous discussion, the type really ought to be a thin
> >> layer over "numeric", with most likely no operations of its own
> >> except I/O conversion.
>
> > And what would it do with it? Add a currency symbol? Which one? Which
> > form? Where? Format the numbers some way?

I'm sure you found answers in "struct lconv" (locale.h), but you're
right (IMHO) better is if datetypes are independent on format.

What support some argument definition in column definition, something
like:

CREATE TABLE tab (
-- curret built-in datetype in/out format
num numeric,

-- default user defined format
num2 numeric WITH FORMAT,

-- column specific format
payme numeric WITH FORMAT='L 999D99',

temperature numeric WITH FORMAT='999D999 C',
);

where format producer for datetype is possible (re)define by:

CREATE FORMATTER FOR numeric
DEFAULT format INPUT funcname OUTPUT funcname;

The columns without "FORMAT" options will use standard (current) in/out
methods. Outputs without connection to some table column can be
formated by:

-- curret built-in datetype in/out format
SELECT expr;

-- default defined format
SELECT FORMAT( expr );

-- specific format
SELECT FORMAT( expr AS 'DD/MM/YYYY' );

I think it's pretty extendable solution in contrast to the current
hardcoded in/out datetypes functions.

Comments?

Is there any plan for locale-per-column setting syntax?

> The idea behind the money type is to format per the lc_monetary locale
> setting, which seems perfectly reasonable to me. Further down the road

Why "money" and why not others things like temperature, speed, weight,
...?

Karel

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Eyinagho Newton 2004-08-23 10:45:55 Re: Installing PostgreSQL in a Unix Platform
Previous Message Karel Zak 2004-08-23 08:20:55 Re: 8.0 Open Items