On Sun, Aug 22, 2004 at 04:07:17PM -0400, Tom Lane wrote:
> Peter Eisentraut <[EMAIL PROTECTED]> 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  <[EMAIL PROTECTED]>
 http://home.zf.jcu.cz/~zakkr/

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to