pthread_t *tid = (pthread_t*)malloc( sizeof(pthread_t) * nclients);
struct timeval begin;
double elapsed;
- int total=0;
+ int total=0, nres=0;
struct timespec sleepTo = { 0, 0 };
/*
for(i=0;i<nclients;i++) {
pthread_join(tid[i], NULL);
+ nres += dbs[i]->nres;
dbs[i]->Close(dbs[i]);
}
printf("%s%d(%.02f%%) queries proceed\n",
(quiet) ? "" : "\r", total, (100.0*(float)total)/(nclients * n));
+ printf("Total number of result: %d\n", nres);
printf("Total time: %.02f sec, Queries per second: %.02f\n", elapsed, total/elapsed);
fflush(stdout);
}
static void
execQuery(ftsDB *adb, char **words, int flags) {
ftsMY *db = (ftsMY*)adb;
- static MYSQL_BIND data;
+ static MYSQL_BIND datain, dataout;
+ static int intout;
+ static my_bool isnull, my_error;
+ static unsigned long length;
MYSQL_RES *res;
if ( db->prepareStmt == NULL ) {
exit(1);
}
- memset(&data, 0, sizeof(MYSQL_BIND));
- data.buffer_type = MYSQL_TYPE_BLOB;
- data.length = (unsigned long*)&(db->b.strlen);
+ memset(&datain, 0, sizeof(MYSQL_BIND));
+ datain.buffer_type = MYSQL_TYPE_BLOB;
+ datain.length = (unsigned long*)&(db->b.strlen);
+
+ memset(&dataout, 0, sizeof(MYSQL_BIND));
+ dataout.buffer_type= MYSQL_TYPE_LONG;
+ dataout.buffer= (char *)&intout;
+ dataout.is_null= &isnull;
+ dataout.length= &length;
+ dataout.error= &my_error;
db->flags = flags;
}
words++;
}
- data.buffer = db->b.str;
- data.buffer_length = db->b.strlen;
+ datain.buffer = db->b.str;
+ datain.buffer_length = db->b.strlen;
- if ( mysql_stmt_bind_param(db->prepareStmt, &data) ) {
+ if ( mysql_stmt_bind_param(db->prepareStmt, &datain) ) {
fprintf(stderr,"mysql_stmt_bind_param failed: %s\n", mysql_error(db->conn));
exit(1);
}
+ res = mysql_stmt_result_metadata(db->prepareStmt);
+ if ( !res ) {
+ fprintf(stderr,"mysql_stmt_result_metadata failed: %s\n", mysql_error(db->conn));
+ exit(1);
+ }
+
if ( mysql_stmt_execute( db->prepareStmt ) ) {
fprintf(stderr,"mysql_stmt_execute failed: %s\n", mysql_error(db->conn));
exit(1);
}
- res = mysql_store_result(db->conn);
- if ( res == NULL ) {
- if ( mysql_errno(db->conn)!=0 ) {
- fprintf(stderr,"mysql_store_result failed: %s\n", mysql_error(db->conn));
- exit(1);
- }
- } else
- mysql_free_result(res);
+ if (mysql_stmt_bind_result( db->prepareStmt, &dataout)) {
+ fprintf(stderr,"mysql_stmt_bind_result failed: %s\n", mysql_error(db->conn));
+ exit(1);
+ }
+
+ if ( mysql_stmt_store_result( db->prepareStmt ) ) {
+ fprintf(stderr,"mysql_stmt_store_result failed: %s\n", mysql_error(db->conn));
+ exit(1);
+ }
+
+ if ( !mysql_stmt_fetch( db->prepareStmt) ) {
+ db->db.nres += intout;
+ } else {
+ fprintf(stderr,"mysql_stmt_fetch returns void result\n");
+ exit(1);
+ }
+
+ mysql_free_result(res);
pthread_mutex_lock(&(db->db.nqueryMutex));
db->db.nquery ++;