From: teodor Date: Fri, 27 Oct 2006 08:59:15 +0000 (+0000) Subject: Add scheme creation for statistic X-Git-Url: http://sigaev.ru/git/gitweb.cgi?p=ftsbench.git;a=commitdiff_plain;h=430dd7ec2f63bd59274f832a28d45eb6cf737cbd Add scheme creation for statistic --- diff --git a/ftsbench.c b/ftsbench.c index a0ef1f3..4eb5c4b 100644 --- a/ftsbench.c +++ b/ftsbench.c @@ -116,6 +116,11 @@ usage() { " or - OR'ing lexemes in query\n", stdout ); + fputs( + "Print SQL-scheme for statistics:\n" + "ftsbench -S\n", + stdout + ); exit(1); } @@ -245,10 +250,10 @@ main(int argn, char *argv[]) { RDBMS rdbms = NULLSQL; int flags = 0; int i; - int quiet = 0; + int quiet = 0, scheme=0; StringBuf b = {NULL,0,0}; - while((i=getopt(argn,argv,"ib:n:l:g:d:c:hf:q")) != EOF) { + while((i=getopt(argn,argv,"ib:n:l:g:d:c:hf:qS")) != EOF) { switch(i) { case 'i': initMode = 1; break; case 'b': rdbms = getRDBMS(optarg); break; @@ -259,12 +264,18 @@ main(int argn, char *argv[]) { case 'd': dbname = strdup(optarg); break; case 'f': flags = getFLAGS(optarg); break; case 'q': quiet = 1; break; + case 'S': scheme = 1; break; case 'h': default: usage(); } } + if ( scheme ) { + printScheme(); + return 0; + } + if (rdbms == NULLSQL) rdbms = getRDBMS(NULL); diff --git a/ftsbench.h b/ftsbench.h index 00c1a62..c29c5ed 100644 --- a/ftsbench.h +++ b/ftsbench.h @@ -40,6 +40,7 @@ typedef struct { } StringBuf; void sb_add(StringBuf *b, char *s, int length); +void printScheme(); /* rand.c */ long rnd(); diff --git a/utils.c b/utils.c index cf05816..213f2fb 100644 --- a/utils.c +++ b/utils.c @@ -61,4 +61,56 @@ sb_add(StringBuf *b, char *s, int length) b->str[ b->strlen ] = '\0'; } +void +printScheme() { + fputs( + "DROP TABLE IF EXISTS fb_create CASCADE;\n" + "DROP TABLE IF EXISTS fb_search CASCADE;\n" + "DROP TABLE IF EXISTS fb_row CASCADE;\n", + stdout + ); + fputs( + "--init configuration\n" + "CREATE TABLE fb_create (\n" + " id integer PRIMARY KEY,\n" + " rdbms text NOT NULL,\n" + " f_gin boolean NOT NULL,\n" + " f_gist boolean NOT NULL,\n" + " f_func boolean NOT NULL,\n" + " rows integer NOT NULL,\n" + " elapsed double precision NOT NULL\n" + ");\n", + stdout + ); + + fputs( + "--summary stats\n" + "CREATE TABLE fb_search (\n" + " id integer NOT NULL,\n" + "--link to fb_create.id\n" + " f_and boolean NOT NULL,\n" + " f_or boolean NOT NULL,\n" + " nclients integer NOT NULL,\n" + " nqueries integer NOT NULL,\n" + " nres integer NOT NULL,\n" + " elapsed double precision NOT NULL\n" + ");\n", + stdout + ); + + fputs( + "--stat per query\n" + "CREATE TABLE fb_row (\n" + "--link to fb_create.id\n" + " id integer NOT NULL,\n" + " f_and boolean NOT NULL,\n" + " f_or boolean NOT NULL,\n" + " nclients integer NOT NULL,\n" + " query text NOT NULL,\n" + " nres integer NOT NULL,\n" + " elapsed double precision NOT NULL\n" + ");\n", + stdout + ); +}