Tag: cws_src680_dba30 User: fs Date: 2006/07/19 05:08:52 Modified: dba/dbaccess/source/core/api/RowSet.cxx
Log: RESYNC: (1.143-1.145); FILE MERGED File Changes: Directory: /dba/dbaccess/source/core/api/ ========================================= File [changed]: RowSet.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSet.cxx?r1=1.133.12.9&r2=1.133.12.10 Delta lines: +453 -424 ----------------------- --- RowSet.cxx 8 May 2006 11:17:30 -0000 1.133.12.9 +++ RowSet.cxx 19 Jul 2006 12:08:49 -0000 1.133.12.10 @@ -51,6 +51,9 @@ #ifndef _CPPUHELPER_INTERFACECONTAINER_H_ #include <cppuhelper/interfacecontainer.h> #endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ #include <cppuhelper/typeprovider.hxx> #endif @@ -131,12 +134,12 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif #ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> #endif -#ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX -#include "SingleSelectQueryComposer.hxx" -#endif #ifndef _DBA_CORE_TABLECONTAINER_HXX_ #include "tablecontainer.hxx" #endif @@ -208,7 +211,7 @@ { static void throwRowSetVetoException( const Reference< XInterface >& _rSource, const sal_Char* _pAsciiMessage ) { - // TODO: localize the message + // TODO: resource (localize the message) RowSetVetoException aException; aException.Message = ::rtl::OUString::createFromAscii( _pAsciiMessage ); aException.Context = _rSource; @@ -263,26 +266,26 @@ ORowSet::ORowSet(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFac) : ORowSet_BASE1(m_aMutex) , ORowSetBase(ORowSet_BASE1::rBHelper,&m_aMutex) - , m_xServiceManager(_xFac) + ,m_xServiceManager(_xFac) ,m_aRowsetListeners(*m_pMutex) ,m_aApproveListeners(*m_pMutex) + ,m_pTables(NULL) ,m_nFetchDirection(FetchDirection::FORWARD) ,m_nFetchSize(1) - ,m_nCommandType(CommandType::COMMAND) ,m_nMaxFieldSize(0) - ,m_nTransactionIsolation(0) - ,m_nPrivileges(0) ,m_nMaxRows(0) ,m_nQueryTimeOut(0) + ,m_nCommandType(CommandType::COMMAND) + ,m_nTransactionIsolation(0) + ,m_nPrivileges(0) ,m_bUseEscapeProcessing(sal_True) ,m_bApplyFilter(sal_False) ,m_bCreateStatement(sal_True) ,m_bModified(sal_False) ,m_bRebuildConnOnExecute(sal_False) - ,m_bNew(sal_False) ,m_bIsBookmarable(sal_True) + ,m_bNew(sal_False) ,m_bCanUpdateInsertedRows(sal_True) - ,m_pTables(NULL) ,m_bOwnConnection(sal_False) { m_nResultSetType = ResultSetType::SCROLL_SENSITIVE; @@ -681,7 +684,6 @@ // dispose the composer to avoid that everbody knows that the querycomposer is eol try { - m_xAnalyzer = NULL; ::comphelper::disposeComponent(m_xComposer); } catch(Exception&) @@ -1102,14 +1104,19 @@ if ( m_bBeforeFirst || m_bAfterLast ) throwSQLException( "Cannot delete the before-first or after-last row.", SQL_INVALID_CURSOR_POSITION, *this ); + // TODO: resource if ( m_bNew ) throwSQLException( "Cannot delete the insert-row.", SQL_INVALID_CURSOR_POSITION, *this ); + // TODO: resource if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) throwSQLException( "Result set is read only.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); + // TODO: resource if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE ) throwSQLException( "DELETE privilege not available.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); + // TODO: resource if ( rowDeleted() ) throwSQLException( "Current row already deleted.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); + // TODO: resource // this call position the cache indirect Any aBookmarkToDelete( m_aBookmark ); @@ -1240,6 +1247,7 @@ NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange); if ( !bCheck ) throwRowSetVetoException( *this, "The record operation has been vetoed." ); + // TODO: resource } // ------------------------------------------------------------------------- void ORowSet::fireRowcount() @@ -1274,6 +1282,7 @@ checkPositioningAllowed(); if ( ( m_pCache->m_nPrivileges & Privilege::INSERT ) != Privilege::INSERT ) throwSQLException( "No insert privileges", SQL_GENERAL_ERROR, *this ); + // TODO: resource if ( notifyAllListenersCursorBeforeMove( aGuard ) ) { @@ -1340,6 +1349,7 @@ // our current row should not be deleted anymore. So, we should not have survived the above // check "if ( !m_pCache->m_bInserted && !m_bModified )" throwSQLException( "The current row is deleted.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); + // TODO: resource if ( notifyAllListenersCursorBeforeMove( aGuard ) ) { @@ -1472,28 +1482,28 @@ return ORowSetBase::getCharacterStream(columnIndex); } // ------------------------------------------------------------------------- -Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex).makeAny(); } // ------------------------------------------------------------------------- -Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { return Reference< XRef >(); } // ------------------------------------------------------------------------- -Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { return Reference< XBlob >(); } // ------------------------------------------------------------------------- -Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { return Reference< XClob >(); } // ------------------------------------------------------------------------- -Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { return Reference< XArray >(); } @@ -1635,72 +1645,89 @@ } // ----------------------------------------------------------------------------- -// XRowSet -void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotification) +Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::execute_NoApprove_NoNewConn" ); + sal_Bool bUseEscapeProcessing = impl_buildActiveCommand_throw( ); + ::rtl::OUString sCommandToExecute( m_aActiveCommand ); + if ( bUseEscapeProcessing ) + sCommandToExecute = impl_getComposedQuery_throw( true ); - // now we can dispose our old connection - ::comphelper::disposeComponent(m_xOldConnection); - m_xOldConnection = NULL; - - ::rtl::OUString aSql; - // do we need a new statement - if (m_bCreateStatement) + Reference< XResultSet> xResultSet; + try { - m_xStatement = NULL; - m_xComposer = NULL; - m_xAnalyzer = NULL; - - // Build the statement - sal_Bool bUseEscapeProcessing; - Reference< ::com::sun::star::container::XNameAccess > xTables; - // xTables will be filled in getCommand - m_aActiveCommand = getCommand(bUseEscapeProcessing,xTables); - if (!m_aActiveCommand.getLength()) - throwGenericSQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Empty command submitted!")),*this); - + m_xStatement = m_xActiveConnection->prepareStatement( sCommandToExecute ); + if ( !m_xStatement.is() ) { - m_xStatement = m_xActiveConnection->prepareStatement( - aSql = getComposedQuery(m_aActiveCommand, bUseEscapeProcessing,xTables)); - - if(m_xStatement.is()) - { - Reference<XPropertySet> xProp(m_xStatement,UNO_QUERY); + SQLException aError; + aError.Context = *this; + aError.SQLState = getStandardSQLState( SQL_GENERAL_ERROR ); + aError.Message = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Internal error: no statement object provided by the database driver." ) ); + // TODO: resource + throw aError; + } + Reference< XPropertySet > xStatementProps( m_xStatement, UNO_QUERY_THROW ); // set the result set type and concurrency try { - xProp->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( sal_True ) ); - setStatementResultSetType( xProp, m_nResultSetType, m_nResultSetConcurrency ); + xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( sal_True ) ); + setStatementResultSetType( xStatementProps, m_nResultSetType, m_nResultSetConcurrency ); } catch(Exception&) { // this exception doesn't matter here because when we catch an exception // then the driver doesn't support this feature } - // xProp->setPropertyValue(PROPERTY_RESULTSETTYPE,makeAny(m_nResultSetType)); - // xProp->setPropertyValue(PROPERTY_RESULTSETCONCURRENCY,makeAny(m_nResultSetConcurrency)); - // if(m_nFetchDirection != FetchDirection::FORWARD) - // xProp->setPropertyValue(PROPERTY_FETCHDIRECTION,makeAny((sal_Int32)m_nFetchDirection)); + Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW ); + sal_Int32 index = 1; + for ( ORowVector< ORowSetValue >::const_iterator aParam = m_aParameterRow.begin(); + aParam != m_aParameterRow.end(); + ++aParam, ++index ) { - Reference<XParameters> xParam(m_xStatement,UNO_QUERY); - sal_Int32 i = 1; - for(ORowVector< ORowSetValue >::const_iterator aIter = m_aParameterRow.begin(); aIter != m_aParameterRow.end();++aIter,++i) + ::dbtools::setObjectWithInfo( xParam, index, aParam->makeAny(), aParam->getTypeKind() ); + } + + xResultSet = m_xStatement->executeQuery(); + } + catch( const SQLException& ) { - ::dbtools::setObjectWithInfo(xParam,i,aIter->makeAny(),aIter->getTypeKind()); + SQLExceptionInfo aError( ::cppu::getCaughtException() ); + OSL_ENSURE( aError.isValid(), "ORowSet::execute_NoApprove_NoNewConn: caught an SQLException which we cannot analyze!" ); + + String sInfo( DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", impl_getComposedQuery_throw( false ) ) ); + aError.append( SQLExceptionInfo::SQL_CONTEXT, sInfo ); + + aError.doThrow(); } - Reference< XResultSet> xResults( m_xStatement->executeQuery() ); - // create the composed table name - ::rtl::OUString aComposedTableName; - if(m_aUpdateTableName.getLength()) - composeTableName(m_xActiveConnection->getMetaData(),m_aUpdateCatalogName,m_aUpdateSchemaName,m_aUpdateTableName,aComposedTableName,sal_False,::dbtools::eInDataManipulation); + return xResultSet; +} + +// ----------------------------------------------------------------------------- +void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotification) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::execute_NoApprove_NoNewConn" ); + // now we can dispose our old connection + ::comphelper::disposeComponent(m_xOldConnection); + m_xOldConnection = NULL; + + // do we need a new statement + if (m_bCreateStatement) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::execute_NoApprove_NoNewConn::createCache" ); - m_pCache = new ORowSetCache(xResults,m_xAnalyzer,m_xServiceManager,m_aParameterRow,aComposedTableName,m_bModified,m_bNew); + m_xStatement = NULL; + m_xComposer = NULL; + + Reference< XResultSet > xResultSet( impl_prepareAndExecute_throw() ); + + ::rtl::OUString aComposedUpdateTableName; + if ( m_aUpdateTableName.getLength() ) + aComposedUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), m_aUpdateCatalogName, m_aUpdateSchemaName, m_aUpdateTableName, sal_False, ::dbtools::eInDataManipulation ); + + { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::execute_NoApprove_NoNewConn: creating cache" ); + m_pCache = new ORowSetCache(xResultSet,m_xComposer.get(),m_xServiceManager,aComposedUpdateTableName,m_bModified,m_bNew); if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) { m_nPrivileges = Privilege::SELECT; @@ -1731,9 +1758,9 @@ ::rtl::OUString aDescription; sal_Int32 nFormatKey = 0; - RTL_LOGFILE_CONTEXT_AUTHOR( aColumnCreateLog, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::execute_NoApprove_NoNewConn::createColumns" ); if(!m_xColumns.is()) { + RTL_LOGFILE_CONTEXT_AUTHOR( aColumnCreateLog, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::execute_NoApprove_NoNewConn::creating columns" ); // use the meta data Reference<XResultSetMetaDataSupplier> xMetaSup(m_xStatement,UNO_QUERY); try @@ -1754,10 +1781,10 @@ if(aColumnMap.find(sName) != aColumnMap.end()) { ::rtl::OUString sAlias(sName); - sal_Int32 i=1; + sal_Int32 searchIndex=1; while(aColumnMap.find(sAlias) != aColumnMap.end()) { - (sAlias = sName) += ::rtl::OUString::valueOf(i++); + (sAlias = sName) += ::rtl::OUString::valueOf(searchIndex++); } sName = sAlias; } @@ -1860,6 +1887,7 @@ xColumn->getPropertyValue(PROPERTY_NAME) >>= sName; else sName = ::rtl::OUString::createFromAscii("Expression1"); + // TODO: resource } pColumn->setName(sName); aNames.push_back(sName); @@ -1906,16 +1934,6 @@ aColumns,*this,m_aColumnsMutex,aNames); } } - } - else - { - ::rtl::OUString sErrorMsg(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The command '"))); - sErrorMsg += aSql; - sErrorMsg += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("' did not succeed.")); - throwGenericSQLException(sErrorMsg,*this); - } - } - } checkCache(); // notify the rowset listeners notifyAllListeners(_rClearForNotification); @@ -2095,25 +2113,33 @@ return m_xActiveConnection; } //------------------------------------------------------------------------------ -rtl::OUString ORowSet::getCommand(sal_Bool& bEscapeProcessing,::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxRetTables) throw( SQLException) +sal_Bool ORowSet::impl_buildActiveCommand_throw() { // create the sql command // from a table name or get the command out of a query (not a view) // the last use the command as it is - bEscapeProcessing = m_bUseEscapeProcessing; - rtl::OUString aQuery; - if (m_aCommand.getLength()) + sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing; + + m_aActiveCommand = ::rtl::OUString(); + ::rtl::OUString sCommand; + + if ( !m_aCommand.getLength() ) + return bDoEscapeProcessing; + + switch (m_nCommandType) + { + case CommandType::TABLE: { - // i always need a tables for the querycomposer - Reference< XTablesSupplier > xTablesAccess(m_xActiveConnection, UNO_QUERY); - if (xTablesAccess.is()) + Reference< XNameAccess > xTables; + Reference< XTablesSupplier > xTablesAccess( m_xActiveConnection, UNO_QUERY ); + if ( xTablesAccess.is() ) { - _rxRetTables = xTablesAccess->getTables(); + xTables.set( xTablesAccess->getTables(), UNO_QUERY_THROW ); } - else // the connection is no table supplier so I make it myself + else { if(!m_xActiveConnection.is()) - throw SQLException(DBACORE_RESSTRING(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() ); + throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() ); sal_Bool bCase = sal_True; try { @@ -2122,24 +2148,28 @@ } catch(SQLException&) { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( m_pTables ) + { + m_pTables->dispose(); // clear all references + DELETEZ(m_pTables); } + m_pTables = new OTableContainer(*this,m_aMutex,m_xActiveConnection,bCase,NULL,NULL); - _rxRetTables = m_pTables; + xTables = m_pTables; Sequence< ::rtl::OUString> aTableFilter(1); aTableFilter[0] = ::rtl::OUString::createFromAscii("%"); m_pTables->construct(aTableFilter,Sequence< ::rtl::OUString>()); } - switch (m_nCommandType) - { - case CommandType::TABLE: - { - OSL_ENSURE(_rxRetTables.is(),"ORowSet::getCommand: We got no tables from the connection!"); - if ( _rxRetTables.is() && _rxRetTables->hasByName(m_aCommand) ) + + if ( xTables->hasByName(m_aCommand) ) { Reference< XPropertySet > xTable; try { - ::cppu::extractInterface(xTable,_rxRetTables->getByName(m_aCommand)); + xTables->getByName( m_aCommand ) >>= xTable; } catch(const WrappedTargetException& e) { @@ -2149,18 +2179,17 @@ } catch(Exception&) { - OSL_ENSURE(0,"Exception catched!"); + DBG_UNHANDLED_EXCEPTION(); } Reference<XColumnsSupplier> xSup(xTable,UNO_QUERY); if ( xSup.is() ) m_xColumns = xSup->getColumns(); - sal_Bool bUseCatalogInSelect = ::dbtools::isDataSourcePropertyEnabled(m_xActiveConnection,PROPERTY_USECATALOGINSELECT,sal_True); - sal_Bool bUseSchemaInSelect = ::dbtools::isDataSourcePropertyEnabled(m_xActiveConnection,PROPERTY_USESCHEMAINSELECT,sal_True); - - aQuery = rtl::OUString::createFromAscii("SELECT * FROM "); - aQuery += ::dbtools::quoteTableName(m_xActiveConnection->getMetaData(), m_aCommand,::dbtools::eInDataManipulation,bUseCatalogInSelect,bUseSchemaInSelect); + sCommand = rtl::OUString::createFromAscii("SELECT * FROM "); + ::rtl::OUString sCatalog, sSchema, sTable; + ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation ); + sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable ); } else { @@ -2170,6 +2199,7 @@ } } break; + case CommandType::QUERY: { Reference< XQueriesSupplier > xQueriesAccess(m_xActiveConnection, UNO_QUERY); @@ -2179,18 +2209,18 @@ if (xQueries->hasByName(m_aCommand)) { Reference< XPropertySet > xQuery(xQueries->getByName(m_aCommand),UNO_QUERY); - OSL_ENSURE(xQuery.is(),"ORowSet::getCommand: Query is NULL!"); + OSL_ENSURE(xQuery.is(),"ORowSet::impl_buildActiveCommand_throw: Query is NULL!"); if ( xQuery.is() ) { - xQuery->getPropertyValue(PROPERTY_COMMAND) >>= aQuery; - bEscapeProcessing = any2bool(xQuery->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING)); + xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand; + xQuery->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING) >>= bDoEscapeProcessing; ::rtl::OUString aCatalog,aSchema,aTable; xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME) >>= aCatalog; xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME) >>= aSchema; xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= aTable; if(aTable.getLength()) - composeTableName(m_xActiveConnection->getMetaData(),aCatalog,aSchema,aTable,m_aUpdateTableName,sal_False,::dbtools::eInDataManipulation); + m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, sal_False, ::dbtools::eInDataManipulation ); Reference<XColumnsSupplier> xSup(xQuery,UNO_QUERY); if(xSup.is()) @@ -2199,51 +2229,49 @@ } else { - ::rtl::OUString sError(RTL_CONSTASCII_USTRINGPARAM("There exists no query with given name: \"")); - sError += m_aCommand; - sError += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"!")); - throwGenericSQLException(sError,*this); + String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) ); + sMessage.SearchAndReplaceAscii( "$table$", m_aCommand ); + throwGenericSQLException(sMessage,*this); } } else - throw SQLException(DBACORE_RESSTRING(RID_STR_NO_XQUERIESSUPPLIER),*this,::rtl::OUString(),0,Any()); - } break; - default: - aQuery = m_aCommand; + throw SQLException(DBA_RES(RID_STR_NO_XQUERIESSUPPLIER),*this,::rtl::OUString(),0,Any()); } + break; + + default: + sCommand = m_aCommand; + break; } - return aQuery; + + m_aActiveCommand = sCommand; + + if ( !m_aActiveCommand.getLength() ) + throwSQLException( "No SQL command was provided.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); + // TODO: resource + + return bDoEscapeProcessing; } //------------------------------------------------------------------------------ -rtl::OUString ORowSet::getComposedQuery(const rtl::OUString& rQuery, sal_Bool bEscapeProcessing,Reference< XNameAccess >& _rxRetTables) throw( SQLException, RuntimeException ) +::rtl::OUString ORowSet::impl_getComposedQuery_throw( bool _bForExecution ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::getComposedQuery" ); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "[EMAIL PROTECTED]", "ORowSet::impl_getComposedQuery_throw" ); - // use query composer to make a useful query with filter and/or order by part - rtl::OUString aComposedStatement = rQuery; - if (bEscapeProcessing) - { - Reference< XMultiServiceFactory > xFactory(m_xActiveConnection, UNO_QUERY); - if (xFactory.is()) - { + Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY_THROW ); try { - m_xAnalyzer.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); - m_xComposer.set(m_xAnalyzer,UNO_QUERY); + ::comphelper::disposeComponent( m_xComposer ); + m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ); } - catch (Exception&) + catch (const Exception& ) { m_xComposer = NULL; } - } - if(!m_xComposer.is()) // no composer so we create one - { - m_xAnalyzer = new OSingleSelectQueryComposer(_rxRetTables,m_xActiveConnection,m_xServiceManager); - m_xComposer.set(m_xAnalyzer,UNO_QUERY); - } - if ( m_xComposer.is() ) - { - m_xComposer->setElementaryQuery( rQuery ); + if ( !m_xComposer.is() ) + throwSQLException( "No query composer could be provided by the connection.", SQL_GENERAL_ERROR, *this ); + // TODO: resource + + m_xComposer->setElementaryQuery( m_aActiveCommand ); if ( m_bApplyFilter ) { @@ -2264,18 +2292,16 @@ m_xComposer->setFilter( ::rtl::OUString::createFromAscii( "0 = 1" ) ); } - if (m_aOrder.getLength()) - m_xComposer->setOrder(m_aOrder); + if ( m_aOrder.getLength() ) + m_xComposer->setOrder( m_aOrder ); - aComposedStatement = m_xComposer->getQuery(); - if(!m_xColumns.is()) + if ( !m_xColumns.is() ) { - Reference<XColumnsSupplier> xCols(m_xComposer,UNO_QUERY); + Reference<XColumnsSupplier> xCols( m_xComposer, UNO_QUERY_THROW ); m_xColumns = xCols->getColumns(); } - } - } - return aComposedStatement; + + return _bForExecution ? m_xComposer->getQueryWithSubstitution() : m_xComposer->getQuery(); } // ----------------------------------------------------------------------------- void ORowSet::checkAndResizeParameters(sal_Int32 parameterIndex) @@ -2288,7 +2314,7 @@ } // ------------------------------------------------------------------------- // XParameters -void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException) +void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aColumnsMutex ); checkAndResizeParameters(parameterIndex); @@ -2296,9 +2322,8 @@ m_aParameterRow[parameterIndex-1].setNull(); } // ------------------------------------------------------------------------- -void SAL_CALL ORowSet::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException) +void SAL_CALL ORowSet::setObjectNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aColumnsMutex ); checkAndResizeParameters(parameterIndex); m_aParameterRow[parameterIndex-1].setNull(); @@ -2421,7 +2446,7 @@ } } // ------------------------------------------------------------------------- -void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) +void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aColumnsMutex ); checkAndResizeParameters(parameterIndex); @@ -2429,24 +2454,24 @@ m_aParameterRow[parameterIndex-1].setTypeKind(targetSqlType); } // ------------------------------------------------------------------------- -void SAL_CALL ORowSet::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) throw(SQLException, RuntimeException) +void SAL_CALL ORowSet::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException) { - throw SQLException(); + ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this ); } // ------------------------------------------------------------------------- -void SAL_CALL ORowSet::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException) +void SAL_CALL ORowSet::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException) { - throw SQLException(); + ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this ); } // ------------------------------------------------------------------------- -void SAL_CALL ORowSet::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException) +void SAL_CALL ORowSet::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException) { - throw SQLException(); + ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this ); } // ------------------------------------------------------------------------- -void SAL_CALL ORowSet::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) throw(SQLException, RuntimeException) +void SAL_CALL ORowSet::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException) { - throw SQLException(); + ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this ); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::clearParameters( ) throw(SQLException, RuntimeException) @@ -2510,12 +2535,16 @@ checkCache(); if ( columnIndex <= 0 ) throwSQLException( "Invalid column index", SQL_INVALID_DESCRIPTOR_INDEX, *this ); + // TODO: resource if ( rowDeleted() ) throwSQLException( "Current row is deleted", SQL_INVALID_CURSOR_POSITION, *this ); + // TODO: resource if ( m_aCurrentRow.isNull() ) throwSQLException( "Invalid cursor state", SQL_INVALID_CURSOR_STATE, *this ); + // TODO: resource if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) throwSQLException( "Result set is not writeable", SQL_GENERAL_ERROR, *this ); + // TODO: resource } // ----------------------------------------------------------------------------- void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException) @@ -2543,10 +2572,10 @@ ORowSetClone::ORowSetClone(ORowSet& rParent,::osl::Mutex* _pMutex) :OSubComponent(m_aMutex, rParent) ,ORowSetBase(OComponentHelper::rBHelper,_pMutex) + ,m_pParent(&rParent) ,m_nFetchDirection(rParent.m_nFetchDirection) ,m_nFetchSize(rParent.m_nFetchSize) ,m_bIsBookmarable(sal_True) - ,m_pParent(&rParent) { DBG_CTOR(ORowSetClone, NULL); @@ -2788,13 +2817,13 @@ } // ------------------------------------------------------------------------- -void SAL_CALL ORowSetClone::addRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException) +void SAL_CALL ORowSetClone::addRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException) { throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this ); } // ------------------------------------------------------------------------- -void SAL_CALL ORowSetClone::removeRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException) +void SAL_CALL ORowSetClone::removeRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException) { throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this ); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
