From: Ian Jackson Date: Tue, 29 Sep 2009 17:16:32 +0000 (+0100) Subject: Fix up nislands; use BEGIN X-Git-Tag: 5.0^2~97 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=commitdiff_plain;h=653fdb17f1516833afb04b034dff94eb610adea7 Fix up nislands; use BEGIN --- diff --git a/yarrg/rscommon.h b/yarrg/rscommon.h index 5c4b3c8..8bfe3e1 100644 --- a/yarrg/rscommon.h +++ b/yarrg/rscommon.h @@ -4,7 +4,8 @@ #include #define DEBUG_FLAG_LIST \ - DF(sql) + DF(sql) \ + DF(value) #define SQL_MUST( call ) ({ \ diff --git a/yarrg/rssetup.c b/yarrg/rssetup.c index 6538677..e169dd5 100644 --- a/yarrg/rssetup.c +++ b/yarrg/rssetup.c @@ -4,8 +4,22 @@ sqlite3 *db; sqlite3_stmt *ss_ipair; +static int busy_handler(void *u, int previous) { + if (DEBUGP(sql)) fprintf(stderr,"[[DB BUSY %d]]",previous); + sysassert(! usleep(5000) ); + return 1; +} + void setup(void) { + sqlite3_stmt *sst; + SQL_MUST( sqlite3_open("OCEAN-Midnight.db", &db) ); + SQL_MUST( sqlite3_busy_handler(db, busy_handler, 0) ); + + SQL_MUST( sqlite3_prepare(db, "BEGIN", -1, &sst, 0) ); + assert( !SQL_STEP(sst) ); + sqlite3_finalize(sst); + setup_value(); } @@ -15,9 +29,21 @@ int sql_step_wrap(sqlite3_stmt *ssh, const char *ssh_string, int sqr; sqr= sqlite3_step((ssh)); switch (sqr) { - case SQLITE_DONE: return 0; - case SQLITE_ROW: return 1; - case SQLITE_BUSY: sysassert(! usleep(5000) ); break; + case SQLITE_DONE: + if (DEBUGP(sql)) + fprintf(stderr,"SQL %s DONE\n",ssh_string); + return 0; + case SQLITE_ROW: + if (DEBUGP(sql)) { + int i; + fprintf(stderr,"SQL %s R",ssh_string); + for (i=0; i