Re: Extended unit

From: Pailloncy Jean-Gerard <jg(at)rilk(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Extended unit
Date: 2005-01-25 15:16:53
Message-ID: 24C2C6B8-6EE4-11D9-8B82-000A95DE2550@rilk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Is CREATE TYPE what you're looking for?
> http://www.postgresql.org/docs/8.0/static/sql-createtype.html
No. I'll try to give an exemple of what I want:

I suppose I have the following table
CREATE TABLE experiment (
distance DOUBLE,
time DOUBLE,
speed DOUBLE
);

I can do the following query :
SELECT distance+time+speed FROM experiment;

This is a valid SQL query, but there is no physical meaning.

Now, I suppose I have "extended type". So the table is:
CREATE TABLE experiment (
distance DOUBLE(m1),
time DOUBLE(s1),
speed DOUBLE(m1s-1),
);

distance is of type DOUBLE and of unit METER
time is of type DOUBLE and of unit SECOND
speed is of type DOUBLE and of unit METER/SECOND

SELECT distance+time+speed FROM experiment;
Would throw an error : "Incompatible unit M1, S1, M1S-1"

SELECT distance/time+speed FROM experiment;
would succeed (obviously).

It may be possible to mess with domain/type to achieve a draft.
But I pretty sure that we need extend the type system to achieve it
cleanly.

Cordialement,
Jean-Gérard Pailloncy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message alejandro fernandez 2005-01-25 15:24:49 Restaurando una base de datos
Previous Message Frank D. Engel, Jr. 2005-01-25 15:09:44 Re: What is the format of 'binary' data in the postgresql client/server protocol version 3