MySQL 5 patch

aledr <[email protected]> Mon, 19 Jan 2009 16:42:52 -0200
Newsgroups gmane.network.dns.bind9.dlz
Message-ID <[email protected]>
Good day!

After a while taking problems with DLZ on MySQL 5 I've decided to look
into the codes.
leorogoski wrote a patch based upon this[1] to enable reconnect (after
a MySQL restart for example) and replaced the mysql_query which was
giving the segmentation fault by mysql_real_query.

Patch based on 9.6.0 P1.

Thanks to leorogoski | at | gmail | com.

[1]: http://www.shell-tips.com/2007/09/04/bind-950-patch-dlz-mysql-5-for-auto-reconnect
--
[ ]'s
Aledr - Alexandre
"OpenSource Solutions for SmallBusiness Problems"

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

_______________________________________________
Bind-dlz-testers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bind-dlz-testers
dlz_mysql.patch (text/x-patch, 1 KB)
diff -Naurh ./dlz_mysql_driver.c bind-9.6.0-P1/contrib/dlz/drivers/dlz_mysql_driver.c
--- ./dlz_mysql_driver.c	2009-01-19 16:17:05.000000000 -0200
+++ bind-9.6.0-P1/contrib/dlz/drivers/dlz_mysql_driver.c	2009-01-19 16:18:13.000000000 -0200
@@ -321,7 +321,7 @@
 
 	/* attempt query up to 3 times. */
 	for (i=0; i < 3; i++) {
-		qres = mysql_query((MYSQL *) dbi->dbconn, querystring);
+		qres = mysql_real_query((MYSQL *) dbi->dbconn, querystring, strlen(querystring));
 		if (qres == 0)
 			break;
 		for (j=0; mysql_ping((MYSQL *) dbi->dbconn) != 0 && j < 4; j++)
@@ -923,6 +923,12 @@
 	pass = getParameterValue(argv[1], "pass=");
 	socket = getParameterValue(argv[1], "socket=");
 
+	if(mysql_options((MYSQL *) dbi->dbconn, MYSQL_OPT_RECONNECT, "1")) {
+		isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
+		    DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
+			"Could not set database reconnect option");
+	}
+
 	for (j=0; dbc == NULL && j < 4; j++)
 		dbc = mysql_real_connect((MYSQL *) dbi->dbconn, host,
 					 user, pass, dbname, port, socket,