Package: pdns-backend-mysql
Version: 4.3.0-4+b3
Severity: important
Tags: upstream
X-Debbugs-Cc: x...@charbonnet.com

Dear Maintainer,

PowerDNS supports using stored procedures for its backend MySQL queries.  
However, it seems
that when the database is MariaDB >= 10.2 (or MySQL >= 5.7), stored procedures 
fail to work.

I have tested this on Stretch, using three different PowerDNS versions: 4.0.3 
(from Stretch),
4.1.6 (from Buster), and 4.3.0 (from Bullseye), all compiled on Stretch.  They 
all have the
same behavior: on MariaDB 10.1, stored procedures work great.  On MariaDB 10.2, 
calls to
procedures which return any rows give the error "Could not bind parameters to 
mysql
statement".  The various versions of MariaDB came from the MariaDB Debian 
repositories.

I have also tried this on a clean Bullseye test system, using the versions of 
PowerDNS and
MariaDB which are native to Bullseye.  Same problem.  This is the system where 
I'm running
reportbug.

I believe this other user on the pdns mailing list encountered this problem:
https://mailman.powerdns.com/pipermail/pdns-users/2020-July/026762.html

My reply failed to actually be a reply, but I also chimed in on the list:
https://mailman.powerdns.com/pipermail/pdns-users/2020-August/026810.html


The relevant code appears to be the following section.  Unfortunately I don't 
know enough
about using MySQL from C++ to be able to tell what to do differently.  This is 
where the
"Could not bind parameters" error is coming from.


#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



-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 5.7.0-2-amd64 (SMP w/1 CPU thread)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages pdns-backend-mysql depends on:
ii  libc6        2.31-2
ii  libgcc-s1    10.1.0-6
ii  libmariadb3  1:10.3.23-1
ii  libstdc++6   10.1.0-6
ii  pdns-server  4.3.0-4+b3

pdns-backend-mysql recommends no packages.

Versions of packages pdns-backend-mysql suggests:
pn  default-mysql-server  <none>

-- no debconf information

Reply via email to