> ... 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