fflush(stdout);
db->finishCreateScheme(db);
printf("done\n");
+ db->Close(db);
} else {
ftsDB **dbs = initConnections(rdbms, nclients, dbname);
pthread_t *tid = (pthread_t*)malloc( sizeof(pthread_t) * nclients);
elapsed = elapsedtime(&begin);
pthread_mutex_unlock( &mutexFinish );
- for(i=0;i<nclients;i++)
+ for(i=0;i<nclients;i++) {
pthread_join(tid[i], NULL);
+ dbs[i]->Close(dbs[i]);
+ }
printf("\r%d(%.02f%%) queries proceed\n", total, (100.0*(float)total)/(nclients * n));
printf("Total time: %.02f sec, Queries per second: %.02f\n", elapsed, total/elapsed);
void (*startCreateScheme)(struct ftsDB*, int);
void (*finishCreateScheme)(struct ftsDB*);
void (*InsertRow)(struct ftsDB*, int, char*);
+ void (*Close)(struct ftsDB*);
/* stats */
pthread_mutex_t nqueryMutex;
}
}
+static void
+Close(ftsDB* adb) {
+ ftsMY *db = (ftsMY*)adb;
+
+ mysql_close(db->conn);
+}
+
ftsDB*
MYInit(char * connstr) {
ftsMY *db = (ftsMY*)malloc(sizeof(ftsMY));
db->db.startCreateScheme = startCreateScheme;
db->db.finishCreateScheme = finishCreateScheme;
db->db.InsertRow = InsertRow;
+ db->db.Close = Close;
return (ftsDB*)db;
}
db->db.nquery++;
}
+static void
+Close(ftsDB* adb) {
+ ftsPG *db = (ftsPG*)adb;
+
+ PQfinish(db->conn);
+}
+
ftsDB*
PGInit(char * connstr) {
ftsPG *db = (ftsPG*)malloc(sizeof(ftsPG));
db->db.startCreateScheme = startCreateScheme;
db->db.finishCreateScheme = finishCreateScheme;
db->db.InsertRow = InsertRow;
+ db->db.Close = Close;
db->socket = PQsocket(db->conn);
if ( db->socket < 0 ) {
fprintf(stderr,"Socket error\n");