From 02a5df653f12696b9738f6cd5f267d3592f85209 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 11 Mar 2025 13:15:41 +0200 Subject: [PATCH] use more concrete UNO in connectivity Change-Id: I3842706a0b28c3bf78c8f359ca2d2226ed5f1b07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182769 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../source/commontools/TIndexColumns.cxx | 52 +++---- connectivity/source/commontools/TIndexes.cxx | 2 +- .../source/commontools/TKeyColumns.cxx | 72 +++++---- connectivity/source/commontools/TKeys.cxx | 2 +- connectivity/source/commontools/dbtools2.cxx | 144 +++++++++--------- .../source/drivers/dbase/DIndexes.cxx | 30 ++-- .../source/drivers/evoab2/NColumns.cxx | 49 +++--- .../source/drivers/evoab2/NTables.cxx | 28 ++-- connectivity/source/drivers/file/FColumns.cxx | 46 +++--- .../source/drivers/firebird/Connection.cxx | 19 +-- .../source/drivers/firebird/Connection.hxx | 6 +- .../source/drivers/hsqldb/HTables.cxx | 40 ++--- connectivity/source/drivers/jdbc/JDriver.cxx | 7 +- .../source/drivers/mysql_jdbc/YTables.cxx | 2 +- .../drivers/odbc/OPreparedStatement.cxx | 2 +- connectivity/source/parse/sqliterator.cxx | 2 +- 16 files changed, 246 insertions(+), 257 deletions(-) diff --git a/connectivity/source/commontools/TIndexColumns.cxx b/connectivity/source/commontools/TIndexColumns.cxx index 2f3b5fb0e043..4bf9115440b5 100644 --- a/connectivity/source/commontools/TIndexColumns.cxx +++ b/connectivity/source/commontools/TIndexColumns.cxx @@ -65,33 +65,33 @@ css::uno::Reference< css::beans::XPropertySet > OIndexColumns::createObject(cons xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns( Catalog, aSchema, aTable, _rName); - css::uno::Reference< css::beans::XPropertySet > xRet; - if ( xResult.is() ) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - while( xResult->next() ) - { - if ( xRow->getString(4) == _rName ) - { - sal_Int32 nDataType = xRow->getInt(5); - OUString aTypeName(xRow->getString(6)); - sal_Int32 nSize = xRow->getInt(7); - sal_Int32 nDec = xRow->getInt(9); - sal_Int32 nNull = xRow->getInt(11); - OUString aColumnDef(xRow->getString(13)); + if ( !xResult.is() ) + return nullptr; - xRet = new OIndexColumn(bAsc, - _rName, - aTypeName, - aColumnDef, - nNull, - nSize, - nDec, - nDataType, - true, - aCatalog, aSchema, aTable); - break; - } + rtl::Reference< OIndexColumn > xRet; + Reference< XRow > xRow(xResult,UNO_QUERY); + while( xResult->next() ) + { + if ( xRow->getString(4) == _rName ) + { + sal_Int32 nDataType = xRow->getInt(5); + OUString aTypeName(xRow->getString(6)); + sal_Int32 nSize = xRow->getInt(7); + sal_Int32 nDec = xRow->getInt(9); + sal_Int32 nNull = xRow->getInt(11); + OUString aColumnDef(xRow->getString(13)); + + xRet = new OIndexColumn(bAsc, + _rName, + aTypeName, + aColumnDef, + nNull, + nSize, + nDec, + nDataType, + true, + aCatalog, aSchema, aTable); + break; } } diff --git a/connectivity/source/commontools/TIndexes.cxx b/connectivity/source/commontools/TIndexes.cxx index ceb9aac439cc..5973806f1257 100644 --- a/connectivity/source/commontools/TIndexes.cxx +++ b/connectivity/source/commontools/TIndexes.cxx @@ -56,7 +56,7 @@ css::uno::Reference< css::beans::XPropertySet > OIndexesHelper::createObject(con if ( !xConnection.is() ) return nullptr; - css::uno::Reference< css::beans::XPropertySet > xRet; + rtl::Reference< OIndexHelper > xRet; OUString aName,aQualifier; sal_Int32 nLen = _rName.indexOf('.'); if ( nLen != -1 ) diff --git a/connectivity/source/commontools/TKeyColumns.cxx b/connectivity/source/commontools/TKeyColumns.cxx index fd976a4e2085..341e130df134 100644 --- a/connectivity/source/commontools/TKeyColumns.cxx +++ b/connectivity/source/commontools/TKeyColumns.cxx @@ -70,48 +70,46 @@ css::uno::Reference< css::beans::XPropertySet > OKeyColumnsHelper::createObject( } } - css::uno::Reference< css::beans::XPropertySet > xRet; - // now describe the column _rName and set his related column xResult = m_pKey->getTable()->getMetaData()->getColumns(Catalog, aSchema, aTable, _rName); - if ( xResult.is() ) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - if ( xResult->next() ) - { - if ( xRow->getString(4) == _rName ) - { - sal_Int32 nDataType = xRow->getInt(5); - OUString aTypeName(xRow->getString(6)); - sal_Int32 nSize = xRow->getInt(7); - sal_Int32 nDec = xRow->getInt(9); - sal_Int32 nNull = xRow->getInt(11); - OUString sColumnDef; - try - { - sColumnDef = xRow->getString(13); - } - catch(const SQLException&) - { - // sometimes we get an error when asking for this param - } + if ( !xResult.is() ) + return nullptr; - xRet = new OKeyColumn(aRefColumnName, - _rName, - aTypeName, - sColumnDef, - nNull, - nSize, - nDec, - nDataType, - isCaseSensitive(), - aCatalog, - aSchema, - aTable); - } - } + Reference< XRow > xRow(xResult,UNO_QUERY); + if ( !xResult->next() ) + return nullptr; + + if ( xRow->getString(4) != _rName ) + return nullptr; + + sal_Int32 nDataType = xRow->getInt(5); + OUString aTypeName(xRow->getString(6)); + sal_Int32 nSize = xRow->getInt(7); + sal_Int32 nDec = xRow->getInt(9); + sal_Int32 nNull = xRow->getInt(11); + OUString sColumnDef; + try + { + sColumnDef = xRow->getString(13); } + catch(const SQLException&) + { + // sometimes we get an error when asking for this param + } + + rtl::Reference xRet = new OKeyColumn(aRefColumnName, + _rName, + aTypeName, + sColumnDef, + nNull, + nSize, + nDec, + nDataType, + isCaseSensitive(), + aCatalog, + aSchema, + aTable); return xRet; } diff --git a/connectivity/source/commontools/TKeys.cxx b/connectivity/source/commontools/TKeys.cxx index 47fb36515de3..26389277c580 100644 --- a/connectivity/source/commontools/TKeys.cxx +++ b/connectivity/source/commontools/TKeys.cxx @@ -52,7 +52,7 @@ OKeysHelper::OKeysHelper( OTableHelper* _pTable, css::uno::Reference< css::beans::XPropertySet > OKeysHelper::createObject(const OUString& _rName) { - css::uno::Reference< css::beans::XPropertySet > xRet; + rtl::Reference< OTableKeyHelper > xRet; if(!_rName.isEmpty()) { diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index c85a5440238f..6526de5d3ce0 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -408,100 +408,100 @@ namespace bool _bIsCurrency, sal_Int32 _nDataType) { - Reference xProp; Reference xMetaData = _xConnection->getMetaData(); Reference< XResultSet > xResult = xMetaData->getColumns(_aCatalog, _aSchema, _aTable, _rQueryName); OUString sCatalog; _aCatalog >>= sCatalog; - if ( xResult.is() ) + if ( !xResult.is() ) + return nullptr; + + rtl::Reference xProp; + UStringMixEqual aMixCompare(_bCase); + Reference< XRow > xRow(xResult,UNO_QUERY); + while( xResult->next() ) { - UStringMixEqual aMixCompare(_bCase); - Reference< XRow > xRow(xResult,UNO_QUERY); - while( xResult->next() ) + if ( aMixCompare(xRow->getString(4),_rName) ) { - if ( aMixCompare(xRow->getString(4),_rName) ) + sal_Int32 nField5 = xRow->getInt(5); + OUString aField6 = xRow->getString(6); + sal_Int32 nField7 = xRow->getInt(7) + , nField9 = xRow->getInt(9) + , nField11= xRow->getInt(11); + OUString sField12 = xRow->getString(12), + sField13 = xRow->getString(13); + ::comphelper::disposeComponent(xRow); + + bool bAutoIncrement = _bIsAutoIncrement + ,bIsCurrency = _bIsCurrency; + if ( _bQueryForInfo ) { - sal_Int32 nField5 = xRow->getInt(5); - OUString aField6 = xRow->getString(6); - sal_Int32 nField7 = xRow->getInt(7) - , nField9 = xRow->getInt(9) - , nField11= xRow->getInt(11); - OUString sField12 = xRow->getString(12), - sField13 = xRow->getString(13); - ::comphelper::disposeComponent(xRow); + const OUString sQuote = xMetaData->getIdentifierQuoteString(); + OUString sQuotedName = ::dbtools::quoteName(sQuote,_rName); + OUString sComposedName = composeTableNameForSelect(_xConnection, getString( _aCatalog ), _aSchema, _aTable ); - bool bAutoIncrement = _bIsAutoIncrement - ,bIsCurrency = _bIsCurrency; - if ( _bQueryForInfo ) + ColumnInformationMap aInfo((UStringMixLess(_bCase))); + collectColumnInformation(_xConnection,sComposedName,sQuotedName,aInfo); + ColumnInformationMap::const_iterator aIter = aInfo.begin(); + if ( aIter != aInfo.end() ) { - const OUString sQuote = xMetaData->getIdentifierQuoteString(); - OUString sQuotedName = ::dbtools::quoteName(sQuote,_rName); - OUString sComposedName = composeTableNameForSelect(_xConnection, getString( _aCatalog ), _aSchema, _aTable ); - - ColumnInformationMap aInfo((UStringMixLess(_bCase))); - collectColumnInformation(_xConnection,sComposedName,sQuotedName,aInfo); - ColumnInformationMap::const_iterator aIter = aInfo.begin(); - if ( aIter != aInfo.end() ) - { - bAutoIncrement = aIter->second.first.first; - bIsCurrency = aIter->second.first.second; - if ( DataType::OTHER == nField5 ) - nField5 = aIter->second.second; - } + bAutoIncrement = aIter->second.first.first; + bIsCurrency = aIter->second.first.second; + if ( DataType::OTHER == nField5 ) + nField5 = aIter->second.second; } - else if ( DataType::OTHER == nField5 ) - nField5 = _nDataType; + } + else if ( DataType::OTHER == nField5 ) + nField5 = _nDataType; - if ( nField11 != ColumnValue::NO_NULLS ) + if ( nField11 != ColumnValue::NO_NULLS ) + { + try { - try + if ( _xPrimaryKeyColumns.is() ) { - if ( _xPrimaryKeyColumns.is() ) - { - if ( _xPrimaryKeyColumns->hasByName(_rName) ) - nField11 = ColumnValue::NO_NULLS; + if ( _xPrimaryKeyColumns->hasByName(_rName) ) + nField11 = ColumnValue::NO_NULLS; - } - else + } + else + { + Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable ); + Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW ); + while( xPKeys->next() ) // there can be only one primary key { - Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable ); - Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW ); - while( xPKeys->next() ) // there can be only one primary key + OUString sKeyColumn = xPKeyRow->getString(4); + if ( aMixCompare(_rName,sKeyColumn) ) { - OUString sKeyColumn = xPKeyRow->getString(4); - if ( aMixCompare(_rName,sKeyColumn) ) - { - nField11 = ColumnValue::NO_NULLS; - break; - } + nField11 = ColumnValue::NO_NULLS; + break; } } } - catch(SQLException&) - { - TOOLS_WARN_EXCEPTION( "connectivity.commontools", "lcl_createSDBCXColumn" ); - } } - - xProp = new connectivity::sdbcx::OColumn(_rName, - aField6, - sField13, - sField12, - nField11, - nField7, - nField9, - nField5, - bAutoIncrement, - false, - bIsCurrency, - _bCase, - sCatalog, - _aSchema, - _aTable); - - break; + catch(SQLException&) + { + TOOLS_WARN_EXCEPTION( "connectivity.commontools", "lcl_createSDBCXColumn" ); + } } + + xProp = new connectivity::sdbcx::OColumn(_rName, + aField6, + sField13, + sField12, + nField11, + nField7, + nField9, + nField5, + bAutoIncrement, + false, + bIsCurrency, + _bCase, + sCatalog, + _aSchema, + _aTable); + + break; } } diff --git a/connectivity/source/drivers/dbase/DIndexes.cxx b/connectivity/source/drivers/dbase/DIndexes.cxx index daee28bb9b51..1ade0679216c 100644 --- a/connectivity/source/drivers/dbase/DIndexes.cxx +++ b/connectivity/source/drivers/dbase/DIndexes.cxx @@ -45,23 +45,8 @@ css::uno::Reference< css::beans::XPropertySet > ODbaseIndexes::createObject(cons ::dbtools::throwGenericSQLException( sError, *m_pTable ); } - css::uno::Reference< css::beans::XPropertySet > xRet; std::unique_ptr pFileStream = ::connectivity::file::OFileTable::createStream_simpleError(sFile, StreamMode::READ | StreamMode::NOCREATE | StreamMode::SHARE_DENYWRITE); - if(pFileStream) - { - pFileStream->SetEndian(SvStreamEndian::LITTLE); - pFileStream->SetBufferSize(DINDEX_PAGE_SIZE); - ODbaseIndex::NDXHeader aHeader; - - pFileStream->Seek(0); - ReadHeader(*pFileStream, aHeader); - pFileStream.reset(); - - rtl::Reference pIndex = new ODbaseIndex(m_pTable,aHeader,_rName); - xRet = pIndex; - pIndex->openIndexFile(); - } - else + if(!pFileStream) { const OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution( STR_COULD_NOT_LOAD_FILE, @@ -69,7 +54,18 @@ css::uno::Reference< css::beans::XPropertySet > ODbaseIndexes::createObject(cons ) ); ::dbtools::throwGenericSQLException( sError, *m_pTable ); } - return xRet; + + pFileStream->SetEndian(SvStreamEndian::LITTLE); + pFileStream->SetBufferSize(DINDEX_PAGE_SIZE); + ODbaseIndex::NDXHeader aHeader; + + pFileStream->Seek(0); + ReadHeader(*pFileStream, aHeader); + pFileStream.reset(); + + rtl::Reference pIndex = new ODbaseIndex(m_pTable,aHeader,_rName); + pIndex->openIndexFile(); + return pIndex; } void ODbaseIndexes::impl_refresh( ) diff --git a/connectivity/source/drivers/evoab2/NColumns.cxx b/connectivity/source/drivers/evoab2/NColumns.cxx index cbd8f7e20839..a07e12d764d7 100644 --- a/connectivity/source/drivers/evoab2/NColumns.cxx +++ b/connectivity/source/drivers/evoab2/NColumns.cxx @@ -42,33 +42,32 @@ css::uno::Reference< css::beans::XPropertySet > OEvoabColumns::createObject(cons sTableName, _rName); - css::uno::Reference< css::beans::XPropertySet > xRet; - if (xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); + if (!xResult.is()) + return nullptr; - while (xResult->next()) + rtl::Reference< OColumn > xRet; + Reference< XRow > xRow(xResult,UNO_QUERY); + while (xResult->next()) + { + if (xRow->getString(4) == _rName) { - if (xRow->getString(4) == _rName) - { - xRet = new OColumn( - _rName, - xRow->getString(6), - xRow->getString(13), - xRow->getString(12), - xRow->getInt(11), - xRow->getInt(7), - xRow->getInt(9), - xRow->getInt(5), - false, - false, - false, - true, - sCatalogName, - sSchemaName, - sTableName); - break; - } + xRet = new OColumn( + _rName, + xRow->getString(6), + xRow->getString(13), + xRow->getString(12), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + false, + false, + false, + true, + sCatalogName, + sSchemaName, + sTableName); + break; } } diff --git a/connectivity/source/drivers/evoab2/NTables.cxx b/connectivity/source/drivers/evoab2/NTables.cxx index 405ce9b4040a..f124f6dbf92a 100644 --- a/connectivity/source/drivers/evoab2/NTables.cxx +++ b/connectivity/source/drivers/evoab2/NTables.cxx @@ -37,21 +37,21 @@ css::uno::Reference< css::beans::XPropertySet > OEvoabTables::createObject(const Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),u"%"_ustr,aName,aTypes); - css::uno::Reference< css::beans::XPropertySet > xRet; - if(xResult.is()) + rtl::Reference< OEvoabTable > xRet; + if(!xResult.is()) + return nullptr; + + Reference< XRow > xRow(xResult,UNO_QUERY); + if(xResult->next()) // there can be only one table with this name { - Reference< XRow > xRow(xResult,UNO_QUERY); - if(xResult->next()) // there can be only one table with this name - { - xRet = new OEvoabTable( - this, - static_cast(m_rParent).getConnection(), - aName, - xRow->getString(4), - xRow->getString(5), - u""_ustr, - u""_ustr); - } + xRet = new OEvoabTable( + this, + static_cast(m_rParent).getConnection(), + aName, + xRow->getString(4), + xRow->getString(5), + u""_ustr, + u""_ustr); } ::comphelper::disposeComponent(xResult); diff --git a/connectivity/source/drivers/file/FColumns.cxx b/connectivity/source/drivers/file/FColumns.cxx index 55727c9a48f0..dbe95ed16d55 100644 --- a/connectivity/source/drivers/file/FColumns.cxx +++ b/connectivity/source/drivers/file/FColumns.cxx @@ -36,31 +36,31 @@ css::uno::Reference< css::beans::XPropertySet > OColumns::createObject(const OUS Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(), sSchemaName, sTableName, _rName); - css::uno::Reference< css::beans::XPropertySet > xRet; - if(xResult.is()) + if(!xResult.is()) + return nullptr; + + rtl::Reference< sdbcx::OColumn > xRet; + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) { - Reference< XRow > xRow(xResult,UNO_QUERY); - while(xResult->next()) + if(xRow->getString(4) == _rName) { - if(xRow->getString(4) == _rName) - { - xRet = new sdbcx::OColumn(_rName, - xRow->getString(6), - xRow->getString(13), - xRow->getString(12), - xRow->getInt(11), - xRow->getInt(7), - xRow->getInt(9), - xRow->getInt(5), - false, - false, - false, - m_pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(), - sCatalogName, - sSchemaName, - sTableName); - break; - } + xRet = new sdbcx::OColumn(_rName, + xRow->getString(6), + xRow->getString(13), + xRow->getString(12), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + false, + false, + false, + m_pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(), + sCatalogName, + sSchemaName, + sTableName); + break; } } diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index d81c3625d5fa..8f2711645ca7 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -709,11 +709,11 @@ Reference< XDatabaseMetaData > SAL_CALL Connection::getMetaData( ) // here we have to create the class with biggest interface // The answer is 42 :-) - Reference< XDatabaseMetaData > xMetaData = m_xMetaData; + rtl::Reference< ODatabaseMetaData > xMetaData = m_xMetaData.get(); if(!xMetaData.is()) { xMetaData = new ODatabaseMetaData(this); // need the connection because it can return it - m_xMetaData = xMetaData; + m_xMetaData = xMetaData.get(); } return xMetaData; @@ -879,7 +879,7 @@ void Connection::disposing() disposeStatements(); - m_xMetaData = css::uno::WeakReference< css::sdbc::XDatabaseMetaData>(); + m_xMetaData.clear(); ISC_STATUS_ARRAY status; /* status vector */ if (m_aTransactionHandle) @@ -949,18 +949,13 @@ uno::Reference< XTablesSupplier > Connection::createCatalog() MutexGuard aGuard(m_aMutex); // m_xCatalog is a weak reference. Reuse it if it still exists. - Reference< XTablesSupplier > xCatalog = m_xCatalog; - if (xCatalog.is()) - { - return xCatalog; - } - else + rtl::Reference< Catalog > xCatalog = m_xCatalog.get(); + if (!xCatalog.is()) { xCatalog = new Catalog(this); - m_xCatalog = xCatalog; - return m_xCatalog; + m_xCatalog = xCatalog.get(); } - + return xCatalog; } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx index a0a033f1f1db..524c0a7c476f 100644 --- a/connectivity/source/drivers/firebird/Connection.hxx +++ b/connectivity/source/drivers/firebird/Connection.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,7 @@ namespace connectivity::firebird class OStatementCommonBase; class FirebirdDriver; class ODatabaseMetaData; + class Catalog; typedef std::vector< ::connectivity::OTypeInfo> TTypeInfoVector; @@ -136,9 +138,9 @@ namespace connectivity::firebird isc_db_handle m_aDBHandle; isc_tr_handle m_aTransactionHandle; - css::uno::WeakReference< css::sdbcx::XTablesSupplier> + unotools::WeakReference< Catalog > m_xCatalog; - css::uno::WeakReference< css::sdbc::XDatabaseMetaData > + unotools::WeakReference< ODatabaseMetaData > m_xMetaData; /** Statements owned by this connection. */ OWeakRefArray m_aStatements; diff --git a/connectivity/source/drivers/hsqldb/HTables.cxx b/connectivity/source/drivers/hsqldb/HTables.cxx index 390f36e19a04..dcb1ee1a33d9 100644 --- a/connectivity/source/drivers/hsqldb/HTables.cxx +++ b/connectivity/source/drivers/hsqldb/HTables.cxx @@ -51,28 +51,28 @@ css::uno::Reference< css::beans::XPropertySet > OTables::createObject(const OUSt aCatalog <<= sCatalog; Reference< XResultSet > xResult = m_xMetaData->getTables(aCatalog,sSchema,sTable,sTableTypes); - css::uno::Reference< css::beans::XPropertySet > xRet; - if ( xResult.is() ) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - if ( xResult->next() ) // there can be only one table with this name - { - sal_Int32 nPrivileges = ::dbtools::getTablePrivileges( m_xMetaData, sCatalog, sSchema, sTable ); - if ( m_xMetaData->isReadOnly() ) - nPrivileges &= ~( Privilege::INSERT | Privilege::UPDATE | Privilege::DELETE | Privilege::CREATE | Privilege::ALTER | Privilege::DROP ); + if ( !xResult.is() ) + return nullptr; - // obtain privileges - xRet = new OHSQLTable( this - ,static_cast(m_rParent).getConnection() - ,sTable - ,xRow->getString(4) - ,xRow->getString(5) - ,sSchema - ,sCatalog - ,nPrivileges); - } - ::comphelper::disposeComponent(xResult); + rtl::Reference< OHSQLTable > xRet; + Reference< XRow > xRow(xResult,UNO_QUERY); + if ( xResult->next() ) // there can be only one table with this name + { + sal_Int32 nPrivileges = ::dbtools::getTablePrivileges( m_xMetaData, sCatalog, sSchema, sTable ); + if ( m_xMetaData->isReadOnly() ) + nPrivileges &= ~( Privilege::INSERT | Privilege::UPDATE | Privilege::DELETE | Privilege::CREATE | Privilege::ALTER | Privilege::DROP ); + + // obtain privileges + xRet = new OHSQLTable( this + ,static_cast(m_rParent).getConnection() + ,sTable + ,xRow->getString(4) + ,xRow->getString(5) + ,sSchema + ,sCatalog + ,nPrivileges); } + ::comphelper::disposeComponent(xResult); return xRet; } diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx index f2f4bf55a08e..efbe25272bea 100644 --- a/connectivity/source/drivers/jdbc/JDriver.cxx +++ b/connectivity/source/drivers/jdbc/JDriver.cxx @@ -68,12 +68,11 @@ Reference< XConnection > SAL_CALL java_sql_Driver::connect( const OUString& url, { m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_CONNECTING_URL, url ); - Reference< XConnection > xOut; + rtl::Reference< java_sql_Connection > xOut; if ( acceptsURL(url ) ) { - rtl::Reference pConnection = new java_sql_Connection( *this ); - xOut = pConnection; - if ( !pConnection->construct(url,info) ) + xOut = new java_sql_Connection( *this ); + if ( !xOut->construct(url,info) ) xOut.clear(); // an error occurred and the java driver didn't throw an exception else m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_SUCCESS ); diff --git a/connectivity/source/drivers/mysql_jdbc/YTables.cxx b/connectivity/source/drivers/mysql_jdbc/YTables.cxx index 999ff79d9e82..b333db670623 100644 --- a/connectivity/source/drivers/mysql_jdbc/YTables.cxx +++ b/connectivity/source/drivers/mysql_jdbc/YTables.cxx @@ -54,7 +54,7 @@ css::uno::Reference OTables::createObject(const OUStri aCatalog <<= sCatalog; Reference xResult = m_xMetaData->getTables(aCatalog, sSchema, sTable, sTableTypes); - css::uno::Reference xRet; + rtl::Reference xRet; if (xResult.is()) { Reference xRow(xResult, UNO_QUERY); diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx index b382b34e9eb5..e0225e0f6407 100644 --- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -231,7 +231,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OStatement_BASE::rBHelper.bDisposed); - Reference< XResultSet > rs; + rtl::Reference< OResultSet > rs; prepareStatement(); diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index e0ea16b36ae0..4e322731a146 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1587,7 +1587,7 @@ void OSQLParseTreeIterator::setSelectColumnName(const OUString & rColumnName,con // without table specified if ( !bFkt ) { - Reference< XPropertySet> xNewColumn; + rtl::Reference< OParseColumn> xNewColumn; for (auto const& table : *m_pImpl->m_pTables) {