+ /* Now use the count() function to find the total number of cases
+ that this query returns.
+ Doing this incurs some overhead. The server has to iterate every
+ case in order to find this number. However, it's performed on the
+ server side, and in all except the most huge databases the extra
+ overhead will be worth the effort.
+ On the other hand, most PSPP functions don't need to know this.
+ The GUI is the notable exception.
+ */
+ ds_init_cstr (&query, "SELECT count (*) FROM (");
+ ds_put_substring (&query, info->sql.ss);
+ ds_put_cstr (&query, ") stupid_sql_standard");
+
+ qres = PQexec (r->conn, ds_cstr (&query));
+ ds_destroy (&query);
+ if ( PQresultStatus (qres) != PGRES_TUPLES_OK )
+ {
+ msg (ME, _("Error from psql source: %s."),
+ PQresultErrorMessage (qres));
+ goto error;
+ }
+ n_cases = atol (PQgetvalue (qres, 0, 0));
+ PQclear (qres);
+
+ qres = PQexec (r->conn, "FETCH FIRST FROM pspp");
+ if ( PQresultStatus (qres) != PGRES_TUPLES_OK )