/* * Copyright (c) 2006 Teodor Sigaev * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include "ftsbench.h" void sb_add(StringBuf *b, char *s, int length) { if ( length <=0 ) length = strlen(s); if ( b->strlen + length + 1 >= b->length ) { if ( b->str == NULL || b->length == 0 ) { b->length = (length + 1)*4; b->str = (char*)malloc( sizeof(char) * b->length ); } else { do b->length *= 2; while( b->strlen + length + 1 >= b->length ); b->str = (char*)realloc( b->str, sizeof(char) * b->length ); } if (!b->str) fatal("Not enough memory (%d bytes)\n", b->length); } memcpy(b->str + b->strlen, s, length); b->strlen += 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" "--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" " 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 ); }