mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-25 14:42:52 +00:00
Make mysqlclient dependency optional.
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
#include "seaf-db.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_MYSQL
|
||||
#include <mysql.h>
|
||||
#endif
|
||||
#include <sqlite3.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -43,6 +45,8 @@ typedef struct DBOperations {
|
||||
|
||||
static DBOperations db_ops;
|
||||
|
||||
#ifdef HAVE_MYSQL
|
||||
|
||||
/* MySQL Ops */
|
||||
static SeafDB *
|
||||
mysql_db_new (const char *host,
|
||||
@@ -105,6 +109,8 @@ seaf_db_new_mysql (const char *host,
|
||||
return db;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* SQLite Ops */
|
||||
static SeafDB *
|
||||
sqlite_db_new (const char *db_path);
|
||||
@@ -500,6 +506,8 @@ seaf_db_trans_foreach_selected_row (SeafDBTrans *trans, const char *sql,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MYSQL
|
||||
|
||||
/* MySQL DB */
|
||||
|
||||
typedef struct MySQLDB {
|
||||
@@ -936,6 +944,8 @@ mysql_db_row_get_column_int64 (SeafDBRow *vrow, int idx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_MYSQL */
|
||||
|
||||
/* SQLite DB */
|
||||
|
||||
/* SQLite thread synchronization rountines.
|
||||
|
@@ -51,6 +51,8 @@ sqlite_db_start (SeafileSession *session)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MYSQL
|
||||
|
||||
#define MYSQL_DEFAULT_PORT 3306
|
||||
|
||||
static int
|
||||
@@ -124,6 +126,8 @@ mysql_db_start (SeafileSession *session)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSTGRESQL
|
||||
|
||||
static int
|
||||
@@ -197,9 +201,11 @@ load_database_config (SeafileSession *session)
|
||||
if (!type || strcasecmp (type, "sqlite") == 0) {
|
||||
ret = sqlite_db_start (session);
|
||||
}
|
||||
#ifdef HAVE_MYSQL
|
||||
else if (strcasecmp (type, "mysql") == 0) {
|
||||
ret = mysql_db_start (session);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_POSTGRESQL
|
||||
else if (strcasecmp (type, "pgsql") == 0) {
|
||||
ret = pgsql_db_start (session);
|
||||
|
@@ -228,12 +228,17 @@ AC_SUBST(ZLIB_CFLAGS)
|
||||
AC_SUBST(ZLIB_LIBS)
|
||||
|
||||
if test "x${MYSQL_CONFIG}" = "xdefault_mysql_config"; then
|
||||
PKG_CHECK_MODULES(MYSQL, [mysqlclient])
|
||||
PKG_CHECK_MODULES(MYSQL, [mysqlclient], [have_mysql="yes"], [have_mysql="no"])
|
||||
if test "x${have_mysql}" = "xyes"; then
|
||||
AC_SUBST(MYSQL_CFLAGS)
|
||||
AC_SUBST(MYSQL_LIBS)
|
||||
AC_DEFINE([HAVE_MYSQL], 1, [Define to 1 if MySQL support is enabled])
|
||||
fi
|
||||
else
|
||||
AC_MSG_CHECKING([for MySQL])
|
||||
MYSQL_CFLAGS=`${MYSQL_CONFIG} --include`
|
||||
MYSQL_LIBS=`${MYSQL_CONFIG} --libs`
|
||||
AC_MSG_RESULT([${MYSQL_CFLAGS}])
|
||||
AC_SUBST(MYSQL_CFLAGS)
|
||||
AC_SUBST(MYSQL_LIBS)
|
||||
fi
|
||||
|
Reference in New Issue
Block a user