diff --git a/connectivity/Library_odbc.mk b/connectivity/Library_odbc.mk index b14412932083..9bc514c9d7d5 100644 --- a/connectivity/Library_odbc.mk +++ b/connectivity/Library_odbc.mk @@ -45,8 +45,6 @@ $(eval $(call gb_Library_use_libraries,odbc,\ )) $(eval $(call gb_Library_add_exception_objects,odbc,\ - connectivity/source/drivers/odbc/ORealDriver \ - connectivity/source/drivers/odbc/OFunctions \ connectivity/source/drivers/odbc/OPreparedStatement \ connectivity/source/drivers/odbc/OStatement \ connectivity/source/drivers/odbc/OResultSetMetaData \ diff --git a/connectivity/source/drivers/odbc/OConnection.cxx b/connectivity/source/drivers/odbc/OConnection.cxx index 996e735ac07c..70e2f782c97e 100644 --- a/connectivity/source/drivers/odbc/OConnection.cxx +++ b/connectivity/source/drivers/odbc/OConnection.cxx @@ -66,20 +66,20 @@ OConnection::~OConnection() if (!m_bClosed) { - rc = N3SQLDisconnect( m_aConnectionHandle ); + rc = functions().Disconnect(m_aConnectionHandle); OSL_ENSURE( rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO, "Failure from SQLDisconnect" ); } - rc = N3SQLFreeHandle( SQL_HANDLE_DBC, m_aConnectionHandle ); + rc = functions().FreeHandle(SQL_HANDLE_DBC, m_aConnectionHandle); OSL_ENSURE( rc == SQL_SUCCESS , "Failure from SQLFreeHandle for connection"); m_aConnectionHandle = SQL_NULL_HANDLE; } -oslGenericFunction OConnection::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const +const Functions& OConnection::functions() const { OSL_ENSURE(m_xDriver, "OConnection::getOdbcFunction: m_xDriver is null!"); - return m_xDriver->getOdbcFunction(_nIndex); + return m_xDriver->functions(); } SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTimeOut, bool bSilent) @@ -97,14 +97,14 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi memcpy(szConnStrIn, aConStr.getStr(), std::min(sal_Int32(2048),aConStr.getLength())); #ifndef MACOSX - N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,reinterpret_cast(static_cast(nTimeOut)),SQL_IS_UINTEGER); + functions().SetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,reinterpret_cast(static_cast(nTimeOut)),SQL_IS_UINTEGER); #else (void)nTimeOut; /* WaE */ #endif #ifdef LINUX (void) bSilent; - nSQLRETURN = N3SQLDriverConnect(m_aConnectionHandle, + nSQLRETURN = functions().DriverConnect(m_aConnectionHandle, nullptr, szConnStrIn, static_cast(std::min(sal_Int32(2048),aConStr.getLength())), @@ -117,7 +117,7 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi #else SQLUSMALLINT nSilent = bSilent ? SQL_DRIVER_NOPROMPT : SQL_DRIVER_COMPLETE; - nSQLRETURN = N3SQLDriverConnect(m_aConnectionHandle, + nSQLRETURN = functions().DriverConnect(m_aConnectionHandle, nullptr, szConnStrIn, static_cast(std::min(sal_Int32(2048),aConStr.getLength())), @@ -156,7 +156,7 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi // autocommit is always default if (!m_bReadOnly) - N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT, reinterpret_cast(SQL_AUTOCOMMIT_ON),SQL_IS_INTEGER); + functions().SetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT, reinterpret_cast(SQL_AUTOCOMMIT_ON),SQL_IS_INTEGER); return nSQLRETURN; } @@ -167,7 +167,7 @@ SQLRETURN OConnection::Construct(const OUString& url,const Sequence< PropertyVal m_sURL = url; setConnectionInfo(info); - N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle); + functions().AllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle); if(m_aConnectionHandle == SQL_NULL_HANDLE) throw SQLException(); @@ -301,7 +301,7 @@ OUString SAL_CALL OConnection::nativeSQL( const OUString& sql ) OString aSql(OUStringToOString(sql,getTextEncoding())); char pOut[2048]; SQLINTEGER nOutLen; - OTools::ThrowException(this,N3SQLNativeSql(m_aConnectionHandle,reinterpret_cast(const_cast(aSql.getStr())),aSql.getLength(),reinterpret_cast(pOut),sizeof pOut - 1,&nOutLen),m_aConnectionHandle,SQL_HANDLE_DBC,*this); + OTools::ThrowException(this,functions().NativeSql(m_aConnectionHandle,reinterpret_cast(const_cast(aSql.getStr())),aSql.getLength(),reinterpret_cast(pOut),sizeof pOut - 1,&nOutLen),m_aConnectionHandle,SQL_HANDLE_DBC,*this); return OUString(pOut,nOutLen,getTextEncoding()); } @@ -311,7 +311,7 @@ void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) checkDisposed(OConnection_BASE::rBHelper.bDisposed); const sal_IntPtr nAutocommit = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; - OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle, + OTools::ThrowException(this,functions().SetConnectAttr(m_aConnectionHandle, SQL_ATTR_AUTOCOMMIT, reinterpret_cast(nAutocommit) ,SQL_IS_INTEGER), m_aConnectionHandle,SQL_HANDLE_DBC,*this); @@ -324,7 +324,7 @@ sal_Bool SAL_CALL OConnection::getAutoCommit( ) sal_uInt32 nOption = 0; - OTools::ThrowException(this,N3SQLGetConnectAttr(m_aConnectionHandle, + OTools::ThrowException(this,functions().GetConnectAttr(m_aConnectionHandle, SQL_ATTR_AUTOCOMMIT, &nOption,0,nullptr),m_aConnectionHandle,SQL_HANDLE_DBC,*this); return nOption == SQL_AUTOCOMMIT_ON ; } @@ -335,7 +335,7 @@ void SAL_CALL OConnection::commit( ) checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OTools::ThrowException(this,N3SQLEndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_COMMIT),m_aConnectionHandle,SQL_HANDLE_DBC,*this); + OTools::ThrowException(this,functions().EndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_COMMIT),m_aConnectionHandle,SQL_HANDLE_DBC,*this); } void SAL_CALL OConnection::rollback( ) @@ -344,7 +344,7 @@ void SAL_CALL OConnection::rollback( ) checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OTools::ThrowException(this,N3SQLEndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_ROLLBACK),m_aConnectionHandle,SQL_HANDLE_DBC,*this); + OTools::ThrowException(this,functions().EndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_ROLLBACK),m_aConnectionHandle,SQL_HANDLE_DBC,*this); } sal_Bool SAL_CALL OConnection::isClosed( ) @@ -376,7 +376,7 @@ void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) OTools::ThrowException(this, - N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_ACCESS_MODE,reinterpret_cast< SQLPOINTER >( readOnly ),SQL_IS_INTEGER), + functions().SetConnectAttr(m_aConnectionHandle,SQL_ATTR_ACCESS_MODE,reinterpret_cast< SQLPOINTER >( readOnly ),SQL_IS_INTEGER), m_aConnectionHandle,SQL_HANDLE_DBC,*this); } @@ -394,7 +394,7 @@ void SAL_CALL OConnection::setCatalog( const OUString& catalog ) OString aCat(OUStringToOString(catalog,getTextEncoding())); OTools::ThrowException(this, - N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,const_cast(aCat.getStr()),SQL_NTS), + functions().SetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,const_cast(aCat.getStr()),SQL_NTS), m_aConnectionHandle,SQL_HANDLE_DBC,*this); } @@ -407,7 +407,7 @@ OUString SAL_CALL OConnection::getCatalog( ) SQLINTEGER nValueLen; char pCat[1024]; OTools::ThrowException(this, - N3SQLGetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,pCat,(sizeof pCat)-1,&nValueLen), + functions().GetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,pCat,(sizeof pCat)-1,&nValueLen), m_aConnectionHandle,SQL_HANDLE_DBC,*this); return OUString(pCat,nValueLen,getTextEncoding()); @@ -419,7 +419,7 @@ void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle, + OTools::ThrowException(this,functions().SetConnectAttr(m_aConnectionHandle, SQL_ATTR_TXN_ISOLATION, reinterpret_cast(static_cast(level)),SQL_IS_INTEGER), m_aConnectionHandle,SQL_HANDLE_DBC,*this); @@ -434,7 +434,7 @@ sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) sal_Int32 nTxn = 0; SQLINTEGER nValueLen; OTools::ThrowException(this, - N3SQLGetConnectAttr(m_aConnectionHandle,SQL_ATTR_TXN_ISOLATION,&nTxn,sizeof nTxn,&nValueLen), + functions().GetConnectAttr(m_aConnectionHandle,SQL_ATTR_TXN_ISOLATION,&nTxn,sizeof nTxn,&nValueLen), m_aConnectionHandle,SQL_HANDLE_DBC,*this); return nTxn; } @@ -486,7 +486,7 @@ void OConnection::disposing() m_aConnections.clear(); if(!m_bClosed) - N3SQLDisconnect(m_aConnectionHandle); + functions().Disconnect(m_aConnectionHandle); m_bClosed = true; } @@ -510,7 +510,7 @@ SQLHANDLE OConnection::createStatementHandle() } SQLHANDLE aStatementHandle = SQL_NULL_HANDLE; - N3SQLAllocHandle(SQL_HANDLE_STMT,xConnectionTemp->getConnection(),&aStatementHandle); + functions().AllocHandle(SQL_HANDLE_STMT,xConnectionTemp->getConnection(),&aStatementHandle); ++m_nStatementCount; if(bNew) m_aConnections.emplace(aStatementHandle,xConnectionTemp); @@ -526,10 +526,10 @@ void OConnection::freeStatementHandle(SQLHANDLE& _pHandle) auto aFind = m_aConnections.find(_pHandle); - N3SQLFreeStmt(_pHandle,SQL_RESET_PARAMS); - N3SQLFreeStmt(_pHandle,SQL_UNBIND); - N3SQLFreeStmt(_pHandle,SQL_CLOSE); - N3SQLFreeHandle(SQL_HANDLE_STMT,_pHandle); + functions().FreeStmt(_pHandle,SQL_RESET_PARAMS); + functions().FreeStmt(_pHandle,SQL_UNBIND); + functions().FreeStmt(_pHandle,SQL_CLOSE); + functions().FreeHandle(SQL_HANDLE_STMT,_pHandle); _pHandle = SQL_NULL_HANDLE; diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index c8c8ac68f9f5..665f94b95181 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -495,7 +495,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) m_bEOF = false; - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0); OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO ); if( bRet ) @@ -510,7 +510,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) ::osl::MutexGuard aGuard( m_aMutex ); - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0); OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); // here I know definitely that I stand on the last record bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO ); @@ -527,7 +527,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) m_bEOF = false; - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row); OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; if(bRet) @@ -543,7 +543,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) m_bEOF = false; - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row); OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; if(bRet) @@ -559,7 +559,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) m_bEOF = false; - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0); OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; if(bRet) @@ -625,8 +625,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) m_bEOF = false; SQLRETURN nOldFetchStatus = m_nCurrentFetchState; - // m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0); - m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle); + // m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0); + m_nCurrentFetchState = functions().Fetch(m_aStatementHandle); OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; if(bRet || ( m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA ) ) @@ -661,7 +661,7 @@ void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) ::osl::MutexGuard aGuard( m_aMutex ); - N3SQLCancel(m_aStatementHandle); + functions().Cancel(m_aStatementHandle); } void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) @@ -826,7 +826,7 @@ void ODatabaseMetaDataResultSet::openTypeInfo() m_aValueRange[2] = aMap; - OTools::ThrowException(m_pConnection.get(),N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this); + OTools::ThrowException(m_pConnection.get(),functions().GetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this); checkColumnCount(); } @@ -868,7 +868,7 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const OUString& else pCOL = SQL_ALL_TABLE_TYPES; - SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + SQLRETURN nRetcode = functions().Tables(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKN)), SQL_NTS, @@ -880,7 +880,7 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const OUString& void ODatabaseMetaDataResultSet::openTablesTypes( ) { - SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + SQLRETURN nRetcode = functions().Tables(m_aStatementHandle, nullptr,0, nullptr,0, nullptr,0, @@ -896,7 +896,7 @@ void ODatabaseMetaDataResultSet::openTablesTypes( ) void ODatabaseMetaDataResultSet::openCatalogs() { - SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + SQLRETURN nRetcode = functions().Tables(m_aStatementHandle, reinterpret_cast(const_cast(SQL_ALL_CATALOGS)),SQL_NTS, reinterpret_cast(const_cast("")),SQL_NTS, reinterpret_cast(const_cast("")),SQL_NTS, @@ -913,7 +913,7 @@ void ODatabaseMetaDataResultSet::openCatalogs() void ODatabaseMetaDataResultSet::openSchemas() { - SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + SQLRETURN nRetcode = functions().Tables(m_aStatementHandle, reinterpret_cast(const_cast("")),SQL_NTS, reinterpret_cast(const_cast(SQL_ALL_SCHEMAS)),SQL_NTS, reinterpret_cast(const_cast("")),SQL_NTS, @@ -952,7 +952,7 @@ void ODatabaseMetaDataResultSet::openColumnPrivileges( const Any& catalog, cons *pCOL = aCOL.getStr(); - SQLRETURN nRetcode = N3SQLColumnPrivileges(m_aStatementHandle, + SQLRETURN nRetcode = functions().ColumnPrivileges(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast(const_cast(pPKN)), SQL_NTS, @@ -985,7 +985,7 @@ void ODatabaseMetaDataResultSet::openColumns( const Any& catalog, *pCOL = aCOL.getStr(); - SQLRETURN nRetcode = N3SQLColumns(m_aStatementHandle, + SQLRETURN nRetcode = functions().Columns(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKN)), SQL_NTS, @@ -1052,7 +1052,7 @@ void ODatabaseMetaDataResultSet::openProcedureColumns( const Any& catalog, *pCOL = aCOL.getStr(); - SQLRETURN nRetcode = N3SQLProcedureColumns(m_aStatementHandle, + SQLRETURN nRetcode = functions().ProcedureColumns(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast(const_cast(pPKN)), SQL_NTS, @@ -1084,7 +1084,7 @@ void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const OUStri *pPKN = aPKN.getStr(); - SQLRETURN nRetcode = N3SQLProcedures(m_aStatementHandle, + SQLRETURN nRetcode = functions().Procedures(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast(const_cast(pPKN)), SQL_NTS); @@ -1123,7 +1123,7 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(bool _bRowVer,const Any& cat *pPKN = aPKN.getStr(); - SQLRETURN nRetcode = N3SQLSpecialColumns(m_aStatementHandle,_bRowVer ? SQL_ROWVER : SQL_BEST_ROWID, + SQLRETURN nRetcode = functions().SpecialColumns(m_aStatementHandle,_bRowVer ? SQL_ROWVER : SQL_BEST_ROWID, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast(const_cast(pPKN)), SQL_NTS, @@ -1183,7 +1183,7 @@ void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const OUSt pFKN = aFKN.getStr(); } - SQLRETURN nRetcode = N3SQLForeignKeys(m_aStatementHandle, + SQLRETURN nRetcode = functions().ForeignKeys(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKN)), pPKN ? SQL_NTS : 0, @@ -1230,7 +1230,7 @@ void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const OUStr *pPKN = aPKN.getStr(); - SQLRETURN nRetcode = N3SQLPrimaryKeys(m_aStatementHandle, + SQLRETURN nRetcode = functions().PrimaryKeys(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast(const_cast(pPKN)), SQL_NTS); @@ -1259,7 +1259,7 @@ void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const O *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : nullptr, *pPKN = aPKN.getStr(); - SQLRETURN nRetcode = N3SQLTablePrivileges(m_aStatementHandle, + SQLRETURN nRetcode = functions().TablePrivileges(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast(const_cast(pPKN)), SQL_NTS); @@ -1288,7 +1288,7 @@ void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const OUStri *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : nullptr, *pPKN = aPKN.getStr(); - SQLRETURN nRetcode = N3SQLStatistics(m_aStatementHandle, + SQLRETURN nRetcode = functions().Statistics(m_aStatementHandle, reinterpret_cast(const_cast(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast(const_cast(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast(const_cast(pPKN)), SQL_NTS, @@ -1301,7 +1301,7 @@ void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const OUStri void ODatabaseMetaDataResultSet::checkColumnCount() { sal_Int16 nNumResultCols=0; - OTools::ThrowException(m_pConnection.get(),N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this); + OTools::ThrowException(m_pConnection.get(),functions().NumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this); m_nDriverColumnCount = nNumResultCols; } diff --git a/connectivity/source/drivers/odbc/ODriver.cxx b/connectivity/source/drivers/odbc/ODriver.cxx index 10f4eec6d5e4..520f1ace0e86 100644 --- a/connectivity/source/drivers/odbc/ODriver.cxx +++ b/connectivity/source/drivers/odbc/ODriver.cxx @@ -17,13 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include +#include + #include -#include +#include +#include +#include + #include #include -#include -#include +#include + #include using namespace connectivity::odbc; @@ -35,7 +39,6 @@ using namespace com::sun::star::sdbc; ODBCDriver::ODBCDriver(css::uno::Reference< css::uno::XComponentContext > _xContext) :ODriver_BASE(m_aMutex) ,m_xContext(std::move(_xContext)) - ,m_pDriverHandle(SQL_NULL_HANDLE) { } @@ -82,13 +85,7 @@ Reference< XConnection > SAL_CALL ODBCDriver::connect( const OUString& url, cons if ( ! acceptsURL(url) ) return nullptr; - if(!m_pDriverHandle) - { - OUString aPath; - if(!EnvironmentHandle(aPath)) - throw SQLException(aPath,*this,OUString(),1000,Any()); - } - rtl::Reference pCon = new OConnection(m_pDriverHandle,this); + rtl::Reference pCon = new OConnection(EnvironmentHandle(), this); pCon->Construct(url,info); m_xConnections.push_back(WeakReferenceHelper(*pCon)); @@ -188,5 +185,526 @@ sal_Int32 SAL_CALL ODBCDriver::getMinorVersion( ) return 0; } +// Implib definitions for ODBC-DLL/shared library: + +namespace +{ +constinit oslGenericFunction pODBC3SQLFunctions[static_cast(ODBC3SQLFunctionId::LAST)]{}; + +bool LoadFunctions(oslModule pODBCso) +{ + auto load = [pODBCso](ODBC3SQLFunctionId id, const OUString& name) + { + assert(id > ODBC3SQLFunctionId::FIRST && id < ODBC3SQLFunctionId::LAST); + auto& rpFunc = pODBC3SQLFunctions[static_cast(id)]; + assert(rpFunc == nullptr); + rpFunc = osl_getFunctionSymbol(pODBCso, name.pData); + return rpFunc != nullptr; + }; + + return load(ODBC3SQLFunctionId::AllocHandle, u"SQLAllocHandle"_ustr) + && load(ODBC3SQLFunctionId::DriverConnect, u"SQLDriverConnect"_ustr) + && load(ODBC3SQLFunctionId::GetInfo, u"SQLGetInfo"_ustr) + && load(ODBC3SQLFunctionId::GetFunctions, u"SQLGetFunctions"_ustr) + && load(ODBC3SQLFunctionId::GetTypeInfo, u"SQLGetTypeInfo"_ustr) + && load(ODBC3SQLFunctionId::SetConnectAttr, u"SQLSetConnectAttr"_ustr) + && load(ODBC3SQLFunctionId::GetConnectAttr, u"SQLGetConnectAttr"_ustr) + && load(ODBC3SQLFunctionId::SetEnvAttr, u"SQLSetEnvAttr"_ustr) + && load(ODBC3SQLFunctionId::GetEnvAttr, u"SQLGetEnvAttr"_ustr) + && load(ODBC3SQLFunctionId::SetStmtAttr, u"SQLSetStmtAttr"_ustr) + && load(ODBC3SQLFunctionId::GetStmtAttr, u"SQLGetStmtAttr"_ustr) + && load(ODBC3SQLFunctionId::Prepare, u"SQLPrepare"_ustr) + && load(ODBC3SQLFunctionId::BindParameter, u"SQLBindParameter"_ustr) + && load(ODBC3SQLFunctionId::SetCursorName, u"SQLSetCursorName"_ustr) + && load(ODBC3SQLFunctionId::Execute, u"SQLExecute"_ustr) + && load(ODBC3SQLFunctionId::ExecDirect, u"SQLExecDirect"_ustr) + && load(ODBC3SQLFunctionId::DescribeParam, u"SQLDescribeParam"_ustr) + && load(ODBC3SQLFunctionId::NumParams, u"SQLNumParams"_ustr) + && load(ODBC3SQLFunctionId::ParamData, u"SQLParamData"_ustr) + && load(ODBC3SQLFunctionId::PutData, u"SQLPutData"_ustr) + && load(ODBC3SQLFunctionId::RowCount, u"SQLRowCount"_ustr) + && load(ODBC3SQLFunctionId::NumResultCols, u"SQLNumResultCols"_ustr) + && load(ODBC3SQLFunctionId::ColAttribute, u"SQLColAttribute"_ustr) + && load(ODBC3SQLFunctionId::BindCol, u"SQLBindCol"_ustr) + && load(ODBC3SQLFunctionId::Fetch, u"SQLFetch"_ustr) + && load(ODBC3SQLFunctionId::FetchScroll, u"SQLFetchScroll"_ustr) + && load(ODBC3SQLFunctionId::GetData, u"SQLGetData"_ustr) + && load(ODBC3SQLFunctionId::SetPos, u"SQLSetPos"_ustr) + && load(ODBC3SQLFunctionId::BulkOperations, u"SQLBulkOperations"_ustr) + && load(ODBC3SQLFunctionId::MoreResults, u"SQLMoreResults"_ustr) + && load(ODBC3SQLFunctionId::GetDiagRec, u"SQLGetDiagRec"_ustr) + && load(ODBC3SQLFunctionId::ColumnPrivileges, u"SQLColumnPrivileges"_ustr) + && load(ODBC3SQLFunctionId::Columns, u"SQLColumns"_ustr) + && load(ODBC3SQLFunctionId::ForeignKeys, u"SQLForeignKeys"_ustr) + && load(ODBC3SQLFunctionId::PrimaryKeys, u"SQLPrimaryKeys"_ustr) + && load(ODBC3SQLFunctionId::ProcedureColumns, u"SQLProcedureColumns"_ustr) + && load(ODBC3SQLFunctionId::Procedures, u"SQLProcedures"_ustr) + && load(ODBC3SQLFunctionId::SpecialColumns, u"SQLSpecialColumns"_ustr) + && load(ODBC3SQLFunctionId::Statistics, u"SQLStatistics"_ustr) + && load(ODBC3SQLFunctionId::TablePrivileges, u"SQLTablePrivileges"_ustr) + && load(ODBC3SQLFunctionId::Tables, u"SQLTables"_ustr) + && load(ODBC3SQLFunctionId::FreeStmt, u"SQLFreeStmt"_ustr) + && load(ODBC3SQLFunctionId::CloseCursor, u"SQLCloseCursor"_ustr) + && load(ODBC3SQLFunctionId::Cancel, u"SQLCancel"_ustr) + && load(ODBC3SQLFunctionId::EndTran, u"SQLEndTran"_ustr) + && load(ODBC3SQLFunctionId::Disconnect, u"SQLDisconnect"_ustr) + && load(ODBC3SQLFunctionId::FreeHandle, u"SQLFreeHandle"_ustr) + && load(ODBC3SQLFunctionId::GetCursorName, u"SQLGetCursorName"_ustr) + && load(ODBC3SQLFunctionId::NativeSql, u"SQLNativeSql"_ustr); +} + +// Take care of Dynamically loading of the DLL/shared lib and Addresses: +// Returns sal_True at success +bool LoadLibrary_ODBC3(OUString &_rPath) +{ + static bool bLoaded = false; + static oslModule pODBCso = nullptr; + + if (bLoaded) + return true; +#ifdef DISABLE_DYNLOADING + (void)_rPath; +#else +#ifdef _WIN32 + _rPath = "ODBC32.DLL"; +#endif +#ifdef UNX + #ifdef MACOSX + _rPath = "libiodbc.dylib"; + #else + _rPath = "libodbc.so.2"; + pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); + if ( !pODBCso ) + { + _rPath = "libodbc.so.1"; + pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); + } + if ( !pODBCso ) + _rPath = "libodbc.so"; + + #endif /* MACOSX */ +#endif + + if ( !pODBCso ) + pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); +#endif // DISABLE_DYNLOADING + if( !pODBCso) + return false; + + bLoaded = LoadFunctions(pODBCso); + return bLoaded; +} + +class ORealOdbcDriver : public connectivity::odbc::ODBCDriver, public connectivity::odbc::Functions +{ +public: + explicit ORealOdbcDriver(const css::uno::Reference& _rxContext) + : ODBCDriver(_rxContext) + { + } + const Functions& functions() const override { return *this; } + + // Functions + + bool has(ODBC3SQLFunctionId id) const override + { + assert(id > ODBC3SQLFunctionId::FIRST && id < ODBC3SQLFunctionId::LAST); + return pODBC3SQLFunctions[static_cast(id)] != nullptr; + } + + SQLRETURN AllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, + SQLHANDLE* OutputHandlePtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::AllocHandle, HandleType, InputHandle, OutputHandlePtr); + } + + SQLRETURN DriverConnect(SQLHDBC ConnectionHandle, HWND WindowHandle, + SQLCHAR* InConnectionString, SQLSMALLINT StringLength1, + SQLCHAR* OutConnectionString, SQLSMALLINT BufferLength, + SQLSMALLINT* StringLength2Ptr, + SQLUSMALLINT DriverCompletion) const override + { + return ODBCFunc(ODBC3SQLFunctionId::DriverConnect, ConnectionHandle, WindowHandle, + InConnectionString, StringLength1, OutConnectionString, BufferLength, + StringLength2Ptr, DriverCompletion); + } + + SQLRETURN GetInfo(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQLPOINTER InfoValuePtr, + SQLSMALLINT BufferLength, SQLSMALLINT* StringLengthPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetInfo, ConnectionHandle, InfoType, InfoValuePtr, + BufferLength, StringLengthPtr); + } + + SQLRETURN GetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, + SQLUSMALLINT* SupportedPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetFunctions, ConnectionHandle, FunctionId, + SupportedPtr); + } + + SQLRETURN GetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetTypeInfo, StatementHandle, DataType); + } + + SQLRETURN SetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, + SQLINTEGER StringLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::SetConnectAttr, ConnectionHandle, Attribute, ValuePtr, + StringLength); + } + + SQLRETURN GetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, SQLINTEGER* StringLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetConnectAttr, ConnectionHandle, Attribute, ValuePtr, + BufferLength, StringLength); + } + + SQLRETURN SetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, + SQLINTEGER StringLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::SetEnvAttr, EnvironmentHandle, Attribute, ValuePtr, + StringLength); + } + + SQLRETURN GetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, SQLINTEGER* StringLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetEnvAttr, EnvironmentHandle, Attribute, ValuePtr, + BufferLength, StringLength); + } + + SQLRETURN SetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, + SQLINTEGER StringLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::SetStmtAttr, StatementHandle, Attribute, ValuePtr, + StringLength); + } + + SQLRETURN GetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, SQLINTEGER* StringLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetStmtAttr, StatementHandle, Attribute, ValuePtr, + BufferLength, StringLength); + } + + SQLRETURN Prepare(SQLHSTMT StatementHandle, SQLCHAR* StatementText, + SQLINTEGER TextLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Prepare, StatementHandle, StatementText, TextLength); + } + + SQLRETURN BindParameter(SQLHSTMT StatementHandle, SQLUSMALLINT ParameterNumber, + SQLSMALLINT InputOutputType, SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, SQLULEN ColumnSize, + SQLSMALLINT DecimalDigits, SQLPOINTER ParameterValuePtr, + SQLLEN BufferLength, SQLLEN* StrLen_or_IndPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::BindParameter, StatementHandle, ParameterNumber, + InputOutputType, ValueType, ParameterType, ColumnSize, DecimalDigits, + ParameterValuePtr, BufferLength, StrLen_or_IndPtr); + } + + SQLRETURN SetCursorName(SQLHSTMT StatementHandle, SQLCHAR* CursorName, + SQLSMALLINT NameLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::SetCursorName, StatementHandle, CursorName, NameLength); + } + + SQLRETURN Execute(SQLHSTMT StatementHandle) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Execute, StatementHandle); + } + + SQLRETURN ExecDirect(SQLHSTMT StatementHandle, SQLCHAR* StatementText, + SQLINTEGER TextLength) const override + { + return ODBCFunc(ODBC3SQLFunctionId::ExecDirect, StatementHandle, StatementText, TextLength); + } + + SQLRETURN DescribeParam(SQLHSTMT StatementHandle, SQLUSMALLINT ParameterNumber, + SQLSMALLINT* DataTypePtr, SQLULEN* ParameterSizePtr, + SQLSMALLINT* DecimalDigitsPtr, SQLSMALLINT* NullablePtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::DescribeParam, StatementHandle, ParameterNumber, + DataTypePtr, ParameterSizePtr, DecimalDigitsPtr, NullablePtr); + } + + SQLRETURN NumParams(SQLHSTMT StatementHandle, SQLSMALLINT* ParameterCountPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::NumParams, StatementHandle, ParameterCountPtr); + } + + SQLRETURN ParamData(SQLHSTMT StatementHandle, SQLPOINTER* ValuePtrPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::ParamData, StatementHandle, ValuePtrPtr); + } + + SQLRETURN PutData(SQLHSTMT StatementHandle, SQLPOINTER DataPtr, + SQLLEN StrLen_or_Ind) const override + { + return ODBCFunc(ODBC3SQLFunctionId::PutData, StatementHandle, DataPtr, StrLen_or_Ind); + } + + SQLRETURN RowCount(SQLHSTMT StatementHandle, SQLLEN* RowCountPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::RowCount, StatementHandle, RowCountPtr); + } + + SQLRETURN NumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT* ColumnCountPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::NumResultCols, StatementHandle, ColumnCountPtr); + } + + SQLRETURN ColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, + SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttributePtr, + SQLSMALLINT BufferLength, SQLSMALLINT* StringLengthPtr, + SQLLEN* NumericAttributePtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::ColAttribute, StatementHandle, ColumnNumber, + FieldIdentifier, CharacterAttributePtr, BufferLength, StringLengthPtr, + NumericAttributePtr); + } + + SQLRETURN BindCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + SQLPOINTER TargetValuePtr, SQLLEN BufferLength, + SQLLEN* StrLen_or_IndPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::BindCol, StatementHandle, ColumnNumber, TargetType, + TargetValuePtr, BufferLength, StrLen_or_IndPtr); + } + + SQLRETURN Fetch(SQLHSTMT StatementHandle) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Fetch, StatementHandle); + } + + SQLRETURN FetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrientation, + SQLLEN FetchOffset) const override + { + return ODBCFunc(ODBC3SQLFunctionId::FetchScroll, StatementHandle, FetchOrientation, + FetchOffset); + } + + SQLRETURN GetData(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + SQLPOINTER TargetValuePtr, SQLLEN BufferLength, + SQLLEN* StrLen_or_IndPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetData, StatementHandle, ColumnNumber, TargetType, + TargetValuePtr, BufferLength, StrLen_or_IndPtr); + } + + SQLRETURN SetPos(SQLHSTMT StatementHandle, SQLSETPOSIROW RowNumber, SQLUSMALLINT Operation, + SQLUSMALLINT LockType) const override + { + return ODBCFunc(ODBC3SQLFunctionId::SetPos, StatementHandle, RowNumber, Operation, + LockType); + } + + SQLRETURN BulkOperations(SQLHSTMT StatementHandle, SQLSMALLINT Operation) const override + { + return ODBCFunc(ODBC3SQLFunctionId::BulkOperations, StatementHandle, Operation); + } + + SQLRETURN MoreResults(SQLHSTMT StatementHandle) const override + { + return ODBCFunc(ODBC3SQLFunctionId::MoreResults, StatementHandle); + } + + SQLRETURN GetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, + SQLCHAR* Sqlstate, SQLINTEGER* NativeErrorPtr, SQLCHAR* MessageText, + SQLSMALLINT BufferLength, SQLSMALLINT* TextLengthPtr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetDiagRec, HandleType, Handle, RecNumber, Sqlstate, + NativeErrorPtr, MessageText, BufferLength, TextLengthPtr); + } + + SQLRETURN ColumnPrivileges(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, SQLCHAR* TableName, SQLSMALLINT NameLength3, + SQLCHAR* ColumnName, SQLSMALLINT NameLength4) const override + { + return ODBCFunc(ODBC3SQLFunctionId::ColumnPrivileges, StatementHandle, CatalogName, + NameLength1, SchemaName, NameLength2, TableName, NameLength3, ColumnName, + NameLength4); + } + + SQLRETURN Columns(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, SQLSMALLINT NameLength2, SQLCHAR* TableName, + SQLSMALLINT NameLength3, SQLCHAR* ColumnName, + SQLSMALLINT NameLength4) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Columns, StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4); + } + + SQLRETURN ForeignKeys(SQLHSTMT StatementHandle, SQLCHAR* PKCatalogName, SQLSMALLINT NameLength1, + SQLCHAR* PKSchemaName, SQLSMALLINT NameLength2, SQLCHAR* PKTableName, + SQLSMALLINT NameLength3, SQLCHAR* FKCatalogName, SQLSMALLINT NameLength4, + SQLCHAR* FKSchemaName, SQLSMALLINT NameLength5, SQLCHAR* FKTableName, + SQLSMALLINT NameLength6) const override + { + return ODBCFunc(ODBC3SQLFunctionId::ForeignKeys, StatementHandle, PKCatalogName, + NameLength1, PKSchemaName, NameLength2, PKTableName, NameLength3, + FKCatalogName, NameLength4, FKSchemaName, NameLength5, FKTableName, + NameLength6); + } + + SQLRETURN PrimaryKeys(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, SQLSMALLINT NameLength2, SQLCHAR* TableName, + SQLSMALLINT NameLength3) const override + { + return ODBCFunc(ODBC3SQLFunctionId::PrimaryKeys, StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3); + } + + SQLRETURN ProcedureColumns(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, SQLCHAR* ProcName, SQLSMALLINT NameLength3, + SQLCHAR* ColumnName, SQLSMALLINT NameLength4) const override + { + return ODBCFunc(ODBC3SQLFunctionId::ProcedureColumns, StatementHandle, CatalogName, + NameLength1, SchemaName, NameLength2, ProcName, NameLength3, ColumnName, + NameLength4); + } + + SQLRETURN Procedures(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, SQLSMALLINT NameLength2, SQLCHAR* ProcName, + SQLSMALLINT NameLength3) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Procedures, StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, ProcName, NameLength3); + } + + SQLRETURN SpecialColumns(SQLHSTMT StatementHandle, SQLUSMALLINT IdentifierType, + SQLCHAR* CatalogName, SQLSMALLINT NameLength1, SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, SQLCHAR* TableName, SQLSMALLINT NameLength3, + SQLUSMALLINT Scope, SQLUSMALLINT Nullable) const override + { + return ODBCFunc(ODBC3SQLFunctionId::SpecialColumns, StatementHandle, IdentifierType, + CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + Scope, Nullable); + } + + SQLRETURN Statistics(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, SQLSMALLINT NameLength2, SQLCHAR* TableName, + SQLSMALLINT NameLength3, SQLUSMALLINT Unique, + SQLUSMALLINT Reserved) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Statistics, StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3, Unique, Reserved); + } + + SQLRETURN TablePrivileges(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, SQLCHAR* SchemaName, SQLSMALLINT NameLength2, + SQLCHAR* TableName, SQLSMALLINT NameLength3) const override + { + return ODBCFunc(ODBC3SQLFunctionId::TablePrivileges, StatementHandle, CatalogName, + NameLength1, SchemaName, NameLength2, TableName, NameLength3); + } + + SQLRETURN Tables(SQLHSTMT StatementHandle, SQLCHAR* CatalogName, SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, SQLSMALLINT NameLength2, SQLCHAR* TableName, + SQLSMALLINT NameLength3, SQLCHAR* TableType, + SQLSMALLINT NameLength4) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Tables, StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4); + } + + SQLRETURN FreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option) const override + { + return ODBCFunc(ODBC3SQLFunctionId::FreeStmt, StatementHandle, Option); + } + + SQLRETURN CloseCursor(SQLHSTMT StatementHandle) const override + { + return ODBCFunc(ODBC3SQLFunctionId::CloseCursor, StatementHandle); + } + + SQLRETURN Cancel(SQLHSTMT StatementHandle) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Cancel, StatementHandle); + } + + SQLRETURN EndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT CompletionType) const override + { + return ODBCFunc(ODBC3SQLFunctionId::EndTran, HandleType, Handle, CompletionType); + } + + SQLRETURN Disconnect(SQLHDBC ConnectionHandle) const override + { + return ODBCFunc(ODBC3SQLFunctionId::Disconnect, ConnectionHandle); + } + + SQLRETURN FreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) const override + { + return ODBCFunc(ODBC3SQLFunctionId::FreeHandle, HandleType, Handle); + } + + SQLRETURN GetCursorName(SQLHSTMT StatementHandle, SQLCHAR* CursorName, SQLSMALLINT BufferLength, + SQLSMALLINT* NameLength2) const override + { + return ODBCFunc(ODBC3SQLFunctionId::GetCursorName, StatementHandle, CursorName, + BufferLength, NameLength2); + } + + SQLRETURN NativeSql(SQLHDBC ConnectionHandle, SQLCHAR* InStatementText, SQLINTEGER TextLength1, + SQLCHAR* OutStatementText, SQLINTEGER BufferLength, + SQLINTEGER* TextLength2Ptr) const override + { + return ODBCFunc(ODBC3SQLFunctionId::NativeSql, ConnectionHandle, InStatementText, + TextLength1, OutStatementText, BufferLength, TextLength2Ptr); + } + +protected: + virtual SQLHANDLE EnvironmentHandle() override; + +private: + template static SQLRETURN ODBCFunc(ODBC3SQLFunctionId id, Args... args) + { + assert(id > ODBC3SQLFunctionId::FIRST && id < ODBC3SQLFunctionId::LAST); + assert(pODBC3SQLFunctions[static_cast(id)]); + using Func_t = SQLRETURN(SQL_API*)(Args...); + return (*reinterpret_cast(pODBC3SQLFunctions[static_cast(id)]))(args...); + } + + SQLHANDLE m_pDriverHandle = SQL_NULL_HANDLE; +}; + +// ODBC Environment (common for all Connections): +SQLHANDLE ORealOdbcDriver::EnvironmentHandle() +{ + // Is (for this instance) already an Environment made? + if (m_pDriverHandle == SQL_NULL_HANDLE) + { + OUString aPath; + SQLHANDLE h = SQL_NULL_HANDLE; + // allocate Environment + // load ODBC-DLL now: + if (!LoadLibrary_ODBC3(aPath) + || AllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h) != SQL_SUCCESS) + dbtools::throwSQLException(aPath, OUString(), *this, 1000); + + // Save in global Structure + m_pDriverHandle = h; + SetEnvAttr(h, SQL_ATTR_ODBC_VERSION, reinterpret_cast(SQL_OV_ODBC3), + SQL_IS_UINTEGER); + //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER); + } + + return m_pDriverHandle; +} +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +connectivity_odbc_ORealOdbcDriver_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence const&) +{ + return cppu::acquire(new ORealOdbcDriver(context)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/odbc/OFunctions.cxx b/connectivity/source/drivers/odbc/OFunctions.cxx deleted file mode 100644 index 87bd726b3bee..000000000000 --- a/connectivity/source/drivers/odbc/OFunctions.cxx +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include - -// Implib definitions for ODBC-DLL/shared library: - -namespace connectivity -{ - T3SQLAllocHandle pODBC3SQLAllocHandle; -T3SQLConnect pODBC3SQLConnect; -T3SQLDriverConnect pODBC3SQLDriverConnect; -T3SQLBrowseConnect pODBC3SQLBrowseConnect; -T3SQLDataSources pODBC3SQLDataSources; -T3SQLDrivers pODBC3SQLDrivers; -T3SQLGetInfo pODBC3SQLGetInfo; -T3SQLGetFunctions pODBC3SQLGetFunctions; -T3SQLGetTypeInfo pODBC3SQLGetTypeInfo; -T3SQLSetConnectAttr pODBC3SQLSetConnectAttr; -T3SQLGetConnectAttr pODBC3SQLGetConnectAttr; -T3SQLSetEnvAttr pODBC3SQLSetEnvAttr; -T3SQLGetEnvAttr pODBC3SQLGetEnvAttr; -T3SQLSetStmtAttr pODBC3SQLSetStmtAttr; -T3SQLGetStmtAttr pODBC3SQLGetStmtAttr; -T3SQLPrepare pODBC3SQLPrepare; -T3SQLBindParameter pODBC3SQLBindParameter; -T3SQLSetCursorName pODBC3SQLSetCursorName; -T3SQLExecute pODBC3SQLExecute; -T3SQLExecDirect pODBC3SQLExecDirect; -T3SQLDescribeParam pODBC3SQLDescribeParam; -T3SQLNumParams pODBC3SQLNumParams; -T3SQLParamData pODBC3SQLParamData; -T3SQLPutData pODBC3SQLPutData; -T3SQLRowCount pODBC3SQLRowCount; -T3SQLNumResultCols pODBC3SQLNumResultCols; -T3SQLDescribeCol pODBC3SQLDescribeCol; -T3SQLColAttribute pODBC3SQLColAttribute; -T3SQLBindCol pODBC3SQLBindCol; -T3SQLFetch pODBC3SQLFetch; -T3SQLFetchScroll pODBC3SQLFetchScroll; -T3SQLGetData pODBC3SQLGetData; -T3SQLSetPos pODBC3SQLSetPos; -T3SQLBulkOperations pODBC3SQLBulkOperations; -T3SQLMoreResults pODBC3SQLMoreResults; -T3SQLGetDiagRec pODBC3SQLGetDiagRec; -T3SQLColumnPrivileges pODBC3SQLColumnPrivileges; -T3SQLColumns pODBC3SQLColumns; -T3SQLForeignKeys pODBC3SQLForeignKeys; -T3SQLPrimaryKeys pODBC3SQLPrimaryKeys; -T3SQLProcedureColumns pODBC3SQLProcedureColumns; -T3SQLProcedures pODBC3SQLProcedures; -T3SQLSpecialColumns pODBC3SQLSpecialColumns; -T3SQLStatistics pODBC3SQLStatistics; -T3SQLTablePrivileges pODBC3SQLTablePrivileges; -T3SQLTables pODBC3SQLTables; -T3SQLFreeStmt pODBC3SQLFreeStmt; -T3SQLCloseCursor pODBC3SQLCloseCursor; -T3SQLCancel pODBC3SQLCancel; -T3SQLEndTran pODBC3SQLEndTran; -T3SQLDisconnect pODBC3SQLDisconnect; -T3SQLFreeHandle pODBC3SQLFreeHandle; -T3SQLGetCursorName pODBC3SQLGetCursorName; -T3SQLNativeSql pODBC3SQLNativeSql; - -static bool LoadFunctions(oslModule pODBCso); - -// Take care of Dynamically loading of the DLL/shared lib and Addresses: -// Returns sal_True at success -bool LoadLibrary_ODBC3(OUString &_rPath) -{ - static bool bLoaded = false; - static oslModule pODBCso = nullptr; - - if (bLoaded) - return true; -#ifdef DISABLE_DYNLOADING - (void)_rPath; -#else -#ifdef _WIN32 - _rPath = "ODBC32.DLL"; -#endif -#ifdef UNX - #ifdef MACOSX - _rPath = "libiodbc.dylib"; - #else - _rPath = "libodbc.so.2"; - pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); - if ( !pODBCso ) - { - _rPath = "libodbc.so.1"; - pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); - } - if ( !pODBCso ) - _rPath = "libodbc.so"; - - #endif /* MACOSX */ -#endif - - if ( !pODBCso ) - pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); -#endif // DISABLE_DYNLOADING - if( !pODBCso) - return false; - - bLoaded = LoadFunctions(pODBCso); - return bLoaded; -} - - -bool LoadFunctions(oslModule pODBCso) -{ - - if( ( pODBC3SQLAllocHandle = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLAllocHandle"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLConnect = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLConnect"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLDriverConnect = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLDriverConnect"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLBrowseConnect = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLBrowseConnect"_ustr.pData ))) == nullptr ) - return false; - if(( pODBC3SQLDataSources = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLDataSources"_ustr.pData ))) == nullptr ) - return false; - if(( pODBC3SQLDrivers = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLDrivers"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetInfo = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetInfo"_ustr.pData ))) == nullptr ) - return false; - if(( pODBC3SQLGetFunctions = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetFunctions"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetTypeInfo = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetTypeInfo"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLSetConnectAttr = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLSetConnectAttr"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetConnectAttr = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetConnectAttr"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLSetEnvAttr = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLSetEnvAttr"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetEnvAttr = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetEnvAttr"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLSetStmtAttr = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLSetStmtAttr"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetStmtAttr = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetStmtAttr"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLPrepare = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLPrepare"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLBindParameter = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLBindParameter"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLSetCursorName = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLSetCursorName"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLExecute = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLExecute"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLExecDirect = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLExecDirect"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLDescribeParam = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLDescribeParam"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLNumParams = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLNumParams"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLParamData = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLParamData"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLPutData = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLPutData"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLRowCount = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLRowCount"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLNumResultCols = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLNumResultCols"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLDescribeCol = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLDescribeCol"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLColAttribute = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLColAttribute"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLBindCol = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLBindCol"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLFetch = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLFetch"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLFetchScroll = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLFetchScroll"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetData = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetData"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLSetPos = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLSetPos"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLBulkOperations = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLBulkOperations"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLMoreResults = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLMoreResults"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetDiagRec = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetDiagRec"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLColumnPrivileges = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLColumnPrivileges"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLColumns = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLColumns"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLForeignKeys = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLForeignKeys"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLPrimaryKeys = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLPrimaryKeys"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLProcedureColumns = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLProcedureColumns"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLProcedures = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLProcedures"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLSpecialColumns = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLSpecialColumns"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLStatistics = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLStatistics"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLTablePrivileges = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLTablePrivileges"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLTables = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLTables"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLFreeStmt = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLFreeStmt"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLCloseCursor = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLCloseCursor"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLCancel = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLCancel"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLEndTran = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLEndTran"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLDisconnect = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLDisconnect"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLFreeHandle = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLFreeHandle"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLGetCursorName = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLGetCursorName"_ustr.pData ))) == nullptr ) - return false; - if( ( pODBC3SQLNativeSql = reinterpret_cast(osl_getFunctionSymbol(pODBCso, u"SQLNativeSql"_ustr.pData ))) == nullptr ) - return false; - - return true; -} - - -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx index f8bb5a6ad0b7..1537ede5f6fe 100644 --- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -147,7 +147,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); try { - SQLRETURN nReturn = N3SQLExecute(m_aStatementHandle); + SQLRETURN nReturn = functions().Execute(m_aStatementHandle); OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this); bool needData = nReturn == SQL_NEED_DATA; @@ -161,7 +161,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) // Get the parameter number that requires data sal_Int32* paramIndex = nullptr; - N3SQLParamData(m_aStatementHandle, reinterpret_cast(¶mIndex)); + functions().ParamData(m_aStatementHandle, reinterpret_cast(¶mIndex)); // If the parameter index is -1, there is no // more data required @@ -373,7 +373,7 @@ void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_ rDataLen = _nDataLen; SQLRETURN nRetcode; - nRetcode = (*reinterpret_cast(m_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindParameter)))( + nRetcode = functions().BindParameter( m_aStatementHandle, // checkParameterIndex guarantees this is safe static_cast(parameterIndex), @@ -513,7 +513,7 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, const sal_I fCType, fSqlType); - SQLRETURN nReturn = N3SQLBindParameter( m_aStatementHandle, + SQLRETURN nReturn = functions().BindParameter( m_aStatementHandle, static_cast(parameterIndex), SQL_PARAM_INPUT, fCType, @@ -639,8 +639,8 @@ void SAL_CALL OPreparedStatement::clearParameters( ) ::osl::MutexGuard aGuard( m_aMutex ); prepareStatement(); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - N3SQLFreeStmt (m_aStatementHandle, SQL_RESET_PARAMS); - N3SQLFreeStmt (m_aStatementHandle, SQL_UNBIND); + functions().FreeStmt (m_aStatementHandle, SQL_RESET_PARAMS); + functions().FreeStmt (m_aStatementHandle, SQL_UNBIND); } void SAL_CALL OPreparedStatement::clearBatch( ) @@ -673,7 +673,7 @@ void OPreparedStatement::initBoundParam () OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); // Get the number of parameters numParams = 0; - N3SQLNumParams (m_aStatementHandle,&numParams); + functions().NumParams (m_aStatementHandle,&numParams); // There are parameter markers, allocate the bound // parameter objects @@ -772,7 +772,7 @@ void OPreparedStatement::putParamData (sal_Int32 index) // Put the data OSL_ENSURE( m_aStatementHandle, "OPreparedStatement::putParamData: StatementHandle is null!" ); - N3SQLPutData ( m_aStatementHandle, buf.getArray(), buf.getLength() ); + functions().PutData ( m_aStatementHandle, buf.getArray(), buf.getLength() ); // decrement the number of bytes still needed maxBytesLeft -= haveRead; @@ -823,7 +823,7 @@ void OPreparedStatement::setStream( OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - N3SQLBindParameter(m_aStatementHandle, + functions().BindParameter(m_aStatementHandle, static_cast(ParameterIndex), SQL_PARAM_INPUT, fCType, @@ -883,7 +883,7 @@ void OPreparedStatement::prepareStatement() { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); OString aSql(OUStringToOString(m_sSqlStatement,getOwnConnection()->getTextEncoding())); - SQLRETURN nReturn = N3SQLPrepare(m_aStatementHandle, reinterpret_cast(const_cast(aSql.getStr())), aSql.getLength()); + SQLRETURN nReturn = functions().Prepare(m_aStatementHandle, reinterpret_cast(const_cast(aSql.getStr())), aSql.getLength()); OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this); m_bPrepared = true; initBoundParam(); diff --git a/connectivity/source/drivers/odbc/ORealDriver.cxx b/connectivity/source/drivers/odbc/ORealDriver.cxx deleted file mode 100644 index 28c054b45f7c..000000000000 --- a/connectivity/source/drivers/odbc/ORealDriver.cxx +++ /dev/null @@ -1,291 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include -#include - -namespace connectivity::odbc -{ - namespace { - - class ORealOdbcDriver : public ODBCDriver - { - protected: - virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const override; - virtual SQLHANDLE EnvironmentHandle(OUString &_rPath) override; - public: - explicit ORealOdbcDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext) : ODBCDriver(_rxContext) {} - }; - - } - -oslGenericFunction ORealOdbcDriver::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const -{ - oslGenericFunction pFunction = nullptr; - switch(_nIndex) - { - case ODBC3SQLFunctionId::AllocHandle: - pFunction = reinterpret_cast(pODBC3SQLAllocHandle); - break; - case ODBC3SQLFunctionId::Connect: - pFunction = reinterpret_cast(pODBC3SQLConnect); - break; - case ODBC3SQLFunctionId::DriverConnect: - pFunction = reinterpret_cast(pODBC3SQLDriverConnect); - break; - case ODBC3SQLFunctionId::BrowseConnect: - pFunction = reinterpret_cast(pODBC3SQLBrowseConnect); - break; - case ODBC3SQLFunctionId::DataSources: - pFunction = reinterpret_cast(pODBC3SQLDataSources); - break; - case ODBC3SQLFunctionId::Drivers: - pFunction = reinterpret_cast(pODBC3SQLDrivers); - break; - case ODBC3SQLFunctionId::GetInfo: - - pFunction = reinterpret_cast(pODBC3SQLGetInfo); - break; - case ODBC3SQLFunctionId::GetFunctions: - - pFunction = reinterpret_cast(pODBC3SQLGetFunctions); - break; - case ODBC3SQLFunctionId::GetTypeInfo: - - pFunction = reinterpret_cast(pODBC3SQLGetTypeInfo); - break; - case ODBC3SQLFunctionId::SetConnectAttr: - - pFunction = reinterpret_cast(pODBC3SQLSetConnectAttr); - break; - case ODBC3SQLFunctionId::GetConnectAttr: - - pFunction = reinterpret_cast(pODBC3SQLGetConnectAttr); - break; - case ODBC3SQLFunctionId::SetEnvAttr: - - pFunction = reinterpret_cast(pODBC3SQLSetEnvAttr); - break; - case ODBC3SQLFunctionId::GetEnvAttr: - - pFunction = reinterpret_cast(pODBC3SQLGetEnvAttr); - break; - case ODBC3SQLFunctionId::SetStmtAttr: - - pFunction = reinterpret_cast(pODBC3SQLSetStmtAttr); - break; - case ODBC3SQLFunctionId::GetStmtAttr: - - pFunction = reinterpret_cast(pODBC3SQLGetStmtAttr); - break; - case ODBC3SQLFunctionId::Prepare: - - pFunction = reinterpret_cast(pODBC3SQLPrepare); - break; - case ODBC3SQLFunctionId::BindParameter: - - pFunction = reinterpret_cast(pODBC3SQLBindParameter); - break; - case ODBC3SQLFunctionId::SetCursorName: - - pFunction = reinterpret_cast(pODBC3SQLSetCursorName); - break; - case ODBC3SQLFunctionId::Execute: - - pFunction = reinterpret_cast(pODBC3SQLExecute); - break; - case ODBC3SQLFunctionId::ExecDirect: - - pFunction = reinterpret_cast(pODBC3SQLExecDirect); - break; - case ODBC3SQLFunctionId::DescribeParam: - - pFunction = reinterpret_cast(pODBC3SQLDescribeParam); - break; - case ODBC3SQLFunctionId::NumParams: - - pFunction = reinterpret_cast(pODBC3SQLNumParams); - break; - case ODBC3SQLFunctionId::ParamData: - - pFunction = reinterpret_cast(pODBC3SQLParamData); - break; - case ODBC3SQLFunctionId::PutData: - - pFunction = reinterpret_cast(pODBC3SQLPutData); - break; - case ODBC3SQLFunctionId::RowCount: - - pFunction = reinterpret_cast(pODBC3SQLRowCount); - break; - case ODBC3SQLFunctionId::NumResultCols: - - pFunction = reinterpret_cast(pODBC3SQLNumResultCols); - break; - case ODBC3SQLFunctionId::DescribeCol: - - pFunction = reinterpret_cast(pODBC3SQLDescribeCol); - break; - case ODBC3SQLFunctionId::ColAttribute: - - pFunction = reinterpret_cast(pODBC3SQLColAttribute); - break; - case ODBC3SQLFunctionId::BindCol: - - pFunction = reinterpret_cast(pODBC3SQLBindCol); - break; - case ODBC3SQLFunctionId::Fetch: - - pFunction = reinterpret_cast(pODBC3SQLFetch); - break; - case ODBC3SQLFunctionId::FetchScroll: - - pFunction = reinterpret_cast(pODBC3SQLFetchScroll); - break; - case ODBC3SQLFunctionId::GetData: - - pFunction = reinterpret_cast(pODBC3SQLGetData); - break; - case ODBC3SQLFunctionId::SetPos: - - pFunction = reinterpret_cast(pODBC3SQLSetPos); - break; - case ODBC3SQLFunctionId::BulkOperations: - - pFunction = reinterpret_cast(pODBC3SQLBulkOperations); - break; - case ODBC3SQLFunctionId::MoreResults: - - pFunction = reinterpret_cast(pODBC3SQLMoreResults); - break; - case ODBC3SQLFunctionId::GetDiagRec: - - pFunction = reinterpret_cast(pODBC3SQLGetDiagRec); - break; - case ODBC3SQLFunctionId::ColumnPrivileges: - - pFunction = reinterpret_cast(pODBC3SQLColumnPrivileges); - break; - case ODBC3SQLFunctionId::Columns: - - pFunction = reinterpret_cast(pODBC3SQLColumns); - break; - case ODBC3SQLFunctionId::ForeignKeys: - - pFunction = reinterpret_cast(pODBC3SQLForeignKeys); - break; - case ODBC3SQLFunctionId::PrimaryKeys: - - pFunction = reinterpret_cast(pODBC3SQLPrimaryKeys); - break; - case ODBC3SQLFunctionId::ProcedureColumns: - - pFunction = reinterpret_cast(pODBC3SQLProcedureColumns); - break; - case ODBC3SQLFunctionId::Procedures: - - pFunction = reinterpret_cast(pODBC3SQLProcedures); - break; - case ODBC3SQLFunctionId::SpecialColumns: - - pFunction = reinterpret_cast(pODBC3SQLSpecialColumns); - break; - case ODBC3SQLFunctionId::Statistics: - - pFunction = reinterpret_cast(pODBC3SQLStatistics); - break; - case ODBC3SQLFunctionId::TablePrivileges: - - pFunction = reinterpret_cast(pODBC3SQLTablePrivileges); - break; - case ODBC3SQLFunctionId::Tables: - - pFunction = reinterpret_cast(pODBC3SQLTables); - break; - case ODBC3SQLFunctionId::FreeStmt: - - pFunction = reinterpret_cast(pODBC3SQLFreeStmt); - break; - case ODBC3SQLFunctionId::CloseCursor: - - pFunction = reinterpret_cast(pODBC3SQLCloseCursor); - break; - case ODBC3SQLFunctionId::Cancel: - - pFunction = reinterpret_cast(pODBC3SQLCancel); - break; - case ODBC3SQLFunctionId::EndTran: - - pFunction = reinterpret_cast(pODBC3SQLEndTran); - break; - case ODBC3SQLFunctionId::Disconnect: - - pFunction = reinterpret_cast(pODBC3SQLDisconnect); - break; - case ODBC3SQLFunctionId::FreeHandle: - - pFunction = reinterpret_cast(pODBC3SQLFreeHandle); - break; - case ODBC3SQLFunctionId::GetCursorName: - - pFunction = reinterpret_cast(pODBC3SQLGetCursorName); - break; - case ODBC3SQLFunctionId::NativeSql: - - pFunction = reinterpret_cast(pODBC3SQLNativeSql); - break; - default: - OSL_FAIL("Function unknown!"); - } - return pFunction; -} - - -// ODBC Environment (common for all Connections): -SQLHANDLE ORealOdbcDriver::EnvironmentHandle(OUString &_rPath) -{ - // Is (for this instance) already an Environment made? - if (!m_pDriverHandle) - { - SQLHANDLE h = SQL_NULL_HANDLE; - // allocate Environment - - // load ODBC-DLL now: - if (!LoadLibrary_ODBC3(_rPath) || N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS) - return SQL_NULL_HANDLE; - - // Save in global Structure - m_pDriverHandle = h; - N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION, reinterpret_cast(SQL_OV_ODBC3), SQL_IS_UINTEGER); - //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER); - } - - return m_pDriverHandle; -} - -} - -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -connectivity_odbc_ORealOdbcDriver_get_implementation( - css::uno::XComponentContext* context, css::uno::Sequence const&) -{ - return cppu::acquire(new connectivity::odbc::ORealOdbcDriver(context)); -} -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index 7a1e81593d58..696df003254e 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -142,10 +142,10 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) : // We use SQLFetchScroll unconditionally in several places // the *only* difference this makes is whether ::next() uses SQLFetchScroll or SQLFetch // so this test seems pointless - if ( getOdbcFunction(ODBC3SQLFunctionId::GetFunctions) ) + if (functions().has(ODBC3SQLFunctionId::GetFunctions)) { SQLUSMALLINT nSupported = 0; - m_bUseFetchScroll = ( N3SQLGetFunctions(m_aConnectionHandle,SQL_API_SQLFETCHSCROLL,&nSupported) == SQL_SUCCESS && nSupported == 1 ); + m_bUseFetchScroll = ( functions().GetFunctions(m_aConnectionHandle,SQL_API_SQLFETCHSCROLL,&nSupported) == SQL_SUCCESS && nSupported == 1 ); } } catch(const Exception&) @@ -169,7 +169,7 @@ void OResultSet::construct() void OResultSet::disposing() { - N3SQLCloseCursor(m_aStatementHandle); + functions().CloseCursor(m_aStatementHandle); OPropertySetHelper::disposing(); ::osl::MutexGuard aGuard(m_aMutex); @@ -184,7 +184,7 @@ SQLRETURN OResultSet::unbind(bool _bUnbindHandle) { SQLRETURN nRet = 0; if ( _bUnbindHandle ) - nRet = N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND); + nRet = functions().FreeStmt(m_aStatementHandle,SQL_UNBIND); if ( !m_aBindVector.empty() ) { @@ -808,7 +808,7 @@ void SAL_CALL OResultSet::cancel( ) checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - N3SQLCancel(m_aStatementHandle); + functions().Cancel(m_aStatementHandle); } void SAL_CALL OResultSet::clearWarnings( ) @@ -830,7 +830,7 @@ void SAL_CALL OResultSet::insertRow( ) Sequence aBookmark(nMaxBookmarkLen); static_assert(o3tl::make_unsigned(nMaxBookmarkLen) >= sizeof(SQLLEN), "must be larger"); - SQLRETURN nRet = N3SQLBindCol(m_aStatementHandle, + SQLRETURN nRet = functions().BindCol(m_aStatementHandle, 0, SQL_C_VARBOOKMARK, aBookmark.getArray(), @@ -838,17 +838,17 @@ void SAL_CALL OResultSet::insertRow( ) &nRealLen ); - bool bPositionByBookmark = ( nullptr != getOdbcFunction( ODBC3SQLFunctionId::BulkOperations ) ); + bool bPositionByBookmark = functions().has(ODBC3SQLFunctionId::BulkOperations); if ( bPositionByBookmark ) { - nRet = N3SQLBulkOperations( m_aStatementHandle, SQL_ADD ); + nRet = functions().BulkOperations( m_aStatementHandle, SQL_ADD ); fillNeededData( nRet ); } else { if(isBeforeFirst()) next(); // must be done - nRet = N3SQLSetPos( m_aStatementHandle, 1, SQL_ADD, SQL_LOCK_NO_CHANGE ); + nRet = functions().SetPos( m_aStatementHandle, 1, SQL_ADD, SQL_LOCK_NO_CHANGE ); fillNeededData( nRet ); } aBookmark.realloc(nRealLen); @@ -869,10 +869,10 @@ void SAL_CALL OResultSet::insertRow( ) { setStmtOption(SQL_ATTR_FETCH_BOOKMARK_PTR, reinterpret_cast(aBookmark.getArray())); - nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0); + nRet = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0); } else - nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); // OJ 06.03.2004 + nRet = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); // OJ 06.03.2004 // sometimes we got an error but we are not interested in anymore #106047# OJ // OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); @@ -905,14 +905,14 @@ void SAL_CALL OResultSet::updateRow( ) try { - bool bPositionByBookmark = ( nullptr != getOdbcFunction( ODBC3SQLFunctionId::BulkOperations ) ); + bool bPositionByBookmark = functions().has(ODBC3SQLFunctionId::BulkOperations); if ( bPositionByBookmark ) { getBookmark(); assert(m_aRow[0].isBound()); Sequence aBookmark(m_aRow[0].getSequence()); SQLLEN nRealLen = aBookmark.getLength(); - nRet = N3SQLBindCol(m_aStatementHandle, + nRet = functions().BindCol(m_aStatementHandle, 0, SQL_C_VARBOOKMARK, aBookmark.getArray(), @@ -920,7 +920,7 @@ void SAL_CALL OResultSet::updateRow( ) &nRealLen ); OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); - nRet = N3SQLBulkOperations(m_aStatementHandle, SQL_UPDATE_BY_BOOKMARK); + nRet = functions().BulkOperations(m_aStatementHandle, SQL_UPDATE_BY_BOOKMARK); fillNeededData(nRet); // the driver should not have touched this // (neither the contents of aBookmark FWIW) @@ -928,7 +928,7 @@ void SAL_CALL OResultSet::updateRow( ) } else { - nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + nRet = functions().SetPos(m_aStatementHandle,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); fillNeededData(nRet); } OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); @@ -952,7 +952,7 @@ void SAL_CALL OResultSet::deleteRow( ) { SQLRETURN nRet = SQL_SUCCESS; sal_Int32 nPos = getDriverPos(); - nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + nRet = functions().SetPos(m_aStatementHandle,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); m_bRowDeleted = ( m_pRowStatusArray[0] == SQL_ROW_DELETED ); @@ -982,7 +982,7 @@ void SAL_CALL OResultSet::moveToInsertRow( ) invalidateCache(); // first unbound all columns OSL_VERIFY( unbind() == SQL_SUCCESS ); - // SQLRETURN nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1,SQL_IS_INTEGER); + // SQLRETURN nRet = functions().SetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1,SQL_IS_INTEGER); } @@ -1122,8 +1122,8 @@ void SAL_CALL OResultSet::refreshRow( ) checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - // SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE); - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); + // SQLRETURN nRet = functions().SetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); } @@ -1192,7 +1192,7 @@ sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) if ( SQL_INVALID_HANDLE != nReturn && SQL_ERROR != nReturn ) { - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0); OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); TBookmarkPosMap::const_iterator aFind = m_aPosToBookmarks.find(aBookmark); if(aFind != m_aPosToBookmarks.end()) @@ -1216,7 +1216,7 @@ sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_ bookmark >>= aBookmark; setStmtOption(SQL_ATTR_FETCH_BOOKMARK_PTR, reinterpret_cast(aBookmark.getArray())); - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,rows); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,rows); OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; } @@ -1270,14 +1270,14 @@ template < typename T, SQLINTEGER BufferLength > T OResultSet::getStmtOption (SQ { T result (0); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - N3SQLGetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, nullptr); + functions().GetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, nullptr); return result; } template < typename T, SQLINTEGER BufferLength > SQLRETURN OResultSet::setStmtOption (SQLINTEGER fOption, T value) const { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); SQLPOINTER sv = reinterpret_cast(value); - return N3SQLSetStmtAttr(m_aStatementHandle, fOption, sv, BufferLength); + return functions().SetStmtAttr(m_aStatementHandle, fOption, sv, BufferLength); } sal_Int32 OResultSet::getResultSetConcurrency() const @@ -1322,7 +1322,7 @@ OUString OResultSet::getCursorName() const { SQLCHAR pName[258]; SQLSMALLINT nRealLen = 0; - N3SQLGetCursorName(m_aStatementHandle,pName,256,&nRealLen); + functions().GetCursorName(m_aStatementHandle,pName,256,&nRealLen); return OUString::createFromAscii(reinterpret_cast(pName)); } @@ -1680,9 +1680,9 @@ bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nO // _eCursorPosition == IResultSetHelper::NEXT/PREVIOUS // when fetchSize > 1 if ( !m_bUseFetchScroll && _eCursorPosition == IResultSetHelper::NEXT ) - m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle); + m_nCurrentFetchState = functions().Fetch(m_aStatementHandle); else - m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,nFetchOrientation,_nOffset); + m_nCurrentFetchState = functions().FetchScroll(m_aStatementHandle,nFetchOrientation,_nOffset); SAL_INFO( "connectivity.odbc", @@ -1773,7 +1773,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) return; void* pColumnIndex = nullptr; - nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex); + nRet = functions().ParamData(m_aStatementHandle,&pColumnIndex); do { @@ -1789,12 +1789,12 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) case DataType::LONGVARBINARY: case DataType::BLOB: aSeq = m_aRow[nColumnIndex].getSequence(); - N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength()); + functions().PutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength()); break; case SQL_WLONGVARCHAR: { OUString const & sRet = m_aRow[nColumnIndex].getString(); - N3SQLPutData (m_aStatementHandle, static_cast(const_cast(sRet.getStr())), sizeof(sal_Unicode)*sRet.getLength()); + functions().PutData (m_aStatementHandle, static_cast(const_cast(sRet.getStr())), sizeof(sal_Unicode)*sRet.getLength()); break; } case DataType::LONGVARCHAR: @@ -1802,13 +1802,13 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) { OUString sRet = m_aRow[nColumnIndex].getString(); OString aString(OUStringToOString(sRet,m_nTextEncoding)); - N3SQLPutData (m_aStatementHandle, static_cast(const_cast(aString.getStr())), aString.getLength()); + functions().PutData (m_aStatementHandle, static_cast(const_cast(aString.getStr())), aString.getLength()); break; } default: SAL_WARN( "connectivity.odbc", "Not supported at the moment!"); } - nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex); + nRet = functions().ParamData(m_aStatementHandle,&pColumnIndex); } while (nRet == SQL_NEED_DATA); } diff --git a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx index f71e77d19c81..8448e7bd6ee9 100644 --- a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx +++ b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx @@ -38,7 +38,7 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) SQLSMALLINT BUFFER_LEN = 128; std::unique_ptr pName(new char[BUFFER_LEN+1]); SQLSMALLINT nRealLen=0; - SQLRETURN nRet = N3SQLColAttribute(m_aStatementHandle, + SQLRETURN nRet = functions().ColAttribute(m_aStatementHandle, static_cast(column), static_cast(ident), static_cast(pName.get()), @@ -58,7 +58,7 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) if(nRealLen > BUFFER_LEN) { pName.reset(new char[nRealLen+1]); - nRet = N3SQLColAttribute(m_aStatementHandle, + nRet = functions().ColAttribute(m_aStatementHandle, static_cast(column), static_cast(ident), static_cast(pName.get()), @@ -81,7 +81,7 @@ SQLLEN OResultSetMetaData::getNumColAttrib(OConnection const * _pConnection ,sal_Int32 _ident) { SQLLEN nValue=0; - OTools::ThrowException(_pConnection,(*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::ColAttribute)))(_aStatementHandle, + OTools::ThrowException(_pConnection,_pConnection->functions().ColAttribute(_aStatementHandle, static_cast(_column), static_cast(_ident), nullptr, @@ -161,7 +161,7 @@ sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) if(m_nColCount != -1) return m_nColCount; sal_Int16 nNumResultCols=0; - OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this); + OTools::ThrowException(m_pConnection,functions().NumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this); m_nColCount = nNumResultCols; return m_nColCount; } diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index 530634747e30..1e9086e9f2eb 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -161,7 +161,7 @@ void SAL_CALL OStatement_Base::cancel( ) checkDisposed(OStatement_BASE::rBHelper.bDisposed); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - N3SQLCancel(m_aStatementHandle); + functions().Cancel(m_aStatementHandle); } @@ -195,7 +195,7 @@ void OStatement_Base::reset() } if(m_aStatementHandle) { - THROW_SQL(N3SQLFreeStmt(m_aStatementHandle, SQL_CLOSE)); + THROW_SQL(functions().FreeStmt(m_aStatementHandle, SQL_CLOSE)); } } @@ -227,7 +227,7 @@ SQLLEN OStatement_Base::getRowCount() SQLLEN numRows = 0; try { - THROW_SQL(N3SQLRowCount(m_aStatementHandle,&numRows)); + THROW_SQL(functions().RowCount(m_aStatementHandle,&numRows)); } catch (const SQLException&) { @@ -299,7 +299,7 @@ sal_Int32 OStatement_Base::getColumnCount() OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); try { - THROW_SQL(N3SQLNumResultCols(m_aStatementHandle,&numCols)); + THROW_SQL(functions().NumResultCols(m_aStatementHandle,&numCols)); } catch (const SQLException&) { @@ -332,7 +332,7 @@ sal_Bool SAL_CALL OStatement_Base::execute( const OUString& sql ) OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); try { - THROW_SQL(N3SQLExecDirect(m_aStatementHandle, reinterpret_cast(const_cast(aSql.getStr())), aSql.getLength())); + THROW_SQL(functions().ExecDirect(m_aStatementHandle, reinterpret_cast(const_cast(aSql.getStr())), aSql.getLength())); } catch (const SQLWarning&) { @@ -404,14 +404,14 @@ template < typename T, SQLINTEGER BufferLength > T OStatement_Base::getStmtOptio { T result (0); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - N3SQLGetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, nullptr); + functions().GetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, nullptr); return result; } template < typename T, SQLINTEGER BufferLength > SQLRETURN OStatement_Base::setStmtOption (SQLINTEGER fOption, T value) const { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); SQLPOINTER sv = reinterpret_cast(value); - return N3SQLSetStmtAttr(m_aStatementHandle, fOption, sv, BufferLength); + return functions().SetStmtAttr(m_aStatementHandle, fOption, sv, BufferLength); } @@ -481,17 +481,17 @@ Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); auto s = aBatchSql.makeStringAndClear(); - THROW_SQL(N3SQLExecDirect(m_aStatementHandle, reinterpret_cast(const_cast(s.getStr())), s.getLength())); + THROW_SQL(functions().ExecDirect(m_aStatementHandle, reinterpret_cast(const_cast(s.getStr())), s.getLength())); Sequence< sal_Int32 > aRet(nLen); sal_Int32* pArray = aRet.getArray(); for(sal_Int32 j=0;j(pName)); } @@ -833,7 +833,7 @@ void OStatement_Base::setCursorName(std::u16string_view _par0) { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); OString aName(OUStringToOString(_par0,getOwnConnection()->getTextEncoding())); - N3SQLSetCursorName(m_aStatementHandle, reinterpret_cast(const_cast(aName.getStr())), static_cast(aName.getLength())); + functions().SetCursorName(m_aStatementHandle, reinterpret_cast(const_cast(aName.getStr())), static_cast(aName.getLength())); } bool OStatement_Base::isUsingBookmarks() const diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx index 4781415de474..fc522c14982d 100644 --- a/connectivity/source/drivers/odbc/OTools.cxx +++ b/connectivity/source/drivers/odbc/OTools.cxx @@ -151,7 +151,7 @@ void OTools::getValue( OConnection const * _pConnection, OSL_ENSURE(o3tl::make_unsigned(_nSize) >= properSize, "memory region is too small"); SQLLEN pcbValue = SQL_NULL_DATA; OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))(_aStatementHandle, + _pConnection->functions().GetData(_aStatementHandle, static_cast(columnIndex), _nType, _pValue, @@ -186,7 +186,7 @@ void OTools::bindValue( OConnection const * _pConnection, if (columnIndex != 0 && !_pValue) { *pLen = SQL_NULL_DATA; - nRetcode = (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindCol)))(_aStatementHandle, + nRetcode = _pConnection->functions().BindCol(_aStatementHandle, static_cast(columnIndex), fCType, _pData, @@ -287,7 +287,7 @@ void OTools::bindValue( OConnection const * _pConnection, { } - nRetcode = (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindCol)))(_aStatementHandle, + nRetcode = _pConnection->functions().BindCol(_aStatementHandle, static_cast(columnIndex), fCType, _pData, @@ -340,7 +340,7 @@ void OTools::ThrowException(const OConnection* _pConnection, // statements of this connection [what in this case will probably be the same, but the Reference // Manual isn't totally clear in this...]. // corresponding for hdbc. - SQLRETURN n = (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetDiagRec)))(_nHandleType,_pContext,1, + SQLRETURN n = _pConnection->functions().GetDiagRec(_nHandleType,_pContext,1, szSqlState, &pfNativeError, szErrorMessage,sizeof szErrorMessage - 1,&pcbErrorMsg); @@ -378,7 +378,7 @@ Sequence OTools::getBytesValue(const OConnection* _pConnection, while (pcbValue == SQL_NO_TOTAL || pcbValue > nMaxLen) { OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))( + _pConnection->functions().GetData( _aStatementHandle, static_cast(columnIndex), _fSqlType, @@ -438,7 +438,7 @@ OUString OTools::getStringValue(OConnection const * _pConnection, while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxSize) ) { OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))( + _pConnection->functions().GetData( _aStatementHandle, static_cast(columnIndex), SQL_C_WCHAR, @@ -482,7 +482,7 @@ OUString OTools::getStringValue(OConnection const * _pConnection, while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxLen) ) { OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))( + _pConnection->functions().GetData( _aStatementHandle, static_cast(columnIndex), SQL_C_CHAR, @@ -530,7 +530,7 @@ void OTools::GetInfo(OConnection const * _pConnection, char aValue[512]; SQLSMALLINT nValueLen=0; OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,aValue,(sizeof aValue)-1,&nValueLen), + _pConnection->functions().GetInfo(_aConnectionHandle,_nInfo,aValue,(sizeof aValue)-1,&nValueLen), _aConnectionHandle,SQL_HANDLE_DBC,_xInterface); _rValue = OUString(aValue,nValueLen,_nTextEncoding); @@ -545,7 +545,7 @@ void OTools::GetInfo(OConnection const * _pConnection, SQLSMALLINT nValueLen; _rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION) OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), + _pConnection->functions().GetInfo(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), _aConnectionHandle,SQL_HANDLE_DBC,_xInterface); } @@ -558,7 +558,7 @@ void OTools::GetInfo(OConnection const * _pConnection, SQLSMALLINT nValueLen; _rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION) OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), + _pConnection->functions().GetInfo(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), _aConnectionHandle,SQL_HANDLE_DBC,_xInterface); } @@ -571,7 +571,7 @@ void OTools::GetInfo(OConnection const * _pConnection, SQLSMALLINT nValueLen; _rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION) OTools::ThrowException(_pConnection, - (*reinterpret_cast(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), + _pConnection->functions().GetInfo(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), _aConnectionHandle,SQL_HANDLE_DBC,_xInterface); } diff --git a/connectivity/source/inc/odbc/OConnection.hxx b/connectivity/source/inc/odbc/OConnection.hxx index 93875c66193c..cc0ec63e7510 100644 --- a/connectivity/source/inc/odbc/OConnection.hxx +++ b/connectivity/source/inc/odbc/OConnection.hxx @@ -37,6 +37,7 @@ namespace connectivity::odbc { class ODBCDriver; + class Functions; typedef connectivity::OMetaConnection OConnection_BASE; typedef std::vector< ::connectivity::OTypeInfo> TTypeInfoVector; @@ -69,7 +70,7 @@ namespace connectivity::odbc SQLRETURN OpenConnection(const OUString& aConnectStr,sal_Int32 nTimeOut, bool bSilent); public: - oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const; + const Functions& functions() const; /// @throws css::sdbc::SQLException SQLRETURN Construct( const OUString& url,const css::uno::Sequence< css::beans::PropertyValue >& info); diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx index dc011f37802c..1e026787cbce 100644 --- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx +++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx @@ -114,10 +114,7 @@ namespace connectivity::odbc ODatabaseMetaDataResultSet(OConnection* _pConnection); - oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const - { - return m_pConnection->getOdbcFunction(_nIndex); - } + const Functions& functions() const { return m_pConnection->functions(); } // ::cppu::OComponentHelper virtual void SAL_CALL disposing() override; // XInterface diff --git a/connectivity/source/inc/odbc/ODriver.hxx b/connectivity/source/inc/odbc/ODriver.hxx index 6cba90648d6e..505a37c01190 100644 --- a/connectivity/source/inc/odbc/ODriver.hxx +++ b/connectivity/source/inc/odbc/ODriver.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include namespace connectivity::odbc @@ -43,16 +44,15 @@ namespace connectivity::odbc // for this Driver css::uno::Reference< css::uno::XComponentContext > m_xContext; - SQLHANDLE m_pDriverHandle; - virtual SQLHANDLE EnvironmentHandle(OUString &_rPath) = 0; + virtual SQLHANDLE EnvironmentHandle() = 0; public: ODBCDriver(css::uno::Reference< css::uno::XComponentContext > xContext); // only possibility to get the odbc functions - virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const = 0; + virtual const Functions& functions() const = 0; // OComponentHelper virtual void SAL_CALL disposing() override; diff --git a/connectivity/source/inc/odbc/OFunctions.hxx b/connectivity/source/inc/odbc/OFunctions.hxx index a44fe5a15031..c4808e75f620 100644 --- a/connectivity/source/inc/odbc/OFunctions.hxx +++ b/connectivity/source/inc/odbc/OFunctions.hxx @@ -19,581 +19,302 @@ #pragma once +#include + #include -#include -#include +#include -namespace connectivity +namespace connectivity::odbc { +// All ODBC wrapper method signatures must match respective SQL* ODBC API functions exactly +class Functions +{ +public: + virtual bool has(ODBC3SQLFunctionId id) const = 0; -// sal_Bool LoadFunctions(oslModule pODBCso, sal_Bool _bDS=sal_True); -bool LoadLibrary_ODBC3(OUString &_rPath); -// sal_Bool LoadLibrary_ADABAS(OUString &_rPath); - - // Connecting to a data source - typedef SQLRETURN (SQL_API *T3SQLAllocHandle) (SQLSMALLINT HandleType,SQLHANDLE InputHandle,SQLHANDLE * OutputHandlePtr); - - #define N3SQLAllocHandle(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::AllocHandle)))(a,b,c) - - typedef SQLRETURN (SQL_API *T3SQLConnect) (SQLHDBC ConnectionHandle,SQLCHAR *ServerName,SQLSMALLINT NameLength1,SQLCHAR *UserName,SQLSMALLINT NameLength2,SQLCHAR *Authentication,SQLSMALLINT NameLength3); - - #define N3SQLConnect(a,b,c,d,e,f,g) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Connect)))(a,b,c,d,e,f,g) - - typedef SQLRETURN (SQL_API *T3SQLDriverConnect) ( SQLHDBC ConnectionHandle, - HWND WindowHandle, - SQLCHAR * InConnectionString, - SQLSMALLINT StringLength1, - SQLCHAR * OutConnectionString, - SQLSMALLINT BufferLength, - SQLSMALLINT * StringLength2Ptr, - SQLUSMALLINT DriverCompletion); - - #define N3SQLDriverConnect(a,b,c,d,e,f,g,h) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::DriverConnect)))(a,b,c,d,e,f,g,h) - - typedef SQLRETURN (SQL_API *T3SQLBrowseConnect) ( SQLHDBC ConnectionHandle, - SQLCHAR * InConnectionString, - SQLSMALLINT StringLength1, - SQLCHAR * OutConnectionString, - SQLSMALLINT BufferLength, - SQLSMALLINT * StringLength2Ptr); - - #define N3SQLBrowseConnect(a,b,c,d,e,f) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::BrowseConnect)))(a,b,c,d,e,f) - + virtual SQLRETURN AllocHandle(SQLSMALLINT HandleType, + SQLHANDLE InputHandle, + SQLHANDLE* OutputHandlePtr) const = 0; + virtual SQLRETURN DriverConnect(SQLHDBC ConnectionHandle, + HWND WindowHandle, + SQLCHAR* InConnectionString, + SQLSMALLINT StringLength1, + SQLCHAR* OutConnectionString, + SQLSMALLINT BufferLength, + SQLSMALLINT* StringLength2Ptr, + SQLUSMALLINT DriverCompletion) const = 0; // Obtaining information about a driver and data source - typedef SQLRETURN (SQL_API *T3SQLDataSources) ( SQLHENV EnvironmentHandle, - SQLUSMALLINT Direction, - SQLCHAR * ServerName, - SQLSMALLINT BufferLength1, - SQLSMALLINT * NameLength1Ptr, - SQLCHAR * Description, - SQLSMALLINT BufferLength2, - SQLSMALLINT * NameLength2Ptr); - - #define N3SQLDataSources(a,b,c,d,e,f,g,h) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::DataSources)))(a,b,c,d,e,f,g,h) - - typedef SQLRETURN (SQL_API *T3SQLDrivers) ( SQLHENV EnvironmentHandle, - SQLUSMALLINT Direction, - SQLCHAR * DriverDescription, - SQLSMALLINT BufferLength1, - SQLSMALLINT * DescriptionLengthPtr, - SQLCHAR * DriverAttributes, - SQLSMALLINT BufferLength2, - SQLSMALLINT * AttributesLengthPtr); - - #define N3SQLDrivers(a,b,c,d,e,f,g,h) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Drivers)))(a,b,c,d,e,f,g,h) - - typedef SQLRETURN (SQL_API *T3SQLGetInfo) ( SQLHDBC ConnectionHandle, - SQLUSMALLINT InfoType, - SQLPOINTER InfoValuePtr, - SQLSMALLINT BufferLength, - SQLSMALLINT * StringLengthPtr); - - #define N3SQLGetInfo(a,b,c,d,e) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(a,b,c,d,e) - - typedef SQLRETURN (SQL_API *T3SQLGetFunctions) (SQLHDBC ConnectionHandle, - SQLUSMALLINT FunctionId, - SQLUSMALLINT * SupportedPtr); - - #define N3SQLGetFunctions(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetFunctions)))(a,b,c) - - typedef SQLRETURN (SQL_API *T3SQLGetTypeInfo) ( SQLHSTMT StatementHandle, - SQLSMALLINT DataType); - - #define N3SQLGetTypeInfo(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetTypeInfo)))(a,b) - + virtual SQLRETURN GetInfo(SQLHDBC ConnectionHandle, + SQLUSMALLINT InfoType, + SQLPOINTER InfoValuePtr, + SQLSMALLINT BufferLength, + SQLSMALLINT* StringLengthPtr) const = 0; + virtual SQLRETURN GetFunctions(SQLHDBC ConnectionHandle, + SQLUSMALLINT FunctionId, + SQLUSMALLINT* SupportedPtr) const = 0; + virtual SQLRETURN GetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType) const = 0; // Setting and retrieving driver attributes - typedef SQLRETURN (SQL_API *T3SQLSetConnectAttr)(SQLHDBC ConnectionHandle, - SQLINTEGER Attribute, - SQLPOINTER ValuePtr, - SQLINTEGER StringLength); - - #define N3SQLSetConnectAttr(a,b,c,d) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SetConnectAttr)))(a,b,c,d) - - typedef SQLRETURN (SQL_API *T3SQLGetConnectAttr) (SQLHDBC ConnectionHandle, - SQLINTEGER Attribute, - SQLPOINTER ValuePtr, - SQLINTEGER BufferLength, - SQLINTEGER* StringLength); - - #define N3SQLGetConnectAttr(a,b,c,d,e) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetConnectAttr)))(a,b,c,d,e) - - - typedef SQLRETURN (SQL_API *T3SQLSetEnvAttr) ( SQLHENV EnvironmentHandle, - SQLINTEGER Attribute, - SQLPOINTER ValuePtr, - SQLINTEGER StringLength); - - #define N3SQLSetEnvAttr(a,b,c,d) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SetEnvAttr)))(a,b,c,d) - - typedef SQLRETURN (SQL_API *T3SQLGetEnvAttr) ( SQLHENV EnvironmentHandle, - SQLINTEGER Attribute, - SQLPOINTER ValuePtr, - SQLINTEGER BufferLength, - SQLINTEGER* StringLength); - - #define N3SQLGetEnvAttr(a,b,c,d,e) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetEnvAttr)))(a,b,c,d,e) - - - typedef SQLRETURN (SQL_API *T3SQLSetStmtAttr) ( SQLHSTMT StatementHandle, - SQLINTEGER Attribute, - SQLPOINTER ValuePtr, - SQLINTEGER StringLength); - - #define N3SQLSetStmtAttr(a,b,c,d) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SetStmtAttr)))(a,b,c,d) - - typedef SQLRETURN (SQL_API *T3SQLGetStmtAttr) ( SQLHSTMT StatementHandle, - SQLINTEGER Attribute, - SQLPOINTER ValuePtr, - SQLINTEGER BufferLength, - SQLINTEGER* StringLength); - - #define N3SQLGetStmtAttr(a,b,c,d,e) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetStmtAttr)))(a,b,c,d,e) - + virtual SQLRETURN SetConnectAttr(SQLHDBC ConnectionHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER StringLength) const = 0; + virtual SQLRETURN GetConnectAttr(SQLHDBC ConnectionHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER* StringLength) const = 0; + virtual SQLRETURN SetEnvAttr(SQLHENV EnvironmentHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER StringLength) const = 0; + virtual SQLRETURN GetEnvAttr(SQLHENV EnvironmentHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER* StringLength) const = 0; + virtual SQLRETURN SetStmtAttr(SQLHSTMT StatementHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER StringLength) const = 0; + virtual SQLRETURN GetStmtAttr(SQLHSTMT StatementHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER* StringLength) const = 0; // Setting and retrieving descriptor fields - /*typedef SQLRETURN (SQL_API *T3SQLSetDescField) (SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, - SQLSMALLINT FieldIdentifier, - SQLPOINTER ValuePtr, - SQLINTEGER BufferLength); - - #define N3SQLSetDescField(a,b,c,d,e) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SetDescField)))(a,b,c,d,e) - - typedef SQLRETURN (SQL_API *T3SQLGetDescField) ( SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, - SQLSMALLINT FieldIdentifier, - SQLPOINTER ValuePtr, - SQLINTEGER BufferLength, - SQLINTEGER * StringLengthPtr); - - #define N3SQLGetDescField(a,b,c,d,e,f) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetDescField)))(a,b,c,d,e,f) - - - typedef SQLRETURN (SQL_API *T3SQLGetDescRec) ( SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, - SQLCHAR * Name, - SQLSMALLINT BufferLength, - SQLSMALLINT * StringLengthPtr, - SQLSMALLINT * TypePtr, - SQLSMALLINT * SubTypePtr, - SQLLEN * LengthPtr, - SQLSMALLINT * PrecisionPtr, - SQLSMALLINT * ScalePtr, - SQLSMALLINT * NullablePtr); - - #define N3SQLGetDescRec(a,b,c,d,e,f,g,h,i,j,k) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetDescRec)))(a,b,c,d,e,f,g,h,i,j,k) - - - typedef SQLRETURN (SQL_API *T3SQLSetDescRec) ( SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, - SQLSMALLINT Type, - SQLSMALLINT SubType, - SQLLEN Length, - SQLSMALLINT Precision, - SQLSMALLINT Scale, - SQLPOINTER DataPtr, - SQLLEN * StringLengthPtr, - SQLLEN * IndicatorPtr); - - #define N3SQLSetDescRec(a,b,c,d,e,f,g,h,i,j) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SetDescRec)))(a,b,c,d,e,f,g,h,i,j) + /* + virtual SQLRETURN SetDescField(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLSMALLINT FieldIdentifier, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength) const = 0; + virtual SQLRETURN GetDescField(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLSMALLINT FieldIdentifier, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER* StringLengthPtr) const = 0; + virtual SQLRETURN GetDescRec(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLCHAR* Name, + SQLSMALLINT BufferLength, + SQLSMALLINT* StringLengthPtr, + SQLSMALLINT* TypePtr, + SQLSMALLINT* SubTypePtr, + SQLLEN* LengthPtr, + SQLSMALLINT* PrecisionPtr, + SQLSMALLINT* ScalePtr, + SQLSMALLINT* NullablePtr) const = 0; + virtual SQLRETURN SetDescRec(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLSMALLINT Type, + SQLSMALLINT SubType, + SQLLEN Length, + SQLSMALLINT Precision, + SQLSMALLINT Scale, + SQLPOINTER DataPtr, + SQLLEN* StringLengthPtr, + SQLLEN* IndicatorPtr) const = 0; */ - // Preparing SQL requests - typedef SQLRETURN (SQL_API *T3SQLPrepare) ( SQLHSTMT StatementHandle, - SQLCHAR * StatementText, - SQLINTEGER TextLength); - - #define N3SQLPrepare(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Prepare)))(a,b,c) - - typedef SQLRETURN (SQL_API *T3SQLBindParameter) (SQLHSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, - SQLSMALLINT InputOutputType, - SQLSMALLINT ValueType, - SQLSMALLINT ParameterType, - SQLULEN ColumnSize, - SQLSMALLINT DecimalDigits, - SQLPOINTER ParameterValuePtr, - SQLLEN BufferLength, - SQLLEN * StrLen_or_IndPtr); - - #define N3SQLBindParameter(a,b,c,d,e,f,g,h,i,j) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::BindParameter)))(a,b,c,d,e,f,g,h,i,j) - - /*typedef SQLRETURN (SQL_API *T3SQLGetCursorName) (SQLHSTMT StatementHandle, - SQLCHAR * CursorName, - SQLSMALLINT BufferLength, - SQLSMALLINT * NameLengthPtr); - - #define N3SQLGetCursorName(a,b,c,d) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetCursorName)))(a,b,c,d) + virtual SQLRETURN Prepare(SQLHSTMT StatementHandle, + SQLCHAR* StatementText, + SQLINTEGER TextLength) const = 0; + virtual SQLRETURN BindParameter(SQLHSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, + SQLSMALLINT InputOutputType, + SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, + SQLULEN ColumnSize, + SQLSMALLINT DecimalDigits, + SQLPOINTER ParameterValuePtr, + SQLLEN BufferLength, + SQLLEN* StrLen_or_IndPtr) const = 0; + /* + virtual SQLRETURN GetCursorName(SQLHSTMT StatementHandle, + SQLCHAR* CursorName, + SQLSMALLINT BufferLength, + SQLSMALLINT* NameLengthPtr) const = 0; */ - - typedef SQLRETURN (SQL_API *T3SQLSetCursorName) (SQLHSTMT StatementHandle, - SQLCHAR * CursorName, - SQLSMALLINT NameLength); - - #define N3SQLSetCursorName(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SetCursorName)))(a,b,c) - + virtual SQLRETURN SetCursorName(SQLHSTMT StatementHandle, + SQLCHAR* CursorName, + SQLSMALLINT NameLength) const = 0; // Submitting requests - typedef SQLRETURN (SQL_API *T3SQLExecute) ( SQLHSTMT StatementHandle); - - #define N3SQLExecute(a) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Execute)))(a) - - typedef SQLRETURN (SQL_API *T3SQLExecDirect) ( SQLHSTMT StatementHandle, - SQLCHAR * StatementText, - SQLINTEGER TextLength); - - #define N3SQLExecDirect(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::ExecDirect)))(a,b,c) - - typedef SQLRETURN (SQL_API *T3SQLDescribeParam) (SQLHSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, - SQLSMALLINT * DataTypePtr, - SQLULEN * ParameterSizePtr, - SQLSMALLINT * DecimalDigitsPtr, - SQLSMALLINT * NullablePtr); - - #define N3SQLDescribeParam(a,b,c,d,e,f) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::DescribeParam)))(a,b,c,d,e,f) - - typedef SQLRETURN (SQL_API *T3SQLNumParams) ( SQLHSTMT StatementHandle, - SQLSMALLINT * ParameterCountPtr); - - #define N3SQLNumParams(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::NumParams)))(a,b) - - typedef SQLRETURN (SQL_API *T3SQLParamData) ( SQLHSTMT StatementHandle, - SQLPOINTER * ValuePtrPtr); - - #define N3SQLParamData(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::ParamData)))(a,b) - - typedef SQLRETURN (SQL_API *T3SQLPutData) ( SQLHSTMT StatementHandle, - SQLPOINTER DataPtr, - SQLLEN StrLen_or_Ind); - - #define N3SQLPutData(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::PutData)))(a,b,c) - + virtual SQLRETURN Execute(SQLHSTMT StatementHandle) const = 0; + virtual SQLRETURN ExecDirect(SQLHSTMT StatementHandle, + SQLCHAR* StatementText, + SQLINTEGER TextLength) const = 0; + virtual SQLRETURN DescribeParam(SQLHSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, + SQLSMALLINT* DataTypePtr, + SQLULEN* ParameterSizePtr, + SQLSMALLINT* DecimalDigitsPtr, + SQLSMALLINT* NullablePtr) const = 0; + virtual SQLRETURN NumParams(SQLHSTMT StatementHandle, SQLSMALLINT* ParameterCountPtr) const = 0; + virtual SQLRETURN ParamData(SQLHSTMT StatementHandle, SQLPOINTER* ValuePtrPtr) const = 0; + virtual SQLRETURN PutData(SQLHSTMT StatementHandle, + SQLPOINTER DataPtr, + SQLLEN StrLen_or_Ind) const = 0; // Retrieving results and information about results - typedef SQLRETURN (SQL_API *T3SQLRowCount) ( SQLHSTMT StatementHandle, - SQLLEN * RowCountPtr); - - #define N3SQLRowCount(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::RowCount)))(a,b) - - typedef SQLRETURN (SQL_API *T3SQLNumResultCols) (SQLHSTMT StatementHandle, - SQLSMALLINT * ColumnCountPtr); - - #define N3SQLNumResultCols(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::NumResultCols)))(a,b) - - typedef SQLRETURN (SQL_API *T3SQLDescribeCol) ( SQLHSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, - SQLCHAR * ColumnName, - SQLSMALLINT BufferLength, - SQLSMALLINT * NameLengthPtr, - SQLSMALLINT * DataTypePtr, - SQLULEN * ColumnSizePtr, - SQLSMALLINT * DecimalDigitsPtr, - SQLSMALLINT * NullablePtr); - - #define N3SQLDescribeCol(a,b,c,d,e,f,g,h,i) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::DescribeCol)))(a,b,c,d,e,f,g,h,i) - - typedef SQLRETURN (SQL_API *T3SQLColAttribute) (SQLHSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, - SQLUSMALLINT FieldIdentifier, - SQLPOINTER CharacterAttributePtr, - SQLSMALLINT BufferLength, - SQLSMALLINT * StringLengthPtr, - SQLLEN * NumericAttributePtr); - - #define N3SQLColAttribute(a,b,c,d,e,f,g) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::ColAttribute)))(a,b,c,d,e,f,g) - - typedef SQLRETURN (SQL_API *T3SQLBindCol) ( SQLHSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, - SQLSMALLINT TargetType, - SQLPOINTER TargetValuePtr, - SQLLEN BufferLength, - SQLLEN * StrLen_or_IndPtr); - - #define N3SQLBindCol(a,b,c,d,e,f) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::BindCol)))(a,b,c,d,e,f) - - typedef SQLRETURN (SQL_API *T3SQLFetch) ( SQLHSTMT StatementHandle); - - #define N3SQLFetch(a) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Fetch)))(a) - - typedef SQLRETURN (SQL_API *T3SQLFetchScroll) ( SQLHSTMT StatementHandle, - SQLSMALLINT FetchOrientation, - SQLLEN FetchOffset); - - #define N3SQLFetchScroll(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::FetchScroll)))(a,b,c) - - typedef SQLRETURN (SQL_API *T3SQLGetData) ( SQLHSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, - SQLSMALLINT TargetType, - SQLPOINTER TargetValuePtr, - SQLLEN BufferLength, - SQLLEN * StrLen_or_IndPtr); - - #define N3SQLGetData(a,b,c,d,e,f) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetData)))(a,b,c,d,e,f) - - typedef SQLRETURN (SQL_API *T3SQLSetPos) ( SQLHSTMT StatementHandle, - SQLSETPOSIROW RowNumber, - SQLUSMALLINT Operation, - SQLUSMALLINT LockType); - - #define N3SQLSetPos(a,b,c,d) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SetPos)))(a,b,c,d) - - typedef SQLRETURN (SQL_API *T3SQLBulkOperations) ( SQLHSTMT StatementHandle, - SQLSMALLINT Operation); - - #define N3SQLBulkOperations(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::BulkOperations)))(a,b) - - typedef SQLRETURN (SQL_API *T3SQLMoreResults) ( SQLHSTMT StatementHandle); - - #define N3SQLMoreResults(a) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::MoreResults)))(a) - - /*typedef SQLRETURN (SQL_API *T3SQLGetDiagField) (SQLSMALLINT HandleType, - SQLHANDLE Handle, - SQLSMALLINT RecNumber, - SQLSMALLINT DiagIdentifier, - SQLPOINTER DiagInfoPtr, - SQLSMALLINT BufferLength, - SQLSMALLINT * StringLengthPtr); - - #define N3SQLGetDiagField(a,b,c,d,e,f,g) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetDiagField)))(a,b,c,d,e,f,g)*/ - - typedef SQLRETURN (SQL_API *T3SQLGetDiagRec) ( SQLSMALLINT HandleType, - SQLHANDLE Handle, - SQLSMALLINT RecNumber, - SQLCHAR * Sqlstate, - SQLINTEGER * NativeErrorPtr, - SQLCHAR * MessageText, - SQLSMALLINT BufferLength, - SQLSMALLINT * TextLengthPtr); - - - #define N3SQLGetDiagRec(a,b,c,d,e,f,g,h) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetDiagRec)))(a,b,c,d,e,f,g,h) - + virtual SQLRETURN RowCount(SQLHSTMT StatementHandle, SQLLEN* RowCountPtr) const = 0; + virtual SQLRETURN NumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT* ColumnCountPtr) const = 0; + virtual SQLRETURN ColAttribute(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, + SQLUSMALLINT FieldIdentifier, + SQLPOINTER CharacterAttributePtr, + SQLSMALLINT BufferLength, + SQLSMALLINT* StringLengthPtr, + SQLLEN* NumericAttributePtr) const = 0; + virtual SQLRETURN BindCol(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, + SQLSMALLINT TargetType, + SQLPOINTER TargetValuePtr, + SQLLEN BufferLength, + SQLLEN* StrLen_or_IndPtr) const = 0; + virtual SQLRETURN Fetch(SQLHSTMT StatementHandle) const = 0; + virtual SQLRETURN FetchScroll(SQLHSTMT StatementHandle, + SQLSMALLINT FetchOrientation, + SQLLEN FetchOffset) const = 0; + virtual SQLRETURN GetData(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, + SQLSMALLINT TargetType, + SQLPOINTER TargetValuePtr, + SQLLEN BufferLength, + SQLLEN* StrLen_or_IndPtr) const = 0; + virtual SQLRETURN SetPos(SQLHSTMT StatementHandle, + SQLSETPOSIROW RowNumber, + SQLUSMALLINT Operation, + SQLUSMALLINT LockType) const = 0; + virtual SQLRETURN BulkOperations(SQLHSTMT StatementHandle, SQLSMALLINT Operation) const = 0; + virtual SQLRETURN MoreResults(SQLHSTMT StatementHandle) const = 0; + /* + virtual SQLRETURN GetDiagField(SQLSMALLINT HandleType, + SQLHANDLE Handle, + SQLSMALLINT RecNumber, + SQLSMALLINT DiagIdentifier, + SQLPOINTER DiagInfoPtr, + SQLSMALLINT BufferLength, + SQLSMALLINT* StringLengthPtr) const = 0; + */ + virtual SQLRETURN GetDiagRec(SQLSMALLINT HandleType, + SQLHANDLE Handle, + SQLSMALLINT RecNumber, + SQLCHAR* Sqlstate, + SQLINTEGER* NativeErrorPtr, + SQLCHAR* MessageText, + SQLSMALLINT BufferLength, + SQLSMALLINT* TextLengthPtr) const = 0; // Obtaining information about the data source's system tables (catalog functions) - typedef SQLRETURN (SQL_API *T3SQLColumnPrivileges) (SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * TableName, - SQLSMALLINT NameLength3, - SQLCHAR * ColumnName, - SQLSMALLINT NameLength4); - - #define N3SQLColumnPrivileges(a,b,c,d,e,f,g,h,i) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::ColumnPrivileges)))(a,b,c,d,e,f,g,h,i) - - typedef SQLRETURN (SQL_API *T3SQLColumns) ( SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * TableName, - SQLSMALLINT NameLength3, - SQLCHAR * ColumnName, - SQLSMALLINT NameLength4); - - #define N3SQLColumns(a,b,c,d,e,f,g,h,i) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Columns)))(a,b,c,d,e,f,g,h,i) - - typedef SQLRETURN (SQL_API *T3SQLForeignKeys) ( SQLHSTMT StatementHandle, - SQLCHAR * PKCatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * PKSchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * PKTableName, - SQLSMALLINT NameLength3, - SQLCHAR * FKCatalogName, - SQLSMALLINT NameLength4, - SQLCHAR * FKSchemaName, - SQLSMALLINT NameLength5, - SQLCHAR * FKTableName, - SQLSMALLINT NameLength6); - - #define N3SQLForeignKeys(a,b,c,d,e,f,g,h,i,j,k,l,m) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::ForeignKeys)))(a,b,c,d,e,f,g,h,i,j,k,l,m) - - typedef SQLRETURN (SQL_API *T3SQLPrimaryKeys) ( SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * TableName, - SQLSMALLINT NameLength3); - - #define N3SQLPrimaryKeys(a,b,c,d,e,f,g) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::PrimaryKeys)))(a,b,c,d,e,f,g) - - typedef SQLRETURN (SQL_API *T3SQLProcedureColumns) (SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * ProcName, - SQLSMALLINT NameLength3, - SQLCHAR * ColumnName, - SQLSMALLINT NameLength4); - - #define N3SQLProcedureColumns(a,b,c,d,e,f,g,h,i) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::ProcedureColumns)))(a,b,c,d,e,f,g,h,i) - - typedef SQLRETURN (SQL_API *T3SQLProcedures) ( SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * ProcName, - SQLSMALLINT NameLength3); - - #define N3SQLProcedures(a,b,c,d,e,f,g) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Procedures)))(a,b,c,d,e,f,g) - - typedef SQLRETURN (SQL_API *T3SQLSpecialColumns) (SQLHSTMT StatementHandle, - SQLUSMALLINT IdentifierType, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * TableName, - SQLSMALLINT NameLength3, - SQLUSMALLINT Scope, - SQLUSMALLINT Nullable); - - #define N3SQLSpecialColumns(a,b,c,d,e,f,g,h,i,j) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::SpecialColumns)))(a,b,c,d,e,f,g,h,i,j) - - typedef SQLRETURN (SQL_API *T3SQLStatistics) ( SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * TableName, - SQLSMALLINT NameLength3, - SQLUSMALLINT Unique, - SQLUSMALLINT Reserved); - - #define N3SQLStatistics(a,b,c,d,e,f,g,h,i) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Statistics)))(a,b,c,d,e,f,g,h,i) - - typedef SQLRETURN (SQL_API *T3SQLTablePrivileges) (SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * TableName, - SQLSMALLINT NameLength3); - - #define N3SQLTablePrivileges(a,b,c,d,e,f,g) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::TablePrivileges)))(a,b,c,d,e,f,g) - - typedef SQLRETURN (SQL_API *T3SQLTables) ( SQLHSTMT StatementHandle, - SQLCHAR * CatalogName, - SQLSMALLINT NameLength1, - SQLCHAR * SchemaName, - SQLSMALLINT NameLength2, - SQLCHAR * TableName, - SQLSMALLINT NameLength3, - SQLCHAR * TableType, - SQLSMALLINT NameLength4); - - #define N3SQLTables(a,b,c,d,e,f,g,h,i) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Tables)))(a,b,c,d,e,f,g,h,i) - + virtual SQLRETURN ColumnPrivileges(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* TableName, + SQLSMALLINT NameLength3, + SQLCHAR* ColumnName, + SQLSMALLINT NameLength4) const = 0; + virtual SQLRETURN Columns(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* TableName, + SQLSMALLINT NameLength3, + SQLCHAR* ColumnName, + SQLSMALLINT NameLength4) const = 0; + virtual SQLRETURN ForeignKeys(SQLHSTMT StatementHandle, + SQLCHAR* PKCatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* PKSchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* PKTableName, + SQLSMALLINT NameLength3, + SQLCHAR* FKCatalogName, + SQLSMALLINT NameLength4, + SQLCHAR* FKSchemaName, + SQLSMALLINT NameLength5, + SQLCHAR* FKTableName, + SQLSMALLINT NameLength6) const = 0; + virtual SQLRETURN PrimaryKeys(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* TableName, + SQLSMALLINT NameLength3) const = 0; + virtual SQLRETURN ProcedureColumns(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* ProcName, + SQLSMALLINT NameLength3, + SQLCHAR* ColumnName, + SQLSMALLINT NameLength4) const = 0; + virtual SQLRETURN Procedures(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* ProcName, + SQLSMALLINT NameLength3) const = 0; + virtual SQLRETURN SpecialColumns(SQLHSTMT StatementHandle, + SQLUSMALLINT IdentifierType, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* TableName, + SQLSMALLINT NameLength3, + SQLUSMALLINT Scope, + SQLUSMALLINT Nullable) const = 0; + virtual SQLRETURN Statistics(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* TableName, + SQLSMALLINT NameLength3, + SQLUSMALLINT Unique, + SQLUSMALLINT Reserved) const = 0; + virtual SQLRETURN TablePrivileges(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* TableName, + SQLSMALLINT NameLength3) const = 0; + virtual SQLRETURN Tables(SQLHSTMT StatementHandle, + SQLCHAR* CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR* SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR* TableName, + SQLSMALLINT NameLength3, + SQLCHAR* TableType, + SQLSMALLINT NameLength4) const = 0; // Terminating a statement - typedef SQLRETURN (SQL_API *T3SQLFreeStmt) ( SQLHSTMT StatementHandle, - SQLUSMALLINT Option); - - #define N3SQLFreeStmt(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::FreeStmt)))(a,b) - - typedef SQLRETURN (SQL_API *T3SQLCloseCursor) (SQLHSTMT StatementHandle); - - #define N3SQLCloseCursor(a) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::CloseCursor)))(a) - - typedef SQLRETURN (SQL_API *T3SQLCancel) ( SQLHSTMT StatementHandle); - - #define N3SQLCancel(a) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Cancel)))(a) - - typedef SQLRETURN (SQL_API *T3SQLEndTran) ( SQLSMALLINT HandleType, - SQLHANDLE Handle, - SQLSMALLINT CompletionType); - - #define N3SQLEndTran(a,b,c) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::EndTran)))(a,b,c) - + virtual SQLRETURN FreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option) const = 0; + virtual SQLRETURN CloseCursor(SQLHSTMT StatementHandle) const = 0; + virtual SQLRETURN Cancel(SQLHSTMT StatementHandle) const = 0; + virtual SQLRETURN EndTran(SQLSMALLINT HandleType, + SQLHANDLE Handle, + SQLSMALLINT CompletionType) const = 0; // Terminating a connection - typedef SQLRETURN (SQL_API *T3SQLDisconnect) (SQLHDBC ConnectionHandle); - - #define N3SQLDisconnect(a) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::Disconnect)))(a) - - typedef SQLRETURN (SQL_API *T3SQLFreeHandle) (SQLSMALLINT HandleType, - SQLHANDLE Handle); - - #define N3SQLFreeHandle(a,b) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::FreeHandle)))(a,b) - - typedef SQLRETURN (SQL_API *T3SQLGetCursorName) ( SQLHSTMT StatementHandle, - SQLCHAR * CursorName, - SQLSMALLINT BufferLength, - SQLSMALLINT* NameLength2); - - #define N3SQLGetCursorName(a,b,c,d) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::GetCursorName)))(a,b,c,d) - - typedef SQLRETURN (SQL_API *T3SQLNativeSql) ( SQLHDBC ConnectionHandle, - SQLCHAR * InStatementText, - SQLINTEGER TextLength1, - SQLCHAR * OutStatementText, - SQLINTEGER BufferLength, - SQLINTEGER * TextLength2Ptr); - - #define N3SQLNativeSql(a,b,c,d,e,f) (*reinterpret_cast(getOdbcFunction(ODBC3SQLFunctionId::NativeSql)))(a,b,c,d,e,f) - - // extern declaration of the function pointer - extern T3SQLAllocHandle pODBC3SQLAllocHandle; - extern T3SQLConnect pODBC3SQLConnect; - extern T3SQLDriverConnect pODBC3SQLDriverConnect; - extern T3SQLBrowseConnect pODBC3SQLBrowseConnect; - extern T3SQLDataSources pODBC3SQLDataSources; - extern T3SQLDrivers pODBC3SQLDrivers; - extern T3SQLGetInfo pODBC3SQLGetInfo; - extern T3SQLGetFunctions pODBC3SQLGetFunctions; - extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo; - extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr; - extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr; - extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr; - extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr; - extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr; - extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr; - //extern T3SQLSetDescField pODBC3SQLSetDescField; - //extern T3SQLGetDescField pODBC3SQLGetDescField; - //extern T3SQLGetDescRec pODBC3SQLGetDescRec; - //extern T3SQLSetDescRec pODBC3SQLSetDescRec; - extern T3SQLPrepare pODBC3SQLPrepare; - extern T3SQLBindParameter pODBC3SQLBindParameter; - //extern T3SQLGetCursorName pODBC3SQLGetCursorName; - extern T3SQLSetCursorName pODBC3SQLSetCursorName; - extern T3SQLExecute pODBC3SQLExecute; - extern T3SQLExecDirect pODBC3SQLExecDirect; - //extern T3SQLNativeSql pODBC3SQLNativeSql; - extern T3SQLDescribeParam pODBC3SQLDescribeParam; - extern T3SQLNumParams pODBC3SQLNumParams; - extern T3SQLParamData pODBC3SQLParamData; - extern T3SQLPutData pODBC3SQLPutData; - extern T3SQLRowCount pODBC3SQLRowCount; - extern T3SQLNumResultCols pODBC3SQLNumResultCols; - extern T3SQLDescribeCol pODBC3SQLDescribeCol; - extern T3SQLColAttribute pODBC3SQLColAttribute; - extern T3SQLBindCol pODBC3SQLBindCol; - extern T3SQLFetch pODBC3SQLFetch; - extern T3SQLFetchScroll pODBC3SQLFetchScroll; - extern T3SQLGetData pODBC3SQLGetData; - extern T3SQLSetPos pODBC3SQLSetPos; - extern T3SQLBulkOperations pODBC3SQLBulkOperations; - extern T3SQLMoreResults pODBC3SQLMoreResults; - //extern T3SQLGetDiagField pODBC3SQLGetDiagField; - extern T3SQLGetDiagRec pODBC3SQLGetDiagRec; - extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges; - extern T3SQLColumns pODBC3SQLColumns; - extern T3SQLForeignKeys pODBC3SQLForeignKeys; - extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys; - extern T3SQLProcedureColumns pODBC3SQLProcedureColumns; - extern T3SQLProcedures pODBC3SQLProcedures; - extern T3SQLSpecialColumns pODBC3SQLSpecialColumns; - extern T3SQLStatistics pODBC3SQLStatistics; - extern T3SQLTablePrivileges pODBC3SQLTablePrivileges; - extern T3SQLTables pODBC3SQLTables; - extern T3SQLFreeStmt pODBC3SQLFreeStmt; - extern T3SQLCloseCursor pODBC3SQLCloseCursor; - extern T3SQLCancel pODBC3SQLCancel; - extern T3SQLEndTran pODBC3SQLEndTran; - extern T3SQLDisconnect pODBC3SQLDisconnect; - extern T3SQLFreeHandle pODBC3SQLFreeHandle; - extern T3SQLGetCursorName pODBC3SQLGetCursorName; - extern T3SQLNativeSql pODBC3SQLNativeSql; + virtual SQLRETURN Disconnect(SQLHDBC ConnectionHandle) const = 0; + virtual SQLRETURN FreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) const = 0; + virtual SQLRETURN GetCursorName(SQLHSTMT StatementHandle, + SQLCHAR* CursorName, + SQLSMALLINT BufferLength, + SQLSMALLINT* NameLength2) const = 0; + virtual SQLRETURN NativeSql(SQLHDBC ConnectionHandle, + SQLCHAR* InStatementText, + SQLINTEGER TextLength1, + SQLCHAR* OutStatementText, + SQLINTEGER BufferLength, + SQLINTEGER* TextLength2Ptr) const = 0; +}; } diff --git a/connectivity/source/inc/odbc/OResultSet.hxx b/connectivity/source/inc/odbc/OResultSet.hxx index 719c6be14da8..caea5aa64812 100644 --- a/connectivity/source/inc/odbc/OResultSet.hxx +++ b/connectivity/source/inc/odbc/OResultSet.hxx @@ -231,10 +231,7 @@ namespace connectivity::odbc void construct(); - oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const - { - return m_pStatement->getOdbcFunction(_nIndex); - } + const Functions& functions() const { return m_pStatement->functions(); } css::uno::Reference< css::uno::XInterface > operator *() { diff --git a/connectivity/source/inc/odbc/OResultSetMetaData.hxx b/connectivity/source/inc/odbc/OResultSetMetaData.hxx index 76abe6eecd06..7f73f6c03f4b 100644 --- a/connectivity/source/inc/odbc/OResultSetMetaData.hxx +++ b/connectivity/source/inc/odbc/OResultSetMetaData.hxx @@ -83,10 +83,7 @@ namespace connectivity::odbc ,const css::uno::Reference< css::uno::XInterface >& _xInterface ,sal_Int32 column); - oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const - { - return m_pConnection->getOdbcFunction(_nIndex); - } + const Functions& functions() const { return m_pConnection->functions(); } virtual sal_Int32 SAL_CALL getColumnCount( ) override; virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) override; diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx index 2f0d0d814fea..4ab5d7170577 100644 --- a/connectivity/source/inc/odbc/OStatement.hxx +++ b/connectivity/source/inc/odbc/OStatement.hxx @@ -158,10 +158,7 @@ namespace connectivity::odbc OStatement_Base(OConnection* _pConnection ); using OStatement_BASE::operator css::uno::Reference< css::uno::XInterface >; - oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const - { - return m_pConnection->getOdbcFunction(_nIndex); - } + const Functions& functions() const { return m_pConnection->functions(); } // OComponentHelper virtual void SAL_CALL disposing() override; // XInterface diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx index b03db91dce33..f6670e5f562a 100644 --- a/connectivity/source/inc/odbc/OTools.hxx +++ b/connectivity/source/inc/odbc/OTools.hxx @@ -31,60 +31,58 @@ enum class ODBC3SQLFunctionId { - AllocHandle = 1, - Connect = 2, - DriverConnect = 3, - BrowseConnect = 4, - DataSources = 5, - Drivers = 6, - GetInfo = 7, - GetFunctions = 8, - GetTypeInfo = 9, - SetConnectAttr = 10, - GetConnectAttr = 11, - SetEnvAttr = 12, - GetEnvAttr = 13, - SetStmtAttr = 14, - GetStmtAttr = 15, - Prepare = 16, - BindParameter = 17, - SetCursorName = 18, - Execute = 19, - ExecDirect = 20, - DescribeParam = 21, - NumParams = 22, - ParamData = 23, - PutData = 24, - RowCount = 25, - NumResultCols = 26, - DescribeCol = 27, - ColAttribute = 28, - BindCol = 29, - Fetch = 30, - FetchScroll = 31, - GetData = 32, - SetPos = 33, - BulkOperations = 34, - MoreResults = 35, - GetDiagRec = 36, - ColumnPrivileges = 37, - Columns = 38, - ForeignKeys = 39, - PrimaryKeys = 40, - ProcedureColumns = 41, - Procedures = 42, - SpecialColumns = 43, - Statistics = 44, - TablePrivileges = 45, - Tables = 46, - FreeStmt = 47, - CloseCursor = 48, - Cancel = 49, - EndTran = 50, - Disconnect = 51, - FreeHandle = 52, - GetCursorName = 53, - NativeSql = 54, + FIRST, + AllocHandle, + DriverConnect, + GetInfo, + GetFunctions, + GetTypeInfo, + SetConnectAttr, + GetConnectAttr, + SetEnvAttr, + GetEnvAttr, + SetStmtAttr, + GetStmtAttr, + Prepare, + BindParameter, + SetCursorName, + Execute, + ExecDirect, + DescribeParam, + NumParams, + ParamData, + PutData, + RowCount, + NumResultCols, + ColAttribute, + BindCol, + Fetch, + FetchScroll, + GetData, + SetPos, + BulkOperations, + MoreResults, + GetDiagRec, + ColumnPrivileges, + Columns, + ForeignKeys, + PrimaryKeys, + ProcedureColumns, + Procedures, + SpecialColumns, + Statistics, + TablePrivileges, + Tables, + FreeStmt, + CloseCursor, + Cancel, + EndTran, + Disconnect, + FreeHandle, + GetCursorName, + NativeSql, + + LAST }; namespace connectivity::odbc diff --git a/include/connectivity/odbc.hxx b/include/connectivity/odbc.hxx index 9f1e487ebf71..bf745ad54ef0 100644 --- a/include/connectivity/odbc.hxx +++ b/include/connectivity/odbc.hxx @@ -24,10 +24,6 @@ // just to go with calling convention of windows #if SYSTEM_ODBC_HEADERS -#if !defined WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif -#include #define SQL_API __stdcall #include #else