Tuning before moving:
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 25 May 2007 14:37:08 +0000 (14:37 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 25 May 2007 14:37:08 +0000 (14:37 +0000)
 - 64bit build
 - expire example utility build
 - turn off error messages by default
 - build fixes
 - fix for transaction detections from LB

org.glite.lb-utils.db/Makefile
org.glite.lb-utils.db/examples/db_test.c
org.glite.lb-utils.db/interface/db.h
org.glite.lb-utils.db/src/db.c

index 362c7cb..447dd4c 100644 (file)
@@ -50,15 +50,21 @@ COMPILE:=libtool --mode=compile ${CC} ${CFLAGS}
 LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS} 
 INSTALL:=libtool --mode=install install
 
+archlib:=lib
+host_cpu:=${shell uname -m}
+ifeq (${host_cpu},x86_64) 
+    archlib:=lib64
+endif
+
 ifneq (${mysql_prefix},/usr)
        ifeq ($(shell echo ${mysql_version} | cut -d. -f1,2),4.1)
-               mysqlib := -L${mysql_prefix}/lib/mysql
+               mysqlib := -L${mysql_prefix}/${archlib}/mysql
        else
-               mysqlib := -L${mysql_prefix}/lib
+               mysqlib := -L${mysql_prefix}/${archlib}
        endif
 endif
 
-EXT_LIBS:=${mysqlib} -lmysqlclient -lglite_lbu_trio
+EXT_LIBS:=${mysqlib} -lmysqlclient -lz -lglite_lbu_trio
 OBJS:=db.o
 TESTOBJS:=dbtest.o
 HDRS:=db.h
@@ -77,6 +83,9 @@ dbtest.lo dbtest.o: db.c db.h
 db_test: db_test.lo libglite_lbu_dbtest.la
        ${LINK} -o $@ $+ ${EXT_LIBS}
 
+db_expire: db_expire.lo libglite_lbu_dbtest.la
+       ${LINK} -o $@ $+ ${EXT_LIBS}
+
 default all: compile
 
 compile: libglite_lbu_db.la
@@ -89,7 +98,7 @@ test_coverage:
        cd coverage && $(MAKE) -f ../Makefile top_srcdir=../../ COVERAGE_FLAGS="-fprofile-arcs -ftest-coverage" check
        cd coverage && for i in `echo ${OBJS} | tr ' ' '\012' | sort -u`; do gcov $$i ; done
 
-examples: db_test
+examples: db_test db_expire
 
 doc:
        doxygen C.dox
index 7890031..02be92a 100644 (file)
@@ -86,7 +86,7 @@ int main(int argn, char *argv[]) {
                goto failcon;
        }
        // caps
-       glite_lbu_DBSetCaps(ctx, caps);
+       glite_lbu_DBSetCaps(ctx, caps || GLITE_LBU_DB_CAP_ERRORS);
        dprintf(("capabilities: %d\n", caps));
        // create all needed tables and data
        dprintf(("creating tables...\n"));
index 0c9002a..2818a4e 100644 (file)
@@ -50,6 +50,14 @@ extern "C" {
 
 
 /**
+ * Print all errors.
+ *
+ * Not returned from detection of capabilities.
+ */
+#define GLITE_LBU_DB_CAP_ERRORS 8
+
+
+/**
  * Database connection context.
  */
 typedef struct glite_lbu_DBContext_s *glite_lbu_DBContext;
index ba54dfb..bce48b8 100644 (file)
@@ -14,7 +14,7 @@
 #include <mysqld_error.h>
 #include <errmsg.h>
 
-#include "glite/lb-utils/trio.h"
+#include "glite/lbu/trio.h"
 #include "db.h"
 
 
@@ -35,6 +35,7 @@
 
 #define USE_TRANS(CTX) ((CTX->caps & GLITE_LBU_DB_CAP_TRANSACTIONS) != 0)
 
+#define dprintf(CTX, FMT...) if (CTX->caps & GLITE_LBU_DB_CAP_ERRORS) fprintf(stderr, ##FMT)
 
 
 struct glite_lbu_DBContext_s {
@@ -708,7 +709,7 @@ static int lbu_err(glite_lbu_DBContext ctx, int code, const char *desc, const ch
                ctx->err.code = code;
                free(ctx->err.desc);
                ctx->err.desc = desc ? strdup(desc) : NULL;
-               fprintf(stderr, "[db] %s:%d %s\n", func, line, desc);
+               dprintf(ctx, "[db %d] %s:%d %s\n", getpid(), func, line, desc);
                return code;
        } else
                return ctx->err.code;
@@ -844,13 +845,13 @@ static int transaction_test(glite_lbu_DBContext ctx, MYSQL *m2, int *have_transa
        pid = getpid();
        *have_transactions = 0;
 
-       asprintf(&cmd_create, "CREATE TABLE test%d (item INT)", pid);
+       asprintf(&cmd_create, "CREATE TABLE test%d (item INT) ENGINE='innodb'", pid);
        asprintf(&cmd_insert, "INSERT INTO test%d (item) VALUES (1)", pid);
        asprintf(&cmd_select, "SELECT item FROM test%d", pid);
        asprintf(&cmd_drop, "DROP TABLE test%d", pid);
 
        m1 = ctx->mysql;
-       glite_lbu_ExecSQL(ctx, cmd_drop, NULL);
+       //glite_lbu_ExecSQL(ctx, cmd_drop, NULL);
        if (glite_lbu_ExecSQL(ctx, cmd_create, NULL) != 0) goto err1;
        if (glite_lbu_Transaction(ctx) != 0) goto err2;
        if (glite_lbu_ExecSQL(ctx, cmd_insert, NULL) != 1) goto err2;