LCOV - code coverage report
Current view: top level - connectivity/source/drivers/firebird - Statement.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 67 0.0 %
Date: 2014-04-14 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "Connection.hxx"
      21             : #include "Driver.hxx"
      22             : #include "ResultSet.hxx"
      23             : #include "Statement.hxx"
      24             : #include "Util.hxx"
      25             : 
      26             : #include <comphelper/sequence.hxx>
      27             : #include <osl/diagnose.h>
      28             : #include <osl/thread.h>
      29             : #include <rtl/ustrbuf.hxx>
      30             : 
      31             : #include <com/sun/star/lang/DisposedException.hpp>
      32             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      33             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      34             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      35             : 
      36             : using namespace connectivity::firebird;
      37             : 
      38             : using namespace com::sun::star;
      39             : using namespace com::sun::star::uno;
      40             : using namespace com::sun::star::lang;
      41             : using namespace com::sun::star::beans;
      42             : using namespace com::sun::star::sdbc;
      43             : using namespace com::sun::star::sdbcx;
      44             : using namespace com::sun::star::container;
      45             : using namespace com::sun::star::io;
      46             : using namespace com::sun::star::util;
      47             : 
      48             : using namespace ::comphelper;
      49             : using namespace ::osl;
      50             : using namespace ::rtl;
      51             : using namespace ::std;
      52             : 
      53             : // ---- XBatchExecution - UNSUPPORTED ----------------------------------------
      54           0 : void SAL_CALL OStatement::addBatch(const OUString& sql)
      55             :     throw(SQLException, RuntimeException, std::exception)
      56             : {
      57             :     (void) sql;
      58           0 : }
      59             : 
      60           0 : void SAL_CALL OStatement::clearBatch() throw(SQLException, RuntimeException, std::exception)
      61             : {
      62           0 : }
      63             : 
      64           0 : Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch() throw(SQLException, RuntimeException, std::exception)
      65             : {
      66           0 :     return Sequence< sal_Int32 >();
      67             : }
      68             : 
      69           0 : IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
      70             : 
      71           0 : void SAL_CALL OStatement::acquire() throw()
      72             : {
      73           0 :     OStatementCommonBase::acquire();
      74           0 : }
      75             : 
      76           0 : void SAL_CALL OStatement::release() throw()
      77             : {
      78           0 :     OStatementCommonBase::release();
      79           0 : }
      80             : 
      81           0 : void OStatement::disposeResultSet()
      82             : {
      83           0 :     MutexGuard aGuard(m_aMutex);
      84           0 :     checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
      85             : 
      86           0 :     OStatementCommonBase::disposeResultSet();
      87             : 
      88           0 :     if (m_pSqlda)
      89             :     {
      90           0 :         freeSQLVAR(m_pSqlda);
      91           0 :         free(m_pSqlda);
      92           0 :         m_pSqlda = 0;
      93           0 :     }
      94           0 : }
      95             : 
      96             : // ---- XStatement -----------------------------------------------------------
      97           0 : sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql)
      98             :     throw(SQLException, RuntimeException, std::exception)
      99             : {
     100           0 :     execute(sql);
     101           0 :     return getStatementChangeCount();
     102             : }
     103             : 
     104             : 
     105           0 : uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& sql)
     106             :     throw(SQLException, RuntimeException, std::exception)
     107             : {
     108           0 :     MutexGuard aGuard(m_aMutex);
     109           0 :     checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
     110             : 
     111             :     SAL_INFO("connectivity.firebird", "executeQuery(" << sql << ")");
     112             : 
     113           0 :     ISC_STATUS aErr = 0;
     114             : 
     115           0 :     disposeResultSet();
     116             : 
     117             :     prepareAndDescribeStatement(sql,
     118           0 :                                 m_pSqlda);
     119             : 
     120             :     aErr = isc_dsql_execute(m_statusVector,
     121           0 :                             &m_pConnection->getTransaction(),
     122             :                             &m_aStatementHandle,
     123             :                             1,
     124           0 :                             NULL);
     125           0 :     if (aErr)
     126             :         SAL_WARN("connectivity.firebird", "isc_dsql_execute failed");
     127             : 
     128           0 :     m_xResultSet = new OResultSet(m_pConnection,
     129             :                                   m_aMutex,
     130             :                                   uno::Reference< XInterface >(*this),
     131             :                                   m_aStatementHandle,
     132           0 :                                   m_pSqlda);
     133             : 
     134             :     // TODO: deal with cleanup
     135             : 
     136           0 :     evaluateStatusVector(m_statusVector, sql, *this);
     137             : 
     138           0 :     if (isDDLStatement())
     139             :     {
     140           0 :         m_pConnection->commit();
     141           0 :         m_pConnection->notifyDatabaseModified();
     142             :     }
     143           0 :     else if (getStatementChangeCount() > 0)
     144             :     {
     145           0 :         m_pConnection->notifyDatabaseModified();
     146             :     }
     147             : 
     148           0 :     return m_xResultSet;
     149             : }
     150             : 
     151           0 : sal_Bool SAL_CALL OStatement::execute(const OUString& sql)
     152             :     throw(SQLException, RuntimeException, std::exception)
     153             : {
     154           0 :     uno::Reference< XResultSet > xResults = executeQuery(sql);
     155           0 :     return xResults.is();
     156             :     // TODO: what if we have multiple results?
     157             : }
     158             : 
     159           0 : uno::Reference< XConnection > SAL_CALL OStatement::getConnection()
     160             :     throw(SQLException, RuntimeException, std::exception)
     161             : {
     162           0 :     MutexGuard aGuard(m_aMutex);
     163           0 :     checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
     164             : 
     165           0 :     return (uno::Reference< XConnection >)m_pConnection;
     166             : }
     167             : 
     168           0 : Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     169             : {
     170           0 :     Any aRet = OStatement_Base::queryInterface(rType);
     171           0 :     if(!aRet.hasValue())
     172           0 :         aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
     173           0 :     if(!aRet.hasValue())
     174           0 :         aRet = OStatementCommonBase::queryInterface(rType);
     175           0 :     return aRet;
     176             : }
     177             : 
     178           0 : uno::Sequence< Type > SAL_CALL OStatement::getTypes()
     179             :     throw(RuntimeException, std::exception)
     180             : {
     181             :     return concatSequences(OStatement_Base::getTypes(),
     182           0 :                            OStatementCommonBase::getTypes());
     183             : }
     184             : 
     185           0 : void SAL_CALL OStatement::close() throw(SQLException, RuntimeException, std::exception)
     186             : {
     187           0 :     OStatementCommonBase::close();
     188           0 : }
     189             : 
     190           0 : void SAL_CALL OStatement::disposing()
     191             : {
     192           0 :     disposeResultSet();
     193           0 :     close();
     194           0 : }
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10