Permalink
Browse files

autodetect MySQL 5.5+ connection charset

Conflicts:
	.travis.yml
  • Loading branch information...
1 parent f9f79b3 commit fa1f84552f3acfcfa0762581eb0de4ee0006a806 @mind04 mind04 committed with Habbie Nov 23, 2013
Showing with 8 additions and 6 deletions.
  1. +0 −2 .travis.yml
  2. +8 −4 modules/gmysqlbackend/smysql.cc
View
@@ -4,8 +4,6 @@ compiler:
before_script:
- sudo apt-get update
- sudo apt-get install libboost-all-dev libtolua-dev bc libcdb-dev libnet-dns-perl unbound-host ldnsutils dnsutils libtool libcdb-dev xmlto dblatex links asciidoc
- - sudo sed -i '0,/\[mysqld\]/s//[mysqld]\nskip-character-set-client-handshake/' /etc/mysql/my.cnf
- - sudo restart mysql
script:
- ./bootstrap
- ./configure --with-modules='gmysql tinydns random' --with-sqlite3 --enable-unit-tests
@@ -22,16 +22,20 @@ SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const
mysql_init(&d_db);
do {
- #if MYSQL_VERSION_ID >= 50013
+#if MYSQL_VERSION_ID >= 50013
my_bool reconnect = 1;
mysql_options(&d_db, MYSQL_OPT_RECONNECT, &reconnect);
- #endif
+#endif
- #if MYSQL_VERSION_ID > 51000
+#if MYSQL_VERSION_ID >= 50100
unsigned int timeout = 10;
mysql_options(&d_db, MYSQL_OPT_READ_TIMEOUT, &timeout);
mysql_options(&d_db, MYSQL_OPT_WRITE_TIMEOUT, &timeout);
- #endif
+#endif
+
+#if MYSQL_VERSION_ID >= 50500
+ mysql_options(&d_db, MYSQL_SET_CHARSET_NAME, MYSQL_AUTODETECT_CHARSET_NAME);
+#endif
if (setIsolation && (retry == 1))
mysql_options(&d_db, MYSQL_INIT_COMMAND,"SET SESSION tx_isolation='READ-COMMITTED'");

0 comments on commit fa1f845

Please sign in to comment.