1
0
mirror of https://github.com/haiwen/ccnet-server.git synced 2025-09-16 14:59:56 +00:00

Conditional compile MySQL and PostgreSQL support.

This commit is contained in:
Jiaqiang Xu
2016-08-20 17:50:06 +08:00
parent 48c3f5edef
commit 51bde41209
5 changed files with 59 additions and 6 deletions

View File

@@ -6,7 +6,19 @@ noinst_LTLIBRARIES = libdbwrapper.la
noinst_HEADERS = db-wrapper.h mysql-db-ops.h sqlite-db-ops.h pgsql-db-ops.h
libdbwrapper_la_SOURCES = db-wrapper.c mysql-db-ops.c sqlite-db-ops.c pgsql-db-ops.c
if WITH_MYSQL
MYSQL_DB_SRC = mysql-db-ops.c
else
MYSQL_DB_SRC =
endif
if WITH_POSTGRESQL
PGSQL_DB_SRC = pgsql-db-ops.c
else
PGSQL_DB_SRC =
endif
libdbwrapper_la_SOURCES = db-wrapper.c sqlite-db-ops.c $(MYSQL_DB_SRC) $(PGSQL_DB_SRC)
libdbwrapper_la_LDFLAGS = -Wl,-z -Wl,defs
libdbwrapper_la_LIBADD = @SSL_LIBS@ @GLIB2_LIBS@ @MYSQL_LIBS@ -lsqlite3 @PGSQL_LIBS@

View File

@@ -1,9 +1,15 @@
#include "common.h"
#include "db-wrapper.h"
#include "mysql-db-ops.h"
#include "sqlite-db-ops.h"
#ifdef HAVE_MYSQL
#include "mysql-db-ops.h"
#endif
#ifdef HAVE_POSTGRESQL
#include "pgsql-db-ops.h"
#endif
typedef struct DBOperations {
void (*db_conn_pool_free) (DBConnPool *);
@@ -40,6 +46,8 @@ init_conn_pool_common (DBConnPool *pool, int max_connections)
pool->max_connections = max_connections;
}
#ifdef HAVE_MYSQL
DBConnPool *
db_conn_pool_new_mysql (const char *host,
const char *user,
@@ -81,6 +89,10 @@ db_conn_pool_new_mysql (const char *host,
return pool;
}
#endif
#ifdef HAVE_POSTGRESQL
DBConnPool *
db_conn_pool_new_pgsql (const char *host,
const char *user,
@@ -118,6 +130,8 @@ db_conn_pool_new_pgsql (const char *host,
return pool;
}
#endif
DBConnPool *
db_conn_pool_new_sqlite (const char *db_path, int max_connections)
{