select_values (PGconn)

    /*
     * call-seq:
     *   conn.select_values(query, *bind_values)
     *
     * Equivalent to conn.query(query, *bind_values).flatten
     */
    static VALUE
    pgconn_select_values(argc, argv, self)
        int argc;
        VALUE *argv;
        VALUE self;
    {
        VALUE pg_result = pgconn_exec(argc, argv, self);
        PGresult * result = get_pgresult(pg_result);
        int ntuples = PQntuples(result);
        int nfields = PQnfields(result);

        VALUE values = rb_ary_new2(ntuples * nfields);
        int row_num, field_num;
        for (row_num = 0; row_num < ntuples; row_num++) {
          for (field_num = 0; field_num < nfields; field_num++) {
            rb_ary_push(values, fetch_pgresult(result, row_num, field_num));
          }
        }

        pgresult_clear(pg_result);
        return values;
    }