bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_statement.hxx
blobe53c203af6d63aa7182ff9c49ee904b482ffcc62
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
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.
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.
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
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
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/.
35 ************************************************************************/
37 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_STATEMENT_HXX
38 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_STATEMENT_HXX
39 #include <cppuhelper/propshlp.hxx>
40 #include <cppuhelper/compbase.hxx>
41 #include <cppuhelper/component.hxx>
43 #include <libpq-fe.h>
45 #include "pq_connection.hxx"
46 #include <com/sun/star/sdbc/XMultipleResults.hpp>
47 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
48 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
50 namespace pq_sdbc_driver
53 static const sal_Int32 STATEMENT_CURSOR_NAME = 0;
54 static const sal_Int32 STATEMENT_ESCAPE_PROCESSING = 1;
55 static const sal_Int32 STATEMENT_FETCH_DIRECTION = 2;
56 static const sal_Int32 STATEMENT_FETCH_SIZE = 3;
57 static const sal_Int32 STATEMENT_MAX_FIELD_SIZE = 4;
58 static const sal_Int32 STATEMENT_MAX_ROWS = 5;
59 static const sal_Int32 STATEMENT_QUERY_TIME_OUT = 6;
60 static const sal_Int32 STATEMENT_RESULT_SET_CONCURRENCY = 7;
61 static const sal_Int32 STATEMENT_RESULT_SET_TYPE = 8;
63 #define STATEMENT_SIZE 9
65 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement,
66 css::sdbc::XCloseable,
67 css::sdbc::XWarningsSupplier,
68 css::sdbc::XMultipleResults,
69 css::sdbc::XGeneratedResultSet,
70 css::sdbc::XResultSetMetaDataSupplier
71 > Statement_BASE;
73 class Statement : public Statement_BASE,
74 public cppu::OPropertySetHelper
76 private:
77 css::uno::Any m_props[STATEMENT_SIZE];
78 css::uno::Reference< css::sdbc::XConnection > m_connection;
79 ConnectionSettings *m_pSettings;
80 css::uno::Reference< css::sdbc::XCloseable > m_lastResultset;
81 ::rtl::Reference< comphelper::RefCountedMutex > m_xMutex;
82 bool m_multipleResultAvailable;
83 sal_Int32 m_multipleResultUpdateCount;
84 sal_Int32 m_lastOidInserted;
85 OUString m_lastTableInserted;
86 OString m_lastQuery;
88 public:
89 /**
90 * @param ppConnection The piece of memory, pConnection points to, is accessible
91 * as long as a reference to parameter con is held.
93 Statement( const rtl::Reference< comphelper::RefCountedMutex > & refMutex,
94 const css::uno::Reference< css::sdbc::XConnection> & con,
95 struct ConnectionSettings *pSettings );
97 virtual ~Statement() override;
98 public: // XInterface
99 virtual void SAL_CALL acquire() throw() override { Statement_BASE::acquire(); }
100 virtual void SAL_CALL release() throw() override { Statement_BASE::release(); }
101 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & reqType ) override;
103 public: // XCloseable
104 virtual void SAL_CALL close( ) override;
106 public: // XStatement
107 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(
108 const OUString& sql ) override;
109 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override;
110 virtual sal_Bool SAL_CALL execute( const OUString& sql ) override;
111 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override;
113 public: // XWarningsSupplier
114 virtual css::uno::Any SAL_CALL getWarnings( ) override;
115 virtual void SAL_CALL clearWarnings( ) override;
117 public: // XTypeProvider, first implemented by OPropertySetHelper
118 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
119 virtual css::uno::Sequence< sal_Int8> SAL_CALL getImplementationId() override;
121 public: // OPropertySetHelper
122 virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
124 virtual sal_Bool SAL_CALL convertFastPropertyValue(
125 css::uno::Any & rConvertedValue,
126 css::uno::Any & rOldValue,
127 sal_Int32 nHandle,
128 const css::uno::Any& rValue ) override;
130 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
131 sal_Int32 nHandle,
132 const css::uno::Any& rValue ) override;
134 using ::cppu::OPropertySetHelper::getFastPropertyValue;
136 void SAL_CALL getFastPropertyValue(
137 css::uno::Any& rValue,
138 sal_Int32 nHandle ) const override;
140 // XPropertySet
141 css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
143 public: // XGeneratedResultSet
144 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
145 getGeneratedValues( ) override;
147 public: // XMultipleResults
148 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override;
149 virtual sal_Int32 SAL_CALL getUpdateCount( ) override;
150 virtual sal_Bool SAL_CALL getMoreResults( ) override;
152 public: // OComponentHelper
153 virtual void SAL_CALL disposing() override;
155 public: // XResultSetMetaDataSupplier (is required by framework (see
156 // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
157 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
159 private:
160 /// @throws css::sdbc::SQLException
161 /// @throws css::uno::RuntimeException
162 void checkClosed();
163 /// @throws css::sdbc::SQLException
164 void raiseSQLException( const OUString & sql, const char * errorMsg );
168 struct CommandData
170 ConnectionSettings **ppSettings;
171 sal_Int32 *pLastOidInserted;
172 sal_Int32 *pMultipleResultUpdateCount;
173 bool *pMultipleResultAvailable;
174 OUString *pLastTableInserted;
175 css::uno::Reference< css::sdbc::XCloseable > *pLastResultset;
176 OString *pLastQuery;
177 ::rtl::Reference< comphelper::RefCountedMutex > refMutex;
178 css::uno::Reference< css::uno::XInterface > owner;
179 css::uno::Reference< css::sdbcx::XTablesSupplier > tableSupplier;
180 sal_Int32 concurrency;
183 bool executePostgresCommand( const OString & cmd, struct CommandData *data );
184 css::uno::Reference< css::sdbc::XResultSet > getGeneratedValuesFromLastInsert(
185 ConnectionSettings *pConnectionSettings,
186 const css::uno::Reference< css::sdbc::XConnection > &connection,
187 sal_Int32 nLastOid,
188 const OUString & lastTableInserted,
189 const OString & lastQuery );
193 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */