LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_statement.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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                 :            :  *    Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
      32                 :            :  *
      33                 :            :  *    The contents of this file are subject to the Mozilla Public License Version
      34                 :            :  *    1.1 (the "License"); you may not use this file except in compliance with
      35                 :            :  *    the License or as specified alternatively below. You may obtain a copy of
      36                 :            :  *    the License at http://www.mozilla.org/MPL/
      37                 :            :  *
      38                 :            :  *    Software distributed under the License is distributed on an "AS IS" basis,
      39                 :            :  *    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      40                 :            :  *    for the specific language governing rights and limitations under the
      41                 :            :  *    License.
      42                 :            :  *
      43                 :            :  *    Major Contributor(s):
      44                 :            :  *    [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
      45                 :            :  *
      46                 :            :  *    All Rights Reserved.
      47                 :            :  *
      48                 :            :  *    For minor contributions see the git repository.
      49                 :            :  *
      50                 :            :  *    Alternatively, the contents of this file may be used under the terms of
      51                 :            :  *    either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      52                 :            :  *    the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
      53                 :            :  *    in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
      54                 :            :  *    instead of those above.
      55                 :            :  *
      56                 :            :  ************************************************************************/
      57                 :            : 
      58                 :            : #ifndef _PQ_STATEMENT_HXX_
      59                 :            : #define _PQ_STATEMENT_HXX_
      60                 :            : #include <cppuhelper/propshlp.hxx>
      61                 :            : #include <cppuhelper/component.hxx>
      62                 :            : 
      63                 :            : #include <libpq-fe.h>
      64                 :            : 
      65                 :            : #include "pq_connection.hxx"
      66                 :            : #include <com/sun/star/sdbc/XMultipleResults.hpp>
      67                 :            : #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
      68                 :            : #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
      69                 :            : 
      70                 :            : namespace pq_sdbc_driver
      71                 :            : {
      72                 :            : 
      73                 :            : static const sal_Int32 STATEMENT_CURSOR_NAME = 0;
      74                 :            : static const sal_Int32 STATEMENT_ESCAPE_PROCESSING = 1;
      75                 :            : static const sal_Int32 STATEMENT_FETCH_DIRECTION = 2;
      76                 :            : static const sal_Int32 STATEMENT_FETCH_SIZE = 3;
      77                 :            : static const sal_Int32 STATEMENT_MAX_FIELD_SIZE = 4;
      78                 :            : static const sal_Int32 STATEMENT_MAX_ROWS = 5;
      79                 :            : static const sal_Int32 STATEMENT_QUERY_TIME_OUT = 6;
      80                 :            : static const sal_Int32 STATEMENT_RESULT_SET_CONCURRENCY = 7;
      81                 :            : static const sal_Int32 STATEMENT_RESULT_SET_TYPE = 8;
      82                 :            : 
      83                 :            : #define STATEMENT_SIZE 9
      84                 :            : 
      85                 :            : class Statement : public cppu::OComponentHelper,
      86                 :            :                   public cppu::OPropertySetHelper,
      87                 :            :                   public com::sun::star::sdbc::XStatement,
      88                 :            :                   public com::sun::star::sdbc::XCloseable,
      89                 :            :                   public com::sun::star::sdbc::XWarningsSupplier,
      90                 :            :                   public com::sun::star::sdbc::XMultipleResults,
      91                 :            :                   public com::sun::star::sdbc::XGeneratedResultSet,
      92                 :            :                   public com::sun::star::sdbc::XResultSetMetaDataSupplier
      93                 :            : {
      94                 :            : private:
      95                 :            :     com::sun::star::uno::Any m_props[STATEMENT_SIZE];
      96                 :            :     com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
      97                 :            :     ConnectionSettings *m_pSettings;
      98                 :            :     com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > m_lastResultset;
      99                 :            :     ::rtl::Reference< RefCountedMutex > m_refMutex;
     100                 :            :     sal_Bool  m_multipleResultAvailable;
     101                 :            :     sal_Int32 m_multipleResultUpdateCount;
     102                 :            :     sal_Int32 m_lastOidInserted;
     103                 :            :     rtl::OUString m_lastTableInserted;
     104                 :            :     rtl::OString m_lastQuery;
     105                 :            : 
     106                 :            : public:
     107                 :            :     /**
     108                 :            :      * @param ppConnection The piece of memory, pConnection points to, is accessisble
     109                 :            :      *                     as long as a reference to paramenter con is held.
     110                 :            :      */
     111                 :            :     Statement( const rtl::Reference< RefCountedMutex > & refMutex,
     112                 :            :                const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection> & con,
     113                 :            :                struct ConnectionSettings *pSettings );
     114                 :            : 
     115                 :            :     virtual ~Statement();
     116                 :            : public: // XInterface
     117                 :          0 :     virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
     118                 :          0 :     virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
     119                 :            :     virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & reqType )
     120                 :            :         throw (com::sun::star::uno::RuntimeException);
     121                 :            : 
     122                 :            : public: // XCloseable
     123                 :            :     virtual void SAL_CALL close(  )
     124                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     125                 :            : 
     126                 :            : public: // XStatement
     127                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
     128                 :            :         const ::rtl::OUString& sql )
     129                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     130                 :            :     virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql )
     131                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     132                 :            :     virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql )
     133                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     134                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(  )
     135                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     136                 :            : 
     137                 :            : public: // XWarningsSupplier
     138                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  )
     139                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     140                 :            :     virtual void SAL_CALL clearWarnings(  )
     141                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     142                 :            : 
     143                 :            : public: // XTypeProvider, first implemented by OPropertySetHelper
     144                 :            :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
     145                 :            :         throw( com::sun::star::uno::RuntimeException );
     146                 :            :     virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
     147                 :            :         throw( com::sun::star::uno::RuntimeException );
     148                 :            : 
     149                 :            : public: // OPropertySetHelper
     150                 :            :     virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
     151                 :            : 
     152                 :            :     virtual sal_Bool SAL_CALL convertFastPropertyValue(
     153                 :            :         ::com::sun::star::uno::Any & rConvertedValue,
     154                 :            :         ::com::sun::star::uno::Any & rOldValue,
     155                 :            :         sal_Int32 nHandle,
     156                 :            :         const ::com::sun::star::uno::Any& rValue )
     157                 :            :         throw (::com::sun::star::lang::IllegalArgumentException);
     158                 :            : 
     159                 :            :     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     160                 :            :         sal_Int32 nHandle,
     161                 :            :         const ::com::sun::star::uno::Any& rValue )
     162                 :            :         throw (::com::sun::star::uno::Exception);
     163                 :            : 
     164                 :            :     using ::cppu::OPropertySetHelper::getFastPropertyValue;
     165                 :            : 
     166                 :            :     void SAL_CALL getFastPropertyValue(
     167                 :            :         ::com::sun::star::uno::Any& rValue,
     168                 :            :         sal_Int32 nHandle ) const;
     169                 :            : 
     170                 :            :     // XPropertySet
     171                 :            :     ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL getPropertySetInfo()
     172                 :            :         throw(com::sun::star::uno::RuntimeException);
     173                 :            : 
     174                 :            : public: // XGeneratedResultSet
     175                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
     176                 :            :     getGeneratedValues(  )
     177                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     178                 :            : 
     179                 :            : public: // XMultipleResults
     180                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet(  )
     181                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     182                 :            :     virtual sal_Int32 SAL_CALL getUpdateCount(  )
     183                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     184                 :            :     virtual sal_Bool SAL_CALL getMoreResults(  )
     185                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     186                 :            : 
     187                 :            : public: // OComponentHelper
     188                 :            :     virtual void SAL_CALL disposing();
     189                 :            : 
     190                 :            : public: // XResultSetMetaDataSupplier (is required by framework (see
     191                 :            :         // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
     192                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
     193                 :            :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     194                 :            : 
     195                 :            : private:
     196                 :            :     void checkClosed() throw (com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException);
     197                 :            :     void raiseSQLException( const ::rtl::OUString & sql, const char * errorMsg, const char *errorType = 0 )
     198                 :            :         throw ( com::sun::star::sdbc::SQLException );
     199                 :            : };
     200                 :            : 
     201                 :            : 
     202                 :          0 : struct CommandData
     203                 :            : {
     204                 :            :     ConnectionSettings **ppSettings;
     205                 :            :     sal_Int32 *pLastOidInserted;
     206                 :            :     sal_Int32 *pMultipleResultUpdateCount;
     207                 :            :     sal_Bool *pMultipleResultAvailable;
     208                 :            :     ::rtl::OUString *pLastTableInserted;
     209                 :            :     ::com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > *pLastResultset;
     210                 :            :     ::rtl::OString *pLastQuery;
     211                 :            :     ::rtl::Reference< RefCountedMutex > refMutex;
     212                 :            :     ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > owner;
     213                 :            :     ::com::sun::star::uno::Reference< com::sun::star::sdbcx::XTablesSupplier > tableSupplier;
     214                 :            :     sal_Int32 concurrency;
     215                 :            : };
     216                 :            : 
     217                 :            : bool executePostgresCommand( const rtl::OString & cmd, struct CommandData *data );
     218                 :            : com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > getGeneratedValuesFromLastInsert(
     219                 :            :     ConnectionSettings *pConnectionSettings,
     220                 :            :     const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &connection,
     221                 :            :     sal_Int32 nLastOid,
     222                 :            :     const rtl::OUString & lastTableInserted,
     223                 :            :     const rtl::OString & lastQuery );
     224                 :            : 
     225                 :            : 
     226                 :            : }
     227                 :            : #endif

Generated by: LCOV version 1.10