Re: proposal: plpgsql - iteration over fields of rec or row variable

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: proposal: plpgsql - iteration over fields of rec or row variable
Date: 2010-11-09 17:18:20
Message-ID: AANLkTi=Vxi=34KiHY2=EFpY4yTXZwXZPZ38Q-FEeOOsk@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hey David,

2010/11/9 David E. Wheeler <david(at)kineticode(dot)com>

> On Nov 9, 2010, at 1:38 AM, Dmitriy Igrishin wrote:
>
> > * text[] = record_to_array(record)
> > * table(id, key, datatype, value) = record_to_table(record)
> > * text = record_get_field(record, text)
> > * record = record_set_field(record, text, anyelement)
> >
> > ??
> > I personally like it. But I propose to add as well:
> > integer := record_nkeys();
> > text := record_get_field(record, integer);
>
> You realize you can pretty much do all this with hstore, right?
>
> hstore hash := hstore(record);
> ary text[] := hstore_to_matrix(hash);
> select * from each(hash); -- TABLE
> text foo := hash -> somekey;
> hash := hash || '"key","value"'::hstore;
> record := populate_record(record, hash);
>
> Yep, but hstore is an additional module. Although, its not a problem.

> Best,
>
> David
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
// Dmitriy.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2010-11-09 17:18:51 Re: proposal: plpgsql - iteration over fields of rec or row variable
Previous Message Tom Lane 2010-11-09 17:15:13 Re: Protecting against unexpected zero-pages: proposal