A little better

This commit is contained in:
kssenii 2021-09-29 10:23:44 +00:00
parent ba839a4af3
commit 58fa0ac13c

View File

@ -81,10 +81,12 @@ T execute(nanodbc::ConnectionHolderPtr connection_holder, std::function<T(nanodb
}
catch (const nanodbc::database_error & e)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
/// SQLState, connection related errors start with 08 (main: 08S01), cursor invalid state is 24000.
/// Invalid cursor state is a retriable error.
/// Invalid transaction state 25000. Truncate to 4 letters, because nanodbc does it.
/// https://docs.microsoft.com/ru-ru/sql/odbc/reference/appendixes/appendix-a-odbc-error-codes?view=sql-server-ver15
if (e.state().starts_with("08") || e.state().starts_with("24"))
if (e.state().starts_with("08") || e.state().starts_with("24") || e.state().starts_with("2500"))
{
connection_holder->updateConnection();
return query_func(connection_holder->get());