From e8d50f40517546432ce6d23deb0252d975f7daa3 Mon Sep 17 00:00:00 2001 From: paulc Date: Tue, 24 Mar 2009 19:59:59 +0000 Subject: [PATCH] Allow mysqldb to compile on systems without mysql_set_character_set. git-svn-id: http://voip.null.ro/svn/yate@2539 acf43c95-373e-0410-b603-e72c3f656dc1 --- conf.d/mysqldb.conf.sample | 1 + configure.in | 1 + modules/server/mysqldb.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/conf.d/mysqldb.conf.sample b/conf.d/mysqldb.conf.sample index 01dd78ea..ba3e3572 100644 --- a/conf.d/mysqldb.conf.sample +++ b/conf.d/mysqldb.conf.sample @@ -36,4 +36,5 @@ ; encoding: string: Character set encoding used to communicate with the server ; If not set or empty will use the default for your system +; This setting is not available on older MySQL client libraries ;encoding= diff --git a/configure.in b/configure.in index 2d5e4830..a414eec5 100644 --- a/configure.in +++ b/configure.in @@ -336,6 +336,7 @@ if test "$HAVE_MYSQL" = "yes"; then AC_CHECK_DECLS([MYSQL_OPT_RECONNECT],[MYSQL_INC="$MYSQL_INC -DMYSQL_OPT_RECONNECT=MYSQL_OPT_RECONNECT"],,[#include]) AC_CHECK_DECLS([MYSQL_OPT_READ_TIMEOUT],[MYSQL_INC="$MYSQL_INC -DMYSQL_OPT_READ_TIMEOUT=MYSQL_OPT_READ_TIMEOUT"],,[#include]) AC_CHECK_DECLS([MYSQL_OPT_WRITE_TIMEOUT],[MYSQL_INC="$MYSQL_INC -DMYSQL_OPT_WRITE_TIMEOUT=MYSQL_OPT_WRITE_TIMEOUT"],,[#include]) + AC_CHECK_DECLS([mysql_set_character_set],[MYSQL_INC="$MYSQL_INC -DHAVE_MYSQL_SET_CHARSET"],,[#include]) CPPFLAGS=$save_CPPFLAGS fi fi diff --git a/modules/server/mysqldb.cpp b/modules/server/mysqldb.cpp index d601889b..0cb94301 100644 --- a/modules/server/mysqldb.cpp +++ b/modules/server/mysqldb.cpp @@ -181,9 +181,14 @@ bool DbConn::initDb() my_bool reconn = 1; mysql_options(m_conn,MYSQL_OPT_RECONNECT,(const char*)&reconn); #endif +#ifdef HAVE_MYSQL_SET_CHARSET if (m_encoding && mysql_set_character_set(m_conn,m_encoding)) Debug(&module,DebugWarn,"Failed to set encoding '%s' on connection '%s'", m_encoding.c_str(),m_name.c_str()); +#else + if (m_encoding) + Debug(&module,DebugWarn,"Your client library does not support setting the character set"); +#endif return true; } Debug(&module,DebugWarn,"Connection for '%s' failed: %s",m_name.c_str(),mysql_error(m_conn));