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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Dec 2 09:35:34 PST 2012


 connectivity/source/drivers/jdbc/JStatement.cxx    |   14 ++++-
 dbaccess/source/ui/inc/TableConnectionData.hxx     |    3 -
 dbaccess/source/ui/querydesign/QueryDesignView.cxx |   56 +++++++++++++--------
 3 files changed, 50 insertions(+), 23 deletions(-)

New commits:
commit c25bb400bbfe20b3b13237ed10935ec9d0f6d769
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Dec 2 18:32:38 2012 +0100

    fdo#42165 make nested joins as per strict ANSI SQL
    
    Change-Id: I605d3811b27c33e35670306bb03b5a796ab72bc0

diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx
index bc084db..728978d 100644
--- a/dbaccess/source/ui/inc/TableConnectionData.hxx
+++ b/dbaccess/source/ui/inc/TableConnectionData.hxx
@@ -81,7 +81,8 @@ namespace dbaui
         */
         void normalizeLines();
 
-        OConnectionLineDataVec* GetConnLineDataList(){ return &m_vConnLineData; }
+        const OConnectionLineDataVec* GetConnLineDataList() const { return &m_vConnLineData; }
+        OConnectionLineDataVec* GetConnLineDataList() { return &m_vConnLineData; }
 
         inline TTableWindowData::value_type getReferencingTable() const { return m_pReferencingTable; }
         inline TTableWindowData::value_type getReferencedTable()  const { return m_pReferencedTable;  }
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index e81da08..8ba3912 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -290,14 +290,14 @@ namespace
     }
     //------------------------------------------------------------------------------
     ::rtl::OUString BuildJoinCriteria(  const Reference< XConnection>& _xConnection,
-                                        OConnectionLineDataVec* pLineDataList,
-                                        OQueryTableConnectionData* pData)
+                                        const OConnectionLineDataVec* pLineDataList,
+                                        const OQueryTableConnectionData* pData)
     {
         ::rtl::OUStringBuffer aCondition;
         if ( _xConnection.is() )
         {
-            OConnectionLineDataVec::iterator aIter = pLineDataList->begin();
-            OConnectionLineDataVec::iterator aEnd = pLineDataList->end();
+            OConnectionLineDataVec::const_iterator aIter = pLineDataList->begin();
+            OConnectionLineDataVec::const_iterator aEnd = pLineDataList->end();
             try
             {
                 const Reference< XDatabaseMetaData >  xMetaData = _xConnection->getMetaData();
@@ -392,7 +392,7 @@ namespace
     ::rtl::OUString BuildJoin(  const Reference< XConnection>& _xConnection,
                                 const ::rtl::OUString& rLh,
                                 const ::rtl::OUString& rRh,
-                                OQueryTableConnectionData* pData)
+                                const OQueryTableConnectionData* pData)
     {
 
         String aErg(rLh);
@@ -430,9 +430,9 @@ namespace
     }
     //------------------------------------------------------------------------------
     ::rtl::OUString BuildJoin(  const Reference< XConnection>& _xConnection,
-                                OQueryTableWindow* pLh,
-                                OQueryTableWindow* pRh,
-                                OQueryTableConnectionData* pData
+                                const OQueryTableWindow* pLh,
+                                const OQueryTableWindow* pRh,
+                                const OQueryTableConnectionData* pData
                                 )
     {
         bool bForce = pData->GetJoinType() == CROSS_JOIN || pData->isNatural();
@@ -441,20 +441,36 @@ namespace
     //------------------------------------------------------------------------------
     ::rtl::OUString BuildJoin(  const Reference< XConnection>& _xConnection,
                                 const ::rtl::OUString &rLh,
-                                OQueryTableWindow* pRh,
-                                OQueryTableConnectionData* pData
+                                const OQueryTableWindow* pRh,
+                                const OQueryTableConnectionData* pData
                                 )
     {
         return BuildJoin(_xConnection,rLh,BuildTable(_xConnection,pRh),pData);
     }
     //------------------------------------------------------------------------------
     ::rtl::OUString BuildJoin(  const Reference< XConnection>& _xConnection,
-                                OQueryTableWindow* pLh,
+                                const OQueryTableWindow* pLh,
                                 const ::rtl::OUString &rRh,
-                                OQueryTableConnectionData* pData
+                                const OQueryTableConnectionData* pData
                                 )
     {
-        return BuildJoin(_xConnection,BuildTable(_xConnection,pLh),rRh,pData);
+        // strict ANSI SQL:
+        // - does not support any bracketing of JOINS
+        // - supports nested joins only in the LEFT HAND SIDE
+        // In this case, we are trying to build a join with a nested join
+        // in the right hand side.
+        // So switch the direction of the join and both hand sides.
+        OQueryTableConnectionData data(*pData);
+        switch (data.GetJoinType())
+        {
+            case LEFT_JOIN:
+                data.SetJoinType(RIGHT_JOIN);
+                break;
+            case RIGHT_JOIN:
+                data.SetJoinType(LEFT_JOIN);
+                break;
+        }
+        return BuildJoin(_xConnection, rRh, BuildTable(_xConnection,pLh), &data);
     }
     //------------------------------------------------------------------------------
     void GetNextJoin(   const Reference< XConnection>& _xConnection,
commit b245079a50c94dc503628619f6342b70dcdc6e66
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Dec 2 18:31:17 2012 +0100

    Expand comment
    
    Change-Id: I7d699222940a6ee99595d84dd8b2068e9b86ee67

diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index a6d21db..e81da08 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -1093,6 +1093,10 @@ namespace
             }
 
             // and now all inner joins
+            // these are implemented as
+            // "FROM tbl1, tbl2 WHERE tbl1.col1=tlb2.col2"
+            // rather than
+            // "FROM tbl1 INNER JOIN tbl2 ON tbl1.col1=tlb2.col2"
             aIter = pConnList->begin();
             for(;aIter != aEnd;++aIter)
             {
commit 66e5cf7096a2dc2287f9265087d45c57f1069b9b
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Dec 2 18:29:18 2012 +0100

    Catch all exceptions to respect specification
    
    In particular, getMaxRows() can throw SQLException
    
    Change-Id: I1f49afe8258d98000bff34e18f4d98967c46e1b3

diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx
index a7e24bc..0745068 100644
--- a/connectivity/source/drivers/jdbc/JStatement.cxx
+++ b/connectivity/source/drivers/jdbc/JStatement.cxx
@@ -30,6 +30,7 @@
 #include <comphelper/sequence.hxx>
 #include "TConnection.hxx"
 #include <comphelper/types.hxx>
+#include <tools/diagnose_ex.h>
 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
 #include <com/sun/star/sdbc/ResultSetType.hpp>
 #include <com/sun/star/sdbc/FetchDirection.hpp>
@@ -623,8 +624,10 @@ sal_Bool java_sql_Statement_Base::convertFastPropertyValue(
                             const Any& rValue )
                                 throw (::com::sun::star::lang::IllegalArgumentException)
 {
-    switch(nHandle)
+    try
     {
+        switch(nHandle)
+        {
         case PROPERTY_ID_QUERYTIMEOUT:
             return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
         case PROPERTY_ID_MAXFIELDSIZE:
@@ -647,6 +650,15 @@ sal_Bool java_sql_Statement_Base::convertFastPropertyValue(
             //  return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
         default:
             ;
+        }
+    }
+    catch(::com::sun::star::lang::IllegalArgumentException)
+    {
+        throw;
+    }
+    catch(::com::sun::star::uno::Exception)
+    {
+        DBG_UNHANDLED_EXCEPTION();
     }
     return sal_False;
 }
commit 6174694ee7efe7b94d0bb1987be1c48f1ca25cf5
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Dec 2 16:06:58 2012 +0100

    janitorial: prefix increment when don't care about current value
    
    Change-Id: Id19369bb9d9cb2a0bab0dacb200cf5bf488c3b20

diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index dfc0114..a6d21db 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -1028,8 +1028,8 @@ namespace
             for(;aIter != aEnd;++aIter)
             {
                 static_cast<OQueryTableConnection*>(*aIter)->SetVisited(sal_False);
-                aConnectionCount[(*aIter)->GetSourceWin()]++;
-                aConnectionCount[(*aIter)->GetDestWin()]++;
+                ++aConnectionCount[(*aIter)->GetSourceWin()];
+                ++aConnectionCount[(*aIter)->GetDestWin()];
             }
             ::std::multimap<sal_Int32 , OTableWindow*> aMulti;
             ::std::map<OTableWindow*,sal_Int32>::iterator aCountIter = aConnectionCount.begin();
commit 0fe6d567be1a58a466b07e8c3732f0cbcc436443
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Dec 2 15:56:35 2012 +0100

    janitorial: simplify code, no behaviour change
    
    operator[] on a map implicitly adds an entry and default-initializes value part
    
    Change-Id: Iab7817fb7fef5e9a6afdeb74be0d523fde59b5c1

diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index cf4fc38..dfc0114 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -1028,14 +1028,8 @@ namespace
             for(;aIter != aEnd;++aIter)
             {
                 static_cast<OQueryTableConnection*>(*aIter)->SetVisited(sal_False);
-                if ( aConnectionCount.find((*aIter)->GetSourceWin()) == aConnectionCount.end() )
-                    aConnectionCount.insert(::std::map<OTableWindow*,sal_Int32>::value_type((*aIter)->GetSourceWin(),0));
-                else
-                    aConnectionCount[(*aIter)->GetSourceWin()]++;
-                if ( aConnectionCount.find((*aIter)->GetDestWin()) == aConnectionCount.end() )
-                    aConnectionCount.insert(::std::map<OTableWindow*,sal_Int32>::value_type((*aIter)->GetDestWin(),0));
-                else
-                    aConnectionCount[(*aIter)->GetDestWin()]++;
+                aConnectionCount[(*aIter)->GetSourceWin()]++;
+                aConnectionCount[(*aIter)->GetDestWin()]++;
             }
             ::std::multimap<sal_Int32 , OTableWindow*> aMulti;
             ::std::map<OTableWindow*,sal_Int32>::iterator aCountIter = aConnectionCount.begin();


More information about the Libreoffice-commits mailing list