Re: Extended unit - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Extended unit
Date
Msg-id 20050126103005.GB23796@svana.org
Whole thread Raw
In response to Re: Extended unit  (Pailloncy Jean-Gerard <jg@rilk.com>)
Responses Re: Extended unit
List pgsql-general
On Tue, Jan 25, 2005 at 11:41:28PM +0100, Pailloncy Jean-Gerard wrote:
> I have begining to put all the SI unit in a table.
> I am writing the function to check the unit in a standard way.
> I plan to use the user-defined type proposed by Tom Lane.
> The check are done at execution time.
>
> But I object that what I am doing is just a proof of concept and not
> the right thing to do.
> I do not want for each column and each row to store the value and the
> unit.
> I do want to put the unit in the definition of the column and the check
> on the parser before any execution.

Actually, there's no reason to store a string there. Just like for
timezones, I was proposing having a table listing all the timezones
postgresql knows about and using the oid of that row as the timezone
identifier. This only requires four bytes per field, not unreasonable.

So, you have 1=Amps, 2=Volts, 3=Ohms, etc... It's a little more
querying but if you wrote the functions in C I think you could get it
all fairly performant.

Now, how to store the relationships between them to handle
multiplication and division. Probably go back to base types...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Thomas Chille
Date:
Subject: Re: difficult JOIN
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Extended unit