Re: Row type select syntax - inconsistency or misunderstanding? - Mailing list pgsql-general

From Randall Lucas
Subject Re: Row type select syntax - inconsistency or misunderstanding?
Date
Msg-id 20060823184309.GT17085@ontology.tercent.com
Whole thread Raw
In response to Re: Row type select syntax - inconsistency or misunderstanding?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Wed, Aug 23, 2006 at 02:31:35PM -0400, Tom Lane wrote:
> Randall Lucas <rlucas@tercent.com> writes:
> > In trying to retrieve a row as a composite rowtype from a table, I'm running
> > into what appears to be an inconsistent result based on whether I select *,
> > table.*, or the list of columns in the table:
>
> FWIW, we've changed the behavior of ROW(foo.*) for 8.2 --- it now
> behaves as if you'd written out all the columns of foo explicitly.
> I don't have a solution for you in 8.1 short of writing 'em all out :-(

If one is willing to construct an expression (for example, for use in
an EXECUTE within a plpgsql function), the following works in 8.1.3:

    create or replace function audit_table_thing(int) returns int as $$
    declare
    in_id alias for $1;
    record_text text;
    begin
    select into record_text quote_literal(textin(record_out(thing.*))) from thing where id=in_id;
    raise notice '%', record_text;
    execute 'insert into thing_audit (audit_id, thing_row) values (' || in_id || ', cast(' || record_text || ' as
thing))'; 
    return 1;
    end
    $$ language 'plpgsql';

Is it safe to say that the row functions are bleeding edge?

Randall

--
Randall Lucas       Tercent, Inc.       DF93EAD1

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Row type select syntax - inconsistency or misunderstanding?
Next
From: Don Isgitt
Date:
Subject: Re: pl/R problem