Re: SYNONYMS (again)

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SYNONYMS (again)
Date: 2011-06-23 18:58:54
Message-ID: 4E03469E020000250003EB31@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-06-23 19:02:13 Re: spinlock contention
Previous Message Gurjeet Singh 2011-06-23 18:44:57 Re: SYNONYMS (again)