add .gitignore
[ftsbench.git] / utils.c
diff --git a/utils.c b/utils.c
index cf05816..ccbc42d 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -50,10 +50,8 @@ sb_add(StringBuf *b, char *s, int length)
                        b->str = (char*)realloc( b->str, sizeof(char) * b->length );
                }
 
-               if (!b->str) {
-                       fprintf(stderr,"Not enough memory (%d bytes)\n", b->length);
-                       exit(1);
-               }
+               if (!b->str) 
+                       fatal("Not enough memory (%d bytes)\n", b->length);
        }
 
        memcpy(b->str + b->strlen, s, length);
@@ -61,4 +59,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"
+               "--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
+       );
+}