Tag: cws_src680_qiq
User: fs      
Date: 06/06/06 06:59:44

Modified:
 /dba/dbaccess/source/core/api/
  query.cxx

Log:
 #i51143# implCollectColumns: provide columns even if the QueryComposer cannot 
parse our statement (as long as at least the underlying connection can)

File Changes:

Directory: /dba/dbaccess/source/core/api/
=========================================

File [changed]: query.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/query.cxx?r1=1.29.124.2&r2=1.29.124.3
Delta lines:  +43 -21
---------------------
--- query.cxx   1 Jun 2006 12:49:35 -0000       1.29.124.2
+++ query.cxx   6 Jun 2006 13:59:41 -0000       1.29.124.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: query.cxx,v $
  *
- *  $Revision: 1.29.124.2 $
+ *  $Revision: 1.29.124.3 $
  *
- *  last change: $Author: fs $ $Date: 2006/06/01 12:49:35 $
+ *  last change: $Author: fs $ $Date: 2006/06/06 13:59:41 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -42,6 +42,9 @@
 #ifndef DBA_CORE_WARNINGS_HXX
 #include "warnings.hxx"
 #endif
+#ifndef DBA_HELPERCOLLECTIONS_HXX
+#include "HelperCollections.hxx"
+#endif
 
 #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
 #include <cppuhelper/queryinterface.hxx>
@@ -56,27 +59,36 @@
 #include <comphelper/sequence.hxx>
 #endif
 
+/** === begin UNO includes === **/
 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
 #include <com/sun/star/sdbc/XConnection.hpp>
 #endif
 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
 #include <com/sun/star/lang/DisposedException.hpp>
 #endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+/** === end UNO includes === **/
+
 #ifndef _COMPHELPER_TYPES_HXX_ 
 #include <comphelper/types.hxx>
 #endif
 #ifndef _COMPHELPER_PROPERTY_HXX_
 #include <comphelper/property.hxx>
 #endif
+#ifndef UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX
+#include <unotools/sharedunocomponent.hxx>
+#endif
 #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
 #include "definitioncolumn.hxx"
 #endif
-#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
-#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_
-#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
-#endif
 
 #include <functional>
 
@@ -105,6 +117,7 @@
 using namespace ::comphelper;
 using namespace ::osl;
 using namespace ::cppu;
+using namespace ::utl;
 
 //........................................................................
 namespace dbaccess
@@ -186,24 +199,33 @@
 
                // fill the columns with columns from the statement
                Reference< XSQLQueryComposerFactory >  xFactory( m_xConnection, 
UNO_QUERY_THROW );
-               Reference< XSQLQueryComposer > xComposer( 
xFactory->createQueryComposer(), UNO_QUERY_THROW );
+        SharedUNOComponent< XSQLQueryComposer, DisposableComponent > xComposer(
+            Reference< XSQLQueryComposer >( xFactory->createQueryComposer(), 
UNO_QUERY_THROW ) );
 
+        Reference< XNameAccess > xColumns;
         try
         {
-                       xComposer->setQuery(m_sCommand);
-        }
-        catch( const SQLException& )
-        {
-            if ( !m_bEscapeProcessing )
-                // with escape processing, this is expected to succeed. It 
didn't,
-                // so handle this below
-                throw;
+                       xComposer->setQuery( m_sCommand );
+                   Reference< XColumnsSupplier > xCols( xComposer, 
UNO_QUERY_THROW );
+                   xColumns.set( xCols->getColumns(), UNO_QUERY_THROW );
         }
+        catch( const SQLException& ) { }
 
-               Reference<XColumnsSupplier> xCols(xComposer,UNO_QUERY);
-               Reference< XNameAccess > xColumns = xCols->getColumns();
+        SharedUNOComponent< XPreparedStatement, DisposableComponent > 
xPreparedStatement;
                if ( !xColumns.is() )
-            return;
+        {   // the QueryComposer could not parse it. Try a lean version.
+            xPreparedStatement.set( m_xConnection->prepareStatement( 
m_sCommand ), UNO_QUERY_THROW );
+                   Reference< XResultSetMetaDataSupplier > xResMetaDataSup( 
xPreparedStatement, UNO_QUERY_THROW );
+            Reference< XResultSetMetaData > xResultSetMeta( 
xResMetaDataSup->getMetaData(), UNO_QUERY_THROW );
+
+            Reference< XDatabaseMetaData > xDBMeta( 
m_xConnection->getMetaData(), UNO_QUERY_THROW );
+            ::vos::ORef< OSQLColumns > aParseColumns(
+                
::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, 
xDBMeta ) );
+            xColumns = OPrivateColumns::createWithIntrinsicNames(
+                aParseColumns, xDBMeta->storesMixedCaseQuotedIdentifiers(), 
*this, m_aMutex );
+            if ( !xColumns.is() )
+                throw RuntimeException();
+        }
 
         Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
                const ::rtl::OUString* pBegin = aNames.getConstArray();




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

Reply via email to