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
This commit is contained in:
paulc 2009-03-24 19:59:59 +00:00
parent 666f82ade4
commit e8d50f4051
3 changed files with 7 additions and 0 deletions

View File

@ -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=

View File

@ -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<mysql.h>])
AC_CHECK_DECLS([MYSQL_OPT_READ_TIMEOUT],[MYSQL_INC="$MYSQL_INC -DMYSQL_OPT_READ_TIMEOUT=MYSQL_OPT_READ_TIMEOUT"],,[#include<mysql.h>])
AC_CHECK_DECLS([MYSQL_OPT_WRITE_TIMEOUT],[MYSQL_INC="$MYSQL_INC -DMYSQL_OPT_WRITE_TIMEOUT=MYSQL_OPT_WRITE_TIMEOUT"],,[#include<mysql.h>])
AC_CHECK_DECLS([mysql_set_character_set],[MYSQL_INC="$MYSQL_INC -DHAVE_MYSQL_SET_CHARSET"],,[#include<mysql.h>])
CPPFLAGS=$save_CPPFLAGS
fi
fi

View File

@ -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));