MySQL Forums
Forum List  »  Connector/C++

Re: Microsoft C++ Exception std::out_of_range mysql-connector-c++-8.0.18-winx64
Posted by: Rafal Somla
Date: November 27, 2019 07:56AM

Hi,

Indeed in common/result.h, in method Row_impl<VAL>::get() we have this non-orthodox code that uses std::out_of_range exception to detect if given field in the row was already cached in m_vals member or not:

try {
..return m_vals.at(pos);
}
catch (const std::out_of_range&)
{
..if (!m_mdata)
....throw;
..const Format_info &fi = m_mdata->get_format(pos);
..convert_at(pos, fi);
..return m_vals.at(pos);
}

The intention is that this out_of_range exception should be thrown only first time given field is accessed, later m_vals.at(pos) should return the value without any further processing. This is why in debug session you see the exceptions being thrown and yes, it can disrupt a debug session a bit. I am not claiming this is the most efficient or the most elegant code, but it is what we have and it worked good enough for us so far.

Btw. We are fixing our code to build seamlessly with VS2019, so watch out for the upcoming release!

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.