LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_statement.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 3 0.0 %
Date: 2014-04-14 Functions: 0 4 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             :  *
       4             :  *  Effective License of whole file:
       5             :  *
       6             :  *    This library is free software; you can redistribute it and/or
       7             :  *    modify it under the terms of the GNU Lesser General Public
       8             :  *    License version 2.1, as published by the Free Software Foundation.
       9             :  *
      10             :  *    This library is distributed in the hope that it will be useful,
      11             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  *    Lesser General Public License for more details.
      14             :  *
      15             :  *    You should have received a copy of the GNU Lesser General Public
      16             :  *    License along with this library; if not, write to the Free Software
      17             :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      18             :  *    MA  02111-1307  USA
      19             :  *
      20             :  *  Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
      21             :  *
      22             :  *    The Contents of this file are made available subject to the terms of
      23             :  *    the GNU Lesser General Public License Version 2.1
      24             :  *
      25             :  *    Copyright: 2000 by Sun Microsystems, Inc.
      26             :  *
      27             :  *    Contributor(s): Joerg Budischewski
      28             :  *
      29             :  *  All parts contributed on or after August 2011:
      30             :  *
      31             :  *    This Source Code Form is subject to the terms of the Mozilla Public
      32             :  *    License, v. 2.0. If a copy of the MPL was not distributed with this
      33             :  *    file, You can obtain one at http://mozilla.org/MPL/2.0/.
      34             :  *
      35             :  ************************************************************************/
      36             : 
      37             : #ifndef _PQ_STATEMENT_HXX_
      38             : #define _PQ_STATEMENT_HXX_
      39             : #include <cppuhelper/propshlp.hxx>
      40             : #include <cppuhelper/component.hxx>
      41             : 
      42             : #include <libpq-fe.h>
      43             : 
      44             : #include "pq_connection.hxx"
      45             : #include <com/sun/star/sdbc/XMultipleResults.hpp>
      46             : #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
      47             : #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
      48             : 
      49             : namespace pq_sdbc_driver
      50             : {
      51             : 
      52             : static const sal_Int32 STATEMENT_CURSOR_NAME = 0;
      53             : static const sal_Int32 STATEMENT_ESCAPE_PROCESSING = 1;
      54             : static const sal_Int32 STATEMENT_FETCH_DIRECTION = 2;
      55             : static const sal_Int32 STATEMENT_FETCH_SIZE = 3;
      56             : static const sal_Int32 STATEMENT_MAX_FIELD_SIZE = 4;
      57             : static const sal_Int32 STATEMENT_MAX_ROWS = 5;
      58             : static const sal_Int32 STATEMENT_QUERY_TIME_OUT = 6;
      59             : static const sal_Int32 STATEMENT_RESULT_SET_CONCURRENCY = 7;
      60             : static const sal_Int32 STATEMENT_RESULT_SET_TYPE = 8;
      61             : 
      62             : #define STATEMENT_SIZE 9
      63             : 
      64             : class Statement : public cppu::OComponentHelper,
      65             :                   public cppu::OPropertySetHelper,
      66             :                   public com::sun::star::sdbc::XStatement,
      67             :                   public com::sun::star::sdbc::XCloseable,
      68             :                   public com::sun::star::sdbc::XWarningsSupplier,
      69             :                   public com::sun::star::sdbc::XMultipleResults,
      70             :                   public com::sun::star::sdbc::XGeneratedResultSet,
      71             :                   public com::sun::star::sdbc::XResultSetMetaDataSupplier
      72             : {
      73             : private:
      74             :     com::sun::star::uno::Any m_props[STATEMENT_SIZE];
      75             :     com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
      76             :     ConnectionSettings *m_pSettings;
      77             :     com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > m_lastResultset;
      78             :     ::rtl::Reference< RefCountedMutex > m_refMutex;
      79             :     sal_Bool  m_multipleResultAvailable;
      80             :     sal_Int32 m_multipleResultUpdateCount;
      81             :     sal_Int32 m_lastOidInserted;
      82             :     OUString m_lastTableInserted;
      83             :     OString m_lastQuery;
      84             : 
      85             : public:
      86             :     /**
      87             :      * @param ppConnection The piece of memory, pConnection points to, is accessisble
      88             :      *                     as long as a reference to paramenter con is held.
      89             :      */
      90             :     Statement( const rtl::Reference< RefCountedMutex > & refMutex,
      91             :                const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection> & con,
      92             :                struct ConnectionSettings *pSettings );
      93             : 
      94             :     virtual ~Statement();
      95             : public: // XInterface
      96           0 :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { OComponentHelper::acquire(); }
      97           0 :     virtual void SAL_CALL release() throw() SAL_OVERRIDE { OComponentHelper::release(); }
      98             :     virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & reqType )
      99             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     100             : 
     101             : public: // XCloseable
     102             :     virtual void SAL_CALL close(  )
     103             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     104             : 
     105             : public: // XStatement
     106             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
     107             :         const OUString& sql )
     108             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     109             :     virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql )
     110             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     111             :     virtual sal_Bool SAL_CALL execute( const OUString& sql )
     112             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(  )
     114             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             : 
     116             : public: // XWarningsSupplier
     117             :     virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  )
     118             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :     virtual void SAL_CALL clearWarnings(  )
     120             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             : 
     122             : public: // XTypeProvider, first implemented by OPropertySetHelper
     123             :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
     124             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     125             :     virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
     126             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     127             : 
     128             : public: // OPropertySetHelper
     129             :     virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
     130             : 
     131             :     virtual sal_Bool SAL_CALL convertFastPropertyValue(
     132             :         ::com::sun::star::uno::Any & rConvertedValue,
     133             :         ::com::sun::star::uno::Any & rOldValue,
     134             :         sal_Int32 nHandle,
     135             :         const ::com::sun::star::uno::Any& rValue )
     136             :         throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
     137             : 
     138             :     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     139             :         sal_Int32 nHandle,
     140             :         const ::com::sun::star::uno::Any& rValue )
     141             :         throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     142             : 
     143             :     using ::cppu::OPropertySetHelper::getFastPropertyValue;
     144             : 
     145             :     void SAL_CALL getFastPropertyValue(
     146             :         ::com::sun::star::uno::Any& rValue,
     147             :         sal_Int32 nHandle ) const SAL_OVERRIDE;
     148             : 
     149             :     // XPropertySet
     150             :     ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL getPropertySetInfo()
     151             :         throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     152             : 
     153             : public: // XGeneratedResultSet
     154             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
     155             :     getGeneratedValues(  )
     156             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     157             : 
     158             : public: // XMultipleResults
     159             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet(  )
     160             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             :     virtual sal_Int32 SAL_CALL getUpdateCount(  )
     162             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     163             :     virtual sal_Bool SAL_CALL getMoreResults(  )
     164             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             : 
     166             : public: // OComponentHelper
     167             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     168             : 
     169             : public: // XResultSetMetaDataSupplier (is required by framework (see
     170             :         // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
     171             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
     172             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             : 
     174             : private:
     175             :     void checkClosed() throw (com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException);
     176             :     void raiseSQLException( const OUString & sql, const char * errorMsg, const char *errorType = 0 )
     177             :         throw ( com::sun::star::sdbc::SQLException );
     178             : };
     179             : 
     180             : 
     181           0 : struct CommandData
     182             : {
     183             :     ConnectionSettings **ppSettings;
     184             :     sal_Int32 *pLastOidInserted;
     185             :     sal_Int32 *pMultipleResultUpdateCount;
     186             :     sal_Bool *pMultipleResultAvailable;
     187             :     OUString *pLastTableInserted;
     188             :     ::com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > *pLastResultset;
     189             :     OString *pLastQuery;
     190             :     ::rtl::Reference< RefCountedMutex > refMutex;
     191             :     ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > owner;
     192             :     ::com::sun::star::uno::Reference< com::sun::star::sdbcx::XTablesSupplier > tableSupplier;
     193             :     sal_Int32 concurrency;
     194             : };
     195             : 
     196             : bool executePostgresCommand( const OString & cmd, struct CommandData *data );
     197             : com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > getGeneratedValuesFromLastInsert(
     198             :     ConnectionSettings *pConnectionSettings,
     199             :     const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &connection,
     200             :     sal_Int32 nLastOid,
     201             :     const OUString & lastTableInserted,
     202             :     const OString & lastQuery );
     203             : 
     204             : 
     205             : }
     206             : #endif
     207             : 
     208             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10