LibreOffice Module connectivity (master) 1
Statement.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "Connection.hxx"
21#include "ResultSet.hxx"
22#include "Statement.hxx"
23#include "Util.hxx"
24
27#include <sal/log.hxx>
28
29using namespace connectivity::firebird;
30
31using namespace com::sun::star;
32using namespace com::sun::star::uno;
33using namespace com::sun::star::lang;
34using namespace com::sun::star::beans;
35using namespace com::sun::star::sdbc;
36using namespace com::sun::star::sdbcx;
37using namespace com::sun::star::container;
38using namespace com::sun::star::io;
39using namespace com::sun::star::util;
40
41using namespace ::comphelper;
42using namespace ::osl;
43
44// ---- XBatchExecution - UNSUPPORTED ----------------------------------------
45void SAL_CALL OStatement::addBatch(const OUString&)
46{
47}
48
50{
51}
52
54{
55 return Sequence< sal_Int32 >();
56}
57
58IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
59
60void SAL_CALL OStatement::acquire() noexcept
61{
63}
64
65void SAL_CALL OStatement::release() noexcept
66{
68}
69
71{
72 MutexGuard aGuard(m_aMutex);
73 if (OStatementCommonBase_Base::rBHelper.bDisposed)
74 return;
75
77
78 if (m_pSqlda)
79 {
81 free(m_pSqlda);
82 m_pSqlda = nullptr;
83 }
84}
85
86// ---- XStatement -----------------------------------------------------------
87sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql)
88{
89 execute(sql);
91}
92
93
94uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& sql)
95{
96 MutexGuard aGuard(m_aMutex);
97 checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
98
99 SAL_INFO("connectivity.firebird", "executeQuery(" << sql << ")");
100
101 ISC_STATUS aErr = 0;
102
104
106 m_pSqlda);
107
108 aErr = isc_dsql_execute(m_statusVector,
109 &m_pConnection->getTransaction(),
111 1,
112 nullptr);
113 if (aErr)
114 SAL_WARN("connectivity.firebird", "isc_dsql_execute failed");
115
117 m_aMutex,
118 uno::Reference< XInterface >(*this),
120 m_pSqlda );
121
122 // TODO: deal with cleanup
123
125
126 if (isDDLStatement())
127 {
128 m_pConnection->commit();
129 }
130
131 return m_xResultSet;
132}
133
134sal_Bool SAL_CALL OStatement::execute(const OUString& sql)
135{
136 uno::Reference< XResultSet > xResults = executeQuery(sql);
137 return xResults.is();
138 // TODO: what if we have multiple results?
139}
140
141uno::Reference< XConnection > SAL_CALL OStatement::getConnection()
142{
143 MutexGuard aGuard(m_aMutex);
144 checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
145
146 return m_pConnection;
147}
148
149Any SAL_CALL OStatement::queryInterface( const Type & rType )
150{
152 if(!aRet.hasValue())
153 aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
154 if(!aRet.hasValue())
156 return aRet;
157}
158
159uno::Sequence< Type > SAL_CALL OStatement::getTypes()
160{
163}
164
166{
168 close();
169}
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement")
virtual void SAL_CALL addBatch() override
This ResultSet does not deal with the management of the SQLDA it is supplied with.
virtual void SAL_CALL release() noexcept override
css::uno::Reference< css::sdbc::XResultSet > m_xResultSet
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
void prepareAndDescribeStatement(std::u16string_view sqlIn, XSQLDA *&pOutSqlda)
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void disposeResultSet() override
Definition: Statement.cxx:70
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const OUString &sql) override
Definition: Statement.cxx:94
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
Definition: Statement.cxx:141
virtual void SAL_CALL release() noexcept override
Definition: Statement.cxx:65
virtual void SAL_CALL disposing() override
Definition: Statement.cxx:165
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual sal_Bool SAL_CALL execute(const OUString &sql) override
Definition: Statement.cxx:134
virtual void SAL_CALL acquire() noexcept override
Definition: Statement.cxx:60
virtual void SAL_CALL clearBatch() override
Definition: Statement.cxx:49
virtual sal_Int32 SAL_CALL executeUpdate(const OUString &sqlIn) override
Definition: Statement.cxx:87
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: Statement.cxx:159
virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() override
Definition: Statement.cxx:53
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
Type
void freeSQLVAR(XSQLDA *pSqlda)
void checkDisposed(bool _bThrow)
Definition: Driver.cxx:208
void evaluateStatusVector(const ISC_STATUS_ARRAY &rStatusVector, std::u16string_view aCause, const css::uno::Reference< css::uno::XInterface > &_rxContext)
Evaluate a firebird status vector and throw exceptions as necessary.
unsigned char sal_Bool