Skip to content

Commit

Permalink
db_mysql: do not set reconnect field explicitely for newer mysql vers…
Browse files Browse the repository at this point in the history
…ions

- exposed with MariaDB 10.2
- include mysql.h instead of mysql_version.h
- reported by GH #1296

(cherry picked from commit c315350)
  • Loading branch information
miconda committed Nov 3, 2017
1 parent 5f8dc56 commit 6f9f851
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/modules/db_mysql/km_my_con.c
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2001-2004 iptel.org
* Copyright (C) 2008 1&1 Internet AG
*
Expand All @@ -14,8 +14,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -28,7 +28,7 @@

#include "km_my_con.h"
#include "km_db_mysql.h"
#include <mysql_version.h>
#include <mysql.h>
#include "../../core/mem/mem.h"
#include "../../core/dprint.h"
#include "../../core/ut.h"
Expand Down Expand Up @@ -108,12 +108,17 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
rec = 1;
mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &rec);
}
#else
if (db_mysql_auto_reconnect)
ptr->con->reconnect = 1;
else
ptr->con->reconnect = 0;
#endif

if (db_mysql_update_affected_found) {
if (db_mysql_update_affected_found) {
connection_flag |= CLIENT_FOUND_ROWS;
}

#if (MYSQL_VERSION_ID >= 40100)
if (!mysql_real_connect(ptr->con, host, id->username, id->password,
id->database, id->port, 0, connection_flag|CLIENT_MULTI_STATEMENTS)) {
Expand All @@ -127,11 +132,6 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
mysql_close(ptr->con);
goto err;
}
/* force reconnection if enabled */
if (db_mysql_auto_reconnect)
ptr->con->reconnect = 1;
else
ptr->con->reconnect = 0;

LM_DBG("connection type is %s\n", mysql_get_host_info(ptr->con));
LM_DBG("protocol version is %d\n", mysql_get_proto_info(ptr->con));
Expand Down

0 comments on commit 6f9f851

Please sign in to comment.