User: ihi Date: 2006/08/04 06:55:13 Modified: dba/dbaccess/source/core/api/RowSet.cxx
Log: INTEGRATION: CWS dba204c (1.145.8); FILE MERGED 2006/07/24 12:21:32 fs 1.145.8.2: #i67453# when extending an error message, caught during execution, with own information, don't allow for secondary exceptions to slip to the caller 2006/07/21 08:45:50 fs 1.145.8.1: #i67594# when the connection cannot provide a query composer, create one stand-alone 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.145&r2=1.146 Delta lines: +85 -52 --------------------- --- RowSet.cxx 10 Jul 2006 15:03:11 -0000 1.145 +++ RowSet.cxx 4 Aug 2006 13:55:11 -0000 1.146 @@ -42,6 +42,9 @@ #ifndef DBACORE_SDBCORETOOLS_HXX #include "sdbcoretools.hxx" #endif +#ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX +#include "SingleSelectQueryComposer.hxx" +#endif #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> #endif @@ -693,11 +696,7 @@ DELETEZ(m_pCache); - if(m_pTables) - { - m_pTables->dispose(); // clear all references - DELETEZ(m_pTables); - } + impl_resetTables_nothrow(); m_xStatement = NULL; m_xTypeMap = NULL; @@ -1694,9 +1693,16 @@ 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 ) ) ); + // append information about what we were actually going to execute + try + { + String sQuery = bUseEscapeProcessing ? impl_getComposedQuery_throw( false ) : m_aActiveCommand; + String sInfo( DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", sQuery ) ); aError.append( SQLExceptionInfo::SQL_CONTEXT, sInfo ); + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + // propagate aError.doThrow(); } @@ -2104,34 +2110,26 @@ } return m_xActiveConnection; } + //------------------------------------------------------------------------------ -sal_Bool ORowSet::impl_buildActiveCommand_throw() +Reference< XNameAccess > ORowSet::impl_getTables_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 - sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing; - - m_aActiveCommand = ::rtl::OUString(); - ::rtl::OUString sCommand; - - if ( !m_aCommand.getLength() ) - return bDoEscapeProcessing; - - switch (m_nCommandType) - { - case CommandType::TABLE: - { Reference< XNameAccess > xTables; + Reference< XTablesSupplier > xTablesAccess( m_xActiveConnection, UNO_QUERY ); if ( xTablesAccess.is() ) { xTables.set( xTablesAccess->getTables(), UNO_QUERY_THROW ); } + else if ( m_pTables ) + { + xTables = m_pTables; + } else { - if(!m_xActiveConnection.is()) + if ( !m_xActiveConnection.is() ) throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() ); + sal_Bool bCase = sal_True; try { @@ -2143,12 +2141,6 @@ 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); xTables = m_pTables; Sequence< ::rtl::OUString> aTableFilter(1); @@ -2156,6 +2148,48 @@ m_pTables->construct(aTableFilter,Sequence< ::rtl::OUString>()); } + return xTables; +} + +//------------------------------------------------------------------------------ +void ORowSet::impl_resetTables_nothrow() +{ + if ( !m_pTables ) + return; + + try + { + m_pTables->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + DELETEZ( m_pTables ); +} + +//------------------------------------------------------------------------------ +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 + sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing; + + m_aActiveCommand = ::rtl::OUString(); + ::rtl::OUString sCommand; + + if ( !m_aCommand.getLength() ) + return bDoEscapeProcessing; + + switch (m_nCommandType) + { + case CommandType::TABLE: + { + impl_resetTables_nothrow(); + Reference< XNameAccess > xTables( impl_getTables_throw() ); + if ( xTables->hasByName(m_aCommand) ) { Reference< XPropertySet > xTable; @@ -2250,19 +2284,18 @@ //------------------------------------------------------------------------------ ::rtl::OUString ORowSet::impl_getComposedQuery_throw( bool _bForExecution ) { - Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY_THROW ); + Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY ); + if ( xFactory.is() ) + { try { ::comphelper::disposeComponent( m_xComposer ); m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ); } - catch (const Exception& ) - { - m_xComposer = NULL; + catch (const Exception& ) { m_xComposer = NULL; } } if ( !m_xComposer.is() ) - throwSQLException( "No query composer could be provided by the connection.", SQL_GENERAL_ERROR, *this ); - // TODO: resource + m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_xServiceManager ); m_xComposer->setElementaryQuery( m_aActiveCommand ); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
