Package: pdns
Severity: normal

Hello,
we have a MySQL database we query using stored procedures; by default this setup
doesn't work since stored proc returns more than one row and mysql connection is
not opened using the CLIENT_MULTI_RESULTS parameter.

I'm attaching the patch we're using to correctly use stored proc to retrieve
data; it doesn't introduce any problem for "plain" mysql queries (in case you
have a standard schema where pdns connects using its default queries).

I also wrote about that on the pdns-users ml[1].

[1] http://mailman.powerdns.com/pipermail/pdns-users/2011-March/007496.html 

Regards,
Sandro

-- System Information:
Debian Release: 6.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.37-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Index: debian-pdns/modules/gmysqlbackend/smysql.cc
===================================================================
--- debian-pdns.orig/modules/gmysqlbackend/smysql.cc	2011-03-08 15:57:20.000000000 +0100
+++ debian-pdns/modules/gmysqlbackend/smysql.cc	2011-03-08 15:57:45.000000000 +0100
@@ -20,7 +20,7 @@
 			  password.empty() ? 0 : password.c_str(),
 			  database.c_str(), port,
 			  msocket.empty() ? 0 : msocket.c_str(),
-			  0)) {
+			  CLIENT_MULTI_RESULTS)) {
 
     throw sPerrorException("Unable to connect to database");
   }
@@ -91,6 +91,13 @@
     return true;
   }
   mysql_free_result(d_rres);  
+
+  while (mysql_next_result(&d_db) == 0) {
+    if (d_rres = mysql_use_result(&d_db)) {
+      mysql_free_result(d_rres);
+    }
+  }
+
   d_rres=0;
   return false;
 }

Reply via email to