Fix ODBC backend get_affected_rows() when using FreeTDS driver.

SQLRowCount() doesn't return the correct number of rows affected for vector
operations when using FreeTDS 0.91 (it seems to always return 1 instead of the
real number of elements). Avoid using this function entirely as we already
have the number of affected rows anyhow, via SQL_ATTR_PARAMS_PROCESSED_PTR.

This is simpler, probably more efficient and works with both the native
Microsoft ODBC driver and FreeTDS.
This commit is contained in:
Vadim Zeitlin
2015-03-17 18:57:47 +01:00
parent f212ca9a90
commit ed37399705

View File

@@ -180,9 +180,12 @@ odbc_statement_backend::execute(int number)
throw odbc_soci_error(SQL_HANDLE_STMT, hstmt_,
"Statement Execute");
}
// We should preserve the number of rows affected here
// where we know for sure that a bulk operation was executed.
else
else if (hasVectorUseElements_)
{
// We already have the number of rows, no need to do anything.
rowsAffected_ = rows_processed;
}
else // We need to retrieve the number of rows affected explicitly.
{
rowsAffected_ = 0;