Skip site navigation (1) Skip section navigation (2)

Re: Object-relational features

From: John DeSoi <jd(at)icx(dot)net>
To: Yasir Malik <ymalik(at)cs(dot)stevens-tech(dot)edu>
Cc: PostgreSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Object-relational features
Date: 2004-03-15 13:28:50
Message-ID: (view raw or whole thread)
Lists: pgsql-sql
On Mar 13, 2004, at 12:30 PM, Yasir Malik wrote:

> For
> example, using "create type as" is totally worthless because you can't 
> use
> it as a field type in a table; you can't compose in another "create 
> type
> as"; and you can't inherit another composite type.  The only way to 
> create
> a true type is to use "create type" and write C code as a shared 
> object,
> so I'm basically doing everything C, which is not something I want to 
> do.

I'm not sure if this is what you are looking for, but it shows how to 
create a column type based on the text type. So your selects will 
return the column type as your custom type and you can process the 
content accordingly. From reading the docs (and asking on the list) I 
did not think this was possible either without writing external code in 
C. But a post about something else finally provided the clues I needed 
to get it working.


John DeSoi, Ph.D.

test=# create or replace function lispin(cstring, oid, int4) returns 
lisp as 'varcharin' language 'internal' immutable strict;
NOTICE:  type "lisp" is not yet defined
DETAIL:  Creating a shell type definition.
test=# create or replace function lispout(lisp) returns cstring as 
'varcharout' language 'internal' immutable strict;
NOTICE:  argument type lisp is only a shell
test=# create type lisp (input=lispin, output=lispout, 
test=# create table tst (a lisp);
test=# insert into tst (a) values ('1');
INSERT 18499 1
test=# insert into tst (a) values ('(+ 5 5)');
INSERT 18500 1
test=# select * from tst;
  (+ 5 5)
(2 rows)

In response to


pgsql-sql by date

Next:From: Yasir MalikDate: 2004-03-15 14:06:39
Subject: Re: Object-relational features
Previous:From: Paul ThomasDate: 2004-03-15 11:42:23
Subject: Re: Invalid Characters

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group