Tag: cws_src680_dba24
User: fs      
Date: 05/02/10 09:31:36

Modified:
 /dba/dbaccess/source/core/api/
  RowSet.cxx, RowSet.hxx

Log:
 #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

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.131.4.1&r2=1.131.4.2
Delta lines:  +58 -5
--------------------
--- RowSet.cxx  10 Feb 2005 16:55:20 -0000      1.131.4.1
+++ RowSet.cxx  10 Feb 2005 17:31:32 -0000      1.131.4.2
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: RowSet.cxx,v $
  *
- *  $Revision: 1.131.4.1 $
+ *  $Revision: 1.131.4.2 $
  *
- *  last change: $Author: fs $ $Date: 2005/02/10 16:55:20 $
+ *  last change: $Author: fs $ $Date: 2005/02/10 17:31:32 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -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
@@ -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)
@@ -1618,15 +1671,15 @@
                 try
                                {
                     xProp->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( 
sal_True ) );
-                    xProp->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( 
m_nResultSetType ) );
-                    xProp->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, 
makeAny( m_nResultSetConcurrency ) );
+                    setStatementResultSetType( xProp, 
ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::UPDATABLE );
                                }
                                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));
 

File [changed]: RowSet.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSet.hxx?r1=1.38&r2=1.38.20.1
Delta lines:  +12 -3
--------------------
--- RowSet.hxx  5 Jan 2005 12:26:59 -0000       1.38
+++ RowSet.hxx  10 Feb 2005 17:31:33 -0000      1.38.20.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: RowSet.hxx,v $
  *
- *  $Revision: 1.38 $
+ *  $Revision: 1.38.20.1 $
  *
- *  last change: $Author: obo $ $Date: 2005/01/05 12:26:59 $
+ *  last change: $Author: fs $ $Date: 2005/02/10 17:31:33 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -402,6 +402,15 @@
                void setActiveConnection( ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection >& _rxNewConn, sal_Bool _bFireEvent = 
sal_True );
 
                void implCancelRowUpdates( sal_Bool _bNotifyModified ) 
SAL_THROW( ( ::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException ) );
+
+        /** sets the given result set type/concurrency at the given statement, 
while respecting
+            possibly related data source settings
+        */
+        void        setStatementResultSetType(
+            const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& _rxStatement,
+            sal_Int32 _nDesiredResultSetType,
+            sal_Int32 _nDesiredResultSetConcurrency
+        );
        };
 
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to