Re: Extended unit

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Extended unit
Дата
Msg-id 20050126103005.GB23796@svana.org
обсуждение исходный текст
Ответ на Re: Extended unit  (Pailloncy Jean-Gerard <jg@rilk.com>)
Ответы Re: Extended unit  (Greg Stark <gsstark@mit.edu>)
Список 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.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Thomas Chille
Дата:
Сообщение: Re: difficult JOIN
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Extended unit