Re: Specifying Rowtypes

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Curt Sampson" <cjs(at)cynic(dot)net>, "PostgreSQL Development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Specifying Rowtypes
Date: 2003-01-29 07:53:23
Message-ID: GNELIHDDFBOCMGBFGEFOIEECCFAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

No, in 7.3 you can create anonymous composite types using the CREATE TYPE
command.

Chris

> -----Original Message-----
> From: pgsql-hackers-owner(at)postgresql(dot)org
> [mailto:pgsql-hackers-owner(at)postgresql(dot)org]On Behalf Of Curt Sampson
> Sent: Wednesday, 29 January 2003 1:45 PM
> To: PostgreSQL Development
> Subject: [HACKERS] Specifying Rowtypes
>
>
>
> So currently the only way to specify a row type is by using a table,
> right? E.g.:
>
> CREATE TABLE t2_retval (
> value1 int NOT NULL DEFAULT -1,
> value2 int NOT NULL,
> value3 int
> );
>
> Are there plans to add another way of declaring this sort of thing so
> that I don't have to add a new table to my schema for every function
> that returns a rowtype?
>
> Second, it seems that there's still a problem with NULLs here:
>
> CREATE FUNCTION t2()
> RETURNS t2_retval
> AS '
> DECLARE
> retval t2_retval%ROWTYPE;
> BEGIN
> SELECT INTO retval null, null, null;
> RETURN retval;
> END
> ' LANGUAGE 'plpgsql';
>
> This is returning a row that (to my mind) doesn't match the type of the
> table above, because it's returning null for non-nullable columns:
>
> cjs=> select coalesce(value1, -999), coalesce(value2, -999),
> cjs-> coalesce(value3, -999) from t2();
> case | case | case
> ------+------+------
> -999 | -999 | -999
> (1 row)
>
> (You get the same result if you delete the SELECT INTO line above.)
>
> Am I misunderstanding something here, or is this a bug?
>
> cjs
> --
> Curt Sampson <cjs(at)cynic(dot)net> +81 90 7737 2974 http://www.netbsd.org
> Don't you know, in this new Dark Age, we're all light. --XTC
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-01-29 08:37:11 Re: [mail] Re: Windows Build System
Previous Message Christopher Kings-Lynne 2003-01-29 07:52:27 FW: [GENERAL] problems with dropped columns