title: Data commit fails for "Upsert" / Merge function when calling through Npgsql
body: <p>I am using Npgsql 3.0.3 with Postgres 9.4. Here is my code in Postgres:</p>
  
  <pre><code>CREATE TABLE temp_test
  (
    id serial NOT NULL,
    name text,
    CONSTRAINT temp_test_pk PRIMARY KEY (id)
  )
  </code></pre>
  
  <p>and the "Upsert" / merge function that returns the changed record as refcursor:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION test_save(
      v_ref refcursor,
      iv_id integer,
      v_name character varying)
    RETURNS refcursor AS
  $BODY$ 
  DECLARE
    v_ref alias for $1;
    v_id integer := iv_id;
  BEGIN
  
    UPDATE onepm.temp_test
    SET name   = v_name
    WHERE id         = v_id;
    IF NOT FOUND THEN
    INSERT INTO onepm.temp_test
        (name)
    VALUES
        (v_name)
    RETURNING id INTO v_id;
    END IF;
  
    OPEN v_ref FOR
    SELECT id 
         , name
    FROM onepm.temp_test
    WHERE id = v_id;
  
    RETURN v_ref;
  END;
  
  $BODY$
    LANGUAGE plpgsql;
  </code></pre>
  
  <p>In my .net project I have the following function that returns a IDatareader:</p>
  
  <pre><code>public static IDataReader ExecuteReader()
          {
              NpgsqlConnection conn = new NpgsqlConnection(connectionString);
              conn.Open();
  
              NpgsqlTransaction _tran = conn.BeginTransaction();
  
              NpgsqlCommand cmd = conn.CreateCommand();
              cmd.CommandType = CommandType.Text;
              cmd.CommandText = "SELECT onepm.test_save(@ref, @id, @name)";
  
              NpgsqlParameter _p = new NpgsqlParameter();
              _p.ParameterName = "@ref";
              _p.NpgsqlDbType = NpgsqlDbType.Refcursor;
              _p.NpgsqlValue = "ref";
              _p.Direction = ParameterDirection.InputOutput;
              cmd.Parameters.Add(_p);
  
              cmd.Parameters.Add(new NpgsqlParameter("@id", 1));
              cmd.Parameters.Add(new NpgsqlParameter("@name", "test"));
  
              cmd.ExecuteNonQuery();
              cmd.CommandText = "fetch all in \"ref\"";
              cmd.CommandType = CommandType.Text;
  
              return cmd.ExecuteReader();
          }
  </code></pre>
  
  <p>This all works fine, I do receice the inserted or updated record in the reader, except that the data is never committed to the table - no data found in pgAdmin. If I call the same function in pgAdmin everything works fine - records are committed:</p>
  
  <pre><code>SELECT onepm.test_save('v_ref', 1, 'xxxxxx');
  
  FETCH ALL IN "v_ref";
  </code></pre>
  
  <p>Thankful for any help!</p>