diff options
author | paul <paul@7b491191-dbf0-0310-aff6-d879d4d69008> | 2007-03-09 14:32:52 +0000 |
---|---|---|
committer | paul <paul@7b491191-dbf0-0310-aff6-d879d4d69008> | 2007-03-09 14:32:52 +0000 |
commit | 52331240c9fead3baa5565d5d91eddaadd3ae35d (patch) | |
tree | 24e0c7f1150b7ef59e752ffc2384ab83cf133f41 /modules/dbsqlite.c | |
parent | b5ea8360fbc80477a7014bbc2662f6cc17c78f67 (diff) |
merging git tree
git-svn-id: https://svn.ic-s.nl/svn/dbmail/branches/dbmail_2_2_branch@2456 7b491191-dbf0-0310-aff6-d879d4d69008
Diffstat (limited to 'modules/dbsqlite.c')
-rw-r--r-- | modules/dbsqlite.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/modules/dbsqlite.c b/modules/dbsqlite.c index 65cbfdd1..a161c695 100644 --- a/modules/dbsqlite.c +++ b/modules/dbsqlite.c @@ -29,6 +29,7 @@ #define THIS_MODULE "sql" db_param_t _db_params; +#define DBPFX _db_params.pfx static sqlite3 *conn; @@ -244,6 +245,21 @@ static void dbsqlite_cslike(sqlite3_context *context, int argc, sqlite3_value ** } /* this is lifted "almost" :) directly from sqlite -- cut here -- */ +static int create_tables(void) +{ + const char *cq = DM_SQLITECREATE; + char *q = g_strdup_printf("SELECT * FROM %susers LIMIT 1", DBPFX); + db_query(q); // ignore errors + g_free(q); + if (db_num_rows()) + return 0; + TRACE(TRACE_DEBUG,"Creating tables in empty database"); + /* FIXME; this does not respect the DBPFX */ + if ( (db_query(cq)) == -1) + TRACE(TRACE_ERROR, "Creation of tables failed"); + return 0; +} + int db_connect() { int result; @@ -258,7 +274,7 @@ int db_connect() return -1; } sqlite3_busy_timeout(conn, 60000); - return 0; + return create_tables(); } int db_check_connection() |