I have been working this code into Postfix, and have a comment
about error reporting for old-style queries.
> while ((host = dict_mysql_get_active(dict_mysql)) != NULL) {
> #if defined(MYSQL_VERSION_ID) && MYSQL_VERSION_ID >= 40000
> @@ -536,9 +541,46 @@
> #endif
>
> if (!(mysql_query(host->db, vstring_str(query)))) {
> - if ((res = mysql_store_result(host->db)) == 0) {
> - msg_warn("mysql query failed: %s", mysql_error(host->db));
> + sp_error = 0;
Here, the old code reported "mysql query failed" when an old-style
query returned no result set.
> + num_rs = 0;
> + res = 0;
> + do {
> + temp_res = mysql_store_result(host->db);
> + /* did statement return data? */
> + if (temp_res) {
> + num_rs++;
> + if (num_rs > 1) {
> + msg_warn("dict_mysql: multiple result sets
> returning data are not supported");
> + mysql_free_result(temp_res);
> + temp_res = 0;
> + } else {
> + res = temp_res;
> + }
> + } else {
> + /* no data, check if there were errors */
> + if (mysql_field_count(host->db) == 0) {
> + if (num_rs == 0) {
> + msg_warn("dict_mysql: stored procedure did
> not return any result set containing data");
> + } else {
> + if (msg_verbose)
> + msg_info("dict_mysql: successful final
> result for stored procedure");
> + }
> + } else {
> + sp_error=1;
> + msg_warn("dict_mysql: unsuccessful final result
> for stored procedure: %s", mysql_error(host->db));
What if Postfix made an old-style query? I think it should just
report the old-style error here.
Wietse