Add query stats from Internet-wide search engine and make it default
[ftsbench.git] / pgdriver.c
index 0a373b6..adf329f 100644 (file)
@@ -260,7 +260,13 @@ execQuery(ftsDB* adb, char ** words, int flags) {
                        fprintf(stderr, "Execution of prepared statement failed: %s\n", PQerrorMessage(db->conn));
                        exit(1);
                }
+       } else if ( PQntuples(res) == 1 ) {
+               db->db.nres += atoi( PQgetvalue(res,0,0) );
+       } else {
+               fprintf(stderr,"Bad PQntuples %d\n", PQntuples(res));
+               exit(1);
        }
+       
        PQclear(res);
 
        db->emptyquery = 0;
@@ -339,8 +345,7 @@ finishCreateScheme(ftsDB* adb) {
                        sprintf(buf,"CREATE INDEX ftsindex ON ftsbench USING %s ( fts );", 
                                                (db->flags & FLG_GIST) ? "GiST" : "GIN" );
 
-               printf("(create index, ");
-               fflush(stdout);
+               report("(create index, ");
 
                res = PQexec(db->conn, buf);
                if (PQresultStatus(res) != PGRES_COMMAND_OK) {
@@ -348,13 +353,10 @@ finishCreateScheme(ftsDB* adb) {
                                exit(1);
                }
                PQclear(res);
-       } else {
-               printf("(");
-               fflush(stdout);
-       }
+       } else 
+               report("(");
 
-       printf("vacuum");
-       fflush(stdout);
+       report("vacuum");
 
        res = PQexec(db->conn, "VACUUM ANALYZE ftsbench;");
        if (PQresultStatus(res) != PGRES_COMMAND_OK) {
@@ -362,8 +364,8 @@ finishCreateScheme(ftsDB* adb) {
                exit(1);
        }
        PQclear(res);
-       printf(") ");
-       fflush(stdout);
+
+       report(") ");
 
        return;
 }