You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix garbled diagnostic record on failed SQLDriverConnect
Every catch block that handled std::exception followed the same broken
pattern:
catch ( std::exception &ex ) {
SQLException &exception = (SQLException&)ex;
// virtual calls on `exception`...
}
The C-style cast is a reinterpret_cast. When the caught object was not
in fact a SQLException -- e.g. a std::bad_alloc, a raw FbException
that bypassed the IscDbc rewrap, or anything else that propagated out
of the IscDbc layer -- the subsequent virtual dispatch through
`exception` read through whatever bytes lay where SQLException's
vtable pointer would have been. On Linux that produced a diagnostic
record with an empty SQLSTATE, a non-deterministic native code, and a
one-byte message ('[') whose reported length disagreed with its
strlen.
This commit replaces each single `catch (std::exception &ex)` with the
idiomatic two-handler form:
catch (SQLException &ex) { ... }
catch (std::exception &ex) { ... }
C++ exception-matching picks the most-derived handler at runtime, so
the SQLException catch sees only true SQLException objects and the
std::exception catch sees only non-SQLException objects -- no
dynamic_cast or helper required.
A companion postError(state, std::exception&) overload pairs with the
existing postError(state, SQLException&); each catch dispatches the
right one statically based on the type of `ex`.
All 64 occurrences of the broken pattern across OdbcConnection /
OdbcStatement / OdbcDesc / OdbcEnv and the Windows OdbcJdbcSetup tree
are converted to this form.
OdbcConnection::connect gets a small rollbackPartialConnect lambda so
its two catch bodies stay short, plus a NULL guard around
connection->close() -- if createConnection() throws before assignment,
the previous code dereferenced a NULL pointer during cleanup.
0 commit comments