Hi,
Some word from my test work.
I try first to just have a parser that can manage a string of unit. like 'm s-1 kg2.5 A3.5/7.2' The parser accept : - any letters for the unit - a + or - or nothing before the power - a fractional power - the unit separator is space ;-/ The system normalize the fraction of the power.
select ('1 m'::text + '1 m'::text)::text '2 m' select ('1 m'::text - '1 m'::text)::text '0 m' select ('1 m'::text / 2)::text '0.5 m' select ('1 m'::text * 2)::text '2 m' select ('1 m'::text + 2)::text 'NULL' select ('1 m'::text * '3 s'::text)::text '3 s m' select ('1 m'::text / '3 s'::text)::text '0.333333333333333 s-1 m' select ('1 m'::text + '3 s'::text)::text 'NULL' select (1 / '3 s'::text)::text '0.333333333333333 s-1' select ('1 m s2 m s kg'::text::doubleunit)::text '1 s3 m2 kg' select ('4.5 m s2 m-3.2/7.1 s'::text::doubleunit)::text '4.5 s3 m39/71'
So with this system you can add with unit checking any value.
But there is no conversion.
So I need to enter all unit in a coherent system.
I have begin to add a translation table for unit.
The first table will to manage affix only (kilo, mega, giga, micro, milli, etc.)
The may problem is because is done at execution time, it is 50 times slower that standard calculus.
Note: I use too much ::text because I mix som CAST definition ;-(
I really want it at parsing time....
Note 2: I think version 8.0 has a better support for function returning composite type. It would be easier to build the system, when I'll upgrade...
Cordialement, Jean-Gérard Pailloncy
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq