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 "seaf-db.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#ifdef HAVE_MYSQL
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
#endif
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
@@ -43,6 +45,8 @@ typedef struct DBOperations {
|
|||||||
|
|
||||||
static DBOperations db_ops;
|
static DBOperations db_ops;
|
||||||
|
|
||||||
|
#ifdef HAVE_MYSQL
|
||||||
|
|
||||||
/* MySQL Ops */
|
/* MySQL Ops */
|
||||||
static SeafDB *
|
static SeafDB *
|
||||||
mysql_db_new (const char *host,
|
mysql_db_new (const char *host,
|
||||||
@@ -105,6 +109,8 @@ seaf_db_new_mysql (const char *host,
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* SQLite Ops */
|
/* SQLite Ops */
|
||||||
static SeafDB *
|
static SeafDB *
|
||||||
sqlite_db_new (const char *db_path);
|
sqlite_db_new (const char *db_path);
|
||||||
@@ -500,6 +506,8 @@ seaf_db_trans_foreach_selected_row (SeafDBTrans *trans, const char *sql,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_MYSQL
|
||||||
|
|
||||||
/* MySQL DB */
|
/* MySQL DB */
|
||||||
|
|
||||||
typedef struct MySQLDB {
|
typedef struct MySQLDB {
|
||||||
@@ -936,6 +944,8 @@ mysql_db_row_get_column_int64 (SeafDBRow *vrow, int idx)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_MYSQL */
|
||||||
|
|
||||||
/* SQLite DB */
|
/* SQLite DB */
|
||||||
|
|
||||||
/* SQLite thread synchronization rountines.
|
/* SQLite thread synchronization rountines.
|
||||||
|
@@ -51,6 +51,8 @@ sqlite_db_start (SeafileSession *session)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_MYSQL
|
||||||
|
|
||||||
#define MYSQL_DEFAULT_PORT 3306
|
#define MYSQL_DEFAULT_PORT 3306
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -124,6 +126,8 @@ mysql_db_start (SeafileSession *session)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_POSTGRESQL
|
#ifdef HAVE_POSTGRESQL
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -197,9 +201,11 @@ load_database_config (SeafileSession *session)
|
|||||||
if (!type || strcasecmp (type, "sqlite") == 0) {
|
if (!type || strcasecmp (type, "sqlite") == 0) {
|
||||||
ret = sqlite_db_start (session);
|
ret = sqlite_db_start (session);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_MYSQL
|
||||||
else if (strcasecmp (type, "mysql") == 0) {
|
else if (strcasecmp (type, "mysql") == 0) {
|
||||||
ret = mysql_db_start (session);
|
ret = mysql_db_start (session);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#ifdef HAVE_POSTGRESQL
|
#ifdef HAVE_POSTGRESQL
|
||||||
else if (strcasecmp (type, "pgsql") == 0) {
|
else if (strcasecmp (type, "pgsql") == 0) {
|
||||||
ret = pgsql_db_start (session);
|
ret = pgsql_db_start (session);
|
||||||
|
11
configure.ac
11
configure.ac
@@ -228,12 +228,17 @@ AC_SUBST(ZLIB_CFLAGS)
|
|||||||
AC_SUBST(ZLIB_LIBS)
|
AC_SUBST(ZLIB_LIBS)
|
||||||
|
|
||||||
if test "x${MYSQL_CONFIG}" = "xdefault_mysql_config"; then
|
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"])
|
||||||
AC_SUBST(MYSQL_CFLAGS)
|
if test "x${have_mysql}" = "xyes"; then
|
||||||
AC_SUBST(MYSQL_LIBS)
|
AC_SUBST(MYSQL_CFLAGS)
|
||||||
|
AC_SUBST(MYSQL_LIBS)
|
||||||
|
AC_DEFINE([HAVE_MYSQL], 1, [Define to 1 if MySQL support is enabled])
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
|
AC_MSG_CHECKING([for MySQL])
|
||||||
MYSQL_CFLAGS=`${MYSQL_CONFIG} --include`
|
MYSQL_CFLAGS=`${MYSQL_CONFIG} --include`
|
||||||
MYSQL_LIBS=`${MYSQL_CONFIG} --libs`
|
MYSQL_LIBS=`${MYSQL_CONFIG} --libs`
|
||||||
|
AC_MSG_RESULT([${MYSQL_CFLAGS}])
|
||||||
AC_SUBST(MYSQL_CFLAGS)
|
AC_SUBST(MYSQL_CFLAGS)
|
||||||
AC_SUBST(MYSQL_LIBS)
|
AC_SUBST(MYSQL_LIBS)
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user