LibreOffice Module connectivity (master) 1
pq_statement.hxx
Go to the documentation of this file.
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#pragma once
38
39#include <sal/config.h>
40
41#include <string_view>
42
46
47#include <libpq-fe.h>
48
49#include "pq_connection.hxx"
50#include <com/sun/star/sdbc/XMultipleResults.hpp>
51#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
52#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
53
54namespace pq_sdbc_driver
55{
56
57const sal_Int32 STATEMENT_CURSOR_NAME = 0;
58const sal_Int32 STATEMENT_ESCAPE_PROCESSING = 1;
59const sal_Int32 STATEMENT_FETCH_DIRECTION = 2;
60const sal_Int32 STATEMENT_FETCH_SIZE = 3;
61const sal_Int32 STATEMENT_MAX_FIELD_SIZE = 4;
62const sal_Int32 STATEMENT_MAX_ROWS = 5;
63const sal_Int32 STATEMENT_QUERY_TIME_OUT = 6;
65const sal_Int32 STATEMENT_RESULT_SET_TYPE = 8;
66
67#define STATEMENT_SIZE 9
68
69typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement,
70 css::sdbc::XCloseable,
71 css::sdbc::XWarningsSupplier,
72 css::sdbc::XMultipleResults,
73 css::sdbc::XGeneratedResultSet,
74 css::sdbc::XResultSetMetaDataSupplier
76
79{
80private:
81 css::uno::Any m_props[STATEMENT_SIZE];
82 css::uno::Reference< css::sdbc::XConnection > m_connection;
84 css::uno::Reference< css::sdbc::XCloseable > m_lastResultset;
90 OString m_lastQuery;
91
92public:
98 const css::uno::Reference< css::sdbc::XConnection> & con,
99 struct ConnectionSettings *pSettings );
100
101 virtual ~Statement() override;
102public: // XInterface
103 virtual void SAL_CALL acquire() noexcept override { Statement_BASE::acquire(); }
104 virtual void SAL_CALL release() noexcept override { Statement_BASE::release(); }
105 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & reqType ) override;
106
107public: // XCloseable
108 virtual void SAL_CALL close( ) override;
109
110public: // XStatement
111 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(
112 const OUString& sql ) override;
113 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override;
114 virtual sal_Bool SAL_CALL execute( const OUString& sql ) override;
115 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override;
116
117public: // XWarningsSupplier
118 virtual css::uno::Any SAL_CALL getWarnings( ) override;
119 virtual void SAL_CALL clearWarnings( ) override;
120
121public: // XTypeProvider, first implemented by OPropertySetHelper
122 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
123 virtual css::uno::Sequence< sal_Int8> SAL_CALL getImplementationId() override;
124
125public: // OPropertySetHelper
126 virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
127
128 virtual sal_Bool SAL_CALL convertFastPropertyValue(
129 css::uno::Any & rConvertedValue,
130 css::uno::Any & rOldValue,
131 sal_Int32 nHandle,
132 const css::uno::Any& rValue ) override;
133
134 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
135 sal_Int32 nHandle,
136 const css::uno::Any& rValue ) override;
137
138 using ::cppu::OPropertySetHelper::getFastPropertyValue;
139
140 void SAL_CALL getFastPropertyValue(
141 css::uno::Any& rValue,
142 sal_Int32 nHandle ) const override;
143
144 // XPropertySet
145 css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
146
147public: // XGeneratedResultSet
148 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
149 getGeneratedValues( ) override;
150
151public: // XMultipleResults
152 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override;
153 virtual sal_Int32 SAL_CALL getUpdateCount( ) override;
154 virtual sal_Bool SAL_CALL getMoreResults( ) override;
155
156public: // OComponentHelper
157 virtual void SAL_CALL disposing() override;
158
159public: // XResultSetMetaDataSupplier (is required by framework (see
160 // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
161 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
162
163private:
166 void checkClosed();
168 void raiseSQLException( std::u16string_view sql, const char * errorMsg );
169};
170
171
173{
179 css::uno::Reference< css::sdbc::XCloseable > *pLastResultset;
180 OString *pLastQuery;
182 css::uno::Reference< css::uno::XInterface > owner;
183 css::uno::Reference< css::sdbcx::XTablesSupplier > tableSupplier;
184 sal_Int32 concurrency;
185};
186
187bool executePostgresCommand( const OString & cmd, struct CommandData *data );
188css::uno::Reference< css::sdbc::XResultSet > getGeneratedValuesFromLastInsert(
189 ConnectionSettings *pConnectionSettings,
190 const css::uno::Reference< css::sdbc::XConnection > &connection,
191 sal_Int32 nLastOid,
192 std::u16string_view lastTableInserted,
193 const OString & lastQuery );
194
195
196}
197
198/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &reqType) override
virtual void SAL_CALL close() override
sal_Int32 m_multipleResultUpdateCount
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
css::uno::Reference< css::sdbc::XCloseable > m_lastResultset
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
ConnectionSettings * m_pSettings
virtual ~Statement() override
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
Statement(const rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &con, struct ConnectionSettings *pSettings)
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL clearWarnings() override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual sal_Int32 SAL_CALL getUpdateCount() override
virtual sal_Bool SAL_CALL execute(const OUString &sql) override
css::uno::Any m_props[STATEMENT_SIZE]
virtual cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual css::uno::Any SAL_CALL getWarnings() override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
void raiseSQLException(std::u16string_view sql, const char *errorMsg)
virtual sal_Int32 SAL_CALL executeUpdate(const OUString &sql) override
void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const OUString &sql) override
virtual sal_Bool SAL_CALL getMoreResults() override
css::uno::Reference< css::sdbc::XConnection > m_connection
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
const sal_Int32 STATEMENT_RESULT_SET_TYPE
const sal_Int32 STATEMENT_FETCH_SIZE
const sal_Int32 STATEMENT_CURSOR_NAME
::cppu::WeakComponentImplHelper< css::sdbc::XStatement, css::sdbc::XCloseable, css::sdbc::XWarningsSupplier, css::sdbc::XMultipleResults, css::sdbc::XGeneratedResultSet, css::sdbc::XResultSetMetaDataSupplier > Statement_BASE
const sal_Int32 STATEMENT_RESULT_SET_CONCURRENCY
const sal_Int32 STATEMENT_MAX_FIELD_SIZE
const sal_Int32 STATEMENT_ESCAPE_PROCESSING
const sal_Int32 STATEMENT_FETCH_DIRECTION
Reference< XResultSet > getGeneratedValuesFromLastInsert(ConnectionSettings *pConnectionSettings, const Reference< XConnection > &connection, sal_Int32 nLastOid, std::u16string_view lastTableInserted, const OString &lastQuery)
bool executePostgresCommand(const OString &cmd, struct CommandData *data)
const sal_Int32 STATEMENT_QUERY_TIME_OUT
const sal_Int32 STATEMENT_MAX_ROWS
#define STATEMENT_SIZE
css::uno::Reference< css::uno::XInterface > owner
sal_Int32 * pMultipleResultUpdateCount
css::uno::Reference< css::sdbc::XCloseable > * pLastResultset
::rtl::Reference< comphelper::RefCountedMutex > refMutex
ConnectionSettings ** ppSettings
css::uno::Reference< css::sdbcx::XTablesSupplier > tableSupplier
unsigned char sal_Bool