[Libreoffice-commits] core.git: 10 commits - connectivity/source

Andrzej J.R. Hunt andrzej at ahunt.org
Thu Jul 18 07:24:15 PDT 2013


 connectivity/source/drivers/firebird/FConnection.cxx        |  109 +
 connectivity/source/drivers/firebird/FConnection.hxx        |   12 
 connectivity/source/drivers/firebird/FDatabaseMetaData.cxx  |   11 
 connectivity/source/drivers/firebird/FDriver.cxx            |    4 
 connectivity/source/drivers/firebird/FPreparedStatement.cxx |   60 
 connectivity/source/drivers/firebird/FPreparedStatement.hxx |    4 
 connectivity/source/drivers/firebird/FResultSet.cxx         |  851 ++++++------
 connectivity/source/drivers/firebird/FResultSet.hxx         |   32 
 connectivity/source/drivers/firebird/FResultSetMetaData.cxx |    2 
 connectivity/source/drivers/firebird/FResultSetMetaData.hxx |    6 
 connectivity/source/drivers/firebird/FStatement.cxx         |  604 ++++----
 connectivity/source/drivers/firebird/FStatement.hxx         |   46 
 12 files changed, 947 insertions(+), 794 deletions(-)

New commits:
commit 9064010ad5b5ac12e0c3ef085a0f0ee56add500d
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Thu Jul 18 16:15:18 2013 +0200

    Ugly/temporary hack to have SQL_SHORT working again.
    
    Change-Id: I33dda57ce5d13ef9d2aff44e2f4949aa634ff0da

diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 07b11eb..48bf0ab 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -113,9 +113,34 @@ void OResultSet::ensureDataAvailable() throw (SQLException)
             XSQLVAR* pVar = m_pSqlda->sqlvar;
             for (int i = 0; i < m_fieldCount; pVar++, i++)
             {
-                aRow[i] = OString(pVar->sqldata, pVar->sqllen);
+//                 if ((pVar->sqltype & 1) == 0) // Cannot contain NULL
+//                 {
+//                 }
+//                 else // Can contain NULL
+//                 {
+//                 }
+//                 switch (pVar->sqltype)
+//                 {
+//                 }
+                if ( pVar->sqltype == SQL_SHORT ||
+                     pVar->sqltype == SQL_SHORT + 1 ||
+                     pVar->sqltype == SQL_LONG ||
+                     pVar->sqltype == SQL_LONG + 1 ||
+                     pVar->sqltype == SQL_INT64 ||
+                     pVar->sqltype == SQL_INT64 + 1)
+                {
+                    aRow[i] = OString::valueOf((sal_Int16) *pVar->sqldata);
+                                        fprintf(stderr, "N_" );
+                    // TODO: sqlscale here.
+                }
+                else
+                {
+                    // For now store as string
+                    aRow[i] = OString(pVar->sqldata, pVar->sqllen);
+                }
             }
             m_sqlData.push_back(aRow);
+            fprintf( stderr, "\n" );
         }
 
         ISC_STATUS aErr = isc_dsql_free_statement(m_statusVector,
diff --git a/connectivity/source/drivers/firebird/FResultSet.hxx b/connectivity/source/drivers/firebird/FResultSet.hxx
index 06b8d2d..3b00fd7 100644
--- a/connectivity/source/drivers/firebird/FResultSet.hxx
+++ b/connectivity/source/drivers/firebird/FResultSet.hxx
@@ -58,8 +58,8 @@ namespace connectivity
     namespace firebird
     {
 
-        typedef std::vector< OString> TRow;
-        typedef std::vector< TRow> TTable;
+        typedef std::vector< ::rtl::OString > TRow;
+        typedef std::vector< TRow > TTable;
 
         /*
         **  OResultSet
commit 3d01edb5ed4c9eaf43b1a1d6049b5ae497372dc7
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Thu Jul 18 12:50:41 2013 +0200

    SAL_INFO in checkRowIndex spams output.
    
    Change-Id: Ie23cc727acaaa8104101c8c69d26094f90523ac5

diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 213efee..07b11eb 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -345,9 +345,6 @@ void SAL_CALL OResultSet::checkRowIndex(sal_Bool mustBeOnValidRow)
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-    SAL_INFO("connectivity.firebird", "Checking if row " << m_currentRow <<
-             "/" << m_rowCount << " is valid.");
-
     if(mustBeOnValidRow)
     {
         if((m_currentRow < 1) || (m_currentRow > m_rowCount))
commit 6fbff56dea641bb0ee27bf7c2e6d864821b856bc
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Thu Jul 18 11:23:01 2013 +0200

    Cleanup SAL_INFO debugging output.
    
    Change-Id: I7d9a94e42da24557a986a0613bcfcbf1234b952d

diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 1528783..1381dfe 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -103,14 +103,14 @@ OConnection::OConnection(FirebirdDriver*    _pDriver)
                          m_DBHandler(0),
                          m_transactionHandle(0)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::OConnection().");
+    SAL_INFO("connectivity.firebird", "OConnection().");
 
     m_pDriver->acquire();
 }
 
 OConnection::~OConnection()
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::~OConnection().");
+    SAL_INFO("connectivity.firebird", "~OConnection().");
 
     if(!isClosed())
         close();
@@ -120,7 +120,7 @@ OConnection::~OConnection()
 
 void SAL_CALL OConnection::release() throw()
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::release().");
+    SAL_INFO("connectivity.firebird", "release().");
 
     relase_ChildImpl();
 }
@@ -146,7 +146,7 @@ static int pr_error(const ISC_STATUS* status, const char* operation)
 void OConnection::construct(const ::rtl::OUString& url, const Sequence< PropertyValue >& info)
     throw(SQLException)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::construct().");
+    SAL_INFO("connectivity.firebird", "construct().");
 
     osl_atomic_increment( &m_refCount );
 
@@ -289,7 +289,7 @@ IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.firebird.OConnect
 Reference< XStatement > SAL_CALL OConnection::createStatement( )
                                         throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::createStatement().");
+    SAL_INFO("connectivity.firebird", "createStatement().");
 
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
@@ -298,7 +298,7 @@ Reference< XStatement > SAL_CALL OConnection::createStatement( )
     if(m_aTypeInfo.empty())
         buildTypeInfo();
 
-    SAL_INFO("connectivity.firebird", "=> OConnection::createStatement(). "
+    SAL_INFO("connectivity.firebird", "createStatement(). "
              "Creating statement.");
 
     // create a statement
@@ -311,7 +311,7 @@ Reference< XStatement > SAL_CALL OConnection::createStatement( )
 Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(
             const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::prepareStatement(). "
+    SAL_INFO("connectivity.firebird", "prepareStatement(). "
              "Got called with sql: " << _sSql);
 
     MutexGuard aGuard( m_aMutex );
@@ -321,7 +321,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(
     if(m_aTypeInfo.empty())
         buildTypeInfo();
 
-    SAL_INFO("connectivity.firebird", "=> OConnection::prepareStatement(). "
+    SAL_INFO("connectivity.firebird", "prepareStatement(). "
              "Creating prepared statement.");
 
     // create a statement
@@ -331,7 +331,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(
                                                                      _sSql);
     m_aStatements.push_back(WeakReferenceHelper(xReturn));
 
-    SAL_INFO("connectivity.firebird", "=> OConnection::prepareStatement(). "
+    SAL_INFO("connectivity.firebird", "prepareStatement(). "
              "Prepared Statement created.");
 
     return xReturn;
@@ -340,7 +340,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(
 Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall(
                 const OUString& _sSql ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::prepareCall(). "
+    SAL_INFO("connectivity.firebird", "prepareCall(). "
              "_sSql: " << _sSql);
 
     MutexGuard aGuard( m_aMutex );
@@ -473,7 +473,7 @@ sal_Bool SAL_CALL OConnection::isClosed(  ) throw(SQLException, RuntimeException
 // --------------------------------------------------------------------------------
 Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData(  ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::getMetaData().");
+    SAL_INFO("connectivity.firebird", "getMetaData().");
 
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
@@ -554,7 +554,7 @@ void SAL_CALL OConnection::setTypeMap(const Reference< XNameAccess >& typeMap)
 //----- XCloseable -----------------------------------------------------------
 void SAL_CALL OConnection::close(  ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::close().");
+    SAL_INFO("connectivity.firebird", "close().");
 
     // we just dispose us
     {
@@ -611,7 +611,7 @@ void SAL_CALL OConnection::disposing( const EventObject& Source ) throw (Runtime
 //--------------------------------------------------------------------
 void OConnection::buildTypeInfo() throw( SQLException)
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::buildTypeInfo().");
+    SAL_INFO("connectivity.firebird", "buildTypeInfo().");
 
     MutexGuard aGuard( m_aMutex );
 
@@ -650,7 +650,7 @@ void OConnection::buildTypeInfo() throw( SQLException)
         m_aTypeInfo.push_back(aInfo);
     }
 
-    SAL_INFO("connectivity.firebird", "=> OConnection::buildTypeInfo(). "
+    SAL_INFO("connectivity.firebird", "buildTypeInfo(). "
              "Type info built.");
 
     // Close the result set/statement.
@@ -658,13 +658,13 @@ void OConnection::buildTypeInfo() throw( SQLException)
     Reference< XCloseable> xClose(xRs,UNO_QUERY);
     xClose->close();
 
-    SAL_INFO("connectivity.firebird", "=> OConnection::buildTypeInfo(). "
+    SAL_INFO("connectivity.firebird", "buildTypeInfo(). "
              "Closed.");
 }
 //------------------------------------------------------------------------------
 void OConnection::disposing()
 {
-    SAL_INFO("connectivity.firebird", "=> OConnection::disposing().");
+    SAL_INFO("connectivity.firebird", "disposing().");
 
     // we noticed that we should be destroied in near future so we have to dispose our statements
     MutexGuard aGuard(m_aMutex);
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
index 71e2181..081626d 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
@@ -788,7 +788,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes(  ) throw(SQLE
 // -------------------------------------------------------------------------
 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo(  ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> ODatabaseMetaData::getTypeInfo().");
+    SAL_INFO("connectivity.firebird", "getTypeInfo().");
 
     // this returns an empty resultset where the column-names are already set
     // in special the metadata of the resultset already returns the right columns
@@ -861,7 +861,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
 {
     (void) catalog;
     (void) types;
-    SAL_INFO("connectivity.firebird", "=> ODatabaseMetaData::getTables(). "
+    SAL_INFO("connectivity.firebird", "getTables(). "
              "Got called with schemaPattern: " << schemaPattern << " , "
              "TableNamePattern: " << tableNamePattern);
 
@@ -893,7 +893,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
         query = query.replaceAll(wld, tableNamePattern);
     }
 
-    SAL_INFO("connectivity.firebird", "=> ODatabaseMetaData::getTables(). "
+    SAL_INFO("connectivity.firebird", "getTables(). "
              "About to execute the query.");
 
     Reference< XResultSet > rs = statement->executeQuery(query.getStr());
diff --git a/connectivity/source/drivers/firebird/FDriver.cxx b/connectivity/source/drivers/firebird/FDriver.cxx
index be2c3d3..e8df069 100644
--- a/connectivity/source/drivers/firebird/FDriver.cxx
+++ b/connectivity/source/drivers/firebird/FDriver.cxx
@@ -59,7 +59,7 @@ namespace connectivity
         Reference< XInterface >  SAL_CALL FirebirdDriver_CreateInstance(
             const Reference< XMultiServiceFactory >& _rxFactory) throw( Exception )
         {
-            SAL_INFO("connectivity.firebird", "=> ODriver_BASE::FirebirdDriver_CreateInstance()" );
+            SAL_INFO("connectivity.firebird", "FirebirdDriver_CreateInstance()" );
             (void) _rxFactory;
             return *(new FirebirdDriver());
         }
@@ -131,7 +131,7 @@ Reference< XConnection > SAL_CALL FirebirdDriver::connect(
 {
     Reference< XConnection > xConnection;
 
-    SAL_INFO("connectivity.firebird", "=> ODriver_BASE::connect(), URL: " << url );
+    SAL_INFO("connectivity.firebird", "connect(), URL: " << url );
 
     MutexGuard aGuard( m_aMutex );
     if (ODriver_BASE::rBHelper.bDisposed)
diff --git a/connectivity/source/drivers/firebird/FPreparedStatement.cxx b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
index 8f3c7b3..168b000 100644
--- a/connectivity/source/drivers/firebird/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
@@ -71,7 +71,7 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,
     ,m_sSqlStatement(sql)
     ,m_bPrepared(sal_False)
 {
-    SAL_INFO("connectivity.firebird", "=> OPreparedStatement::OPreparedStatement_BASE(). "
+    SAL_INFO("connectivity.firebird", "OPreparedStatement_BASE(). "
              "sql: " << sql);
 
 //     prepareQuery(m_sSqlStatement);
@@ -120,7 +120,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData(  ) thr
 
 void SAL_CALL OPreparedStatement::close(  ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OPreparedStatement::close()");
+    SAL_INFO("connectivity.firebird", "close()");
 
     ::osl::MutexGuard aGuard( m_aMutex );
     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
@@ -164,7 +164,7 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate(  ) throw(SQLException, Run
 
 void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OPreparedStatement::setString(). "
+    SAL_INFO("connectivity.firebird", "setString(). "
              "parameterIndex: " << parameterIndex << " , "
              "x: " << x);
 
@@ -173,13 +173,13 @@ void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::r
 
     if (NULL == m_INsqlda)
     {
-        SAL_WARN("connectivity.firebird", "=> OPreparedStatement::setString(). "
+        SAL_WARN("connectivity.firebird", "setString(). "
                  "The query has not input parameters.");
         return;
     }
 
     OString str = OUStringToOString(x , RTL_TEXTENCODING_UTF8 );
-    SAL_INFO("connectivity.firebird", "=> OPreparedStatement::setString(). "
+    SAL_INFO("connectivity.firebird", "setString(). "
              "Setting parameter as: " << str);
 
     XSQLVAR *var = m_INsqlda->sqlvar + (parameterIndex - 1);
@@ -212,7 +212,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection(  ) throw(SQ
 
 Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery(  ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OPreparedStatement::executeQuery(). "
+    SAL_INFO("connectivity.firebird", "executeQuery(). "
              "Got called with sql: " <<  m_sSqlStatement);
 
     ::osl::MutexGuard aGuard( m_aMutex );
@@ -229,7 +229,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery(  ) throw(SQLE
     //initializeResultSet( pResult.get() );
     Reference< XResultSet > xRS = pResult.get();
 
-    SAL_INFO("connectivity.firebird", "=> OPreparedStatement::executeQuery(). "
+    SAL_INFO("connectivity.firebird", "executeQuery(). "
              "Query executed.");
 
     return xRS;
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 5260f09..213efee 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -78,7 +78,7 @@ OResultSet::OResultSet(const uno::Reference< XStatement >& xStatement,
     , m_rowCount(0)
     , m_fieldCount(pSqlda? pSqlda->sqld : 0)
 {
-    SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet().");
+    SAL_INFO("connectivity.firebird", "OResultSet().");
 
     if (!pSqlda)
         return; // TODO: what?
@@ -366,7 +366,7 @@ void SAL_CALL OResultSet::checkRowIndex(sal_Bool mustBeOnValidRow)
 // -------------------------------------------------------------------------
 void OResultSet::disposing(void)
 {
-    SAL_INFO("connectivity.firebird", "=> OResultSet::disposing().");
+    SAL_INFO("connectivity.firebird", "disposing().");
 
     OPropertySetHelper::disposing();
 
@@ -666,7 +666,7 @@ DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLExc
 
 void SAL_CALL OResultSet::close(  ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OResultSet::close().");
+    SAL_INFO("connectivity.firebird", "close().");
 
     {
         MutexGuard aGuard( m_aMutex );
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index 366f273..728b9c8 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -100,7 +100,7 @@ void OStatement_Base::disposeResultSet()
 
 void OStatement_BASE2::disposing()
 {
-    SAL_INFO("connectivity.firebird", "=> OStatement_BASE2::disposing().");
+    SAL_INFO("connectivity.firebird", "disposing().");
 
     MutexGuard aGuard(m_aMutex);
 
@@ -163,7 +163,7 @@ void SAL_CALL OStatement_Base::cancel(  ) throw(RuntimeException)
 
 void SAL_CALL OStatement_Base::close(  ) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OStatement_Base::close().");
+    SAL_INFO("connectivity.firebird", "close().");
 
     {
         MutexGuard aGuard( m_aMutex );
@@ -212,7 +212,7 @@ OUString OStatement_Base::sanitizeSqlString(const OUString& sqlIn)
 {
     // TODO: verify this is all we need.
     static const sal_Unicode pattern('"');
-    static const sal_Unicode empty(' ');
+    static const sal_Unicode empty('\'');
     return sqlIn.replace(pattern, empty);
 }
 
@@ -387,7 +387,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery(const OUStri
 
 sal_Bool SAL_CALL OStatement_Base::execute(const OUString& sql) throw(SQLException, RuntimeException)
 {
-    SAL_INFO("connectivity.firebird", "=> OStatement_Base::executeQuery(). "
+    SAL_INFO("connectivity.firebird", "executeQuery(). "
              "Got called with sql: " << sql);
 
     MutexGuard aGuard( m_aMutex );
commit e63194a8a22d68746affa9c3930443ce47a84f2f
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Thu Jul 18 10:59:11 2013 +0200

    Implement retrieval of basic types from firebird.
    
    Change-Id: If8f78d83544e92a429ad5e5e5f2ff673b7f0b2fb

diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 72eb41f..5260f09 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -39,6 +39,7 @@
 
 #include <comphelper/sequence.hxx>
 #include <cppuhelper/typeprovider.hxx>
+#include <rtl/string.hxx>
 #include <rtl/ustrbuf.hxx>
 
 #include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -95,7 +96,7 @@ void OResultSet::ensureDataAvailable() throw (SQLException)
 
     if (!m_bIsPopulated)
     {
-
+        SAL_INFO("connectivity.firebird", "Iterating over data cursor");
         ISC_STATUS fetchStat;
 
         // Firebird doesn't support scrollable cursors so we have to load everything
@@ -112,9 +113,9 @@ void OResultSet::ensureDataAvailable() throw (SQLException)
             XSQLVAR* pVar = m_pSqlda->sqlvar;
             for (int i = 0; i < m_fieldCount; pVar++, i++)
             {
-                aRow[i] = OUString(pVar->sqldata, pVar->sqllen, RTL_TEXTENCODING_UTF8);
+                aRow[i] = OString(pVar->sqldata, pVar->sqllen);
             }
-            m_sqldata.push_back(aRow);
+            m_sqlData.push_back(aRow);
         }
 
         ISC_STATUS aErr = isc_dsql_free_statement(m_statusVector,
@@ -124,14 +125,28 @@ void OResultSet::ensureDataAvailable() throw (SQLException)
 
         // fetchstat == 100L if fetching of data completed successfully.
         if ((fetchStat != 100L) || aErr)
+        {
+            SAL_WARN("connectivity.firebird", "Error when populating data");
             OConnection::evaluateStatusVector(m_statusVector,
                                               "isc_dsql_free_statement",
                                               *this);
+        }
 
+        SAL_INFO("connectivity.firebird", "Populated dataset with " << m_rowCount << " rows.");
         m_bIsPopulated = true;
     }
 }
 
+const OString& OResultSet::getSqlData(sal_Int32 aRow, sal_Int32 aColumn)
+    throw(SQLException)
+{
+    // Validate input (throws Exceptions as appropriate)
+    checkRowIndex(aRow);
+    checkColumnIndex(aColumn);
+
+    return m_sqlData[aRow-1][aColumn-1];
+}
+
 // ---- XResultSet -- Row retrieval methods ------------------------------------
 sal_Int32 SAL_CALL OResultSet::getRow() throw(SQLException, RuntimeException)
 {
@@ -147,7 +162,7 @@ sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException)
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-    if (m_currentRow <= m_rowCount)
+    if (m_currentRow < m_rowCount)
     {
         m_currentRow++;
         return sal_True;
@@ -324,22 +339,25 @@ void SAL_CALL OResultSet::checkColumnIndex(sal_Int32 index ) throw ( SQLExceptio
     }
 }
 
-void SAL_CALL OResultSet::checkRowIndex( sal_Bool mustBeOnValidRow )
+void SAL_CALL OResultSet::checkRowIndex(sal_Bool mustBeOnValidRow)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-    if( mustBeOnValidRow )
+    SAL_INFO("connectivity.firebird", "Checking if row " << m_currentRow <<
+             "/" << m_rowCount << " is valid.");
+
+    if(mustBeOnValidRow)
     {
-        if( m_currentRow < 0 || m_currentRow >= m_rowCount )
+        if((m_currentRow < 1) || (m_currentRow > m_rowCount))
         {
             throw SQLException( "Row index is out of valid range.", *this, OUString(),1, Any() );
         }
     }
     else
     {
-        if( m_currentRow < -1 || m_currentRow > m_rowCount )
+        if((m_currentRow < 0) || (m_currentRow > 1 + m_rowCount))
         {
             throw SQLException( "Row index is invalid", *this, OUString(),1, Any() );
         }
@@ -417,14 +435,27 @@ uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int3
     return NULL;
 }
 
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 columnIndex)
+    throw(SQLException, RuntimeException)
 {
-    (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
+    const OString& aData = getSqlData(m_currentRow,columnIndex);
+
+    if(aData.getLength())
+    {
+        switch(aData[0])
+        {
+        case '1':
+        case 't':
+        case 'T':
+        case 'y':
+        case 'Y':
+            return sal_True;
+        }
+    }
     return sal_False;
 }
 // -------------------------------------------------------------------------
@@ -464,56 +495,51 @@ Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, R
     Date nRet;
     return nRet;
 }
-// -------------------------------------------------------------------------
 
-double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+double SAL_CALL OResultSet::getDouble(sal_Int32 columnIndex)
+    throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-
-    double nRet = 0;
-    return nRet;
+    const OString& aData = getSqlData(m_currentRow,columnIndex);
+    return aData.toDouble();
 }
-// -------------------------------------------------------------------------
 
-float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+float SAL_CALL OResultSet::getFloat(sal_Int32 columnIndex)
+    throw(SQLException, RuntimeException)
 {
-    (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-
-    float nVal(0);
-    return nVal;
+    const OString& aData = getSqlData(m_currentRow,columnIndex);
+    return aData.toFloat();
 }
-// -------------------------------------------------------------------------
 
-sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+sal_Int32 SAL_CALL OResultSet::getInt(sal_Int32 columnIndex)
+    throw(SQLException, RuntimeException)
 {
-    (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-    sal_Int32 nRet=0;
-    return nRet;
+    // TODO: check in the sqlda somehow?
+    const OString& aData = getSqlData(m_currentRow,columnIndex);
+    return aData.toInt32();
 }
 
-
-// -------------------------------------------------------------------------
-
-sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+sal_Int64 SAL_CALL OResultSet::getLong(sal_Int32 columnIndex)
+    throw(SQLException, RuntimeException)
 {
-    (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-    return sal_Int64();
+    const OString& aData = getSqlData(m_currentRow,columnIndex);
+    return aData.toInt64();
 }
 // -------------------------------------------------------------------------
 
@@ -583,22 +609,20 @@ Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const uno::Reference<
 
     return Any();
 }
-// -------------------------------------------------------------------------
 
-sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+sal_Int16 SAL_CALL OResultSet::getShort(sal_Int32 columnIndex)
+    throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     ensureDataAvailable();
 
-    char *str = strdup(OUStringToOString(m_sqldata[m_currentRow][columnIndex-1] , RTL_TEXTENCODING_UTF8 ).getStr());
-
-    sal_Int16 nRet= *str;
-    return nRet;
+    const OString& aData = getSqlData(m_currentRow,columnIndex);
+    return aData.toInt32();
 }
-// -------------------------------------------------------------------------
 
-OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+OUString SAL_CALL OResultSet::getString(sal_Int32 columnIndex)
+    throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -606,7 +630,8 @@ OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLExcept
     checkColumnIndex( columnIndex );
     checkRowIndex( sal_True /* must be on row */ );
 
-    return m_sqldata[m_currentRow][columnIndex-1];
+    return OStringToOUString(getSqlData(m_currentRow,columnIndex),
+                             RTL_TEXTENCODING_UTF8);
 }
 // -------------------------------------------------------------------------
 
@@ -652,7 +677,8 @@ void SAL_CALL OResultSet::close(  ) throw(SQLException, RuntimeException)
 }
 
 
-uno::Reference< XInterface > SAL_CALL OResultSet::getStatement() throw(SQLException, RuntimeException)
+uno::Reference< XInterface > SAL_CALL OResultSet::getStatement()
+    throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
diff --git a/connectivity/source/drivers/firebird/FResultSet.hxx b/connectivity/source/drivers/firebird/FResultSet.hxx
index 9367170..06b8d2d 100644
--- a/connectivity/source/drivers/firebird/FResultSet.hxx
+++ b/connectivity/source/drivers/firebird/FResultSet.hxx
@@ -58,7 +58,7 @@ namespace connectivity
     namespace firebird
     {
 
-        typedef std::vector< OUString> TRow;
+        typedef std::vector< OString> TRow;
         typedef std::vector< TRow> TTable;
 
         /*
@@ -96,10 +96,13 @@ namespace connectivity
             sal_Int32                                   m_currentRow;
             sal_Int32                                   m_rowCount;
             const sal_Int32                             m_fieldCount;
-            TTable                                      m_sqldata;
+            TTable                                      m_sqlData;
             ISC_STATUS_ARRAY                            m_statusVector;
 
-            void ensureDataAvailable() throw (::com::sun::star::sdbc::SQLException);
+            void ensureDataAvailable()
+                throw (::com::sun::star::sdbc::SQLException);
+            const OString& getSqlData(sal_Int32 aRow, sal_Int32 aColumn)
+                throw (::com::sun::star::sdbc::SQLException);
 
             // OPropertyArrayUsageHelper
             virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
commit fefd6fbab1d4666a2872bc38d98e832f05398359
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Thu Jul 18 09:54:11 2013 +0200

    Move data retrieval/resultset population from constructor to on-demand.
    
    Change-Id: Ie380ffb07d7246923304de0b43f41015182ee05a

diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index c75a00c..72eb41f 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -71,6 +71,7 @@ OResultSet::OResultSet(const uno::Reference< XStatement >& xStatement,
     , m_xMetaData(NULL)
     , m_pSqlda(pSqlda)
     , m_statementHandle(aStatementHandle)
+    , m_bIsPopulated(sal_False)
     , m_bWasNull(sal_True)
     , m_currentRow(0)
     , m_rowCount(0)
@@ -81,60 +82,60 @@ OResultSet::OResultSet(const uno::Reference< XStatement >& xStatement,
     if (!pSqlda)
         return; // TODO: what?
 
-    // Load data into memory here...
-  // status vector
-//     ISC_STATUS aErr = 0;
-//     int j = 0;
-//     while ((retcode = isc_dsql_fetch(status, &aStatementHandle, 1, pSqlda)) == 0)
-//     {
-//         m_rowCount++;
-//
-//         TRow row(m_fieldCount);
-//         XSQLVAR *var = NULL;
-//         for (j=0, var = pSqlda->sqlvar; j < m_fieldCount; j++, var++)
-//         {
-//             row[j] = OUString(var->sqldata, var->sqllen, RTL_TEXTENCODING_UTF8);
-//         }
-//         m_sqldata.push_back(row);
-//     }
-//     if (retcode != 100L)
-//     {
-//         SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet(). "
-//                  "Retcode: " << retcode);
-//         if (pr_error(status, "fetch data"))
-//             return;
-//     }
-//     if (isc_dsql_free_statement(status, &stmt, DSQL_close))
-//         if (pr_error(status, "free statement"))
-//             return;
-
-
-
-//     ISC_STATUS fetchStat = isc_dsql_fetch(m_statusVector,
-//                                           &m_statementHandle,
-//                                           1,
-//                                           m_pSqlda);
-//     if (fetchStat == 0)
-//         return true;
-//     else if (fetchStat == 100L) // No more rows to be retrieved
-//         return false;
-//     else
-//     {
-//         // Processes error and throws exception
-//         OConnection::evaluateStatusVector(m_statusVector, "OResultSet::next()", *this);
-//         return false;
-//     }
-        // TODO: isc_dsql_free_statement  -- probably better in the dispsoe method
 }
 
 OResultSet::~OResultSet()
 {
 }
 
+void OResultSet::ensureDataAvailable() throw (SQLException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if (!m_bIsPopulated)
+    {
+
+        ISC_STATUS fetchStat;
+
+        // Firebird doesn't support scrollable cursors so we have to load everything
+        // into memory. Can't really be done on demand as we need to determine the
+        // number of rows which can only be done by iterating over the XSQLDA
+        while ( 0 == (fetchStat = isc_dsql_fetch(m_statusVector,
+                                                 &m_statementHandle,
+                                                 1,
+                                                 m_pSqlda)))
+        {
+            m_rowCount++;
+
+            TRow aRow(m_fieldCount);
+            XSQLVAR* pVar = m_pSqlda->sqlvar;
+            for (int i = 0; i < m_fieldCount; pVar++, i++)
+            {
+                aRow[i] = OUString(pVar->sqldata, pVar->sqllen, RTL_TEXTENCODING_UTF8);
+            }
+            m_sqldata.push_back(aRow);
+        }
+
+        ISC_STATUS aErr = isc_dsql_free_statement(m_statusVector,
+                                                  &m_statementHandle,
+                                                  DSQL_drop);
+        // TODO: cleanup the XSQLDA, probably in the destructor?
+
+        // fetchstat == 100L if fetching of data completed successfully.
+        if ((fetchStat != 100L) || aErr)
+            OConnection::evaluateStatusVector(m_statusVector,
+                                              "isc_dsql_free_statement",
+                                              *this);
+
+        m_bIsPopulated = true;
+    }
+}
+
 // ---- XResultSet -- Row retrieval methods ------------------------------------
 sal_Int32 SAL_CALL OResultSet::getRow() throw(SQLException, RuntimeException)
 {
-    MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard(m_aMutex);
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return m_currentRow;
@@ -142,8 +143,9 @@ sal_Int32 SAL_CALL OResultSet::getRow() throw(SQLException, RuntimeException)
 
 sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException)
 {
-    MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard(m_aMutex);
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     if (m_currentRow <= m_rowCount)
     {
@@ -156,10 +158,11 @@ sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException)
     }
 }
 
-sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException)
+sal_Bool SAL_CALL OResultSet::previous() throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     if (m_currentRow > 0)
     {
@@ -184,6 +187,7 @@ sal_Bool SAL_CALL OResultSet::isAfterLast() throw(SQLException, RuntimeException
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return m_currentRow > m_rowCount;
 }
@@ -192,6 +196,7 @@ sal_Bool SAL_CALL OResultSet::isFirst() throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return m_currentRow == 1 && m_rowCount;
 }
@@ -200,6 +205,7 @@ sal_Bool SAL_CALL OResultSet::isLast() throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return (m_currentRow > 0) && (m_currentRow == m_rowCount);
 }
@@ -217,6 +223,7 @@ void SAL_CALL OResultSet::afterLast() throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     m_currentRow = m_rowCount + 1;
 }
@@ -225,6 +232,7 @@ sal_Bool SAL_CALL OResultSet::first() throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     if (m_rowCount > 0)
     {
@@ -241,6 +249,7 @@ sal_Bool SAL_CALL OResultSet::last() throw(SQLException, RuntimeException)
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     if (m_rowCount > 0)
     {
@@ -257,6 +266,8 @@ sal_Bool SAL_CALL OResultSet::absolute(sal_Int32 aRow) throw(SQLException, Runti
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
+
     if (m_rowCount > 0)
     {
         if( aRow > 0 )
@@ -283,6 +294,7 @@ sal_Bool SAL_CALL OResultSet::relative(sal_Int32 row) throw(SQLException, Runtim
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     if (m_rowCount > 0)
     {
@@ -316,6 +328,7 @@ void SAL_CALL OResultSet::checkRowIndex( sal_Bool mustBeOnValidRow )
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     if( mustBeOnValidRow )
     {
@@ -387,6 +400,7 @@ uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 c
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     return NULL;
@@ -397,6 +411,7 @@ uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int3
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     return NULL;
@@ -408,6 +423,7 @@ sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLExcep
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return sal_False;
 }
@@ -418,6 +434,7 @@ sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLExceptio
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     sal_Int8 nRet = 0;
@@ -429,6 +446,7 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) thro
 {
     (void) columnIndex;
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
     MutexGuard aGuard( m_aMutex );
 
     return Sequence< sal_Int8 >();
@@ -440,6 +458,7 @@ Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, R
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     Date nRet;
@@ -452,6 +471,7 @@ double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLExceptio
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     double nRet = 0;
@@ -464,6 +484,7 @@ float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException,
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     float nVal(0);
@@ -476,6 +497,7 @@ sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLExceptio
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     sal_Int32 nRet=0;
     return nRet;
@@ -489,6 +511,7 @@ sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLExcepti
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return sal_Int64();
 }
@@ -498,6 +521,7 @@ uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     if(!m_xMetaData.is())
@@ -510,6 +534,7 @@ uno::Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex )
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return NULL;
 }
@@ -521,6 +546,7 @@ uno::Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) th
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return NULL;
 }
@@ -530,6 +556,7 @@ uno::Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) th
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return NULL;
 }
@@ -540,6 +567,7 @@ uno::Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) thro
     (void) columnIndex;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return NULL;
 }
@@ -551,6 +579,7 @@ Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const uno::Reference<
     (void) typeMap;
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     return Any();
 }
@@ -560,6 +589,7 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     char *str = strdup(OUStringToOString(m_sqldata[m_currentRow][columnIndex-1] , RTL_TEXTENCODING_UTF8 ).getStr());
 
@@ -572,6 +602,7 @@ OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLExcept
 {
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
     checkColumnIndex( columnIndex );
     checkRowIndex( sal_True /* must be on row */ );
 
@@ -583,6 +614,7 @@ Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, R
 {
     (void) columnIndex;
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
     MutexGuard aGuard( m_aMutex );
 
@@ -596,6 +628,7 @@ DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLExc
 {
     (void) columnIndex;
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    ensureDataAvailable();
 
 
     MutexGuard aGuard( m_aMutex );
diff --git a/connectivity/source/drivers/firebird/FResultSet.hxx b/connectivity/source/drivers/firebird/FResultSet.hxx
index 0efc5d4..9367170 100644
--- a/connectivity/source/drivers/firebird/FResultSet.hxx
+++ b/connectivity/source/drivers/firebird/FResultSet.hxx
@@ -89,15 +89,18 @@ namespace connectivity
 
             XSQLDA*                                     m_pSqlda;
             isc_stmt_handle                             m_statementHandle;
+            sal_Bool                                    m_bIsPopulated;
 
             sal_Bool                                    m_bWasNull;
-            // Row numberign starts with 0 for "in front of first row"
+            // Row numbering starts with 0 for "in front of first row"
             sal_Int32                                   m_currentRow;
-            const sal_Int32                             m_rowCount;
+            sal_Int32                                   m_rowCount;
             const sal_Int32                             m_fieldCount;
             TTable                                      m_sqldata;
             ISC_STATUS_ARRAY                            m_statusVector;
 
+            void ensureDataAvailable() throw (::com::sun::star::sdbc::SQLException);
+
             // OPropertyArrayUsageHelper
             virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
             // OPropertySetHelper
@@ -133,7 +136,6 @@ namespace connectivity
                        isc_stmt_handle& aStatementHandle,
                        XSQLDA* aSqlda);
 
-
             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
             {
                 return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this);
commit 630c95503ccadd0d4912fa3a8ed2ff0c9538da08
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Thu Jul 18 08:57:15 2013 +0200

    Refactor row number access.
    
    Change-Id: I876c4ee1a0d5daed5ff9ed09b4d37babb0029612

diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index ee31c39..1528783 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -692,7 +692,8 @@ void OConnection::disposing()
 }
 
 void SAL_CALL OConnection::evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector,
-                                                 const OUString& aCause )
+                                                 const OUString& aCause,
+                                                 const uno::Reference< XInterface >& _rxContext)
     throw(SQLException)
 {
     if (aStatusVector[0]==1 && aStatusVector[1]) // indicates error
@@ -713,7 +714,7 @@ void SAL_CALL OConnection::evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector
         OUString error = buf.makeStringAndClear();
         SAL_WARN( "connectivity.firebird", error );
 
-        throw SQLException( error, *this, OUString(), 1, Any() );
+        throw SQLException( error, _rxContext, OUString(), 1, Any() );
     }
 }
 
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index a7411c3..1942821 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -181,8 +181,9 @@ namespace connectivity
              * Evaluate a firebird status vector and throw exceptions as necessary.
              * The content of the status vector is included in the thrown exception.
              */
-            void evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector,
-                                       const ::rtl::OUString& aCause )
+            static void evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector,
+                                       const ::rtl::OUString& aCause,
+                                       const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext)
                 throw (::com::sun::star::sdbc::SQLException);
         };
     }
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 8861577..c75a00c 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -49,6 +49,7 @@
 using namespace ::comphelper;
 using namespace ::connectivity::firebird;
 using namespace ::cppu;
+using namespace ::osl;
 using namespace ::rtl;
 
 using namespace ::com::sun::star;
@@ -69,47 +70,267 @@ OResultSet::OResultSet(const uno::Reference< XStatement >& xStatement,
     , m_xStatement(xStatement)
     , m_xMetaData(NULL)
     , m_pSqlda(pSqlda)
+    , m_statementHandle(aStatementHandle)
     , m_bWasNull(sal_True)
-    , m_row(-1)
+    , m_currentRow(0)
     , m_rowCount(0)
-    , m_fieldCount(0)
+    , m_fieldCount(pSqlda? pSqlda->sqld : 0)
 {
     SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet().");
 
     if (!pSqlda)
         return; // TODO: what?
 
-    m_fieldCount = pSqlda->sqld;
+    // Load data into memory here...
+  // status vector
+//     ISC_STATUS aErr = 0;
+//     int j = 0;
+//     while ((retcode = isc_dsql_fetch(status, &aStatementHandle, 1, pSqlda)) == 0)
+//     {
+//         m_rowCount++;
+//
+//         TRow row(m_fieldCount);
+//         XSQLVAR *var = NULL;
+//         for (j=0, var = pSqlda->sqlvar; j < m_fieldCount; j++, var++)
+//         {
+//             row[j] = OUString(var->sqldata, var->sqllen, RTL_TEXTENCODING_UTF8);
+//         }
+//         m_sqldata.push_back(row);
+//     }
+//     if (retcode != 100L)
+//     {
+//         SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet(). "
+//                  "Retcode: " << retcode);
+//         if (pr_error(status, "fetch data"))
+//             return;
+//     }
+//     if (isc_dsql_free_statement(status, &stmt, DSQL_close))
+//         if (pr_error(status, "free statement"))
+//             return;
+
 
-    ISC_STATUS_ARRAY status;  // status vector
-    ISC_STATUS retcode;
-    int j = 0;
-    while ((retcode = isc_dsql_fetch(status, &aStatementHandle, 1, pSqlda)) == 0)
+
+//     ISC_STATUS fetchStat = isc_dsql_fetch(m_statusVector,
+//                                           &m_statementHandle,
+//                                           1,
+//                                           m_pSqlda);
+//     if (fetchStat == 0)
+//         return true;
+//     else if (fetchStat == 100L) // No more rows to be retrieved
+//         return false;
+//     else
+//     {
+//         // Processes error and throws exception
+//         OConnection::evaluateStatusVector(m_statusVector, "OResultSet::next()", *this);
+//         return false;
+//     }
+        // TODO: isc_dsql_free_statement  -- probably better in the dispsoe method
+}
+
+OResultSet::~OResultSet()
+{
+}
+
+// ---- XResultSet -- Row retrieval methods ------------------------------------
+sal_Int32 SAL_CALL OResultSet::getRow() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    return m_currentRow;
+}
+
+sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if (m_currentRow <= m_rowCount)
+    {
+        m_currentRow++;
+        return sal_True;
+    }
+    else
     {
-        m_rowCount++;
+        return sal_False;
+    }
+}
+
+sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if (m_currentRow > 0)
+    {
+        m_currentRow--;
+        return sal_True;
+    }
+    else
+    {
+        return sal_False;
+    }
+}
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    return m_currentRow == 0;
+}
+
+sal_Bool SAL_CALL OResultSet::isAfterLast() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    return m_currentRow > m_rowCount;
+}
+
+sal_Bool SAL_CALL OResultSet::isFirst() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    return m_currentRow == 1 && m_rowCount;
+}
+
+sal_Bool SAL_CALL OResultSet::isLast() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    return (m_currentRow > 0) && (m_currentRow == m_rowCount);
+}
 
-        TRow row(m_fieldCount);
-        XSQLVAR *var = NULL;
-        for (j=0, var = pSqlda->sqlvar; j < m_fieldCount; j++, var++)
+// Move to front
+void SAL_CALL OResultSet::beforeFirst() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    m_currentRow = 0;
+}
+// Move to back
+void SAL_CALL OResultSet::afterLast() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    m_currentRow = m_rowCount + 1;
+}
+
+sal_Bool SAL_CALL OResultSet::first() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if (m_rowCount > 0)
+    {
+        m_currentRow = 1;
+        return sal_True;
+    }
+    else
+    {
+        return sal_False;
+    }
+}
+
+sal_Bool SAL_CALL OResultSet::last() throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if (m_rowCount > 0)
+    {
+        m_currentRow = m_rowCount;
+        return sal_True;
+    }
+    else
+    {
+        return sal_False;
+    }
+}
+
+sal_Bool SAL_CALL OResultSet::absolute(sal_Int32 aRow) throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    if (m_rowCount > 0)
+    {
+        if( aRow > 0 )
         {
-            row[j] = OUString(var->sqldata, var->sqllen, RTL_TEXTENCODING_UTF8);
+            m_currentRow = aRow;
+            if( m_currentRow > m_rowCount )
+                m_currentRow = m_rowCount + 1;
         }
-        m_sqldata.push_back(row);
+        else
+        {
+            m_currentRow = m_rowCount + 1 + aRow;
+            if( m_currentRow < 0 )
+                m_currentRow = 0;
+        }
+        return sal_True;
     }
-    if (retcode != 100L)
+    else
     {
-        SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet(). "
-                 "Retcode: " << retcode);
-//         if (pr_error(status, "fetch data"))
-//             return;
+        return sal_False;
     }
-//     if (isc_dsql_free_statement(status, &stmt, DSQL_close))
-//         if (pr_error(status, "free statement"))
-//             return;
 }
 
-OResultSet::~OResultSet()
+sal_Bool SAL_CALL OResultSet::relative(sal_Int32 row) throw(SQLException, RuntimeException)
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if (m_rowCount > 0)
+    {
+        m_currentRow += row;
+
+        if( m_currentRow > m_rowCount )
+            m_currentRow = m_rowCount + 1;
+        else if ( m_currentRow < -1 )
+            m_currentRow = -1;
+
+        return sal_True;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+void SAL_CALL OResultSet::checkColumnIndex(sal_Int32 index ) throw ( SQLException, RuntimeException )
+{
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if( index < 1 || index > m_fieldCount )
+    {
+        throw SQLException( "Column Index is outwith valid range", *this, OUString(), 1, Any() );
+    }
+}
+
+void SAL_CALL OResultSet::checkRowIndex( sal_Bool mustBeOnValidRow )
 {
+    MutexGuard aGuard( m_aMutex );
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+    if( mustBeOnValidRow )
+    {
+        if( m_currentRow < 0 || m_currentRow >= m_rowCount )
+        {
+            throw SQLException( "Row index is out of valid range.", *this, OUString(),1, Any() );
+        }
+    }
+    else
+    {
+        if( m_currentRow < -1 || m_currentRow > m_rowCount )
+        {
+            throw SQLException( "Row index is invalid", *this, OUString(),1, Any() );
+        }
+    }
 }
 // -------------------------------------------------------------------------
 void OResultSet::disposing(void)
@@ -118,7 +339,7 @@ void OResultSet::disposing(void)
 
     OPropertySetHelper::disposing();
 
-    ::osl::MutexGuard aGuard(m_aMutex);
+    MutexGuard aGuard(m_aMutex);
 
     m_xMetaData     = NULL;
 }
@@ -149,7 +370,7 @@ sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName ) throw(SQ
 
     // find the first column with the name columnName
 
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
 
     uno::Reference< XResultSetMetaData > xMeta = getMetaData();
     sal_Int32 nLen = xMeta->getColumnCount();
@@ -164,7 +385,7 @@ sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName ) throw(SQ
 uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -174,7 +395,7 @@ uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 c
 uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -185,7 +406,7 @@ uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int3
 sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return sal_False;
@@ -195,7 +416,7 @@ sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLExcep
 sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -208,7 +429,7 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) thro
 {
     (void) columnIndex;
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
 
     return Sequence< sal_Int8 >();
 }
@@ -217,7 +438,7 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) thro
 Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -229,7 +450,7 @@ Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, R
 double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -241,7 +462,7 @@ double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLExceptio
 float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -253,27 +474,20 @@ float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException,
 sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     sal_Int32 nRet=0;
     return nRet;
 }
-// -------------------------------------------------------------------------
 
-sal_Int32 SAL_CALL OResultSet::getRow(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
-    return m_row +1;
-}
 // -------------------------------------------------------------------------
 
 sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return sal_Int64();
@@ -282,7 +496,7 @@ sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLExcepti
 
 uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -294,7 +508,7 @@ uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(
 uno::Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return NULL;
@@ -305,7 +519,7 @@ uno::Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex )
 uno::Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return NULL;
@@ -314,7 +528,7 @@ uno::Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) th
 uno::Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return NULL;
@@ -324,7 +538,7 @@ uno::Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) th
 uno::Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return NULL;
@@ -335,7 +549,7 @@ Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const uno::Reference<
 {
     (void) columnIndex;
     (void) typeMap;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return Any();
@@ -344,10 +558,10 @@ Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const uno::Reference<
 
 sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
-    char *str = strdup(OUStringToOString(m_sqldata[m_row][columnIndex-1] , RTL_TEXTENCODING_UTF8 ).getStr());
+    char *str = strdup(OUStringToOString(m_sqldata[m_currentRow][columnIndex-1] , RTL_TEXTENCODING_UTF8 ).getStr());
 
     sal_Int16 nRet= *str;
     return nRet;
@@ -356,12 +570,12 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept
 
 OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     checkColumnIndex( columnIndex );
     checkRowIndex( sal_True /* must be on row */ );
 
-    return m_sqldata[m_row][columnIndex-1];
+    return m_sqldata[m_currentRow][columnIndex-1];
 }
 // -------------------------------------------------------------------------
 
@@ -370,7 +584,7 @@ Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, R
     (void) columnIndex;
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
 
     Time nRet;
     return nRet;
@@ -384,60 +598,12 @@ DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLExc
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
 
     DateTime nRet;
     return nRet;
 }
-// -------------------------------------------------------------------------
 
-sal_Bool SAL_CALL OResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    return m_row == -1;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::isAfterLast(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    return m_row >= m_rowCount;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::isFirst(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    return m_row == 0 && m_rowCount;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::isLast(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    return m_row >= 0 && m_row + 1 == m_rowCount;
-}
-// -------------------------------------------------------------------------
-void SAL_CALL OResultSet::beforeFirst(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    m_row = -1;
-}
-// -------------------------------------------------------------------------
-void SAL_CALL OResultSet::afterLast(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    m_row = m_rowCount;
-}
 // -------------------------------------------------------------------------
 
 void SAL_CALL OResultSet::close(  ) throw(SQLException, RuntimeException)
@@ -445,85 +611,17 @@ void SAL_CALL OResultSet::close(  ) throw(SQLException, RuntimeException)
     SAL_INFO("connectivity.firebird", "=> OResultSet::close().");
 
     {
-        ::osl::MutexGuard aGuard( m_aMutex );
+        MutexGuard aGuard( m_aMutex );
         checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     }
     dispose();
 }
-// -------------------------------------------------------------------------
 
-sal_Bool SAL_CALL OResultSet::first(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    sal_Bool bRet = ( m_rowCount > 0 );
-    if( bRet )
-        m_row = 0;
-    return bRet;
-}
-// -------------------------------------------------------------------------
-
-sal_Bool SAL_CALL OResultSet::last(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    sal_Bool bRet = ( m_rowCount > 0 );
-    if( bRet )
-        m_row = m_rowCount -1;
-    return bRet;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    if( row > 0 )
-    {
-        m_row = row -1;
-        if( m_row > m_rowCount )
-            m_row = m_rowCount;
-    }
-    else
-    {
-        m_row = m_rowCount + row;
-        if( m_row < -1 )
-            m_row = -1;
-    }
-    return sal_True;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    m_row += row;
-
-    if( m_row > m_rowCount )
-        m_row = m_rowCount;
-    else if ( m_row < -1 )
-        m_row = -1;
-    return sal_True;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    sal_Bool bRet = ( m_row != -1 );
-    if( bRet )
-        m_row --;
-    return bRet;
-}
 
 uno::Reference< XInterface > SAL_CALL OResultSet::getStatement() throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return m_xStatement;
@@ -532,7 +630,7 @@ uno::Reference< XInterface > SAL_CALL OResultSet::getStatement() throw(SQLExcept
 
 sal_Bool SAL_CALL OResultSet::rowDeleted(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -541,7 +639,7 @@ sal_Bool SAL_CALL OResultSet::rowDeleted(  ) throw(SQLException, RuntimeExceptio
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::rowInserted(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -550,27 +648,18 @@ sal_Bool SAL_CALL OResultSet::rowInserted(  ) throw(SQLException, RuntimeExcepti
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::rowUpdated(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
     return sal_False;
 }
-// -------------------------------------------------------------------------
 
-sal_Bool SAL_CALL OResultSet::next(  ) throw(SQLException, RuntimeException)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-    m_row ++;
-    return m_row < m_rowCount;
-}
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSet::wasNull(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -580,7 +669,7 @@ sal_Bool SAL_CALL OResultSet::wasNull(  ) throw(SQLException, RuntimeException)
 
 void SAL_CALL OResultSet::cancel(  ) throw(RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -596,7 +685,7 @@ Any SAL_CALL OResultSet::getWarnings(  ) throw(SQLException, RuntimeException)
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::insertRow(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     // you only have to implement this if you want to insert new rows
@@ -604,7 +693,7 @@ void SAL_CALL OResultSet::insertRow(  ) throw(SQLException, RuntimeException)
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::updateRow(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -613,21 +702,21 @@ void SAL_CALL OResultSet::updateRow(  ) throw(SQLException, RuntimeException)
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::deleteRow(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 }
 // -------------------------------------------------------------------------
 
 void SAL_CALL OResultSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 }
 // -------------------------------------------------------------------------
 
 void SAL_CALL OResultSet::moveToInsertRow(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
@@ -637,7 +726,7 @@ void SAL_CALL OResultSet::moveToInsertRow(  ) throw(SQLException, RuntimeExcepti
 
 void SAL_CALL OResultSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 }
 // -------------------------------------------------------------------------
@@ -645,7 +734,7 @@ void SAL_CALL OResultSet::moveToCurrentRow(  ) throw(SQLException, RuntimeExcept
 void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 }
 // -------------------------------------------------------------------------
@@ -654,7 +743,7 @@ void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) thr
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -664,7 +753,7 @@ void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(
     (void) columnIndex;
     (void) x;
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
 
 }
 // -------------------------------------------------------------------------
@@ -673,7 +762,7 @@ void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) thro
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -683,7 +772,7 @@ void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(
     (void) columnIndex;
     (void) x;
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
 
 }
 // -------------------------------------------------------------------------
@@ -691,7 +780,7 @@ void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -700,7 +789,7 @@ void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQ
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -710,7 +799,7 @@ void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -719,7 +808,7 @@ void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const OUString& x
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -728,7 +817,7 @@ void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sa
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -737,7 +826,7 @@ void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const Date& x ) thr
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -747,7 +836,7 @@ void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const Time& x ) thr
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -757,7 +846,7 @@ void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const DateTime
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -768,7 +857,7 @@ void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const uno::
     (void) columnIndex;
     (void) x;
     (void) length;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -778,14 +867,14 @@ void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const un
     (void) columnIndex;
     (void) x;
     (void) length;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::refreshRow(  ) throw(SQLException, RuntimeException)
 {
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -794,7 +883,7 @@ void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) th
 {
     (void) columnIndex;
     (void) x;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -805,7 +894,7 @@ void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any&
     (void) columnIndex;
     (void) x;
     (void) scale;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 }
@@ -813,7 +902,7 @@ void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any&
 // XRowLocate
 Any SAL_CALL OResultSet::getBookmark(  ) throw( SQLException,  RuntimeException)
 {
-     ::osl::MutexGuard aGuard( m_aMutex );
+     MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     // if you don't want to support bookmark you must remove the XRowLocate interface
@@ -824,7 +913,7 @@ Any SAL_CALL OResultSet::getBookmark(  ) throw( SQLException,  RuntimeException)
 sal_Bool SAL_CALL OResultSet::moveToBookmark( const  Any& bookmark ) throw( SQLException,  RuntimeException)
 {
     (void) bookmark;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return sal_False;
@@ -834,7 +923,7 @@ sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const  Any& bookmark, sal_
 {
     (void) bookmark;
     (void) rows;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return sal_False;
@@ -844,7 +933,7 @@ sal_Int32 SAL_CALL OResultSet::compareBookmarks( const  Any& aFirst, const  Any&
 {
     (void) aFirst;
     (void) aSecond;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return CompareBookmark::NOT_EQUAL;
@@ -865,7 +954,7 @@ sal_Int32 SAL_CALL OResultSet::hashBookmark( const  Any& bookmark ) throw( SQLEx
 Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const  Sequence<  Any >& rows ) throw( SQLException,  RuntimeException)
 {
     (void) rows;
-    ::osl::MutexGuard aGuard( m_aMutex );
+    MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
     return Sequence< sal_Int32 >();
@@ -975,49 +1064,6 @@ uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet:
 }
 // -----------------------------------------------------------------------------
 
-void SAL_CALL OResultSet::checkColumnIndex(sal_Int32 index ) throw ( SQLException, RuntimeException )
-{
-    if( index < 1 || index > m_fieldCount )
-    {
-        OUStringBuffer buf(128);
-        buf.appendAscii( "pq_resultset: index out of range (" );
-        buf.append( index );
-        buf.appendAscii( ", allowed range is 1 to " );
-        buf.append( m_fieldCount );
-        buf.appendAscii( ")" );
-        throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any() );
-    }
-
-}
-
-void SAL_CALL OResultSet::checkRowIndex( sal_Bool mustBeOnValidRow )
-{
-    OUStringBuffer buf( 128 );
-    buf.appendAscii( "pq_baseresultset: row index out of range, allowed is " );
-    if( mustBeOnValidRow )
-    {
-        if( m_row < 0 || m_row >= m_rowCount )
-        {
-            buf.appendAscii( "0 to " );
-            buf.append( ((sal_Int32)(m_rowCount -1)) );
-            buf.appendAscii( ", got " );
-            buf.append( m_row );
-            throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
-        }
-    }
-    else
-    {
-        if( m_row < -1 || m_row > m_rowCount )
-        {
-            buf.appendAscii( "-1 to " );
-            buf.append( m_rowCount );
-            buf.appendAscii( ", got " );
-            buf.append( m_row );
-            throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
-        }
-    }
-}
-
 // ---- XServiceInfo -----------------------------------------------------------
 OUString SAL_CALL OResultSet::getImplementationName() throw ( RuntimeException)
 {
diff --git a/connectivity/source/drivers/firebird/FResultSet.hxx b/connectivity/source/drivers/firebird/FResultSet.hxx
index 90bbb22..0efc5d4 100644
--- a/connectivity/source/drivers/firebird/FResultSet.hxx
+++ b/connectivity/source/drivers/firebird/FResultSet.hxx
@@ -88,12 +88,15 @@ namespace connectivity
             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>        m_xMetaData;
 
             XSQLDA*                                     m_pSqlda;
+            isc_stmt_handle                             m_statementHandle;
 
             sal_Bool                                    m_bWasNull;
-            sal_Int32                                   m_row;
-            sal_Int32                                   m_rowCount;
-            sal_Int32                                   m_fieldCount;
+            // Row numberign starts with 0 for "in front of first row"
+            sal_Int32                                   m_currentRow;
+            const sal_Int32                             m_rowCount;
+            const sal_Int32                             m_fieldCount;
             TTable                                      m_sqldata;
+            ISC_STATUS_ARRAY                            m_statusVector;
 
             // OPropertyArrayUsageHelper
             virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index a4a6d82..366f273 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -185,6 +185,7 @@ Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeExcep
 sal_Int32 SAL_CALL OStatement_Base::executeUpdate(const OUString& sqlIn)
     throw(SQLException, RuntimeException)
 {
+    // TODO: close ResultSet if existing -- so so in all 3 execute methods.
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
@@ -201,7 +202,7 @@ sal_Int32 SAL_CALL OStatement_Base::executeUpdate(const OUString& sqlIn)
     if (aErr)
         SAL_WARN("connectivity.firebird", "isc_dsql_execute_immediate failed" );
 
-    m_pConnection->evaluateStatusVector(m_statusVector, sql);
+    m_pConnection->evaluateStatusVector(m_statusVector, sql, *this);
     // TODO: get number of changed rows with SELECT ROW_COUNT (use executeQuery)
     //     return getUpdateCount();
     return 0;
@@ -380,7 +381,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery(const OUStri
 
     // TODO: deal with cleanup
 //    close();
-    m_pConnection->evaluateStatusVector(m_statusVector, sql);
+    m_pConnection->evaluateStatusVector(m_statusVector, sql, *this);
     return m_xResultSet;
 }
 
@@ -418,7 +419,7 @@ sal_Bool SAL_CALL OStatement_Base::execute(const OUString& sql) throw(SQLExcepti
             SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
     }
 
-    m_pConnection->evaluateStatusVector(m_statusVector, sql);
+    m_pConnection->evaluateStatusVector(m_statusVector, sql, *this);
 
     // returns true when a resultset is available
     return sal_False;
commit 95ee08a98b7e7fc49ec8155bf41e905764efd8c7
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Wed Jul 17 22:04:03 2013 +0200

    Improve formatting of firebird-sdbc error messages.
    
    Change-Id: I5892b8bd6dd2d63655dbc0781aa038b60546317b

diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 1713a14..ee31c39 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -698,19 +698,18 @@ void SAL_CALL OConnection::evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector
     if (aStatusVector[0]==1 && aStatusVector[1]) // indicates error
     {
         OUStringBuffer buf;
-        buf.appendAscii( "firebird_sdbc error: ");
-
-        char msg[512];
+        char msg[512]; // Size is based on suggestion in docs.
         const ISC_STATUS* pStatus = (const ISC_STATUS*) &aStatusVector;
 
+        buf.appendAscii("firebird_sdbc error:");
         while(fb_interpret(msg, sizeof(msg), &pStatus))
         {
             // TODO: verify encoding
+            buf.appendAscii("\n*");
             buf.append(OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8));
         }
-        buf.appendAscii( " (caused by '" );
-        buf.append( aCause );
-        buf.appendAscii( "')" );
+        buf.appendAscii("\ncaused by\n'").append(aCause).appendAscii("'\n");
+
         OUString error = buf.makeStringAndClear();
         SAL_WARN( "connectivity.firebird", error );
 
commit c0c5d960e7e272b84a198f8d6e530f05156907f3
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Wed Jul 17 21:03:16 2013 +0200

    Replace raw pointer with Reference to Statement in FResultSet.
    
    Change-Id: Id4019470cf1d2723ea46f3d8ea09e75eb947aed0

diff --git a/connectivity/source/drivers/firebird/FPreparedStatement.cxx b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
index c819b0c..8f3c7b3 100644
--- a/connectivity/source/drivers/firebird/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
@@ -224,7 +224,8 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery(  ) throw(SQLE
 //         if (pr_error(status, "execute query"))
 //             return NULL;
 
-    Reference< OResultSet > pResult( new OResultSet( this, 0) );
+    isc_stmt_handle aHandle = 0;
+    Reference< OResultSet > pResult( new OResultSet( this, aHandle, 0) );
     //initializeResultSet( pResult.get() );
     Reference< XResultSet > xRS = pResult.get();
 
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 5ba1880..8861577 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -35,83 +35,56 @@
 
 #include "FResultSet.hxx"
 #include "FResultSetMetaData.hxx"
+#include "propertyids.hxx"
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
 #include <rtl/ustrbuf.hxx>
-#include <com/sun/star/sdbc/DataType.hpp>
+
 #include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <com/sun/star/sdbcx/CompareBookmark.hpp>
-#include <cppuhelper/typeprovider.hxx>
 #include <com/sun/star/lang/DisposedException.hpp>
-#include "propertyids.hxx"
-#include <comphelper/sequence.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
 
 using namespace ::comphelper;
-using namespace connectivity::firebird;
-using namespace cppu;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::sdbc;
-using namespace com::sun::star::sdbcx;
-using namespace com::sun::star::container;
-using namespace com::sun::star::io;
-using namespace com::sun::star::util;
-
-//------------------------------------------------------------------------------
-//  IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
-::rtl::OUString SAL_CALL OResultSet::getImplementationName(  ) throw ( RuntimeException)    \
-{
-    return ::rtl::OUString("com.sun.star.sdbcx.firebird.ResultSet");
-}
-// -------------------------------------------------------------------------
- Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames(  ) throw( RuntimeException)
-{
-     Sequence< ::rtl::OUString > aSupported(2);
-    aSupported[0] = ::rtl::OUString("com.sun.star.sdbc.ResultSet");
-    aSupported[1] = ::rtl::OUString("com.sun.star.sdbcx.ResultSet");
-    return aSupported;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
-{
-    Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
-    const ::rtl::OUString* pSupported = aSupported.getConstArray();
-    const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
-    for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
-        ;
-
-    return pSupported != pEnd;
-}
-
-// -------------------------------------------------------------------------
-OResultSet::OResultSet(OStatement_Base* pStmt,
+using namespace ::connectivity::firebird;
+using namespace ::cppu;
+using namespace ::rtl;
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::util;
+
+OResultSet::OResultSet(const uno::Reference< XStatement >& xStatement,
+                       isc_stmt_handle& aStatementHandle,
                        XSQLDA* pSqlda)
     : OResultSet_BASE(m_aMutex)
-    ,OPropertySetHelper(OResultSet_BASE::rBHelper)
-    ,m_pStatement(pStmt)
-    ,m_aStatement((OWeakObject*)pStmt)
-    ,m_xMetaData(NULL)
-    ,m_pSqlda(pSqlda)
-    ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
-    ,m_bWasNull(sal_True)
-    ,m_row(-1)
+    , OPropertySetHelper(OResultSet_BASE::rBHelper)
+    , m_xStatement(xStatement)
+    , m_xMetaData(NULL)
+    , m_pSqlda(pSqlda)
+    , m_bWasNull(sal_True)
+    , m_row(-1)
+    , m_rowCount(0)
+    , m_fieldCount(0)
 {
     SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet().");
 
-    isc_stmt_handle stmt = 0;// m_pStatement->getSTMTHandler();
+    if (!pSqlda)
+        return; // TODO: what?
 
-    if (pSqlda == NULL)
-    {
-        m_rowCount = 0;
-        m_fieldCount = 0;
-    } else {
-        m_rowCount = 0;
-        m_fieldCount = pSqlda->sqld;
-    }
+    m_fieldCount = pSqlda->sqld;
 
     ISC_STATUS_ARRAY status;  // status vector
     ISC_STATUS retcode;
     int j = 0;
-    while ((retcode = isc_dsql_fetch(status, &stmt, 1, pSqlda)) == 0)
+    while ((retcode = isc_dsql_fetch(status, &aStatementHandle, 1, pSqlda)) == 0)
     {
         m_rowCount++;
 
@@ -134,7 +107,7 @@ OResultSet::OResultSet(OStatement_Base* pStmt,
 //         if (pr_error(status, "free statement"))
 //             return;
 }
-// -------------------------------------------------------------------------
+
 OResultSet::~OResultSet()
 {
 }
@@ -147,7 +120,6 @@ void OResultSet::disposing(void)
 
     ::osl::MutexGuard aGuard(m_aMutex);
 
-    m_aStatement    = NULL;
     m_xMetaData     = NULL;
 }
 // -------------------------------------------------------------------------
@@ -162,15 +134,15 @@ Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeExcep
  Sequence<  Type > SAL_CALL OResultSet::getTypes(  ) throw( RuntimeException)
 {
     OTypeCollection aTypes(
-        ::cppu::UnoType< Reference< ::com::sun::star::beans::XMultiPropertySet > >::get(),
-        ::cppu::UnoType< Reference< ::com::sun::star::beans::XFastPropertySet > >::get(),
-        ::cppu::UnoType< Reference< ::com::sun::star::beans::XPropertySet > >::get());
+        ::cppu::UnoType< uno::Reference< ::com::sun::star::beans::XMultiPropertySet > >::get(),
+        ::cppu::UnoType< uno::Reference< ::com::sun::star::beans::XFastPropertySet > >::get(),
+        ::cppu::UnoType< uno::Reference< ::com::sun::star::beans::XPropertySet > >::get());
 
     return concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
 }
 // -------------------------------------------------------------------------
 
-sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException)
 {
 
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -179,7 +151,7 @@ sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) t
 
     ::osl::MutexGuard aGuard( m_aMutex );
 
-    Reference< XResultSetMetaData > xMeta = getMetaData();
+    uno::Reference< XResultSetMetaData > xMeta = getMetaData();
     sal_Int32 nLen = xMeta->getColumnCount();
     sal_Int32 i = 1;
     for(;i<=nLen;++i)
@@ -189,7 +161,7 @@ sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) t
     return i;
 }
 // -------------------------------------------------------------------------
-Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     ::osl::MutexGuard aGuard( m_aMutex );
@@ -199,7 +171,7 @@ Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 column
     return NULL;
 }
 // -------------------------------------------------------------------------
-Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     ::osl::MutexGuard aGuard( m_aMutex );
@@ -308,18 +280,18 @@ sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLExcepti
 }
 // -------------------------------------------------------------------------
 
-Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException)
+uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException)
 {
     ::osl::MutexGuard aGuard( m_aMutex );
     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
     if(!m_xMetaData.is())
-        m_xMetaData = new OResultSetMetaData(m_pStatement->getOwnConnection());
+        m_xMetaData = new OResultSetMetaData(m_xStatement->getConnection());
     return m_xMetaData;
 }
 // -------------------------------------------------------------------------
-Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+uno::Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     ::osl::MutexGuard aGuard( m_aMutex );
@@ -330,7 +302,7 @@ Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw
 
 // -------------------------------------------------------------------------
 
-Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+uno::Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     ::osl::MutexGuard aGuard( m_aMutex );
@@ -339,7 +311,7 @@ Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(S
     return NULL;
 }
 // -------------------------------------------------------------------------
-Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+uno::Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     ::osl::MutexGuard aGuard( m_aMutex );
@@ -349,7 +321,7 @@ Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(S
 }
 // -------------------------------------------------------------------------
 
-Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+uno::Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     ::osl::MutexGuard aGuard( m_aMutex );
@@ -359,7 +331,7 @@ Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQL
 }
 // -------------------------------------------------------------------------
 
-Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
+Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
 {
     (void) columnIndex;
     (void) typeMap;
@@ -382,7 +354,7 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept
 }
 // -------------------------------------------------------------------------
 
-::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
     ::osl::MutexGuard aGuard( m_aMutex );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list