title: Postgresql return setof record
body: <p>I have a custom type:</p>
  
  <pre><code>create type some_type as (
      some_bool_param     boolean, 
      str                 varchar
  );
  </code></pre>
  
  <p>I create a table with fields of this type and insert some data:</p>
  
  <pre><code>create table test_table (
      strs some_type
  );
  
  insert into test_table(strs) values
    ((false, 'First str'))
  , ((false, 'Second str '))
  , ((false, 'Third str'))
  , ((false, 'Yet another str'));
  </code></pre>
  
  <p>And now I try to return setof <code>some_type</code> data:</p>
  
  <pre><code>create or replace function get_str() returns setof some_type as
  $$
  declare
      r some_type;
  begin
      for r in 
          select * from test_table loop
      return next r;
      end loop;
      return;
  end;
  </code></pre>
  
  <p>I call <code>get_str()</code>:</p>
  
  <pre><code>select * from get_str();
  </code></pre>
  
  <p>But get an error: </p>
  
  <blockquote>
  <pre><code>ERROR:  error in boolean type value: "(f,"First str")"
  CONTEXT:  PL/pgSQL function "get_str" line 4 at FOR by result of SELECT
  </code></pre>
  </blockquote>
  
  <p>How can I fix it?</p>