Обсуждение: PostgreSQL 7.3: help on new CREATE TYPE

Поиск
Список
Период
Сортировка

PostgreSQL 7.3: help on new CREATE TYPE

От
"Jerome Chochon"
Дата:
Hi all.
 
I have read the last version of PostgreSQL (7.3 beta) and found that the second version of CREATE TYPE is very interesting.
 
So we can create a type that look like a RECORD.
For example:
CREATE TYPE adress AS (number int, street text, country VARCHAR);
 
But can i use this type in a table definition like this:
CREATE TABLE person (his_name VARCHAR, his_adress adress);
 
Someone can answer to my question.
 
Thanks for your help.
 
Jérôme Chochon.
 
 

Re: PostgreSQL 7.3: help on new CREATE TYPE

От
"Christopher Kings-Lynne"
Дата:
Hi Jerome,

The RECORD type is used for writing stored procedures and functions that
return sets.

eg.  CREATE FUNCTION foo() RETURNS setof adress
AS '...';

Sort of thing...

Chris
-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Jerome Chochon
Sent: Tuesday, 17 September 2002 5:17 PM
To: pgsql-hackers@postgresql.org; pgsql-announce@postgresql.org;
pgsql-general@postgresql.org
Subject: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE


Hi all.

I have read the last version of PostgreSQL (7.3 beta) and found that the
second version of CREATE TYPE is very interesting.

So we can create a type that look like a RECORD.
For example:
CREATE TYPE adress AS (number int, street text, country VARCHAR);

But can i use this type in a table definition like this:
CREATE TABLE person (his_name VARCHAR, his_adress adress);

Someone can answer to my question.

Thanks for your help.

Jérôme Chochon.


Backend crash

От
"Michael Paesold"
Дата:
Hi all,

I have a problem with inserting one milling records into a table using a
function. This is for testing. The backend crashes on that every time,
although the error messages seem to be different. Can I post a full
description here or should that go to pgsql-general?

Thanks.

Best Regards,
Michael Paesold



Re: PostgreSQL 7.3: help on new CREATE TYPE

От
"Jerome Chochon"
Дата:
Sorry if my english is not very good. ;-).

When I say that the second form of CREATE TYPE allow you to make RECORD type
like RECORD, i don't want to speak about the record in PlPgsql but RECORD
from programming language like ADA or C (typedef struct).

So the real question is:
Can I use this new type like other user-type ?
CREATE TABLE person (his_name VARCHAR, his_adress adress);
...where adress is CREATE TYPE adress AS (number int, street text, country
VARCHAR);

Thanks for your reply ?




----- Original Message -----
From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
To: "Jerome Chochon" <jerome.chochon@ensma.fr>;
<pgsql-hackers@postgresql.org>; <pgsql-announce@postgresql.org>;
<pgsql-general@postgresql.org>
Sent: Tuesday, September 17, 2002 11:25 AM
Subject: RE: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE


> Hi Jerome,
>
> The RECORD type is used for writing stored procedures and functions that
> return sets.
>
> eg.  CREATE FUNCTION foo() RETURNS setof adress
> AS '...';
>
> Sort of thing...
>
> Chris
> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Jerome Chochon
> Sent: Tuesday, 17 September 2002 5:17 PM
> To: pgsql-hackers@postgresql.org; pgsql-announce@postgresql.org;
> pgsql-general@postgresql.org
> Subject: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE
>
>
> Hi all.
>
> I have read the last version of PostgreSQL (7.3 beta) and found that the
> second version of CREATE TYPE is very interesting.
>
> So we can create a type that look like a RECORD.
> For example:
> CREATE TYPE adress AS (number int, street text, country VARCHAR);
>
> But can i use this type in a table definition like this:
> CREATE TABLE person (his_name VARCHAR, his_adress adress);
>
> Someone can answer to my question.
>
> Thanks for your help.
>
> Jérôme Chochon.
>


Re: [GENERAL] PostgreSQL 7.3: help on new CREATE TYPE

От
Tom Lane
Дата:
"Jerome Chochon" <jerome.chochon@ensma.fr> writes:
> Can I use this new type like other user-type ?
> CREATE TABLE person (his_name VARCHAR, his_adress adress);
> ...where adress is CREATE TYPE adress AS (number int, street text, country
> VARCHAR);

Not at the moment, though that might be an interesting direction to
pursue in future releases.  At present, the only thing such a type is
useful for is to define the argument or result type of a function that
takes or returns records.

            regards, tom lane

Re: PostgreSQL 7.3: help on new CREATE TYPE

От
"Christopher Kings-Lynne"
Дата:
> When I say that the second form of CREATE TYPE allow you to make
> RECORD type
> like RECORD, i don't want to speak about the record in PlPgsql but RECORD
> from programming language like ADA or C (typedef struct).
>
> So the real question is:
> Can I use this new type like other user-type ?
> CREATE TABLE person (his_name VARCHAR, his_adress adress);
> ...where adress is CREATE TYPE adress AS (number int, street text, country
> VARCHAR);

No.

By the way - the pgsql-announce list is not for asking quetsions in!

Chris


Re: PostgreSQL 7.3: help on new CREATE TYPE

От
elein
Дата:
Illustra did a very nice job with "composite types" which
correspond to these record types.  The composite types
were able to be used as a column type as jerome describes.
The subcolumns were accessed with dots.  This gave usschema.table.column.attribute
where of course attribute could itself be a composite type....
Well, ok, it had some drawbacks, too.

If we ever are serious about implementing this I would help
with discussing and/or writing the specs.  I can put together a nice spec.
When I get a break on my book project, I might just write it up anyway.

elein
elein@norcov.com

PS: Everyone please forgive me for reading list mail late and out of order...
I am in awe of anyone keeping up.

On Tuesday 17 September 2002 07:22, Tom Lane wrote:
> "Jerome Chochon" <jerome.chochon@ensma.fr> writes:
> > Can I use this new type like other user-type ?
> > CREATE TABLE person (his_name VARCHAR, his_adress adress);
> > ...where adress is CREATE TYPE adress AS (number int, street text,
> > country VARCHAR);
>
> Not at the moment, though that might be an interesting direction to
> pursue in future releases.  At present, the only thing such a type is
> useful for is to define the argument or result type of a function that
> takes or returns records.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org