Search Postgresql Archives

Re: Row type select syntax - inconsistency or misunderstanding?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 23, 2006 at 02:31:35PM -0400, Tom Lane wrote:
> Randall Lucas <rlucas@xxxxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux