| Ticket Hash: | e6cf4b6fbb4b8ceab208f45bb0ecd599f120ea64 | ||
| Title: | Errors not checked when fetch_row returns NULL | ||
| Status: | Closed | Type: | Code Defect |
| Severity: | Minor | Priority: | Immediate |
| Subsystem: | Library | Resolution: | Fixed |
| Last Modified: |
2020-07-23 06:59:24 5.28 years ago |
Created: |
2019-10-25 23:16:29 6.02 years ago |
| Version Found In: | 3.2.4 | ||
| User Comments: | ||||
anonymous added on 2019-10-25 23:16:29:
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.
tangent added on 2020-07-23 06:59:24: Fixed by [a45de8b0b23]. | ||||