Re: SYNONYMS (again) - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: SYNONYMS (again)
Date
Msg-id 4E03469E020000250003EB31@gw.wicourts.gov
Whole thread Raw
In response to Re: SYNONYMS (again)  (Gurjeet Singh <singh.gurjeet@gmail.com>)
Responses Re: SYNONYMS (again)
List pgsql-hackers
Gurjeet Singh <singh.gurjeet@gmail.com> wrote:
> Instead of just synonyms of columns, why don't we think about
implementing
> virtual columns (feature as named in other RDBMS). This is the
ability to
> define a column in a table which is derived using an expression
around other
> non-virtual columns.
How do you see that working differently from what PostgreSQL can
currently do?
test=# create table line_item(id int primary key not null, quantity int
not null, unit_price numeric(13,2));
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"line_item_pkey" for table "line_item"
CREATE TABLE
test=# insert into line_item values (1,15,'12.53'),(2,5,'16.23');
INSERT 0 2
test=# create function line_total(line_item) returns numeric(13,2)
language sql immutable as $$ select ($1.quantity *
$1.unit_price)::numeric(13,2);$$;
CREATE FUNCTION
test=# select li.id, li.line_total from line_item li;id | line_total
----+------------ 1 |     187.95 2 |      81.15
(2 rows)
-Kevin


pgsql-hackers by date:

Previous
From: Gurjeet Singh
Date:
Subject: Re: SYNONYMS (again)
Next
From: Robert Haas
Date:
Subject: Re: spinlock contention