[Libreoffice-commits] .: 3 commits - connectivity/source dbaccess/source

Lionel Elie Mamane lmamane at kemper.freedesktop.org
Wed Nov 30 07:03:13 PST 2011


 connectivity/source/drivers/odbcbase/OStatement.cxx            |   19 ++--
 connectivity/source/drivers/postgresql/pq_connection.cxx       |    1 
 connectivity/source/drivers/postgresql/pq_databasemetadata.cxx |   13 +-
 connectivity/source/drivers/postgresql/pq_tools.cxx            |   46 +++++++---
 connectivity/source/drivers/postgresql/pq_tools.hxx            |    8 +
 connectivity/source/drivers/postgresql/pq_xcolumns.cxx         |   17 +--
 connectivity/source/drivers/postgresql/pq_xindexes.cxx         |   15 +--
 connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx      |   15 +--
 connectivity/source/drivers/postgresql/pq_xkeys.cxx            |   18 ++-
 connectivity/source/drivers/postgresql/pq_xtables.cxx          |   19 ++--
 connectivity/source/drivers/postgresql/pq_xusers.cxx           |   15 +--
 connectivity/source/drivers/postgresql/pq_xviews.cxx           |   20 ++--
 connectivity/source/inc/odbc/OStatement.hxx                    |    8 -
 dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx              |    2 
 dbaccess/source/ui/dlg/detailpages.cxx                         |    2 
 15 files changed, 129 insertions(+), 89 deletions(-)

New commits:
commit 5f3bd5bed3f5d677208dc1b897b2f21eb5f622bb
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Nov 30 15:57:08 2011 +0100

    pgsql-sdbc: Robustify against empty arrays, etc

diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx
index bf30c77..ef6ec78 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -492,6 +492,7 @@ static void properties2arrays( const Sequence< PropertyValue > & args,
     for( int i = 0; i < args.getLength() ; ++i )
     {
         bool append = true;
+        // TODO: rewrite this as a static table of keywords, and a loop over these keywords.
         if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "password" ) ) )
         {
             keywords.push_back( "password", SAL_NO_ACQUIRE );
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index 7bca582..28aad9c 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -1250,8 +1250,7 @@ sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions(  ) throw (SQLExc
         closeable->close();
 
     return new SequenceResultSet(
-        m_refMutex, *this, statics.tablesRowNames,
-        Sequence< Sequence< Any > > ( &vec[0],vec.size() ), m_pSettings->tc );
+        m_refMutex, *this, statics.tablesRowNames, sequence_of_vector(vec), m_pSettings->tc );
 }
 
 struct SortInternalSchemasLastAndPublicFirst
@@ -1325,8 +1324,7 @@ struct SortInternalSchemasLastAndPublicFirst
     if( closeable.is() )
         closeable->close();
     return new SequenceResultSet(
-        m_refMutex, *this, getStatics().schemaNames,
-        Sequence< Sequence< Any > > ( &vec[0], vec.size() ), m_pSettings->tc );
+        m_refMutex, *this, getStatics().schemaNames, sequence_of_vector(vec), m_pSettings->tc );
 }
 
 ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getCatalogs(  )
@@ -1670,8 +1668,7 @@ static void columnMetaData2DatabaseTypeDescription(
         closeable->close();
 
     return new SequenceResultSet(
-        m_refMutex, *this, statics.columnRowNames,
-        Sequence< Sequence< Any > > ( &vec[0],vec.size() ), m_pSettings->tc );
+        m_refMutex, *this, statics.columnRowNames, sequence_of_vector(vec), m_pSettings->tc );
 }
 
 ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getColumnPrivileges(
@@ -2348,7 +2345,7 @@ static void pgTypeInfo2ResultSet(
         m_refMutex,
         *this,
         getStatics().typeinfoColumnNames,
-        Sequence< Sequence< Any > > ( &vec[0] , vec.size() ),
+        sequence_of_vector(vec),
         m_pSettings->tc,
         &( getStatics().typeInfoMetaData ));
 }
@@ -2494,7 +2491,7 @@ static sal_Int32 seqContains( const Sequence< sal_Int32 > &seq, sal_Int32 value
     }
     return new SequenceResultSet(
         m_refMutex, *this, getStatics().indexinfoColumnNames,
-        Sequence< Sequence< Any > > ( &vec[0] , vec.size() ),
+        sequence_of_vector(vec),
         m_pSettings->tc );
 }
 
diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx
index ac9c66f..c27bf15 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.cxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.cxx
@@ -829,8 +829,7 @@ com::sun::star::uno::Sequence< Any > parseArray( const rtl::OUString & str ) thr
         }
         i++;
     }
-    ret = Sequence< Any > ( &elements[0] , elements.size() );
-    return ret;
+    return sequence_of_vector(elements);
 }
 
 com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const ::rtl::OUString & str )
@@ -846,7 +845,7 @@ com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const ::rtl::OUString
     }
     vec.push_back( (sal_Int32)rtl_ustr_toInt32( &str.pData->buffer[start], 10 ) );
 //     printf( "found %d\n" , rtl_ustr_toInt32( &str.pData->buffer[start], 10 ));
-    return Sequence< sal_Int32 > ( &vec[0], vec.size() );
+    return sequence_of_vector(vec);
 }
 
 void fillAttnum2attnameMap(
@@ -987,16 +986,44 @@ void fillAttnum2attnameMap(
 com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const ::rtl::OUString & str )
 {
     com::sun::star::uno::Sequence< sal_Int32 > ret;
-    if( str.getLength() > 1 && '{' == str[0] )
+    const sal_Int32 strlen = str.getLength();
+    if( str.getLength() > 1 )
     {
-        std::vector< sal_Int32, Allocator< sal_Int32 > > vec;
         sal_Int32 start = 0;
+        while ( iswspace( str.iterateCodePoints(&start) ) )
+            if ( start == strlen)
+                return ret;
+        if ( str.iterateCodePoints(&start) != L'{' )
+            return ret;
+        while ( iswspace( str.iterateCodePoints(&start) ) )
+            if ( start == strlen)
+                return ret;
+        if ( str.iterateCodePoints(&start, 0) == L'}' )
+            return ret;
+
+        std::vector< sal_Int32, Allocator< sal_Int32 > > vec;
         do
         {
-            start ++;
-            vec.push_back( (sal_Int32)rtl_ustr_toInt32( &str.getStr()[start], 10 ) );
-            start = str.indexOf( ',' , start );
-        } while( start != -1 );
+            ::rtl::OUString digits;
+            sal_Int32 c;
+            while ( isdigit( c = str.iterateCodePoints(&start) ) )
+            {
+                if ( start == strlen)
+                    return ret;
+                digits += OUString(c);
+            }
+            vec.push_back( digits.toInt32() );
+            while ( iswspace( str.iterateCodePoints(&start) ) )
+                if ( start == strlen)
+                    return ret;
+            if ( str.iterateCodePoints(&start, 0) == L'}' )
+                break;
+            if ( str.iterateCodePoints(&start) != L',' )
+                return ret;
+            if ( start == strlen)
+                return ret;
+        } while( true );
+        // vec is guaranteed non-empty
         ret = com::sun::star::uno::Sequence< sal_Int32 > ( &vec[0] , vec.size() );
     }
     return ret;
@@ -1346,5 +1373,4 @@ bool implSetObject(	const Reference< XParameters >& _rxParameters,
     return bSuccessfullyReRouted;
 }
 
-
 }
diff --git a/connectivity/source/drivers/postgresql/pq_tools.hxx b/connectivity/source/drivers/postgresql/pq_tools.hxx
index a5b7128..2f68802 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.hxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.hxx
@@ -197,6 +197,14 @@ public:
     void executeUpdate( const rtl::OUString & sql );
 };
 
+template < typename T, typename Allocator > com::sun::star::uno::Sequence<T> sequence_of_vector ( const std::vector<T, Allocator> &vec )
+{
+    if ( vec.size() == 0 )
+        return com::sun::star::uno::Sequence<T>();
+    else
+        return com::sun::star::uno::Sequence<T>( &vec[0], vec.size());
+}
+
 }
 
 #endif
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index 1e1bfd3..18f2965 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
@@ -55,8 +55,6 @@
  *
  ************************************************************************/
 
-#include <vector>
-
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 
@@ -340,8 +338,8 @@ void Columns::refresh()
 
         String2IntMap map;
 
-        std::vector< Any, Allocator< Any> > vec;
-        sal_Int32 columnIndex = 0;
+        m_values = Sequence< com::sun::star::uno::Any > ();
+        int columnIndex = 0;
         while( rs->next() )
         {
             Column * pColumn =
@@ -359,11 +357,14 @@ void Columns::refresh()
 //                     m_tableName,
 //                     name ) );
 
-            vec.push_back( makeAny( prop ) );
-            map[ name ] = columnIndex;
-            columnIndex ++;
+            {
+                const int currentColumnIndex = columnIndex++;
+                assert(currentColumnIndex  == m_values.getLength());
+                m_values.realloc( columnIndex );
+                m_values[currentColumnIndex] = makeAny( prop );
+                map[ name ] = currentColumnIndex;
+            }
         }
-        m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
         m_name2index.swap( map );
     }
     catch ( com::sun::star::sdbc::SQLException & e )
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
index c965bac..523bc65 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
@@ -55,8 +55,6 @@
  *
  ************************************************************************/
 
-#include <vector>
-
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 
@@ -165,7 +163,7 @@ void Indexes::refresh()
 
         Reference< XRow > row( rs, UNO_QUERY );
         String2IntMap map;
-        std::vector< Any, Allocator< Any> > vec;
+        m_values = Sequence< com::sun::star::uno::Any > ();
         sal_Int32 index = 0;
         while( rs->next() )
         {
@@ -205,11 +203,14 @@ void Indexes::refresh()
             pIndex->setPropertyValue_NoBroadcast_public(
                 st.PRIVATE_COLUMN_INDEXES, makeAny( columnNames ));
 
-            vec.push_back( makeAny( prop ) );
-            map[ currentIndexName ] = index;
-            index ++;
+            {
+                const int currentIndex = index++;
+                assert(currentIndex  == m_values.getLength());
+                m_values.realloc( index );
+                m_values[currentIndex] = makeAny( prop );
+                map[ currentIndexName ] = currentIndex;
+            }
         }
-        m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
         m_name2index.swap( map );
     }
     catch ( com::sun::star::sdbc::SQLException & e )
diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
index ac0d65e..bbee0fa 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
@@ -55,8 +55,6 @@
  *
  ************************************************************************/
 
-#include <vector>
-
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 
@@ -151,7 +149,7 @@ void KeyColumns::refresh()
 
         String2IntMap map;
 
-        std::vector< Any, Allocator< Any> > vec;
+        m_values = Sequence< com::sun::star::uno::Any > ();
         sal_Int32 columnIndex = 0;
         while( rs->next() )
         {
@@ -177,11 +175,14 @@ void KeyColumns::refresh()
                     st.RELATED_COLUMN, makeAny( m_foreignColumnNames[keyindex]) );
             }
 
-            vec.push_back( makeAny( prop ) );
-            map[ name ] = columnIndex;
-            columnIndex ++;
+            {
+                const int currentColumnIndex = columnIndex++;
+                assert(currentColumnIndex  == m_values.getLength());
+                m_values.realloc( columnIndex );
+                m_values[currentColumnIndex] = makeAny( prop );
+                map[ name ] = currentColumnIndex;
+            }
         }
-        m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
         m_name2index.swap( map );
     }
     catch ( com::sun::star::sdbc::SQLException & e )
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
index 4db692e..9ad71b1 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
@@ -55,8 +55,6 @@
  *
  ************************************************************************/
 
-#include <vector>
-
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 
@@ -226,8 +224,8 @@ void Keys::refresh()
         Reference< XRow > xRow( rs , UNO_QUERY );
 
         String2IntMap map;
-        std::vector< Any, Allocator< Any> > vec;
-        sal_Int32 keyIndex = 0;
+        m_values = Sequence< com::sun::star::uno::Any > ();
+        int keyIndex = 0;
         while( rs->next() )
         {
             Key * pKey =
@@ -268,11 +266,15 @@ void Keys::refresh()
                         string2intarray( xRow->getString(8) ) ) ) );
             }
 
-            vec.push_back( makeAny( prop ) );
-            map[ xRow->getString( 1 ) ] = keyIndex;
-            keyIndex ++;
+
+            {
+                const int currentKeyIndex = keyIndex++;
+                map[ xRow->getString( 1 ) ] = currentKeyIndex;
+                assert(currentKeyIndex == m_values.getLength());
+                m_values.realloc( keyIndex );
+                m_values[currentKeyIndex] = makeAny( prop );
+            }
         }
-        m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
         m_name2index.swap( map );
     }
     catch ( com::sun::star::sdbc::SQLException & e )
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx
index 8e7207d..483cc3f 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx
@@ -55,8 +55,6 @@
  *
  ************************************************************************/
 
-#include <vector>
-
 #include <rtl/ustrbuf.hxx>
 
 #include <com/sun/star/sdbc/XRow.hpp>
@@ -137,7 +135,7 @@ void Tables::refresh()
 
         String2IntMap map;
 
-        std::vector< Any, Allocator< Any> > vec;
+        m_values = Sequence< com::sun::star::uno::Any > ();
         sal_Int32 tableIndex = 0;
         while( rs->next() )
         {
@@ -170,13 +168,16 @@ void Tables::refresh()
                            com::sun::star::sdbcx::Privilege::REFERENCE |
                            com::sun::star::sdbcx::Privilege::DROP ) ) );
 
-            vec.push_back( makeAny( prop ) );
-            OUStringBuffer buf( name.getLength() + schema.getLength() + 1);
-            buf.append( schema ).appendAscii( "." ).append( name );
-            map[ buf.makeStringAndClear() ] = tableIndex;
-            tableIndex ++;
+            {
+                const int currentTableIndex = tableIndex++;
+                assert(currentTableIndex  == m_values.getLength());
+                m_values.realloc( tableIndex );
+                m_values[currentTableIndex] = makeAny( prop );
+                OUStringBuffer buf( name.getLength() + schema.getLength() + 1);
+                buf.append( schema ).appendAscii( "." ).append( name );
+                map[ buf.makeStringAndClear() ] = currentTableIndex;
+            }
         }
-        m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
         m_name2index.swap( map );
     }
     catch ( com::sun::star::sdbc::SQLException & e )
diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx
index b41bd3a..390bc47 100644
--- a/connectivity/source/drivers/postgresql/pq_xusers.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx
@@ -55,8 +55,6 @@
  *
  ************************************************************************/
 
-#include <vector>
-
 #include <rtl/ustrbuf.hxx>
 
 #include <com/sun/star/sdbc/XRow.hpp>
@@ -126,7 +124,7 @@ void Users::refresh()
 
         String2IntMap map;
 
-        std::vector< Any, Allocator< Any> > vec;
+        m_values = Sequence< com::sun::star::uno::Any > ( );
         sal_Int32 tableIndex = 0;
         while( rs->next() )
         {
@@ -138,11 +136,14 @@ void Users::refresh()
             pUser->setPropertyValue_NoBroadcast_public(
                 st.NAME , makeAny(xRow->getString( TABLE_INDEX_CATALOG+1) ) );
 
-            vec.push_back( makeAny(prop ) );
-            map[ name ] = tableIndex;
-            tableIndex ++;
+            {
+                const int currentTableIndex = tableIndex++;
+                assert(currentTableIndex  == m_values.getLength());
+                m_values.realloc( tableIndex );
+                m_values[currentTableIndex] = makeAny( prop );
+                map[ name ] = currentTableIndex;
+            }
         }
-        m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
         m_name2index.swap( map );
     }
     catch ( com::sun::star::sdbc::SQLException & e )
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx
index b39bb42..b949c1a 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx
@@ -55,8 +55,6 @@
  *
  ************************************************************************/
 
-#include <vector>
-
 #include <rtl/ustrbuf.hxx>
 
 #include <com/sun/star/sdbc/XRow.hpp>
@@ -135,7 +133,7 @@ void Views::refresh()
 
         Reference< XRow > xRow( rs , UNO_QUERY );
 
-        std::vector< Any, Allocator< Any> > vec;
+        m_values = Sequence< com::sun::star::uno::Any > ();
         String2IntMap map;
         sal_Int32 viewIndex = 0;
 
@@ -152,15 +150,17 @@ void Views::refresh()
             pView->setPropertyValue_NoBroadcast_public(st.NAME , makeAny(table) );
             pView->setPropertyValue_NoBroadcast_public(st.SCHEMA_NAME, makeAny(schema) );
             pView->setPropertyValue_NoBroadcast_public(st.COMMAND, makeAny(command) );
-            vec.push_back( makeAny( prop ) );
-
-            OUStringBuffer buf( table.getLength() + schema.getLength() + 1);
-            buf.append( schema ).appendAscii( "." ).append( table );
-            map[ buf.makeStringAndClear() ] = viewIndex;
-            viewIndex ++;
 
+            {
+                const int currentViewIndex = viewIndex++;
+                assert(currentViewIndex  == m_values.getLength());
+                m_values.realloc( viewIndex );
+                m_values[currentViewIndex] = makeAny( prop );
+                OUStringBuffer buf( table.getLength() + schema.getLength() + 1);
+                buf.append( schema ).appendAscii( "." ).append( table );
+                map[ buf.makeStringAndClear() ] = currentViewIndex;
+            }
         }
-        m_values = Sequence< com::sun::star::uno::Any > ( &vec[0], vec.size() );
         m_name2index.swap( map );
     }
     catch ( com::sun::star::sdbc::SQLException & e )
commit c75e15c980714c746a0b4b023cecf486cbe81bdc
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Nov 30 12:51:46 2011 +0100

    Failure to load JDBC driver is an error, not info

diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
index edc4274..2f54e75 100644
--- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
@@ -578,7 +578,7 @@ DBG_NAME(OMySQLIntroPageSetup)
         }
 
         sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
-        OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
+        OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String(), WB_OK | WB_DEF_OK, OSQLMessageBox::MessageType::Error );
         aMsg.Execute();
         return 0L;
     }
diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx
index accc7c5..734bba1 100644
--- a/dbaccess/source/ui/dlg/detailpages.cxx
+++ b/dbaccess/source/ui/dlg/detailpages.cxx
@@ -647,7 +647,7 @@ namespace dbaui
         }
 
         sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
-        OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
+        OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String(), WB_OK | WB_DEF_OK, OSQLMessageBox::MessageType::Error );
         aMsg.Execute();
         return 0L;
     }
commit 9a466d9718cceeb4ace9e3352a173c7b62387eee
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Nov 29 17:49:36 2011 +0100

    ODBC: use right integer length to get Statement Options
    
    Else (on 64bits platform) the driver smashes our stack: SQL_ULEN is 64 bits
    Widen result type of getQueryTimeOut, getMaxFieldSize and getMaxRows so that it will always fit

diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx
index 0c0a10a..1e8558c 100644
--- a/connectivity/source/drivers/odbcbase/OStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OStatement.cxx
@@ -446,11 +446,11 @@ Reference< XResultSet > OStatement_Base::getResultSet (sal_Bool checkCount) thro
 // Invoke SQLGetStmtOption with the given option.
 //--------------------------------------------------------------------
 
-sal_Int32 OStatement_Base::getStmtOption (short fOption) const
+template < typename T, SQLINTEGER BufferLength > T OStatement_Base::getStmtOption (short fOption) const
 {
-    sal_Int32   result = 0;
+    T result = 0;
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
-    N3SQLGetStmtAttr(m_aStatementHandle, fOption,&result,SQL_IS_INTEGER,NULL);
+    N3SQLGetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, NULL);
     return result;
 }
 // -------------------------------------------------------------------------
@@ -669,14 +669,15 @@ void SAL_CALL OStatement_Base::clearWarnings(  ) throw(SQLException, RuntimeExce
 }
 // -------------------------------------------------------------------------
 //------------------------------------------------------------------------------
-sal_Int32 OStatement_Base::getQueryTimeOut() const
+sal_Int64 OStatement_Base::getQueryTimeOut() const
 {
-    return getStmtOption(SQL_ATTR_QUERY_TIMEOUT);
+    return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_QUERY_TIMEOUT);
 }
 //------------------------------------------------------------------------------
-sal_Int32 OStatement_Base::getMaxRows() const
+sal_Int64 OStatement_Base::getMaxRows() const
 {
-    return getStmtOption(SQL_ATTR_MAX_ROWS);
+    // How do I say I want a SQLULEN??
+    return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_ROWS);
 }
 //------------------------------------------------------------------------------
 sal_Int32 OStatement_Base::getResultSetConcurrency() const
@@ -745,9 +746,9 @@ sal_Int32 OStatement_Base::getFetchSize() const
     return nValue;
 }
 //------------------------------------------------------------------------------
-sal_Int32 OStatement_Base::getMaxFieldSize() const
+sal_Int64 OStatement_Base::getMaxFieldSize() const
 {
-    return getStmtOption(SQL_ATTR_MAX_LENGTH);
+    return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_LENGTH);
 }
 //------------------------------------------------------------------------------
 ::rtl::OUString OStatement_Base::getCursorName() const
diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx
index 3532156..2ad1a42 100644
--- a/connectivity/source/inc/odbc/OStatement.hxx
+++ b/connectivity/source/inc/odbc/OStatement.hxx
@@ -87,9 +87,9 @@ namespace connectivity
 
         protected:
 
-            sal_Int32 getQueryTimeOut()         const;
-            sal_Int32 getMaxFieldSize()         const;
-            sal_Int32 getMaxRows()              const;
+            sal_Int64 getQueryTimeOut()         const;
+            sal_Int64 getMaxFieldSize()         const;
+            sal_Int64 getMaxRows()              const;
             sal_Int32 getResultSetConcurrency() const;
             sal_Int32 getResultSetType()        const;
             sal_Int32 getFetchDirection()       const;
@@ -97,7 +97,7 @@ namespace connectivity
             ::rtl::OUString getCursorName()     const;
             sal_Bool isUsingBookmarks()         const;
             sal_Bool getEscapeProcessing()      const;
-            sal_Int32 getStmtOption (short fOption) const;
+            template < typename T, SQLINTEGER BufferLength > T getStmtOption (short fOption) const;
 
             void setQueryTimeOut(sal_Int32 _par0)           ;
             void setMaxFieldSize(sal_Int32 _par0)           ;


More information about the Libreoffice-commits mailing list