On 12/18/2016 02:09 AM, Wietse Venema wrote:
> 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

I agree. It might be as simple as changing

msg_warn("dict_mysql: stored procedure did not return any result set
containing data");

to

msg_warn("mysql query failed: %s", mysql_error(host->db));


But I think I need to do some tests with unmodified postfix and then compare 
behaviour to the patched version to make sure the warnings are really the same.

John

Reply via email to