Re: Extended unit

From: Pailloncy Jean-Gerard <jg(at)rilk(dot)com>
To: Postgres mailing list general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Extended unit
Date: 2005-01-28 17:26:14
Message-ID: 3b06e0ed5108c9ef0bdd048d786d73cd@rilk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

De: jg(at)rilk(dot)com
Objet: Rép : [GENERAL] Extended unit
Date: 28 janvier 2005 18:18:18 GMT+01:00
À: jg(at)rilk(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message William Yu 2005-01-28 19:36:15 Re: Splitting queries across servers
Previous Message Josh Berkus 2005-01-28 17:04:35 Re: MySQL worm attacks Windows servers