X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 97BF3D1B91C for ; Mon, 15 Mar 2004 14:06:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 22347-05 for ; Mon, 15 Mar 2004 10:06:39 -0400 (AST) Received: from guinness.cs.stevens-tech.edu (guinness.cs.stevens-tech.edu [155.246.89.8]) by svr1.postgresql.org (Postfix) with ESMTP id EBB37D1CC8D for ; Mon, 15 Mar 2004 10:06:35 -0400 (AST) Received: from dab.cs.stevens-tech.edu (dab.cs.stevens-tech.edu [155.246.89.71]) by guinness.cs.stevens-tech.edu (Postfix) with ESMTP id 8B7B0141642; Mon, 15 Mar 2004 09:06:32 -0500 (EST) Received: by dab.cs.stevens-tech.edu (Postfix, from userid 4405) id 822081CD818; Mon, 15 Mar 2004 09:06:39 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by dab.cs.stevens-tech.edu (Postfix) with ESMTP id 5E24D1BBC70; Mon, 15 Mar 2004 09:06:39 -0500 (EST) Date: Mon, 15 Mar 2004 09:06:39 -0500 (EST) From: Yasir Malik To: John DeSoi Cc: PostgreSQL Subject: Re: Object-relational features In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/157 X-Sequence-Number: 17256 Dr. DeSoi Thanks for your reply. What is an "immutable strict" and what is an "internal" language? Does Postgres plan on implenting types as Oracle does? For example: create type AddrType as (street char(20), city char(20), zip char(5)); create type CustType as (name varchar(2), addr AddrType); create table Cust of CustType; Which is superior to Postgres's way of implementing types (writing a C function). Thanks, Yasir On Mon, 15 Mar 2004, John DeSoi wrote: > Date: Mon, 15 Mar 2004 08:28:50 -0500 > From: John DeSoi > To: Yasir Malik > Cc: PostgreSQL > Subject: Re: [SQL] Object-relational features > > > 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. > > Best, > > 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. > CREATE FUNCTION > test=# create or replace function lispout(lisp) returns cstring as > 'varcharout' language 'internal' immutable strict; > NOTICE: argument type lisp is only a shell > CREATE FUNCTION > test=# create type lisp (input=lispin, output=lispout, > internallength=variable); > CREATE TYPE > test=# create table tst (a lisp); > CREATE TABLE > 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; > a > --------- > 1 > (+ 5 5) > (2 rows) > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html >