[Pdns-users] Problem with stored procedure pdns 4.1.6-3
Xan Charbonnet
xan at charbonnet.com
Wed Aug 26 16:29:48 UTC 2020
I believe I am having the same problem as you, Masood. It seems to not
be related to the PowerDNS version but rather to the version of MySQL.
Using stored procedures with the pdns MySQL backend works fine for me on
Debian Stretch with MariaDB 10.1 on pdns versions 4.0.3, 4.1.6, and 4.3.0.
I should note that the Debian version of 4.0.3 contains a backported fix
for dealing with stored procedures, which is native in 4.1.6 and 4.3.0:
https://github.com/Habbie/pdns/commit/d64a77e368495132d92833f4ab2bc91b647d2beb
Without this fix, 4.0.3 wouldn't be able to deal with stored procedures
at all. I believe that Masood is also using this Debian version of 4.0.3.
The other two versions, 4.1.6 and 4.3.0, I compiled myself on Stretch
(oldstable) from sources in Debian Buster (stable) and Debian Bullseye
(testing), respectively.
When I move from MariaDB 10.1 to MariaDB 10.2 (or greater), all three
pdns versions fail with the "Prepared statement contains no metadata"
error. Masood's experience leads me to believe that the same breakage
happened between MySQL 5.6 and 5.7.
There are two places in smysql.cc where the same error, "Could not bind
parameters to mysql statement", can be thrown. I have found that in
this case, it's the second one (the one near the comment "For some
reason mysql_stmt_result_metadata returns NULL here") which is causing
the problem.
I'm afraid I don't know enough about MySQL development in C++ to know
what to do here. Can anyone shine any light?
This is the relevant code (pardon the word wrapping):
#if MYSQL_VERSION_ID >= 50500
if (d_residx >= d_resnum) {
mysql_stmt_free_result(d_stmt);
while(!mysql_stmt_next_result(d_stmt)) {
if ((err = mysql_stmt_store_result(d_stmt))) {
string error(mysql_stmt_error(d_stmt));
releaseStatement();
throw SSqlException("Could not store mysql statement while
processing additional sets: " + d_query + string(": ") + error);
}
d_resnum = mysql_stmt_num_rows(d_stmt);
// XXX: For some reason mysql_stmt_result_metadata returns
NULL here, so we cannot
// ensure row field count matches first result set.
if (d_resnum > 0) { // ignore empty result set
if (d_res_bind != nullptr && (err =
mysql_stmt_bind_result(d_stmt, d_res_bind))) {
string error(mysql_stmt_error(d_stmt));
releaseStatement();
throw SSqlException("Could not bind parameters to mysql
statement: " + d_query + string(": ") + error);
}
d_residx = 0;
break;
}
mysql_stmt_free_result(d_stmt);
}
}
#endif
More information about the Pdns-users
mailing list