connectivity/source/drivers/odbc/OResultSet.cxx | 4 +++- connectivity/source/drivers/odbc/OTools.cxx | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-)
New commits: commit e47197b4ef1753af4d005a6918c26e6a3d589c67 Author: Mike Kaganski <[email protected]> AuthorDate: Tue Jul 30 16:58:30 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Aug 1 07:27:04 2024 +0200 tdf#148367: avoid using SQLBulkOperations with SQL_UPDATE_BY_BOOKMARK ... because that fails with MS Access ODBC 64-bit driver (bug in the driver). And SQLSetPos does the job anyway. Change-Id: I2d356a6a3f6de4d3c2c9a2e49cb3dd8c66af7794 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171270 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index 53488dc00417..65fd1419271e 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -845,6 +845,8 @@ void SAL_CALL OResultSet::updateRow( ) try { + /* tdf#148367 this block is commented out, because SQLBulkOperations fails + with Access ODBC 64-bit drivers on Windows bool bPositionByBookmark = functions().has(ODBC3SQLFunctionId::BulkOperations); if ( bPositionByBookmark ) { @@ -866,7 +868,7 @@ void SAL_CALL OResultSet::updateRow( ) // (neither the contents of aBookmark FWIW) assert(nRealLen == aBookmark.getLength()); } - else + else */ { nRet = functions().SetPos(m_aStatementHandle,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); fillNeededData(nRet); commit 1c8a48ba766f30c9babc80db46e2cf24074486b8 Author: Mike Kaganski <[email protected]> AuthorDate: Tue Jul 30 15:07:35 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Aug 1 07:26:54 2024 +0200 Fix OTools::ThrowException First, it used 5-character buffer for SQL state, where MS documentation for SQLGetDiagRec specifies, that the buffer is for five-character code plus terminating NULL. The declaration of the function in Windows Kit's sqlucode.h uses decoration '_Out_writes_opt_(6)' for the parameter. Next, SQLGetDiagRec may fail or return SQL_NO_DATA; and then, the data in buffers will be undefiled. Change-Id: Ia36555b4fe4f49c8803a25f8fc1cc1a3b6ac4ddc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171238 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx index 999324a4d571..0909b03f14b2 100644 --- a/connectivity/source/drivers/odbc/OTools.cxx +++ b/connectivity/source/drivers/odbc/OTools.cxx @@ -203,7 +203,7 @@ void OTools::ThrowException(const OConnection* _pConnection, // corresponding for hdbc. if (bUseWChar && _pConnection->functions().has(ODBC3SQLFunctionId::GetDiagRecW)) { - SQLWCHAR szSqlState[5]; + SQLWCHAR szSqlState[6]; SQLWCHAR szErrorMessage[SQL_MAX_MESSAGE_LENGTH]; szErrorMessage[0] = ' SQLSMALLINT cchErrorMsg = 0; @@ -212,12 +212,15 @@ void OTools::ThrowException(const OConnection* _pConnection, szSqlState, &pfNativeError, szErrorMessage, std::size(szErrorMessage) - 1, &cchErrorMsg); - errorMessage = toUString(szErrorMessage, cchErrorMsg); - sqlState = toUString(szSqlState, std::size(szSqlState)); + if (SQL_SUCCEEDED(n)) + { + errorMessage = toUString(szErrorMessage, cchErrorMsg); + sqlState = toUString(szSqlState, 5); + } } else { - SQLCHAR szSqlState[5]; + SQLCHAR szSqlState[6]; SQLCHAR szErrorMessage[SQL_MAX_MESSAGE_LENGTH]; szErrorMessage[0] = ' SQLSMALLINT pcbErrorMsg = 0; @@ -226,9 +229,12 @@ void OTools::ThrowException(const OConnection* _pConnection, szSqlState, &pfNativeError, szErrorMessage,sizeof szErrorMessage - 1,&pcbErrorMsg); - rtl_TextEncoding _nTextEncoding = osl_getThreadTextEncoding(); - errorMessage = toUString(szErrorMessage, pcbErrorMsg, _nTextEncoding); - sqlState = toUString(szSqlState, std::size(szSqlState), _nTextEncoding); + if (SQL_SUCCEEDED(n)) + { + rtl_TextEncoding _nTextEncoding = osl_getThreadTextEncoding(); + errorMessage = toUString(szErrorMessage, pcbErrorMsg, _nTextEncoding); + sqlState = toUString(szSqlState, 5, _nTextEncoding); + } } OSL_ENSURE(n != SQL_INVALID_HANDLE,"SdbODBC3_SetStatus: SQLError returned SQL_INVALID_HANDLE"); OSL_ENSURE(n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO || n == SQL_NO_DATA_FOUND || n == SQL_ERROR,"SdbODBC3_SetStatus: SQLError failed");
