title: Insert within function fails with "query has no destination for result data"
body: <p>Here is the complete example code: </p>
  
  <pre><code>CREATE TABLE testtbl (
    id     integer NOT NULL, 
    intval integer,
    strval varchar(64)
  );
  CREATE SEQUENCE testtbl_id_seq 
    START WITH 1 INCREMENT BY 1 
    NO MINVALUE NO MAXVALUE CACHE 1;
  ALTER SEQUENCE testtbl_id_seq OWNED BY testtbl.id;
  ALTER TABLE ONLY testtbl ALTER COLUMN id SET DEFAULT
    nextval('testtbl_id_seq'::regclass);
  ALTER TABLE ONLY testtbl ADD CONSTRAINT testtbl_pkey PRIMARY KEY (id);
  
  CREATE FUNCTION insert_testtbl (p_intval integer, p_strval varchar(64)) 
    RETURNS integer AS $$ 
    DECLARE
      v_new_id integer;
    BEGIN
      INSERT INTO testtbl (intval, strval) VALUES (p_intval, p_strval) 
        RETURNING v_new_id;
      RETURN v_new_id;
    END;
  $$ LANGUAGE plpgsql;
  
  SELECT insert_testtbl(1, 'One');
  </code></pre>
  
  <p>When I run this (PostgreSQL version is 9.6.1), I get:</p>
  
  <pre><code>ERROR:  query has no destination for result data
  CONTEXT:  PL/pgSQL function insert_testtbl(integer,character varying) line 5 at SQL statement
  </code></pre>
  
  <p>This doesn't make sense; I <em>AM</em> specifying a destination for the result!</p>
  
  <p>What am I doing wrong here? Thanks!!!</p>