User: vg Date: 05/03/10 08:30:58 Modified: /dba/dbaccess/source/core/api/ RowSet.cxx
Log: INTEGRATION: CWS dba24 (1.131.4); FILE MERGED 2005/02/21 13:07:33 oj 1.131.4.4: RESYNC: (1.131-1.132); FILE MERGED 2005/02/11 11:15:23 fs 1.131.4.3: still #i15113#: setStatementResultSetType: use our own type/concurrency - no need to require more from the statement than what clients require from ourself 2005/02/10 17:31:32 fs 1.131.4.2: #i15113# when executing the row set, care for a data-source-setting which enables defensive usage of ResultSetType and ResultSetConcurrency - IBM's Universe database didn't like our previous aggressive behaviour 2005/02/10 16:55:20 fs 1.131.4.1: #i15113# - default m_nResultSetType to SCROLL_SENSITIVE - when executing, forward our ResultSetType/Concurrency to the statement 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.132&r2=1.133 Delta lines: +59 -7 -------------------- --- RowSet.cxx 17 Feb 2005 11:01:38 -0000 1.132 +++ RowSet.cxx 10 Mar 2005 16:30:55 -0000 1.133 @@ -65,6 +65,9 @@ #ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" #endif +#ifndef DBACORE_SDBCORETOOLS_HXX +#include "sdbcoretools.hxx" +#endif #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> #endif @@ -315,7 +318,7 @@ ,m_pTables(NULL) ,m_bOwnConnection(sal_False) { - m_nResultSetType = ResultSetType::SCROLL_INSENSITIVE; + m_nResultSetType = ResultSetType::SCROLL_SENSITIVE; m_nResultSetConcurrency = ResultSetConcurrency::UPDATABLE; m_pMySelf = this; m_aActiveConnection <<= m_xActiveConnection; @@ -1582,6 +1585,56 @@ execute_NoApprove_NoNewConn(aGuard); } +//------------------------------------------------------------------------------ +void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxStatement, sal_Int32 _nDesiredResultSetType, sal_Int32 _nDesiredResultSetConcurrency ) +{ + OSL_ENSURE( _rxStatement.is(), "ORowSet::setStatementResultSetType: invalid statement - this will crash!" ); + + sal_Int32 nResultSetType( _nDesiredResultSetType ); + sal_Int32 nResultSetConcurrency( _nDesiredResultSetConcurrency ); + + // there *might* be a data source setting which tells use to be more defensive with those settings + // #i15113# / 2005-02-10 / [EMAIL PROTECTED] + sal_Bool bRespectDriverRST = sal_False; + Any aSetting; + if ( getDataSourceSetting( ::dbaccess::getDataSource( m_xActiveConnection ), "RespectDriverResultSetType", aSetting ) ) + { + OSL_VERIFY( aSetting >>= bRespectDriverRST ); + } + + if ( bRespectDriverRST ) + { + // try type/concurrency settings with decreasing usefullness, and rely on what the connection claims + // to support + Reference< XDatabaseMetaData > xMeta( m_xActiveConnection->getMetaData() ); + + sal_Int32 nCharacteristics[5][2] = + { { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::UPDATABLE }, + { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::UPDATABLE }, + { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::READ_ONLY }, + { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::READ_ONLY }, + { ResultSetType::FORWARD_ONLY, ResultSetConcurrency::READ_ONLY } + }; + for ( sal_Int32 i=0; i<5; ++i ) + { + nResultSetType = nCharacteristics[i][0]; + nResultSetConcurrency = nCharacteristics[i][1]; + + // don't try type/concurrency pairs which are more featured than what our caller requested + if ( nResultSetType > _nDesiredResultSetType ) + continue; + if ( nResultSetConcurrency > _nDesiredResultSetConcurrency ) + continue; + + if ( xMeta.is() && xMeta->supportsResultSetConcurrency( nResultSetType, nResultSetConcurrency ) ) + break; + } + } + + _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( nResultSetType ) ); + _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, makeAny( nResultSetConcurrency ) ); +} + // ----------------------------------------------------------------------------- // XRowSet void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotification) @@ -1614,17 +1667,16 @@ { Reference<XPropertySet> xProp(m_xStatement,UNO_QUERY); + // set the result set type and concurrency try { - xProp->setPropertyValue(PROPERTY_USEBOOKMARKS,makeAny(sal_True)); - xProp->setPropertyValue(PROPERTY_RESULTSETTYPE,makeAny(ResultSetType::SCROLL_SENSITIVE)); - xProp->setPropertyValue(PROPERTY_RESULTSETCONCURRENCY,makeAny(ResultSetConcurrency::UPDATABLE)); - + xProp->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( sal_True ) ); + setStatementResultSetType( xProp, m_nResultSetType, m_nResultSetConcurrency ); } catch(Exception&) { // this exception doesn't matter here because when we catch an exception - // than the driver doesn't support this feature + // then the driver doesn't support this feature } // xProp->setPropertyValue(PROPERTY_RESULTSETTYPE,makeAny(m_nResultSetType)); // xProp->setPropertyValue(PROPERTY_RESULTSETCONCURRENCY,makeAny(m_nResultSetConcurrency)); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
