LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_preparedstatement.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 2 0.0 %
Date: 2014-11-03 Functions: 0 2 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 INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_PREPAREDSTATEMENT_HXX
      38             : #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_PREPAREDSTATEMENT_HXX
      39             : #include <vector>
      40             : 
      41             : #include <libpq-fe.h>
      42             : 
      43             : #include <cppuhelper/propshlp.hxx>
      44             : #include <cppuhelper/component.hxx>
      45             : 
      46             : #include <com/sun/star/sdbc/XParameters.hpp>
      47             : #include <com/sun/star/sdbc/XMultipleResults.hpp>
      48             : #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
      49             : #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
      50             : 
      51             : #include "pq_connection.hxx"
      52             : namespace pq_sdbc_driver
      53             : {
      54             : 
      55             : static const sal_Int32 PREPARED_STATEMENT_CURSOR_NAME = 0;
      56             : static const sal_Int32 PREPARED_STATEMENT_ESCAPE_PROCESSING = 1;
      57             : static const sal_Int32 PREPARED_STATEMENT_FETCH_DIRECTION = 2;
      58             : static const sal_Int32 PREPARED_STATEMENT_FETCH_SIZE = 3;
      59             : static const sal_Int32 PREPARED_STATEMENT_MAX_FIELD_SIZE = 4;
      60             : static const sal_Int32 PREPARED_STATEMENT_MAX_ROWS = 5;
      61             : static const sal_Int32 PREPARED_STATEMENT_QUERY_TIME_OUT = 6;
      62             : static const sal_Int32 PREPARED_STATEMENT_RESULT_SET_CONCURRENCY = 7;
      63             : static const sal_Int32 PREPARED_STATEMENT_RESULT_SET_TYPE = 8;
      64             : 
      65             : #define PREPARED_STATEMENT_SIZE 9
      66             : 
      67             : class PreparedStatement : public cppu::OComponentHelper,
      68             :                           public cppu::OPropertySetHelper,
      69             :                           public com::sun::star::sdbc::XPreparedStatement,
      70             :                           public com::sun::star::sdbc::XParameters,
      71             :                           public com::sun::star::sdbc::XCloseable,
      72             :                           public com::sun::star::sdbc::XWarningsSupplier,
      73             :                           public com::sun::star::sdbc::XMultipleResults,
      74             :                           public com::sun::star::sdbc::XGeneratedResultSet,
      75             :                           public com::sun::star::sdbc::XResultSetMetaDataSupplier
      76             : {
      77             : private:
      78             :     com::sun::star::uno::Any m_props[PREPARED_STATEMENT_SIZE];
      79             :     com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
      80             :     ConnectionSettings *m_pSettings;
      81             :     ::com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > m_lastResultset;
      82             :     OString m_stmt;
      83             :     OString m_executedStatement;
      84             :     ::rtl::Reference< RefCountedMutex > m_refMutex;
      85             :     OStringVector m_vars;
      86             :     OStringVector m_splittedStatement;
      87             :     bool  m_multipleResultAvailable;
      88             :     sal_Int32 m_multipleResultUpdateCount;
      89             :     sal_Int32 m_lastOidInserted;
      90             :     OUString m_lastTableInserted;
      91             :     OString m_lastQuery;
      92             : 
      93             : public:
      94             :     /**
      95             :      * @param ppConnection The piece of memory, pConnection points to, is accessisble
      96             :      *                     as long as a reference to paramenter con is held.
      97             :      */
      98             :     PreparedStatement( const rtl::Reference< RefCountedMutex > & refMutex,
      99             :                        const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection> & con,
     100             :                        struct ConnectionSettings *pSettings,
     101             :                        const OString &stmt );
     102             : 
     103             :      virtual ~PreparedStatement();
     104             : public: // XInterface
     105           0 :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { OComponentHelper::acquire(); }
     106           0 :     virtual void SAL_CALL release() throw() SAL_OVERRIDE { OComponentHelper::release(); }
     107             :     virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & reqType )
     108             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     109             : 
     110             : public: // XCloseable
     111             :     virtual void SAL_CALL close(  )
     112             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             : 
     114             : public: // XPreparedStatement
     115             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery()
     116             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     117             :     virtual sal_Int32 SAL_CALL executeUpdate(  )
     118             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :     virtual sal_Bool SAL_CALL execute(  )
     120             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(  )
     122             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             : public: // XParameters
     124             :     virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType )
     125             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     126             :     virtual void SAL_CALL setObjectNull(
     127             :         sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName )
     128             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             :     virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x )
     130             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     131             :     virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x )
     132             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             :     virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x )
     134             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     135             :     virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x )
     136             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x )
     138             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     139             :     virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x )
     140             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             :     virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x )
     142             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     143             :     virtual void SAL_CALL setString( sal_Int32 parameterIndex, const OUString& x )
     144             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             :     virtual void SAL_CALL setBytes(
     146             :         sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x )
     147             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     148             :     virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x )
     149             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             :     virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x )
     151             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     152             :     virtual void SAL_CALL setTimestamp(
     153             :         sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x )
     154             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     155             :     virtual void SAL_CALL setBinaryStream(
     156             :         sal_Int32 parameterIndex,
     157             :         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,
     158             :         sal_Int32 length )
     159             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     160             :     virtual void SAL_CALL setCharacterStream(
     161             :         sal_Int32 parameterIndex,
     162             :         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,
     163             :         sal_Int32 length )
     164             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             :     virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x )
     166             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             :     virtual void SAL_CALL setObjectWithInfo(
     168             :         sal_Int32 parameterIndex,
     169             :         const ::com::sun::star::uno::Any& x,
     170             :         sal_Int32 targetSqlType,
     171             :         sal_Int32 scale )
     172             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             :     virtual void SAL_CALL setRef(
     174             :         sal_Int32 parameterIndex,
     175             :         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x )
     176             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     177             :     virtual void SAL_CALL setBlob(
     178             :         sal_Int32 parameterIndex,
     179             :         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x )
     180             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             :     virtual void SAL_CALL setClob(
     182             :         sal_Int32 parameterIndex,
     183             :         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x )
     184             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     185             :     virtual void SAL_CALL setArray(
     186             :         sal_Int32 parameterIndex,
     187             :         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x )
     188             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     189             :     virtual void SAL_CALL clearParameters(  )
     190             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     191             : 
     192             : public: // XWarningsSupplier
     193             :     virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  )
     194             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     195             :     virtual void SAL_CALL clearWarnings(  )
     196             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     197             : 
     198             : public: // XTypeProvider, first implemented by OPropertySetHelper
     199             :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
     200             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     201             :     virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
     202             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     203             : 
     204             : public: // OPropertySetHelper
     205             :     virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
     206             : 
     207             :     virtual sal_Bool SAL_CALL convertFastPropertyValue(
     208             :         ::com::sun::star::uno::Any & rConvertedValue,
     209             :         ::com::sun::star::uno::Any & rOldValue,
     210             :         sal_Int32 nHandle,
     211             :         const ::com::sun::star::uno::Any& rValue )
     212             :         throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
     213             : 
     214             :     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     215             :         sal_Int32 nHandle,
     216             :         const ::com::sun::star::uno::Any& rValue )
     217             :         throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     218             : 
     219             :     using ::cppu::OPropertySetHelper::getFastPropertyValue;
     220             : 
     221             :     void SAL_CALL getFastPropertyValue(
     222             :         ::com::sun::star::uno::Any& rValue,
     223             :         sal_Int32 nHandle ) const SAL_OVERRIDE;
     224             : 
     225             :     // XPropertySet
     226             :     ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL getPropertySetInfo()
     227             :         throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     228             : 
     229             : public: // XGeneratedResultSet
     230             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
     231             :     getGeneratedValues(  )
     232             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     233             : 
     234             : public: // XMultipleResults
     235             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet(  )
     236             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     237             :     virtual sal_Int32 SAL_CALL getUpdateCount(  )
     238             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             :     virtual sal_Bool SAL_CALL getMoreResults(  )
     240             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     241             : 
     242             : public: // XResultSetMetaDataSupplier (is required by framework (see
     243             :         // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
     244             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
     245             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     246             : 
     247             : public: // OComponentHelper
     248             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     249             : 
     250             : private:
     251             :     void checkColumnIndex( sal_Int32 parameterIndex );
     252             :     void checkClosed() throw (com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException);
     253             :     void raiseSQLException( const char * errorMsg, const char *errorType = 0 )
     254             :         throw ( com::sun::star::sdbc::SQLException );
     255             : //     PGresult *pgExecute( OString *pQuery );
     256             : };
     257             : 
     258             : }
     259             : #endif
     260             : 
     261             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10