Re: Extended unit - Mailing list pgsql-general

From Pailloncy Jean-Gerard
Subject Re: Extended unit
Date
Msg-id 404BC0C9-6F22-11D9-9590-000A95DE2550@rilk.com
Whole thread Raw
In response to Re: Extended unit  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Extended unit  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Extended unit  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
> ... none of which require any extensions to the core type system.
>
> AFAICS this could easily be implemented as a user-defined type, along
> the lines of
>
>     CREATE TYPE measurement AS (value double, units text);
>
> and if you want to constrain a particular column to contain only one
> value of units, use CHECK.
>
> The argument that we should extend the type system for this would
> become
> a lot more credible if there were a widely-used extension in existence
> for it to prove that there's sufficient demand.
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.

Cordialement,
Jean-Gérard Pailloncy


pgsql-general by date:

Previous
From: James Thompson
Date:
Subject: Re: Data entry - forms design or other APIs etc. - what is there?
Next
From: David Siebert
Date:
Subject: Problem with Postgres V 8 and DBI maybe