[Libreoffice-commits] .: Branch 'feature/base-preview' - 69 commits - comphelper/inc comphelper/source connectivity/inc connectivity/source dbaccess/source forms/source hsqldb/patches reportdesign/source sal/osl setup_native/source solenv/gbuild solenv/inc svl/source svtools/source svx/source sw/inc sw/source tools/source wizards/com writerfilter/source xmloff/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 15 13:24:56 PDT 2012


Rebased ref, commits from common ancestor:
commit 71791c2cdb762ede120c819020ee2e746bdf6199
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Jul 24 17:59:11 2012 +0200

    janitorial: C++-style cast instead of legacy C-style cast
    
    Change-Id: I86cd5d87751c5a9dd31a392e2b3847e8f5741524

diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index 1bf3f97..1625e15 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -900,7 +900,7 @@ namespace svt
             return sal_False;
         }
 
-        EditBrowseBox * pTHIS = (EditBrowseBox *) this;
+        EditBrowseBox * pTHIS = const_cast<EditBrowseBox *> (this);
 
         // save the cell content if
         // a) a selection is beeing made
commit 75cb470cf0ee32e2a82f3a6a56d123a4430c2359
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jul 23 16:05:25 2012 +0200

    TODO fdo#52179
    
    Change-Id: I3144087cfe60b15a38853460f15a39ec730f0bf4

diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 9a4943f..c3e2ea6 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -3009,6 +3009,7 @@ void ODatabaseForm::reload_impl(sal_Bool bMoveToFirst, const Reference< XInterac
     }
 
     sal_Bool bSuccess = sal_True;
+    // TODO: get bookmark
     try
     {
         m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_REFRESHING_FORM);
@@ -3026,6 +3027,8 @@ void ODatabaseForm::reload_impl(sal_Bool bMoveToFirst, const Reference< XInterac
         while (aIter.hasMoreElements())
             ((XLoadListener*)aIter.next())->reloaded(aEvent);
 
+        // TODO: go to bookmark
+
         // if we are on the insert row, we have to reset all controls
         // to set the default values
         if (getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
commit 2a91cf973e6b93e077dc700d4da9a0a88c803de9
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Jul 24 17:15:55 2012 +0200

    forcing repaint has catastrophic performance implications; invalidate only
    
    In Base:
    1) Open a big table (hundreds of rows)
    2) Only the first 40 to 100 rows are fetched into the cache and shown
       (depending on screen / window size).
    3) Move to last row (click on icon |>|)
    4) The last 40 to 100 rows are fetched into the cache; the data of the
       first 40/100 rows is pushed out of the cache.
    5) The first 40 to 100 rows are fetched, just so that the call to
       rWindow.Paint() can do its job, because they are not in the cache
       anymore (!). The last 40/100 rows are pushed out of the cache.
    6) The last 40 to 100 rows are fetched into the cache and displayed;
       the first 40/100 rows are pushed out of the cache *again*.
    
    Steps 5 and 6 are obviously *very* stupid.
    
    Change-Id: Ic11b893ea9440c2c5a142bd3c77c95d6730aa723

diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index 42f3158..1bf3f97 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -929,8 +929,6 @@ namespace svt
         if (nNewRow != nEditRow)
         {
             Window& rWindow = GetDataWindow();
-            // don't paint too much
-            // update the status immediatly if possible
             if ((nEditRow >= 0) && (GetBrowserFlags() & EBBF_NO_HANDLE_COLUMN_CONTENT) == 0)
             {
                 Rectangle aRect = GetFieldRectPixel(nEditRow, 0, sal_False );
@@ -939,7 +937,7 @@ namespace svt
                 // probably because it is part of a bitfield
                 pTHIS->bPaintStatus = static_cast< sal_Bool >
                     (( GetBrowserFlags() & EBBF_HANDLE_COLUMN_TEXT ) == EBBF_HANDLE_COLUMN_TEXT );
-                rWindow.Paint(aRect);
+                rWindow.Invalidate(aRect);
                 pTHIS->bPaintStatus = sal_True;
             }
 
commit 557169a8e5281e87cebefd95d4fa8232f48d0530
Author: Terrence Enger <tenger at iseries-guru.com>
Date:   Wed Jul 18 14:46:11 2012 -0400

    stop some leaked statement handles
    
    Change-Id: I06764e0569ea615e66de6cd5946614c7c538e60e
    Signed-off-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
index accb801..4d4b224 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
@@ -75,7 +75,6 @@ ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection
     ,m_nCurrentFetchState(0)
     ,m_bWasNull(sal_True)
     ,m_bEOF(sal_False)
-    ,m_bFreeHandle(sal_False)
 {
     OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
     if( SQL_NULL_HANDLE == m_aStatementHandle )
@@ -105,8 +104,8 @@ void ODatabaseMetaDataResultSet::disposing(void)
     OPropertySetHelper::disposing();
 
     ::osl::MutexGuard aGuard(m_aMutex);
-    if(m_bFreeHandle)
-        m_pConnection->freeStatementHandle(m_aStatementHandle);
+
+    m_pConnection->freeStatementHandle(m_aStatementHandle);
 
     m_aStatement    = NULL;
 m_xMetaData.clear();
@@ -854,7 +853,6 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const ::rtl::OUS
                             const ::rtl::OUString& tableNamePattern,
                             const Sequence< ::rtl::OUString >& types )  throw(SQLException, RuntimeException)
 {
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
     const ::rtl::OUString *pSchemaPat = NULL;
 
@@ -902,7 +900,6 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const ::rtl::OUS
 //-----------------------------------------------------------------------------
 void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeException)
 {
-    m_bFreeHandle = sal_True;
     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
                             0,0,
                             0,0,
@@ -919,7 +916,6 @@ void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeE
 // -------------------------------------------------------------------------
 void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeException)
 {
-    m_bFreeHandle = sal_True;
     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
                             (SDB_ODBC_CHAR *) SQL_ALL_CATALOGS,SQL_NTS,
                             (SDB_ODBC_CHAR *) "",SQL_NTS,
@@ -937,7 +933,6 @@ void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeExcep
 // -------------------------------------------------------------------------
 void ODatabaseMetaDataResultSet::openSchemas() throw(SQLException, RuntimeException)
 {
-    m_bFreeHandle = sal_True;
     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
                             (SDB_ODBC_CHAR *) "",SQL_NTS,
                             (SDB_ODBC_CHAR *) SQL_ALL_SCHEMAS,SQL_NTS,
@@ -963,7 +958,6 @@ void ODatabaseMetaDataResultSet::openColumnPrivileges(  const Any& catalog, cons
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
 
     if ( catalog.hasValue() )
@@ -999,7 +993,6 @@ void ODatabaseMetaDataResultSet::openColumns(   const Any& catalog,
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
     if ( catalog.hasValue() )
         aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1068,7 +1061,6 @@ void ODatabaseMetaDataResultSet::openProcedureColumns(  const Any& catalog,
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
     if ( catalog.hasValue() )
         aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1103,7 +1095,6 @@ void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const ::rtl:
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
 
     if ( catalog.hasValue() )
@@ -1148,7 +1139,6 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(sal_Bool _bRowVer,const Any&
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
     if ( catalog.hasValue() )
     aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1187,8 +1177,6 @@ void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const ::rt
                                   const Any& catalog2, const ::rtl::OUString* schema2,
                                   const ::rtl::OUString* table2) throw(SQLException, RuntimeException)
 {
-    m_bFreeHandle = sal_True;
-
     ::rtl::OString aPKQ,aPKO,aPKN, aFKQ, aFKO, aFKN;
     if ( catalog.hasValue() )
         aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1238,7 +1226,6 @@ void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const ::rtl
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
 
     if ( catalog.hasValue() )
@@ -1268,7 +1255,6 @@ void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const :
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN;
 
     if ( catalog.hasValue() )
@@ -1299,7 +1285,6 @@ void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const ::rtl:
     else
         pSchemaPat = NULL;
 
-    m_bFreeHandle = sal_True;
     ::rtl::OString aPKQ,aPKO,aPKN;
 
     if ( catalog.hasValue() )
diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
index 7a17249..0296085 100644
--- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
+++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
@@ -76,7 +76,7 @@ namespace connectivity
             ::std::map<sal_Int32, ::connectivity::TInt2StringMap >              m_aIntValueRange;
             ::std::map<sal_Int32,SWORD>                                         m_aODBCColumnTypes;
 
-            SQLHANDLE                                                                   m_aStatementHandle;
+            SQLHANDLE                                                                   m_aStatementHandle;   // ... until freed
             SQLHANDLE                                                                   m_aConnectionHandle;
             ::com::sun::star::uno::WeakReferenceHelper                                  m_aStatement;
             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>        m_xMetaData;
@@ -89,7 +89,6 @@ namespace connectivity
             SQLRETURN                                   m_nCurrentFetchState;
             sal_Bool                                    m_bWasNull;
             sal_Bool                                    m_bEOF;                 // after last record
-            sal_Bool                                    m_bFreeHandle;
 
             // set the columncount of the driver
             void checkColumnCount();
commit 7cfe4269ab45f8acf768bf4c4e6610cd005e7598
Author: Terrence Enger <tenger at iseries-guru.com>
Date:   Wed Jul 18 14:46:11 2012 -0400

    ODBMetaDataRS ctor: abort if statement handle allocation failed
    
    Change-Id: Ieac069565bbc14c909eeecf3e67588191191992f
    Signed-off-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
index ec3ab25..accb801 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
@@ -78,6 +78,9 @@ ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection
     ,m_bFreeHandle(sal_False)
 {
     OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
+    if( SQL_NULL_HANDLE == m_aStatementHandle )
+        throw RuntimeException();
+
     osl_incrementInterlockedCount( &m_refCount );
     m_pConnection->acquire();
     m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
commit c08004827eb8daf44fc47e7d4ab46a8254edb262
Author: Terrence Enger <tenger at iseries-guru.com>
Date:   Wed Jul 18 14:46:11 2012 -0400

    avoid freeing the NULL handle
    
    Change-Id: Id3f22bacfbf5e582656cc8ac38d60b781a25b4c3
    Signed-off-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/connectivity/source/drivers/odbcbase/OConnection.cxx b/connectivity/source/drivers/odbcbase/OConnection.cxx
index 04df960..b1686ff 100644
--- a/connectivity/source/drivers/odbcbase/OConnection.cxx
+++ b/connectivity/source/drivers/odbcbase/OConnection.cxx
@@ -657,6 +657,9 @@ SQLHANDLE OConnection::createStatementHandle()
 // -----------------------------------------------------------------------------
 void OConnection::freeStatementHandle(SQLHANDLE& _pHandle)
 {
+    if( SQL_NULL_HANDLE == _pHandle )
+        return;
+
     ::std::map< SQLHANDLE,OConnection*>::iterator aFind = m_aConnections.find(_pHandle);
 
     N3SQLFreeStmt(_pHandle,SQL_RESET_PARAMS);
commit 597a22242a53bd7b4ac7baadca46b10d870a0eab
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jul 16 23:58:18 2012 +0200

    fdo#51239 refresh row lazily (when data is requested)
    
    This avoids fetching data that will not be requested when the "cursor" is only moved and no data requested. That is typically what RowSetCache does when its own cursor is moved within its window.
    
    This basically makes the whole {next,previous,absolute,...}_checked story obsolete, by basically always being as fast as the i_bFetchRow==false case, but in a safer way.
    
    Change-Id: I89eaf277069736b3077bde8b45325929db290f2d

diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
index 8f90a1c..97dea62 100644
--- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx
+++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
@@ -150,6 +150,7 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c
 
 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_PreparedStatement::executeQuery(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
 {
+    std::cerr << ::rtl::OUStringToOString( this->m_sSqlStatement, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl;
     m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_QUERY );
     ::osl::MutexGuard aGuard( m_aMutex );
     checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
commit 9c29cd1b1ad339711c8ca5e8059152f9af04c3e5
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Jul 12 23:28:10 2012 +0200

    errors to stderr
    
    Change-Id: I01756622dd7700d3918d156f118cd69c8a15879a

diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index 4b30ce6..4d1a396 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -76,7 +76,7 @@ public class SQLQueryComposer
         }
         catch (Exception exception)
         {
-            exception.printStackTrace(System.out);
+            exception.printStackTrace(System.err);
         }
     }
 
@@ -149,7 +149,7 @@ public class SQLQueryComposer
         }
         catch (Exception exception)
         {
-            exception.printStackTrace(System.out);
+            exception.printStackTrace(System.err);
         }
     }
 
@@ -180,7 +180,7 @@ public class SQLQueryComposer
             }
             catch (Exception e)
             {
-                e.printStackTrace(System.out);
+                e.printStackTrace(System.err);
             }
         }
     }
@@ -336,7 +336,7 @@ public class SQLQueryComposer
         }
         catch (Exception exception)
         {
-            exception.printStackTrace(System.out);
+            exception.printStackTrace(System.err);
             displaySQLErrorDialog(exception, _xParentWindow);
             return false;
         }
@@ -434,7 +434,7 @@ public class SQLQueryComposer
         }
         catch (Exception typeexception)
         {
-            typeexception.printStackTrace(System.out);
+            typeexception.printStackTrace(System.err);
         }
     }
 
commit 3762b68141ae1d3065433f3233dd8ae97f2cd77c
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Jul 12 18:10:14 2012 +0200

    debug unexpected exception
    
    Change-Id: I404072caf6ddab0ed833586066507c7d332fcea4

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 04f7a5a..6bc4c5d 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -626,6 +626,7 @@ void SAL_CALL OSingleSelectQueryComposer::setElementaryQuery( const ::rtl::OUStr
     {
         (void)e;
         OSL_FAIL( "OSingleSelectQueryComposer::setElementaryQuery: there should be no error anymore for the additive statement!" );
+        DBG_UNHANDLED_EXCEPTION();
         // every part of the additive statement should have passed other tests already, and should not
         // be able to cause any errors ... me thinks
     }
commit 63b136b507d5613d025a0ee07054430ded3bc369
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Jul 12 13:07:03 2012 +0200

    fix hsqldb java version detection
    
    1) The values were not properly exclusive.
       E.g. when compiling under OpenJDK 1.6, iscjava12 was set (!)
    
    2) On Java 1.6, should not enable the parts that are (only) for Java7!
    
    3) When non-JAVA7, need to preprocess the files that have JAVA7-only code, so that it gets removed
    
    Change-Id: I99b6bd9e781fee1007a04a4dc3d3f952c1b2eb00

diff --git a/hsqldb/patches/jdbc-4.1.patch b/hsqldb/patches/jdbc-4.1.patch
index 89149c4..4c4eb85 100644
--- a/hsqldb/patches/jdbc-4.1.patch
+++ b/hsqldb/patches/jdbc-4.1.patch
@@ -1,19 +1,50 @@
---- misc/hsqldb/build/build.xml	2012-02-08 15:14:42.827123541 +0000
-+++ misc/build/hsqldb/build/build.xml	2012-02-08 15:21:43.827722388 +0000
-@@ -98,7 +98,11 @@
+--- misc/hsqldb/build/build.xml	2012-07-12 10:58:11.000000000 +0200
++++ misc/build/hsqldb/build/build.xml	2012-07-12 10:49:28.000000000 +0200
+@@ -98,16 +98,24 @@
        <echo message="ant.java.hasjsse=${ant.java.hasjsse}" />
     </target>
  
 -   <target name="javaversion6">
-+   <target name="javaversion7">
++   <target name="javaversion7" unless="ant.java.iscjavaset">
 +      <available classname="java.util.Objects" property="ant.java.iscjava17"/>
++      <available classname="java.util.Objects" property="ant.java.iscjavaset"/>
 +   </target>
 +
-+   <target name="javaversion6" depends="javaversion7" unless="ant.java.iscjava17">
++   <target name="javaversion6" depends="javaversion7" unless="ant.java.iscjavaset">
        <available classname="java.net.IDN" property="ant.java.iscjava16"/>
++      <available classname="java.net.IDN" property="ant.java.iscjavaset"/>
     </target>
  
-@@ -210,6 +214,7 @@
+-   <target name="javaversion4" depends="javaversion6" unless="ant.java.iscjava16">
++   <target name="javaversion4" depends="javaversion6" unless="ant.java.iscjavaset">
+       <available classname="java.nio.Buffer" property="ant.java.iscjava14"/>
++      <available classname="java.nio.Buffer" property="ant.java.iscjavaset"/>
+    </target>
+ 
+-   <target name="javaversion2" depends="javaversion4" unless="ant.java.iscjava14">
++   <target name="javaversion2" depends="javaversion4" unless="ant.java.iscjavaset">
+       <available classname="java.lang.ref.Reference" property="ant.java.iscjava12"/>
++      <available classname="java.lang.ref.Reference" property="ant.java.iscjavaset"/>
+    </target>
+ 
+    <target name="-prepare" depends="init,javaversion2">
+@@ -166,6 +177,7 @@
+       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+         <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+         <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++        <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcStatement.java"/>
+         <arg file="${src}/org/hsqldb/persist/LockFile.java"/>
+         <arg file="${src}/org/hsqldb/persist/Logger.java"/>
+@@ -183,6 +195,7 @@
+       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+         <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+         <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++        <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcDataSource.java"/>
+@@ -210,6 +223,7 @@
          <arg value="+JAVA2FULL"/>
          <arg value="-JAVA4"/>
          <arg value="-JAVA6"/>
@@ -21,7 +52,15 @@
         </java>
      </target>
  
-@@ -244,6 +249,7 @@
+@@ -218,6 +232,7 @@
+       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+         <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+         <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++        <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcDataSource.java"/>
+@@ -244,6 +259,7 @@
          <arg value="+JAVA2FULL"/>
          <arg value="+JAVA4"/>
          <arg value="-JAVA6"/>
@@ -29,19 +68,10 @@
         </java>
      </target>
  
-@@ -279,10 +285,47 @@
-         <arg value="+JAVA2FULL"/>
-         <arg value="+JAVA4"/>
-         <arg value="+JAVA6"/>
-+        <arg value="+JAVA7"/>
-+      </java>
-+    </target>
-+
-+    <target name="switchtojdk17" depends="switchtojdk16"
-+            description="self explanatory" if="ant.java.iscjava17">
-+      <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
-+        <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
-+        <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
+@@ -253,6 +269,43 @@
+       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+         <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+         <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
 +        <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
 +        <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
 +        <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
@@ -69,6 +99,23 @@
 +        <arg value="+JAVA2FULL"/>
 +        <arg value="+JAVA4"/>
 +        <arg value="+JAVA6"/>
++        <arg value="-JAVA7"/>
++      </java>
++    </target>
++
++    <target name="switchtojdk17" depends="switchtojdk16"
++            description="self explanatory" if="ant.java.iscjava17">
++      <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
++        <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
++        <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++        <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
+         <arg file="${src}/org/hsqldb/jdbc/jdbcDataSource.java"/>
+@@ -279,10 +332,11 @@
+         <arg value="+JAVA2FULL"/>
+         <arg value="+JAVA4"/>
+         <arg value="+JAVA6"/>
 +        <arg value="+JAVA7"/>
        </java>
      </target>
commit 162f29a02453e114ad1b7e249e3ef174125afbbe
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Jul 3 20:17:01 2012 +0200

    embedded HSQLDB: reclaim space occupied by deleted rows
    
    Disadvantage is that saving/closing the file may take a significantly longer time
    
    Change-Id: I1cc35c34b49e60d73e8d341549c5a3c5ef314b6d

diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx
index 2021e79..d56a4e2 100644
--- a/connectivity/source/drivers/hsqldb/HConnection.cxx
+++ b/connectivity/source/drivers/hsqldb/HConnection.cxx
@@ -189,7 +189,7 @@ namespace connectivity { namespace hsqldb
                 if ( !m_bReadOnly )
                 {
                     Reference< XStatement > xStmt( m_xConnection->createStatement(), UNO_QUERY_THROW );
-                    xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CHECKPOINT" ) ) );
+                    xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CHECKPOINT DEFRAG" ) ) );
                 }
             }
 
commit 7983317ef5853b700e6866cfbf1ecaceac5642e2
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jul 2 19:33:38 2012 +0200

    LEM notes
    
    Change-Id: I16939e5d6e1f7c0a83f7f2b2dbc9a5b397b45c36

diff --git a/connectivity/source/drivers/hsqldb/HView.cxx b/connectivity/source/drivers/hsqldb/HView.cxx
index b9b2361..b58ada0 100644
--- a/connectivity/source/drivers/hsqldb/HView.cxx
+++ b/connectivity/source/drivers/hsqldb/HView.cxx
@@ -113,6 +113,8 @@ namespace connectivity { namespace hsqldb
         ::rtl::OUStringBuffer aRestoreCommand;
         aRestoreCommand.appendAscii( "CREATE VIEW " );
         aRestoreCommand.append     ( sQualifiedName );
+        // LEM TODO: this looks like it does not put _any_ aliases (column names) in the view definition?
+        // unless it is in sQualifiedName, which would be quite hacky
         aRestoreCommand.appendAscii( " AS " );
         aRestoreCommand.append     ( impl_getCommand_throw( true ) );
         ::rtl::OUString sRestoreCommand( aRestoreCommand.makeStringAndClear() );
@@ -130,6 +132,8 @@ namespace connectivity { namespace hsqldb
             // create a new one with the same name
             aCommand.appendAscii( "CREATE VIEW " );
             aCommand.append     ( sQualifiedName );
+            // LEM TODO: this looks like it does not put _any_ aliases (column names) in the view definition?
+            // unless it is in sQualifiedName, which would be quite hacky
             aCommand.appendAscii( " AS " );
             aCommand.append     ( _rNewCommand );
             xStatement->execute( aCommand.makeStringAndClear() );
diff --git a/connectivity/source/drivers/hsqldb/HViews.cxx b/connectivity/source/drivers/hsqldb/HViews.cxx
index e3a7ed0..13ac33d 100644
--- a/connectivity/source/drivers/hsqldb/HViews.cxx
+++ b/connectivity/source/drivers/hsqldb/HViews.cxx
@@ -145,7 +145,8 @@ void HViews::createView( const Reference< XPropertySet >& descriptor )
     ::rtl::OUString sSchema,sCommand;
 
     aSql += ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::eInTableDefinitions, false, false, true );
-
+    // LEM TODO: this looks like it does not put _any_ aliases (column names) in the view definition?
+    // unless it is in the result of ::dbtools::composeTableName, which would be quite hacky
     aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" AS "));
     descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand;
     aSql += sCommand;
commit 420485dab222b8259c02d249da3988e8a8bde98b
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jul 2 14:48:03 2012 +0200

    janitorial: remove unused xParamsAsNames variable
    
    Change-Id: Ic4fe24faf75d38a8123a8f0e8304c054760bad85

diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 5113e4f..9286efd 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -1817,7 +1817,6 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer,
     Reference<XParametersSupplier>  xParameters = Reference<XParametersSupplier> (_xComposer, UNO_QUERY);
 
     Reference<XIndexAccess>  xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
-    Reference<XNameAccess>   xParamsAsNames(xParamsAsIndicies, UNO_QUERY);
     sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
     ::std::vector<bool, std::allocator<bool> > aNewParameterSet( _aParametersSet );
     if ( nParamCount && ::std::count(aNewParameterSet.begin(),aNewParameterSet.end(),true) != nParamCount )
commit 0dcdebb99eec06c6736412b09eaf7677eb45eb51
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 6 14:28:50 2012 +0200

    legacy reports: unify treatment of query and table
    
    In *both* cases, the value of hidden control "Sorting" (if non-empty)
    decides the columns being sorted on.
    
    Change-Id: I7f4b50c3af8c12e48e5dedd36b5877ad7a9e1b66

diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
index 6be5b36..937d9f2 100644
--- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
+++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
@@ -264,7 +264,8 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
                 }
                 getRecordParser().setRecordFieldNames(sNewList);
                 getRecordParser().GroupFieldNames = JavaTools.ArrayoutofString(sGroupFieldNames, PropertyNames.SEMI_COLON);
-                getRecordParser().setCommandType(Integer.valueOf(sCommandType).intValue());
+                int nOrigCommandType = Integer.valueOf(sCommandType).intValue();
+                getRecordParser().setCommandType(nOrigCommandType);
 
                 sMsgQueryCreationImpossible = JavaTools.replaceSubString(sMsgQueryCreationImpossible, getRecordParser().Command, "<STATEMENT>");
                 bgetConnection = getRecordParser().getConnection(_properties);
@@ -278,8 +279,6 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
                         if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()))
                         {
                             getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND);
-                            getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command);
-                            getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery();
                         }
                         else
                         {
@@ -291,14 +290,24 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
                     bexecute = getRecordParser().executeCommand(nCommandType); //sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot, sFieldNameList, true);
                     if (bexecute)
                     {
-                        DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName);
                         bexecute = getRecordParser().getFields(sFieldNameList, true);
-                        if (bexecute && getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()))
+
+                        boolean addSort = true;
+                        if ( (nOrigCommandType == CommandType.QUERY) && !sQueryName.equals(PropertyNames.EMPTY_STRING) )
                         {
-                            getRecordParser().getSQLQueryComposer().prependSortingCriteria();
-                            getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery();
-                            bexecute = getRecordParser().executeCommand(nCommandType);
+                            DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName);
+                            if (!getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()))
+                                addSort = false;
                         }
+                        if ( !(addSort && bexecute) )
+                        {
+                            return bexecute;
+                        }
+                        getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command);
+                        getRecordParser().getSQLQueryComposer().prependSortingCriteria();
+                        getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery();
+
+                        bexecute = getRecordParser().executeCommand(nCommandType);
                     }
                     return bexecute;
                 }
commit c97e5d692a7bd4806a56a91fc69adccb103d0e1d
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 6 14:26:58 2012 +0200

    legacy report wizard: when source is table, save name in QueryName
    
    Change-Id: Ie0bdbed9578b95f7fccc3d9ff6d9c8b5b91ac0ab

diff --git a/wizards/com/sun/star/wizards/report/ReportTextDocument.java b/wizards/com/sun/star/wizards/report/ReportTextDocument.java
index 5cddeca..cbb7b9a 100644
--- a/wizards/com/sun/star/wizards/report/ReportTextDocument.java
+++ b/wizards/com/sun/star/wizards/report/ReportTextDocument.java
@@ -206,16 +206,15 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen
         com.sun.star.container.XNameContainer xNamedForm = oFormHandler.insertFormbyName(SOREPORTFORMNAME);
         XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xNamedForm);
         oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND_TYPE, Integer.toString(CurDBMetaData.getCommandType()));
+        oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, CurDBMetaData.getCommandName());
         if (CurDBMetaData.getCommandType() == CommandType.QUERY)
         {
-            oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, CurDBMetaData.getCommandName());
             oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND, "");
             //DBMetaData.CommandObject oCommand = CurDBMetaData.getQueryByName(CurDBMetaData.getCommandName());
             //oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, COMMAND, CurDBMetaData.Command);
         }
         else
         {
-            oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, "");
             oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND, CurDBMetaData.Command);
         }
         oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "GroupFieldNames", JavaTools.ArraytoString(CurDBMetaData.GroupFieldNames));
commit 07795ccb6555c8d89a47d573e2d1db6ed4f41a76
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 6 14:25:51 2012 +0200

    SQLQueryComposer allow setQueryCommand with prependSorting instead of append
    
    Change-Id: Ia06794537ea4d0f6f069c83709792ebbcc084804

diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index f25f90d..4b30ce6 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -295,6 +295,11 @@ public class SQLQueryComposer
 
     public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery)
     {
+        return setQueryCommand(_xParentWindow, _bincludeGrouping, _baddAliasFieldNames, addQuery, false);
+    }
+
+    public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery, boolean prependSortingCriteria)
+    {
         try
         {
             bincludeGrouping = _bincludeGrouping;
@@ -318,7 +323,14 @@ public class SQLQueryComposer
                     m_queryComposer.setStructuredHavingClause(CurDBMetaData.GroupByFilterConditions);
                 }
             }
-            appendSortingcriteria(_baddAliasFieldNames);
+            if (prependSortingCriteria)
+            {
+                prependSortingCriteria(_baddAliasFieldNames);
+            }
+            else
+            {
+                appendSortingcriteria(_baddAliasFieldNames);
+            }
 
             return true;
         }
commit bac39b11b5147dee9f3ebc2487149e0422e1e3ad
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 6 14:24:54 2012 +0200

    db.SQLQueryComposer allow prependSortingCriteria call with addAliasFieldNames
    
    Change-Id: I05889ccac213743a55c302bd7249b30f817c0428

diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index c454c9c..f25f90d 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -155,11 +155,16 @@ public class SQLQueryComposer
 
     public void prependSortingCriteria() throws SQLException
     {
+        prependSortingCriteria(false);
+    }
+
+    public void prependSortingCriteria(boolean _baddAliasFieldNames) throws SQLException
+    {
         XIndexAccess xColumnIndexAccess = m_xQueryAnalyzer.getOrderColumns();
         m_queryComposer.setOrder("");
         for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++)
         {
-            appendSortingCriterion(i, false);
+            appendSortingCriterion(i, _baddAliasFieldNames);
         }
         for (int i = 0; i < xColumnIndexAccess.getCount(); i++)
         {
commit c5bb9c07df25f1930f2dceb32f607be8e8b51fc8
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 6 14:23:50 2012 +0200

    cleanup
    
    Change-Id: I1ce4279d434ffa58328e17863b2e68af1e813a99

diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index 3a2d0b6..c454c9c 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -242,7 +242,6 @@ public class SQLQueryComposer
         {
             for (int m = 0; m < _filterconditions[n].length; m++)
             {
-            //	_filterconditions[n][m].Name = getComposedAliasFieldName(_filterconditions[n][m].Name);
                 final String aliasName = getComposedAliasFieldName(_filterconditions[n][m].Name);
                 if ( columns.hasByName(aliasName))
                     _filterconditions[n][m].Name = aliasName;
commit 7205e38669d4f070d387baf75a35b21faa59f30c
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 6 14:23:30 2012 +0200

    untabify
    
    Change-Id: I984c84534cb4c6cda8bd73a43d79ec8e49afcdeb

diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
index 33f3cf0..6be5b36 100644
--- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
+++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
@@ -241,7 +241,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
                 }
                 catch (UnknownHiddenControlException exception)
                 {
-		    sorting = "";
+                    sorting = "";
                 }
                 String sRecordFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "RecordFieldNames", sMsg);
                 if (xNamedForm.hasByName("QueryName"))
commit 6c5aa14d44d44a020b8e20cdb9f16ad0df6ce209
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jun 4 17:40:30 2012 +0200

    Cleanup m_xSet in destructor
    
    Change-Id: I3d7023fcb1857da1ef107a8af0d373b9ca464f03

diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 285916e..34057d3 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -96,6 +96,22 @@ namespace
             }
         }
     }
+
+    template < typename T > inline void tryDispose( Reference<T> &r )
+    {
+        try
+        {
+            ::comphelper::disposeComponent(r);
+        }
+        catch(const Exception&)
+        {
+            r = NULL;
+        }
+        catch(...)
+        {
+            OSL_FAIL("Unknown Exception occurred");
+        }
+    }
 }
 DBG_NAME(OKeySet)
 
@@ -126,18 +142,9 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
 
 OKeySet::~OKeySet()
 {
-    try
-    {
-        ::comphelper::disposeComponent(m_xStatement);
-    }
-    catch(const Exception&)
-    {
-        m_xStatement = NULL;
-    }
-    catch(...)
-    {
-        OSL_FAIL("Unknown Exception occurred");
-    }
+    tryDispose(m_xStatement);
+    tryDispose(m_xSet);
+
     m_xComposer = NULL;
 
     DBG_DTOR(OKeySet,NULL);
commit 4403564891478e46505bfeb533fd922721d406f0
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jun 4 17:35:52 2012 +0200

    typos in comments
    
    Change-Id: I1dbb1990033602d7909ecdee72b8b699cce44cab

diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 3503978..285916e 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -294,7 +294,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
     findTableColumnsMatching_throw(makeAny(m_xTable),m_sUpdateTableName,xMeta,xQueryColumns,m_pKeyColumnNames);
 
     // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
-    // without extra varaible to be set
+    // without extra variable to be set
     m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
     m_aKeyIter = m_aKeyMap.begin();
 
@@ -443,7 +443,7 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows
     aSql.append(m_aComposedTableName);
     aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")));
 
-    // list all cloumns that should be set
+    // list all columns that should be set
     const ::rtl::OUString aQuote    = getIdentifierQuoteString();
     static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
     static ::rtl::OUString aOr(RTL_CONSTASCII_USTRINGPARAM(" OR "));
commit 754e9d6fc38cfd59c4f634775459589ee048e33b
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jun 4 17:31:25 2012 +0200

    Remove wrong optimisation
    
    fixup of d4ae29a37873843c20fe7d5f5f071f8fb201fed9
    after the call to m_pCacheSet->absolute_checked, the data *is* used,
    so we cannot anymore exempt m_pCacheSet from giving correct data.
    
    Change-Id: I7d3644ca08ce43cb030a80984605a1f8a8a64211

diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 83978cd..f8e54e1 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -79,6 +79,14 @@ using namespace ::osl;
 
 #define CHECK_MATRIX_POS(M) OSL_ENSURE(((M) >= static_cast<ORowSetMatrix::difference_type>(0)) && ((M) < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!")
 
+// This class calls m_pCacheSet->FOO_checked(..., sal_False)
+// (where FOO is absolute, last, previous)
+// when it does not immediately care about the values in the row's columns.
+// As a corollary, m_pCacheSet may be left in an inconsistent state,
+// and all ->fillFOO calls (and ->getFOO) may fail or give wrong results,
+// until m_pCacheSet is moved (or refreshed) again.
+// So always make sure m_pCacheSet is moved or refreshed before accessing column values.
+
 DBG_NAME(ORowSetCache)
 
 ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
@@ -1076,7 +1084,7 @@ sal_Bool ORowSetCache::moveWindow()
                 aIter = m_pMatrix->begin();
 
                 nPos    = m_nStartPos + 1;
-                bCheck  = m_pCacheSet->absolute_checked(nPos, sal_False);
+                bCheck  = m_pCacheSet->absolute_checked(nPos, sal_True);
                 for(; !aIter->is() && bCheck;++aIter, ++nPos)
                 {
                     OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator");
commit fc630450af1e6de4f58b1fa12952bfd7ff239ab4
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Jun 1 15:42:27 2012 +0200

    OKeySet::refreshRow: Invalidate m_xRow/m_xSet when BeforeFirst or AfterLast
    
    Change-Id: I0f48c099eddc077b2a89e3b7fab66b5da55b57c8

diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 526ac52..3503978 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -1371,11 +1371,12 @@ bool OKeySet::doTryRefetch_throw()  throw(SQLException, RuntimeException)
 void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen at sun.com", "OKeySet::refreshRow" );
-    if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
-        return;
 
     invalidateRow();
 
+    if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
+        return;
+
     if ( m_aKeyIter->second.second.second.is() )
     {
         m_xRow = m_aKeyIter->second.second.second;
commit d6c4ce545814e46506d1049154b72f79050ca0ff
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Jun 1 14:49:02 2012 +0200

    Update comments
    
    Change-Id: I7e3f09d61cb35165000a35c8d3c3f2d284cf164e

diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index df74076..9910859 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -693,8 +693,8 @@ Sequence<sal_Int8> OTools::getBytesValue(OConnection* _pConnection,
                 --nLen;
             aData.append(::rtl::OUString((const sal_Char*)aCharArray,nLen, _nTextEncoding));
 
-            // It is about Binariy Data, a String, that for StarView is to long or
-            // the driver kan't predict the length of the data - as well as save the
+            // It is about Binary Data, a String, that for StarView is too long or
+            // the driver can't predict the length of the data - as well as save the
             // MemoryStream.
             while ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen)
             {
commit f0b46629252e03cb4bc6af100ede9b87af377dcd
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Apr 4 16:00:52 2012 +0200

    ORowSetCache::moveWindow m_nEndPos == m_nStartPos == 0 is OK

diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 68aa8d5..83978cd 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -467,7 +467,7 @@ void ORowSetCache::setFetchSize(sal_Int32 _nSize)
     }
     else
     {
-        OSL_FAIL("m_nPosition not between m_nStartPos and m_nEndpos");
+        OSL_FAIL("m_nPosition not between m_nStartPos and m_nEndPos");
         // try to repair
         moveWindow();
         m_aMatrixIter = calcPosition();
@@ -849,7 +849,8 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndP
 sal_Bool ORowSetCache::moveWindow()
 {
     OSL_ENSURE(m_nStartPos >= 0,"ORowSetCache::moveWindow: m_nStartPos is less than 0!");
-    OSL_ENSURE(m_nEndPos > m_nStartPos,"ORowSetCache::moveWindow: m_nStartPos not smaller than m_nEndPos");
+    OSL_ENSURE(m_nEndPos > m_nStartPos || (m_nEndPos == 0 && m_nStartPos == 0),
+               "ORowSetCache::moveWindow: m_nStartPos not smaller than m_nEndPos");
     OSL_ENSURE(m_nEndPos-m_nStartPos <= m_nFetchSize,"ORowSetCache::moveWindow: m_nStartPos and m_nEndPos too far apart");
 
     if ( m_nStartPos < m_nPosition && m_nPosition <= m_nEndPos )
commit 7220d5b9aeeb288ec8cb7725348a57262c4687d0
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Feb 27 13:47:24 2012 +0100

    fdo#46675: fixup

diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index 362ebfb..b40ba8e 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -2096,7 +2096,7 @@ void DatabaseMetaData::init_getPrivs_stmt ()
     sSQL.append( ASCII_STR(
             " ) dp,"
             " (SELECT oid, rolname FROM pg_catalog.pg_roles UNION ALL VALUES (0, 'PUBLIC')) pr"
-            " WHERE table_schem LIKE ? AND table_name LIKE ? AND pg_has_role(pr.oid, dp.grantee, 'USAGE')"
+            " WHERE table_schem LIKE ? AND table_name LIKE ? AND (dp.grantee = 'PUBLIC' OR pg_has_role(pr.oid, dp.grantee, 'USAGE'))"
             " ORDER BY table_schem, table_name, privilege" ) );
 
     m_getTablePrivs_stmt = m_origin->prepareStatement( sSQL.makeStringAndClear() );
@@ -2126,7 +2126,7 @@ void DatabaseMetaData::init_getPrivs_stmt ()
     sSQL.append( ASCII_STR(
             " ) dp,"
             " (SELECT oid, rolname FROM pg_catalog.pg_roles UNION ALL VALUES (0, 'PUBLIC')) pr"
-            " WHERE table_schem = ? AND table_name = ? AND column_name LIKE ? AND pg_has_role(pr.oid, dp.grantee, 'USAGE')"
+            " WHERE table_schem = ? AND table_name = ? AND column_name LIKE ? AND (dp.grantee = 'PUBLIC' OR pg_has_role(pr.oid, dp.grantee, 'USAGE'))"
             " ORDER BY column_name, privilege" ) );
 
     m_getColumnPrivs_stmt = m_origin->prepareStatement( sSQL.makeStringAndClear() );
commit 15c35446ea32be96d76abe6ba9566bfc9c7bd681
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Feb 27 13:10:40 2012 +0100

    fdo#46675: expand group memberships in get*Privileges

diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index b596eb4..362ebfb 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -2071,7 +2071,8 @@ void DatabaseMetaData::init_getPrivs_stmt ()
 {
     rtl::OUStringBuffer sSQL(300);
     sSQL.append( ASCII_STR(
-            " SELECT * FROM ("
+            " SELECT dp.TABLE_CAT, dp.TABLE_SCHEM, dp.TABLE_NAME, dp.GRANTOR, pr.rolname AS GRANTEE, dp.privilege, dp.is_grantable "
+            " FROM ("
             "  SELECT table_catalog AS TABLE_CAT, table_schema AS TABLE_SCHEM, table_name,"
             "         grantor, grantee, privilege_type AS PRIVILEGE, is_grantable"
             "  FROM information_schema.table_privileges") );
@@ -2093,14 +2094,15 @@ void DatabaseMetaData::init_getPrivs_stmt ()
             "  WHERE c.relkind IN ('r', 'v') AND c.relacl IS NULL AND pg_has_role(rg.oid, c.relowner, 'USAGE')"
             "        AND c.relowner=ro.oid AND c.relnamespace = pn.oid") );
     sSQL.append( ASCII_STR(
-            " ) s"
-            " WHERE table_schem LIKE ? AND table_name LIKE ? "
+            " ) dp,"
+            " (SELECT oid, rolname FROM pg_catalog.pg_roles UNION ALL VALUES (0, 'PUBLIC')) pr"
+            " WHERE table_schem LIKE ? AND table_name LIKE ? AND pg_has_role(pr.oid, dp.grantee, 'USAGE')"
             " ORDER BY table_schem, table_name, privilege" ) );
 
     m_getTablePrivs_stmt = m_origin->prepareStatement( sSQL.makeStringAndClear() );
 
     sSQL.append( ASCII_STR(
-            " SELECT * FROM ("
+            " SELECT dp.TABLE_CAT, dp.TABLE_SCHEM, dp.TABLE_NAME, dp.COLUMN_NAME, dp.GRANTOR, pr.rolname AS GRANTEE, dp.PRIVILEGE, dp.IS_GRANTABLE FROM ("
             "  SELECT table_catalog AS TABLE_CAT, table_schema AS TABLE_SCHEM, table_name, column_name,"
             "         grantor, grantee, privilege_type AS PRIVILEGE, is_grantable"
             "  FROM information_schema.column_privileges") );
@@ -2122,8 +2124,9 @@ void DatabaseMetaData::init_getPrivs_stmt ()
             "  WHERE c.relkind IN ('r', 'v') AND c.relacl IS NULL AND pg_has_role(rg.oid, c.relowner, 'USAGE')"
             "        AND c.relowner=ro.oid AND c.relnamespace = pn.oid AND a.attrelid = c.oid AND a.attnum > 0") );
     sSQL.append( ASCII_STR(
-            " ) s"
-            " WHERE table_schem = ? AND table_name = ? AND column_name LIKE ? "
+            " ) dp,"
+            " (SELECT oid, rolname FROM pg_catalog.pg_roles UNION ALL VALUES (0, 'PUBLIC')) pr"
+            " WHERE table_schem = ? AND table_name = ? AND column_name LIKE ? AND pg_has_role(pr.oid, dp.grantee, 'USAGE')"
             " ORDER BY column_name, privilege" ) );
 
     m_getColumnPrivs_stmt = m_origin->prepareStatement( sSQL.makeStringAndClear() );
commit a83d9a4d60de4a4f82304329743f942c476fddb5
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Feb 16 09:29:54 2012 +0100

    correct indentation

diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index 7d3b72b..cecf52e 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -897,9 +897,9 @@ namespace frm
                     }
                 }
                 break;
-                default:
-                    OSL_FAIL( "OListBoxModel::loadData: unreachable!" );
-                    break;
+            default:
+                OSL_FAIL( "OListBoxModel::loadData: unreachable!" );
+                break;
             }
         }
         catch(SQLException& eSQL)
commit 22525a945d4b423548355129d26f2e612b30b52d
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Feb 16 09:11:08 2012 +0100

    typo & copy/paste error in error message

diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index 444e2bc..acd1ef0 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -258,7 +258,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType)
                 break;
             default:
                 (*this) = makeAny();
-                OSL_FAIL("ORowSetValue:operator==(): UNSPUPPORTED TYPE!");
+                OSL_FAIL("ORowSetValue::setTypeKind(): UNSUPPORTED TYPE!");
         }
     }
 
@@ -895,7 +895,7 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const
             break;
         default:
             bRet = false;
-            OSL_FAIL("ORowSetValue::operator==(): UNSPUPPORTED TYPE!");
+            OSL_FAIL("ORowSetValue::operator==(): UNSUPPORTED TYPE!");
             break;
     }
     return bRet;
commit 19ec3002b7fd6674852953559940051e87859f86
Author: Kate Goss <katherine.goss at gmail.com>
Date:   Mon Feb 13 21:53:08 2012 +0000

    Remove unused code from connectivity::odbc::OPreparedStatement
    
    Remove methods getDataBuf(int), getParamLength(int), getPrecision(int).

diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
index 63401f5..d1288f9 100644
--- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
@@ -674,27 +674,6 @@ sal_Int8* OPreparedStatement::allocBindBuf( sal_Int32 index,sal_Int32 bufLen)
 // -------------------------------------------------------------------------
 
 //--------------------------------------------------------------------
-// getDataBuf
-// Gets the data buffer for the given parameter index
-//--------------------------------------------------------------------
-
-sal_Int8* OPreparedStatement::getDataBuf (sal_Int32 index)
-{
-    sal_Int8* b = NULL;
-
-    // Sanity check the parameter number
-
-    if ((index >= 1) &&
-        (index <= numParams))
-    {
-        b = boundParams[index - 1].getBindDataBuffer ();
-    }
-
-    return b;
-}
-// -------------------------------------------------------------------------
-
-//--------------------------------------------------------------------
 // getLengthBuf
 // Gets the length buffer for the given parameter index
 //--------------------------------------------------------------------
@@ -716,34 +695,6 @@ sal_Int8* OPreparedStatement::getLengthBuf (sal_Int32 index)
 // -------------------------------------------------------------------------
 
 //--------------------------------------------------------------------
-// getParamLength
-// Returns the length of the given parameter number.  When each
-// parameter was bound, a 4-sal_Int8 buffer was given to hold the
-// length (stored in native format).  Get the buffer, convert the
-// buffer from native format, and return it.  If the length is -1,
-// the column is considered to be NULL.
-//--------------------------------------------------------------------
-
-sal_Int32 OPreparedStatement::getParamLength (  sal_Int32 index)
-{
-    sal_Int32 paramLen = SQL_NULL_DATA;
-
-    // Sanity check the parameter number
-
-    if ((index >= 1) &&
-        (index <= numParams)) {
-
-        // Now get the length of the parameter from the
-        // bound param array.  -1 is returned if it is NULL.
-        long n = 0;
-        memcpy (&n, boundParams[index -1].getBindLengthBuffer (), sizeof (n));
-        paramLen = n;
-    }
-    return paramLen;
-}
-// -------------------------------------------------------------------------
-
-//--------------------------------------------------------------------
 // putParamData
 // Puts parameter data from a previously bound input stream.  The
 // input stream was bound using SQL_LEN_DATA_AT_EXEC.
@@ -810,34 +761,6 @@ void OPreparedStatement::putParamData (sal_Int32 index) throw(SQLException)
     }
 }
 // -------------------------------------------------------------------------
-//--------------------------------------------------------------------
-// getPrecision
-// Given a SQL type, return the maximum precision for the column.
-// Returns -1 if not known
-//--------------------------------------------------------------------
-
-sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    checkDisposed(OStatement_BASE::rBHelper.bDisposed);
-
-    sal_Int32 prec = -1;
-    const TTypeInfoVector& rTypeInfo = m_pConnection->getTypeInfo();
-    if ( !rTypeInfo.empty() )
-    {
-        m_pConnection->buildTypeInfo();
-    }
-
-    if ( !rTypeInfo.empty() )
-    {
-        OTypeInfo aInfo;
-        aInfo.nType = (sal_Int16)sqlType;
-        TTypeInfoVector::const_iterator aIter = ::std::find(rTypeInfo.begin(),rTypeInfo.end(),aInfo);
-        if(aIter != rTypeInfo.end())
-            prec = (*aIter).nPrecision;
-    }
-    return prec;
-}
 
 //--------------------------------------------------------------------
 // setStream
diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx
index 8c41355..076c9e0 100644
--- a/connectivity/source/inc/odbc/OPreparedStatement.hxx
+++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx
@@ -88,15 +88,11 @@ namespace connectivity
             void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException);
             void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x,
                                                         SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException);
-            sal_Int32 getParamLength (  sal_Int32 index);
             sal_Int8* getLengthBuf (sal_Int32 index);
-            sal_Int8* getDataBuf (sal_Int32 index);
             sal_Int8* allocBindBuf (    sal_Int32 index,    sal_Int32 bufLen);
             void initBoundParam () throw(::com::sun::star::sdbc::SQLException);
             void setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData);
 
-            sal_Int32 getPrecision ( sal_Int32 sqlType);
-
             sal_Bool isPrepared() const { return m_bPrepared;}
             void prepareStatement();
             void checkParameterIndex(sal_Int32 _parameterIndex);
commit d6966dbf94530c8a522f4d51671d396772d74b78
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Feb 14 19:41:08 2012 +0100

    ODBC: align *all* the handling of SQLULEN properties with maximal ODBC size

diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx
index f09a08a..86ba6bd 100644
--- a/connectivity/source/drivers/odbcbase/OStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OStatement.cxx
@@ -756,13 +756,13 @@ sal_Int64 OStatement_Base::getMaxFieldSize() const
     return ::rtl::OUString::createFromAscii((const char*)pName);
 }
 //------------------------------------------------------------------------------
-void OStatement_Base::setQueryTimeOut(sal_Int32 seconds)
+void OStatement_Base::setQueryTimeOut(sal_Int64 seconds)
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_QUERY_TIMEOUT,seconds);
 }
 //------------------------------------------------------------------------------
-void OStatement_Base::setMaxRows(sal_Int32 _par0)
+void OStatement_Base::setMaxRows(sal_Int64 _par0)
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_ROWS, _par0);
@@ -872,7 +872,7 @@ void OStatement_Base::setFetchSize(sal_Int32 _par0)
     }
 }
 //------------------------------------------------------------------------------
-void OStatement_Base::setMaxFieldSize(sal_Int32 _par0)
+void OStatement_Base::setMaxFieldSize(sal_Int64 _par0)
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_LENGTH, _par0);
@@ -913,9 +913,9 @@ void OStatement_Base::setUsingBookmarks(sal_Bool _bUseBookmark)
     DECL_BOOL_PROP0(ESCAPEPROCESSING);
     DECL_PROP0(FETCHDIRECTION,sal_Int32);
     DECL_PROP0(FETCHSIZE,   sal_Int32);
-    DECL_PROP0(MAXFIELDSIZE,sal_Int32);
-    DECL_PROP0(MAXROWS,     sal_Int32);
-    DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+    DECL_PROP0(MAXFIELDSIZE,sal_Int64);
+    DECL_PROP0(MAXROWS,     sal_Int64);
+    DECL_PROP0(QUERYTIMEOUT,sal_Int64);
     DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
     DECL_PROP0(RESULTSETTYPE,sal_Int32);
     DECL_BOOL_PROP0(USEBOOKMARKS);
@@ -997,13 +997,13 @@ void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const A
         switch(nHandle)
         {
             case PROPERTY_ID_QUERYTIMEOUT:
-                setQueryTimeOut(comphelper::getINT32(rValue));
+                setQueryTimeOut(comphelper::getINT64(rValue));
                 break;
             case PROPERTY_ID_MAXFIELDSIZE:
-                setMaxFieldSize(comphelper::getINT32(rValue));
+                setMaxFieldSize(comphelper::getINT64(rValue));
                 break;
             case PROPERTY_ID_MAXROWS:
-                setMaxRows(comphelper::getINT32(rValue));
+                setMaxRows(comphelper::getINT64(rValue));
                 break;
             case PROPERTY_ID_CURSORNAME:
                 setCursorName(comphelper::getString(rValue));
diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx
index e0d4663..4768f70 100644
--- a/connectivity/source/inc/odbc/OStatement.hxx
+++ b/connectivity/source/inc/odbc/OStatement.hxx
@@ -99,9 +99,9 @@ namespace connectivity
             sal_Bool getEscapeProcessing()      const;
             template < typename T, SQLINTEGER BufferLength > T getStmtOption (SQLINTEGER fOption, T dflt = 0) const;
 
-            void setQueryTimeOut(sal_Int32 _par0)           ;
-            void setMaxFieldSize(sal_Int32 _par0)           ;
-            void setMaxRows(sal_Int32 _par0)                ;
+            void setQueryTimeOut(sal_Int64 _par0)           ;
+            void setMaxFieldSize(sal_Int64 _par0)           ;
+            void setMaxRows(sal_Int64 _par0)                ;
             void setFetchDirection(sal_Int32 _par0)         ;
             void setFetchSize(sal_Int32 _par0)              ;
             void setCursorName(const ::rtl::OUString &_par0);
commit 4f596e4561011e77e6fd448f7b91d7a180efee32
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Feb 14 19:39:01 2012 +0100

    comphelper: add getINT64

diff --git a/comphelper/inc/comphelper/types.hxx b/comphelper/inc/comphelper/types.hxx
index dfa1565..a23116f 100644
--- a/comphelper/inc/comphelper/types.hxx
+++ b/comphelper/inc/comphelper/types.hxx
@@ -156,6 +156,7 @@ namespace comphelper
     // no, we don't use templates here. This would lead to a lot of implicit uses of the conversion methods,
     // which would be difficult to trace ...
 
+    COMPHELPER_DLLPUBLIC sal_Int64      getINT64(const staruno::Any& _rAny);
     COMPHELPER_DLLPUBLIC sal_Int32      getINT32(const staruno::Any& _rAny);
     COMPHELPER_DLLPUBLIC sal_Int16      getINT16(const staruno::Any& _rAny);
     COMPHELPER_DLLPUBLIC double         getDouble(const staruno::Any& _rAny);
diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx
index f3df258..c9eb6bb 100644
--- a/comphelper/source/misc/types.cxx
+++ b/comphelper/source/misc/types.cxx
@@ -80,6 +80,14 @@ sal_Bool operator ==(const Time& _rLeft, const Time& _rRight)
 }
 
 //------------------------------------------------------------------------------
+sal_Int64 getINT64(const Any& _rAny)
+{
+    sal_Int64 nReturn = 0;
+    OSL_VERIFY( _rAny >>= nReturn );
+    return nReturn;
+}
+
+//------------------------------------------------------------------------------
 sal_Int32 getINT32(const Any& _rAny)
 {
     sal_Int32 nReturn = 0;
commit 31d78b028e3881fbfec957e05c353c098988bf7c
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Feb 14 18:34:52 2012 +0100

    improve OTools::binParameter/bindData interaction
    
    Don't duplicate the decision point for "data at execution or copied data"

diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index 9e8714c..df74076 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -181,14 +181,15 @@ void OTools::bindParameter( OConnection* _pConnection,
     SQLLEN* pLen    = (SQLLEN*)pLenBuffer;
     SQLULEN nColumnSize=0;
     SQLSMALLINT nDecimalDigits=0;
+    bool atExec;
 
     OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nODBCtype,fCType,fSqlType);
 
-    OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize);
+    OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize, atExec);
     if ((nColumnSize == 0) && (fSqlType == SQL_CHAR || fSqlType == SQL_VARCHAR || fSqlType == SQL_LONGVARCHAR))
         nColumnSize = 1;
 
-    if(fSqlType == SQL_LONGVARCHAR || fSqlType == SQL_LONGVARBINARY)
+    if (atExec)
         memcpy(pDataBuffer,&nPos,sizeof(nPos));
 
     nRetcode = (*(T3SQLBindParameter)_pConnection->getOdbcFunction(ODBC3SQLBindParameter))(_hStmt,
@@ -211,10 +212,12 @@ void OTools::bindData(  SQLSMALLINT _nOdbcType,
                         SQLLEN*& pLen,
                         const void* _pValue,
                         rtl_TextEncoding _nTextEncoding,
-                        SQLULEN& _nColumnSize)
+                        SQLULEN& _nColumnSize,
+                        bool &atExec)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen at sun.com", "OTools::bindData" );
     _nColumnSize = 0;
+    atExec = false;
 
     switch (_nOdbcType)
     {
@@ -307,6 +310,7 @@ void OTools::bindData(  SQLSMALLINT _nOdbcType,
                 nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
                 *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
             }
+            atExec = true;
             break;
         case SQL_LONGVARCHAR:
         {
@@ -319,6 +323,7 @@ void OTools::bindData(  SQLSMALLINT _nOdbcType,
                 nLen = aString.getLength();
             }
             *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
+            atExec = true;
         }   break;
         case SQL_DATE:
             *(DATE_STRUCT*)_pData = *(DATE_STRUCT*)_pValue;
diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx
index 7f48373..ad1fb12 100644
--- a/connectivity/source/inc/odbc/OTools.hxx
+++ b/connectivity/source/inc/odbc/OTools.hxx
@@ -216,13 +216,16 @@ namespace connectivity
                                     SQLLEN _nSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
 
             /**
-                bindData copies the from pValue to pData
-                @param  _nOdbcType          the ODBC sql type
-                @param  _bUseWChar          true when Unicode should be used
-                @param  _pData              contains a copy of the data to be set
-                @param  _pValue             contains the data to be copied
-                @param  _nTextEncoding      the text encoding
-                @param  _nColumnSize        the columnsize which is a out param
+                bindData copies data from pValue to pData
+                @param  _nOdbcType          [in] the ODBC sql type
+                @param  _bUseWChar          [in] true when Unicode should be used
+                @param  _pData              [in/out] data copy destination
+                @param  pLen                [out] buffer length of data written to _pData
+                @param  _pValue             [in] contains the data to be copied
+                @param  _nTextEncoding      [in] the text encoding
+                @param  _nColumnSize        [out] columnSize of data written to _pData
+                @param  atExec              [out] data was not copied, but setup for data-at-execution;
+                                                  caller is responsible for writing a token in _pData
             */
             static void bindData(   SQLSMALLINT _nOdbcType,
                                     sal_Bool _bUseWChar,
@@ -230,7 +233,8 @@ namespace connectivity
                                     SQLLEN*& pLen,
                                     const void* _pValue,
                                     rtl_TextEncoding _nTextEncoding,
-                                    SQLULEN& _nColumnSize);
+                                    SQLULEN& _nColumnSize,
+                                    bool &atExec);
 
             static void bindParameter(  OConnection* _pConnection,
                                         SQLHANDLE _hStmt,
commit 28beeb14ce2e76480ccfd2f8a0fa919897b73bb8
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Feb 14 09:49:19 2012 +0100

    new[] already allocates each element of the array
    
    And calls the default constructor, naturally.

diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
index 2dbde52..63401f5 100644
--- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
@@ -641,11 +641,10 @@ void OPreparedStatement::initBoundParam () throw(SQLException)
 
         boundParams = new OBoundParam[numParams];
 
-        // Allocate and initialize each bound parameter
+        // initialize each bound parameter
 
         for (sal_Int32 i = 0; i < numParams; i++)
         {
-            boundParams[i] = OBoundParam();
             boundParams[i].initialize ();
         }
     }
commit 9435f6ba7ad07c9de67ba6a1bee46716875ab979
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Feb 14 06:27:51 2012 +0100

    odbc getTableTypes: ask the driver instead of guessing

diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
index 3169a77..07cb672 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
@@ -728,43 +728,18 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins(  ) throw(SQLException,
 // -------------------------------------------------------------------------
 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes(  ) throw(SQLException, RuntimeException)
 {
-
-    // there exists no possibility to get table types so we have to check
-    static ::rtl::OUString sTableTypes[] =
-    {
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE")),
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")),
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSTEM TABLE")),
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GLOBAL TEMPORARY")),
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL TEMPORARY")),
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ALIAS")),
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYNONYM"))
-    };
-    sal_Int32  nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
-    ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
-    Reference< XResultSet > xRef = pResult;
-    SQLUINTEGER nValue = 0;
+    Reference< XResultSet > xRef;
     try
     {
-        OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CREATE_VIEW,nValue,*this);
-    }
-    catch(const Exception&)
-    {
+        ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+        xRef = pResult;
+        pResult->openTablesTypes();
     }
-    sal_Bool bViewsSupported = (nValue & SQL_CV_CREATE_VIEW) == SQL_CV_CREATE_VIEW;
-
-    ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
-    for(sal_Int32 i=0;i < nSize;++i)
+    catch(SQLException&)
     {
-        if( !bViewsSupported && i == 1)
-            continue; // no views supported
-        ::connectivity::ODatabaseMetaDataResultSet::ORow aRow;
-        aRow.push_back(::connectivity::ODatabaseMetaDataResultSet::getEmptyValue());
-        aRow.push_back(new ::connectivity::ORowSetValueDecorator(sTableTypes[i]));
-        aRows.push_back(aRow);
+        xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
     }
-    pResult->setRows(aRows);
-     return xRef;
+    return xRef;
 }
 // -------------------------------------------------------------------------
 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw(  )
commit 193cbcadd5c7dc7ced311abff1e29f8f9817d95a
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Feb 13 17:53:19 2012 +0100

    ResMgr::TestStack more robust

diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index a4c3a86..005407f 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -1025,18 +1025,29 @@ void ResMgr::TestStack( const Resource* pResObj )
 {
     osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
 
+    int upperLimit = nCurStack;
+
+    if ( upperLimit < 0 )
+    {
+        OSL_FAIL( "resource stack underrun!" );
+        upperLimit = aStack.size() - 1;
+    }
+    else if ( upperLimit >=  static_cast<int>(aStack.size()) )
+    {
+        OSL_FAIL( "stack occupation index > allocated stack size" );
+        upperLimit = aStack.size() - 1;
+    }
+
     if ( DbgIsResource() )
     {
-        for( int i = 1; i <= nCurStack; ++i )
+        for( int i = 1; i <= upperLimit; ++i )
         {
             if ( aStack[i].pResObj == pResObj )
             {
-#ifdef DBG_UTIL
                 RscError_Impl( "Resource not freed! ", this,
                                aStack[i].pResource->GetRT(),
                                aStack[i].pResource->GetId(),
                                aStack, i-1 );
-#endif
             }
         }
     }
commit 2cb836f207d513fc718168332c793e11035c1b3d
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Feb 9 13:06:27 2012 +0100

    reorganise code for better readability
    
    No behaviour change intended. However, if behaviour changed, probably the *old* behaviour is buggy, not new one.

diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 8d7610b..68aa8d5 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -1074,17 +1074,17 @@ sal_Bool ORowSetCache::moveWindow()
             {
                 aIter = m_pMatrix->begin();
 
-                nPos    = m_nStartPos;
-                bCheck  = m_pCacheSet->absolute_checked(m_nStartPos,sal_False);
-                for(; !aIter->is() && bCheck;++aIter)
+                nPos    = m_nStartPos + 1;
+                bCheck  = m_pCacheSet->absolute_checked(nPos, sal_False);
+                for(; !aIter->is() && bCheck;++aIter, ++nPos)
                 {
                     OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator");
-                    bCheck = m_pCacheSet->next();
                     if ( bCheck ) // resultset stands on right position
                     {
                         *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
-                        m_pCacheSet->fillValueRow(*aIter,++nPos);
+                        m_pCacheSet->fillValueRow(*aIter, nPos);
                     }
+                    bCheck = m_pCacheSet->next();
                 }
             }
         }
commit 7eeee1d56b722055c2a4763e25825acecb625b10
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Feb 9 13:04:34 2012 +0100

    typo in comment

diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 1c54d97..8d7610b 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -917,7 +917,7 @@ sal_Bool ORowSetCache::moveWindow()
             const sal_Int32 nStartPosOffset = m_nStartPos - nNewStartPos; // by how much m_nStartPos moves
             m_nStartPos = nNewStartPos;
             OSL_ENSURE( static_cast<ORowSetMatrix::size_type>(nOverlapSize) <= m_pMatrix->size(), "new window end is after end of cache matrix!" );
-            // the first position in m_pMatrix whos data we don't keep;
+            // the first position in m_pMatrix whose data we don't keep;
             // content will be moved to m_pMatrix.begin()
             ORowSetMatrix::iterator aEnd (m_pMatrix->begin() + nOverlapSize);
             // the first unused position after we are done; it == m_pMatrix.end() if and only if the window is full
commit 51ebd3cc960114268d1c4cea6627702b2b1c2e48
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Feb 9 13:03:24 2012 +0100

    ORowSetCache::moveWindow: yet another off-by-one error

diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 05860f5..1c54d97 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -909,7 +909,7 @@ sal_Bool ORowSetCache::moveWindow()
             // then we fill in the rows between new and old start pos.
 
             sal_Bool bCheck;
-            bCheck = m_pCacheSet->absolute(nNewStartPos);
+            bCheck = m_pCacheSet->absolute(nNewStartPos + 1);
 
             // m_nEndPos < nNewEndPos when window not filled (e.g. there are less rows in total than window size)
             m_nEndPos = std::min(nNewEndPos, m_nEndPos);
commit 3e150b2e8e74238d63ef505da6af04b2cc4ad83e
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Feb 8 19:08:20 2012 +0100

    ORowSetCache::moveWindow fix variable inversion; fixes subsequentcheck

diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 62c43ec..05860f5 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -914,7 +914,7 @@ sal_Bool ORowSetCache::moveWindow()
             // m_nEndPos < nNewEndPos when window not filled (e.g. there are less rows in total than window size)
             m_nEndPos = std::min(nNewEndPos, m_nEndPos);
             const sal_Int32 nOverlapSize = m_nEndPos - m_nStartPos;
-            const sal_Int32 nStartPosOffset = nNewStartPos - m_nStartPos; // by how much m_nStartPos moves
+            const sal_Int32 nStartPosOffset = m_nStartPos - nNewStartPos; // by how much m_nStartPos moves
             m_nStartPos = nNewStartPos;
             OSL_ENSURE( static_cast<ORowSetMatrix::size_type>(nOverlapSize) <= m_pMatrix->size(), "new window end is after end of cache matrix!" );
             // the first position in m_pMatrix whos data we don't keep;
commit 87cf109324c7b83171e0bfaf09774496488bdfbf
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Feb 8 12:41:54 2012 +0100

    ORowSetCache: handle case total data < m_nFetchSize
    
    As a drive-by: fillMatrix update m_nEndSize

diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 0070096..62c43ec 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -762,15 +762,18 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndP
     ORowSetMatrix::iterator aIter;
     sal_Int32 i;
     sal_Bool bCheck;
+    sal_Int32 requestedStartPos;
     if ( _nNewStartPos == -1 )
     {
         aIter = m_pMatrix->begin() + (m_nEndPos - m_nStartPos);
         i = m_nEndPos + 1;
+        requestedStartPos = m_nStartPos;
     }
     else
     {
         aIter = m_pMatrix->begin();
         i = _nNewStartPos + 1;
+        requestedStartPos = _nNewStartPos;
     }
     bCheck = m_pCacheSet->absolute(i);
 
@@ -804,17 +807,17 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndP
             else
             {
                 nPos = 0;
-                _nNewEndPos = m_nRowCount;
             }
             _nNewStartPos = nPos;
+            _nNewEndPos = m_nRowCount;
             ++nPos;
             bCheck = m_pCacheSet->absolute(nPos);
 
-            for(;bCheck && nPos <= m_nStartPos && aIter != aRealEnd; ++aIter)
+            for(;bCheck && nPos <= requestedStartPos && aIter != aRealEnd; ++aIter, ++nPos)
             {
                 if(!aIter->is())
                     *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
-                m_pCacheSet->fillValueRow(*aIter,nPos++);
+                m_pCacheSet->fillValueRow(*aIter, nPos);
                 bCheck = m_pCacheSet->next();
             }
             if(aIter != aEnd)
@@ -845,6 +848,9 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndP
 // Caller is responsible for updating m_aMatrixIter
 sal_Bool ORowSetCache::moveWindow()
 {
+    OSL_ENSURE(m_nStartPos >= 0,"ORowSetCache::moveWindow: m_nStartPos is less than 0!");
+    OSL_ENSURE(m_nEndPos > m_nStartPos,"ORowSetCache::moveWindow: m_nStartPos not smaller than m_nEndPos");
+    OSL_ENSURE(m_nEndPos-m_nStartPos <= m_nFetchSize,"ORowSetCache::moveWindow: m_nStartPos and m_nEndPos too far apart");
 
     if ( m_nStartPos < m_nPosition && m_nPosition <= m_nEndPos )
     {
@@ -885,11 +891,16 @@ sal_Bool ORowSetCache::moveWindow()
     sal_Int32 nNewStartPos  = (m_nPosition - nDiff) - 1; //m_nPosition is 1-based, but m_nStartPos is 0-based
     sal_Int32 nNewEndPos    = nNewStartPos + m_nFetchSize;
 
-    if ( nNewStartPos <= m_nStartPos )
-    {   // the new window starts behind the old start pos
-        if(!m_nStartPos)
-            // Can't go any lower than that
-            return sal_True;
+    if ( nNewStartPos < 0 )
+    {
+        // The computed new window crashes through the floor (begins before first row);
+        // nNew*Pos has to be shifted by -nNewStartPos
+        nNewEndPos -= nNewStartPos;
+        nNewStartPos = 0;
+    }
+
+    if ( nNewStartPos < m_nStartPos )
+    {   // need to fill data *before* m_nStartPos
         if ( nNewEndPos > m_nStartPos )
         {   // The two regions are overlapping.
             // We'll first rotate the contents of m_pMatrix so that the overlap area
@@ -897,40 +908,41 @@ sal_Bool ORowSetCache::moveWindow()
             // it has to go to the end.
             // then we fill in the rows between new and old start pos.
 
-            sal_Bool bCheck = sal_True;
-            if ( nNewStartPos < 0 )
-            {
-                // The computed new window crashes through the floor (begins before first row);
-                // nNew*Pos has to be shifted by -nNewStartPos
-                nNewEndPos -= nNewStartPos;
-                nNewStartPos = 0;
-                bCheck = m_pCacheSet->first();
-            }
-            else
-            {
-                bCheck = m_pCacheSet->absolute(nNewStartPos);
-            }
-            const sal_Int32 nOverlapSize = nNewEndPos - m_nStartPos;
+            sal_Bool bCheck;
+            bCheck = m_pCacheSet->absolute(nNewStartPos);
+
+            // m_nEndPos < nNewEndPos when window not filled (e.g. there are less rows in total than window size)
+            m_nEndPos = std::min(nNewEndPos, m_nEndPos);
+            const sal_Int32 nOverlapSize = m_nEndPos - m_nStartPos;
+            const sal_Int32 nStartPosOffset = nNewStartPos - m_nStartPos; // by how much m_nStartPos moves
+            m_nStartPos = nNewStartPos;
             OSL_ENSURE( static_cast<ORowSetMatrix::size_type>(nOverlapSize) <= m_pMatrix->size(), "new window end is after end of cache matrix!" );
-            // the first position in m_pMatrix we don't recycle;
+            // the first position in m_pMatrix whos data we don't keep;
             // content will be moved to m_pMatrix.begin()
             ORowSetMatrix::iterator aEnd (m_pMatrix->begin() + nOverlapSize);
-            m_nStartPos = nNewStartPos;
-            m_nEndPos = nNewEndPos;
+            // the first unused position after we are done; it == m_pMatrix.end() if and only if the window is full
+            ORowSetMatrix::iterator aNewEnd (aEnd + nStartPosOffset);
+            // *m_pMatrix now looks like:
+            //   [0; nOverlapSize) i.e. [begin(); aEnd): data kept
+            //   [nOverlapSize; nOverlapSize + nStartPosOffet) i.e. [aEnd, aNewEnd): new data of positions < old m_nStartPos
+            //   [nOverlapSize + nStartPosOffet; size()) i.e. [aNewEnd, end()): unused
+            // Note that nOverlapSize + nStartPosOffet == m_nEndPos - m_nStartPos (new values)
+            // When we are finished:
+            //   [0; nStartPosOffset) i.e. [begin(); aEnd): new data of positions < old m_nStartPos
+            //   [nStartPosOffset; nOverlapSize + nStartPosOffet) i.e. [aEnd, aNewEnd): kept
+            //   [nOverlapSize + nStartPosOffet; size()) i.e. [aNewEnd, end()): unused
 
             if ( bCheck )
             {
                 {
                     ORowSetMatrix::iterator aIter(aEnd);
                     sal_Int32 nPos = m_nStartPos + 1;
-                    bCheck = fill(aIter, m_pMatrix->end(), nPos, bCheck);
+                    bCheck = fill(aIter, aNewEnd, nPos, bCheck);
                 }
 
-                ::std::rotate(m_pMatrix->begin(),aEnd,m_pMatrix->end());
+                ::std::rotate(m_pMatrix->begin(), aEnd, aNewEnd);
                 // now correct the iterator in our iterator vector
                 //  rotateCacheIterator(aEnd-m_pMatrix->begin()); //can't be used because they decrement and here we need to increment
-                ptrdiff_t nNewDist = aEnd - m_pMatrix->begin();
-                ptrdiff_t nOffSet = m_pMatrix->end() - aEnd;
                 ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
                 const ORowSetCacheMap::const_iterator aCacheEnd  = m_aCacheIterators.end();
                 for(;aCacheIter != aCacheEnd;++aCacheIter)
@@ -939,7 +951,7 @@ sal_Bool ORowSetCache::moveWindow()
                         && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified )
                     {
                         const ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
-                        if ( nDist >= nNewDist )
+                        if ( nDist >= nOverlapSize )
                         {
                             // That's from outside the overlap area; invalidate iterator.
                             aCacheIter->second.aIterator = m_pMatrix->end();
@@ -947,8 +959,8 @@ sal_Bool ORowSetCache::moveWindow()
                         else
                         {
                             // Inside overlap area: move to correct position
-                            CHECK_MATRIX_POS( (nDist + nOffSet) );
-                            aCacheIter->second.aIterator += nOffSet;
+                            CHECK_MATRIX_POS( (nDist + nStartPosOffset) );
+                            aCacheIter->second.aIterator += nStartPosOffset;
                             OSL_ENSURE(aCacheIter->second.aIterator >= m_pMatrix->begin()
                                     && aCacheIter->second.aIterator < m_pMatrix->end(),"Iterator out of area!");
                         }
@@ -963,44 +975,42 @@ sal_Bool ORowSetCache::moveWindow()
         }
         else
         {// no rows can be reused so fill again
-            if(nNewStartPos < 1) // special case // LEM: Err... Why not just call reFillMatrix(0, m_nFetchSize) ?
-            {
-                m_nStartPos = 0;
-
-                rotateCacheIterator(static_cast<ORowSetMatrix::difference_type>(m_nFetchSize+1)); // invalidate every iterator
-
-                m_pCacheSet->beforeFirst();
-
-                ORowSetMatrix::iterator aIter = m_pMatrix->begin();
-                for(sal_Int32 i=1;i<=m_nFetchSize;++i,++aIter)
-                {
-                    bool bCheck = m_pCacheSet->next();
-                    if ( bCheck )
-                    {
-                        if(!aIter->is())
-                            *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
-                        m_pCacheSet->fillValueRow(*aIter,i);
-                    }
-                    else
-                        *aIter = NULL;
-                }
-            }
-            else
-                bRet = reFillMatrix(nNewStartPos,nNewEndPos);
+            bRet = reFillMatrix(nNewStartPos,nNewEndPos);
         }
     }
-    else /* nNewStartPos > m_nStartPos */
-    {   // the new start pos is above the startpos of the window
 
-        if(nNewStartPos < (m_nStartPos+m_nFetchSize))
-        {   // Position behind window but the region is overlapping.
-            // The rows from begin() [inclusive] to (begin() + nNewStartPos - m_nStartPos) [exclusive]
+    OSL_ENSURE(nNewStartPos >= m_nStartPos, "ORowSetCache::moveWindow internal error: new start pos before current start pos");
+    if ( m_nEndPos < nNewEndPos )
+    {   // need to fill data *after* m_nEndPos
+        if( nNewStartPos < m_nEndPos )
+        {   // The two regions are overlapping.
+            const sal_Int32 nRowsInCache = m_nEndPos - m_nStartPos;
+            if ( nRowsInCache < m_nFetchSize )
+            {
+                // There is some unused space in *m_pMatrix; fill it
+                CHECK_MATRIX_POS(nRowsInCache);
+                sal_Int32 nPos = m_nEndPos + 1;
+                sal_Bool bCheck = m_pCacheSet->absolute(nPos);
+                ORowSetMatrix::iterator aIter = m_pMatrix->begin() + nRowsInCache;
+                const sal_Int32 nRowsToFetch = std::min(nNewEndPos-m_nEndPos, m_nFetchSize-nRowsInCache);
+                const ORowSetMatrix::const_iterator aEnd = aIter + nRowsToFetch;
+                bCheck = fill(aIter, aEnd, nPos, bCheck);
+                m_nEndPos = nPos - 1;
+                OSL_ENSURE( (!bCheck && m_nEndPos <= nNewEndPos ) ||
+                            ( bCheck && m_nEndPos == nNewEndPos ),
+                             "ORowSetCache::moveWindow opportunistic fetch-after-current-end went badly");
+            }
+
+            // À priori, the rows from begin() [inclusive] to (begin() + nNewStartPos - m_nStartPos) [exclusive]
             // have to be refilled with new to-be-fetched rows.
             // The rows behind this can be reused
             ORowSetMatrix::iterator aIter = m_pMatrix->begin();
             const sal_Int32 nNewStartPosInMatrix = nNewStartPos - m_nStartPos;
             CHECK_MATRIX_POS( nNewStartPosInMatrix );
-            const ORowSetMatrix::iterator aEnd  = m_pMatrix->begin() + nNewStartPosInMatrix;
+            // first position we reuse
+            const ORowSetMatrix::const_iterator aEnd  = m_pMatrix->begin() + nNewStartPosInMatrix;
+            // End of used portion of the matrix. Is < m_pMatrix->end() if less data than window size
+            ORowSetMatrix::iterator aDataEnd  = m_pMatrix->begin() + (m_nEndPos - m_nStartPos);
 
             sal_Int32 nPos = m_nEndPos + 1;
             sal_Bool bCheck = m_pCacheSet->absolute(nPos);
@@ -1012,9 +1022,9 @@ sal_Bool ORowSetCache::moveWindow()
             {
                 OSL_ENSURE(aIter == aEnd, "fill() said went till end, but did not.");
                 // rotate the end to the front
-                ::std::rotate(m_pMatrix->begin(), aEnd, m_pMatrix->end());
+                ::std::rotate(m_pMatrix->begin(), aIter, aDataEnd);
                 // now correct the iterator in our iterator vector
-                rotateCacheIterator( aEnd - m_pMatrix->begin() );
+                rotateCacheIterator( nNewStartPosInMatrix );
                 m_nStartPos = nNewStartPos;
                 m_nEndPos = nNewEndPos;
                 // now I can say how many rows we have
@@ -1038,24 +1048,26 @@ sal_Bool ORowSetCache::moveWindow()
             else
             {   // the end was reached before or at end() so we can set the start before or at nNewStartPos
                 // and possibly keep more of m_pMatrix than planned.
-                const ORowSetMatrix::iterator::difference_type nStartPosOffset  = aIter - m_pMatrix->begin();
-
-                m_nStartPos += nStartPosOffset;
-                ::std::rotate(m_pMatrix->begin(),aIter,m_pMatrix->end());
+                const ORowSetMatrix::iterator::difference_type nFetchedRows  = aIter - m_pMatrix->begin();
+                // *m_pMatrix now looks like:
+                // [0; nFetchedRows) i.e. [begin(); aIter): newly fetched data for positions m_nEndPos to m_nEndPos+nFetchedRows
+                // [nFetchedRows; ???) i.e. [aIter; aDataEnd]: data to be kept for positions m_nStartPos+nFetchedRows to ???
+
+                nPos -= 1;
+                m_nStartPos += nFetchedRows;
+                m_nEndPos = nPos;
+                ::std::rotate(m_pMatrix->begin(), aIter, aDataEnd);
                 // now correct the iterator in our iterator vector
-                rotateCacheIterator( nStartPosOffset );
+                rotateCacheIterator( nFetchedRows );
 
                 if ( !m_bRowCountFinal )
                 {
                     m_pCacheSet->previous_checked(sal_False);                   // because we stand after the last row
-                    m_nRowCount      = std::max(m_nRowCount,--nPos);    // here we have the row count
+                    m_nRowCount      = std::max(m_nRowCount, nPos);    // here we have the row count
                     OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos isn't valid!");
                     m_bRowCountFinal = sal_True;
                 }
 
-                if(m_nStartPos < 0)
-                    m_nStartPos = 0;
-                m_nEndPos = m_nStartPos + m_nFetchSize;
             }
             // here we need only to check if the beginning row is valid. If not we have to fetch it.
             if(!m_pMatrix->begin()->is())
@@ -1083,6 +1095,8 @@ sal_Bool ORowSetCache::moveWindow()
     if(!m_bRowCountFinal)
        m_nRowCount = std::max(m_nPosition,m_nRowCount);
     OSL_ENSURE(m_nStartPos >= 0,"ORowSetCache::moveWindow: m_nStartPos is less than 0!");
+    OSL_ENSURE(m_nEndPos > m_nStartPos,"ORowSetCache::moveWindow: m_nStartPos not smaller than m_nEndPos");
+    OSL_ENSURE(m_nEndPos-m_nStartPos <= m_nFetchSize,"ORowSetCache::moveWindow: m_nStartPos and m_nEndPos too far apart");
 
     return bRet;
 }
commit 744ab9be71aee1924d1de51a563be3c0db793471
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Jan 31 11:39:47 2012 +0100

    pgsql: simpler / safer check for system column

diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index b988bac..b596eb4 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -1394,16 +1394,11 @@ sal_Int32 typeNameToDataType( const OUString &typeName, const OUString &typtype
     return ret;
 }
 
-static bool isSystemColumn( const OUString &columnName )
+namespace {
+inline bool isSystemColumn( sal_Int16 attnum )
 {
-    return
-        columnName.compareToAscii( "oid" ) == 0 ||
-        columnName.compareToAscii( "tableoid" ) == 0 ||
-        columnName.compareToAscii( "xmin" ) == 0 ||
-        columnName.compareToAscii( "cmin" ) == 0 ||
-        columnName.compareToAscii( "xmax" ) == 0 ||
-        columnName.compareToAscii( "cmax" ) == 0 ||
-        columnName.compareToAscii( "ctid" ) == 0;
+    return attnum <= 0;
+}
 }
 
 // is not exported by the postgres header
@@ -1598,7 +1593,8 @@ static void columnMetaData2DatabaseTypeDescription(
             "pg_type.typtype, "              // 8
             "pg_attrdef.adsrc, "             // 9
             "pg_description.description, "   // 10
-            "pg_type.typbasetype "           // 11
+            "pg_type.typbasetype, "          // 11
+            "pg_attribute.attnum "           // 12
             "FROM pg_class, "
                  "pg_attribute LEFT JOIN pg_attrdef ON pg_attribute.attrelid = pg_attrdef.adrelid AND pg_attribute.attnum = pg_attrdef.adnum "
                               "LEFT JOIN pg_description ON pg_attribute.attrelid = pg_description.objoid AND pg_attribute.attnum=pg_description.objsubid,"
@@ -1632,8 +1628,7 @@ static void columnMetaData2DatabaseTypeDescription(
 
     while( rs->next() )
     {
-        OUString columnName = xRow->getString(3);
-        if( m_pSettings->showSystemColumns || ! isSystemColumn( columnName ) )
+        if( m_pSettings->showSystemColumns || ! isSystemColumn( xRow->getShort( 12 ) ) )
         {
             OUString sNewSchema( xRow->getString(1) );
             OUString sNewTable(  xRow->getString(2) );
@@ -1650,7 +1645,7 @@ static void columnMetaData2DatabaseTypeDescription(
             row[0] <<= m_pSettings->catalog;
             row[1] <<= sNewSchema;
             row[2] <<= sNewTable;
-            row[3] <<= columnName;
+            row[3] <<= xRow->getString(3);
             if( xRow->getString(8).equalsAscii( "d" ) )
             {
                 DatabaseTypeDescription desc( domainMap[xRow->getInt(11)] );
@@ -1667,7 +1662,7 @@ static void columnMetaData2DatabaseTypeDescription(
             // row[7] BUFFER_LENGTH not used
             row[8] <<= scale;
             // row[9] RADIX TODO
-            if( xRow->getBoolean( 6 ) && ! isSystemColumn(xRow->getString(3)) )
+            if( xRow->getBoolean( 6 ) && ! isSystemColumn(xRow->getInt( 12 )) )
             {
                 row[10] <<= OUString::valueOf(com::sun::star::sdbc::ColumnValue::NO_NULLS);
                 row[17] <<= statics.NO;
commit 5f4340c7ca645fcadfd9193dc6e633e5a8077a9b
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Feb 1 18:28:59 2012 +0100


... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list