Re: Extended unit - Mailing list pgsql-general

From Pailloncy Jean-Gerard
Subject Re: Extended unit
Date
Msg-id 3b06e0ed5108c9ef0bdd048d786d73cd@rilk.com
Whole thread Raw
In response to Re: Extended unit  (Pailloncy Jean-Gerard <jg@rilk.com>)
List pgsql-general
    De:       jg@rilk.com
    Objet:     Rép : [GENERAL] Extended unit
    Date:     28 janvier 2005 18:18:18 GMT+01:00
    À:       jg@rilk.com

I have done a new version with
- a new conversion function
- possibility to enter value as fraction
- addition of the operator + - * / = <> != > < >= <=
- SQL only code

Some results :
                 calcul                |         result
--------------------------------------+------------------------
  1 m                                  | 1 m
  1/4 m kg-1/2 m1/2 s-3                | 0.25 s-3 m3/2 kg-1/2
  1/2 m2 + 1/4 m2                      | 0.75 m2
  1.5/2 m2 - 1/2.5 m2                  | 0.35 m2
  1 m + 1 s                            | null
  1 m s-1 * 1 s3/2                     | 1 s1/2 m
  1 / 1 s                              | 1 s-1
  2 m ^ 3                              | 8 m3
  1 m = 1 m                            | T
  1 m = 3 m                            | F
  1 m = 1 s                            | null
  unit_conv(3/2 C J2.5 m-1/2.5 kg m-1) | 150 s-6 A m18/5 kg7/2

Exemple of the command:
select ('1.5/2 m2'::text::du - '1/2.5 m2'::text::du)::text
0.35 m2

The code is 600 lines.
I do not know if it is too big to be send on the mailing list.
If someone want to test it, contact me in private.

Note 1: I add a trouble in CAST where a quoted string is recognize as
"unknown' and not as "text". For this reason I force the type to
"texte" before anything else.
Note 2: There is some trouble with the set of SI compatible units.
Example: Pa may peta-are or Pascal. I supress the less important unit
to keep uniquenness of the unit symbol.

Cordialement,
Jean-Gérard Pailloncy

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Shared Memory/Shared Buffers
Next
From: William Yu
Date:
Subject: Re: Splitting queries across servers