0f8d17e
From 302cd2b4b101990483ee30dee6473890d0095e99 Mon Sep 17 00:00:00 2001
0f8d17e
From: Augusto Caringi <acaringi@redhat.com>
0f8d17e
Date: Thu, 20 Jul 2017 15:07:16 +0200
0f8d17e
Subject: [PATCH] db_mysql: fix build against MariaDB 10.2
0f8d17e
0f8d17e
Fixes the following build error while building against MariaDB 10.2
0f8d17e
library:
0f8d17e
0f8d17e
my_con.c: In function 'db_mysql_connect':
0f8d17e
my_con.c:68:10: error: 'MYSQL {aka struct st_mysql}' has no member named
0f8d17e
'reconnect'
0f8d17e
ptr->con->reconnect = 0;
0f8d17e
          ^~
0f8d17e
0f8d17e
In this new version of the library the reconnect field was moved to
0f8d17e
another struct. Setting it through API seems to be a better approach.
0f8d17e
---
0f8d17e
 modules/db_mysql/my_con.c | 3 ++-
0f8d17e
 1 file changed, 2 insertions(+), 1 deletion(-)
0f8d17e
0f8d17e
diff --git a/modules/db_mysql/my_con.c b/modules/db_mysql/my_con.c
0f8d17e
index ba1a7379b..d93287304 100644
0f8d17e
--- a/modules/db_mysql/my_con.c
0f8d17e
+++ b/modules/db_mysql/my_con.c
0f8d17e
@@ -34,6 +34,7 @@ extern struct tls_domain *tls_dom;
0f8d17e
 
0f8d17e
 int db_mysql_connect(struct my_con* ptr)
0f8d17e
 {
0f8d17e
+	my_bool reconnect = 0;
0f8d17e
 	/* if connection already in use, close it first*/
0f8d17e
 	if (ptr->init)
0f8d17e
 		mysql_close(ptr->con);
0f8d17e
@@ -81,7 +82,7 @@ int db_mysql_connect(struct my_con* ptr)
0f8d17e
 		return -1;
0f8d17e
 	}
0f8d17e
 	/* force no auto reconnection */
0f8d17e
-	ptr->con->reconnect = 0;
0f8d17e
+	mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &reconnect);
0f8d17e
 
0f8d17e
 	LM_DBG("connection type is %s\n", mysql_get_host_info(ptr->con));
0f8d17e
 	LM_DBG("protocol version is %d\n", mysql_get_proto_info(ptr->con));