title: Returning a set of hstore values as a set of records of a table type
body: <p>I started to experiment with the audit logging function of Postgres as described in <a href="http://wiki.postgresql.org/wiki/Audit_trigger_91plus" rel="nofollow">http://wiki.postgresql.org/wiki/Audit_trigger_91plus</a>
  This function stores the new values of the changed record in an hstore field.</p>
  
  <p>I would like to retrieve the hstore field values as a <strong>set of records</strong> of the logged table.</p>
  
  <p>Postgres documentation says converting an hstore to a record type goes like this:</p>
  
  <pre><code>CREATE TABLE test (col1 integer, col2 text, col3 text);
  SELECT * FROM populate_record(null::test, '"col1"=&gt;"456", "col2"=&gt;"zzz"');
  </code></pre>
  
  <p>This works for a signle record, but I don't know how to do the same with multiple records. I tried this one:</p>
  
  <pre><code>SELECT
    populate_record(null::public.usr, logged_actions.row_data)
  FROM
    audit.logged_actions
  WHERE
    audit.logged_actions.table_name = 'usr'
  </code></pre>
  
  <p>... but it returns a single composit column for each logged record of the usr table.</p>
  
  <p>Any ideas how to return the set of hstore values as a set of records of type usr here?</p>