MySQL++

Ticket Change Details
Login
Overview

Artifact ID: 0126570deb9f9e06ec9af516c7f65f3ca4aae8ab69ca827eddc51dfaba7f6af9
Ticket: e6cf4b6fbb4b8ceab208f45bb0ecd599f120ea64
Errors not checked when fetch_row returns NULL
User & Date: anonymous 2019-10-25 23:16:29
Changes

  1. foundin changed to: "3.2.4"
  2. icomment:
    In UseQueryResult::fetch_row and StoreQueryResult::StoreQueryResult, when
    DBDriver::fetch_row returns NULL it is assumed to mean there are no more
    rows. DBDriver::fetch_row can also return NULL when there are error
    conditions (such as the connection being dropped while iterating), and yet
    no exception is thrown when they are enabled. This can result in incomplete
    result sets if the error state is not checked immediately after the query
    completed, which is probably unexpected behaviour?
    
    We've fixed this with the following patch:
    
    --- mysql++-3.2.4/lib/result.cpp	2019-07-21 04:32:30.000000000 -0700
    +++ mysql++-3.2.4/lib/result_new.cpp	2019-10-25 15:38:30.659424092 -0700
    @@ -110,8 +110,10 @@
     				++it;
     			}
     		}
    -
     		dbd->free_result(res);
    +		if (throw_exceptions() && dbd->errnum() != 0) {
    +			throw UseQueryError(dbd->error());
    +		}
     	}
     }
     
    @@ -190,6 +192,9 @@
     		}
     	}
     	else {
    +		if (throw_exceptions() && driver_->errnum() != 0) {
    +			throw UseQueryError(driver_->error());
    +		}
     		// Prior to v3, this was considered an error, but it just means
     		// we've fallen off the end of a "use" query's result set.  You
     		// can't predict when this will happen, but it isn't an error.
    
  3. login: "anonymous"
  4. mimetype: "text/x-fossil-plain"
  5. private_contact changed to: "1edb4d11c026a98bf7e4d75966de07849a19965d"
  6. severity changed to: "Minor"
  7. status changed to: "Open"
  8. title changed to: "Errors not checked when fetch_row returns NULL"
  9. type changed to: "Code Defect"