1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "mysqlc_statement.hxx"
22 #include "mysqlc_resultset.hxx"
24 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
25 #include <com/sun/star/sdbc/XParameters.hpp>
26 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
27 #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
28 #include <com/sun/star/io/XInputStream.hpp>
29 #include <cppuhelper/compbase4.hxx>
31 namespace connectivity::mysqlc
33 using ::com::sun::star::sdbc::SQLException
;
34 using ::com::sun::star::sdbc::XResultSetMetaData
;
35 using ::com::sun::star::uno::Any
;
36 using ::com::sun::star::uno::Reference
;
37 using ::com::sun::star::uno::RuntimeException
;
38 using ::com::sun::star::uno::Type
;
40 #if defined MYSQL_VERSION_ID && (MYSQL_VERSION_ID >= 80000) && !defined MARIADB_BASE_VERSION
48 my_bool is_null
= false;
49 unsigned long length
= 0;
50 my_bool error
= false;
53 typedef ::cppu::ImplHelper4
<css::sdbc::XPreparedStatement
, css::sdbc::XParameters
,
54 css::sdbc::XResultSetMetaDataSupplier
, css::lang::XServiceInfo
>
55 OPreparedStatement_BASE
;
57 class OPreparedStatement final
: public OCommonStatement
, public OPreparedStatement_BASE
59 unsigned int m_paramCount
= 0; // number of placeholders
60 Reference
<XResultSetMetaData
> m_xMetaData
;
62 std::vector
<MYSQL_BIND
> m_binds
;
63 std::vector
<BindMetaData
> m_bindMetas
;
65 void checkParameterIndex(sal_Int32 parameter
);
67 void SAL_CALL
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
, const Any
& rValue
) override
;
68 virtual ~OPreparedStatement() override
;
71 virtual OUString SAL_CALL
getImplementationName() override
;
73 virtual sal_Bool SAL_CALL
supportsService(OUString
const& ServiceName
) override
;
75 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
77 OPreparedStatement(OConnection
* _pConnection
, MYSQL_STMT
* pStmt
);
80 Any SAL_CALL
queryInterface(const Type
& rType
) override
;
81 void SAL_CALL
acquire() noexcept override
;
82 void SAL_CALL
release() noexcept override
;
85 css::uno::Sequence
<Type
> SAL_CALL
getTypes() override
;
88 Reference
<css::sdbc::XResultSet
> SAL_CALL
executeQuery() override
;
89 sal_Int32 SAL_CALL
executeUpdate() override
;
90 sal_Bool SAL_CALL
execute() override
;
91 Reference
<css::sdbc::XConnection
> SAL_CALL
getConnection() override
;
94 void SAL_CALL
setNull(sal_Int32 parameter
, sal_Int32 sqlType
) override
;
96 void SAL_CALL
setObjectNull(sal_Int32 parameter
, sal_Int32 sqlType
,
97 const OUString
& typeName
) override
;
99 void SAL_CALL
setBoolean(sal_Int32 parameter
, sal_Bool x
) override
;
101 void SAL_CALL
setByte(sal_Int32 parameter
, sal_Int8 x
) override
;
103 void SAL_CALL
setShort(sal_Int32 parameter
, sal_Int16 x
) override
;
105 void SAL_CALL
setInt(sal_Int32 parameter
, sal_Int32 x
) override
;
107 void SAL_CALL
setLong(sal_Int32 parameter
, sal_Int64 x
) override
;
109 void SAL_CALL
setFloat(sal_Int32 parameter
, float x
) override
;
111 void SAL_CALL
setDouble(sal_Int32 parameter
, double x
) override
;
113 void SAL_CALL
setString(sal_Int32 parameter
, const OUString
& x
) override
;
115 void SAL_CALL
setBytes(sal_Int32 parameter
, const css::uno::Sequence
<sal_Int8
>& x
) override
;
117 void SAL_CALL
setDate(sal_Int32 parameter
, const css::util::Date
& x
) override
;
119 void SAL_CALL
setTime(sal_Int32 parameter
, const css::util::Time
& x
) override
;
120 void SAL_CALL
setTimestamp(sal_Int32 parameter
, const css::util::DateTime
& x
) override
;
122 void SAL_CALL
setBinaryStream(sal_Int32 parameter
, const Reference
<css::io::XInputStream
>& x
,
123 sal_Int32 length
) override
;
125 void SAL_CALL
setCharacterStream(sal_Int32 parameter
, const Reference
<css::io::XInputStream
>& x
,
126 sal_Int32 length
) override
;
128 void SAL_CALL
setObject(sal_Int32 parameter
, const Any
& x
) override
;
130 void SAL_CALL
setObjectWithInfo(sal_Int32 parameter
, const Any
& x
, sal_Int32 targetSqlType
,
131 sal_Int32 scale
) override
;
133 void SAL_CALL
setRef(sal_Int32 parameter
, const Reference
<css::sdbc::XRef
>& x
) override
;
135 void SAL_CALL
setBlob(sal_Int32 parameter
, const Reference
<css::sdbc::XBlob
>& x
) override
;
137 void SAL_CALL
setClob(sal_Int32 parameter
, const Reference
<css::sdbc::XClob
>& x
) override
;
139 void SAL_CALL
setArray(sal_Int32 parameter
, const Reference
<css::sdbc::XArray
>& x
) override
;
141 void SAL_CALL
clearParameters() override
;
143 // XPreparedBatchExecution
144 // void SAL_CALL addBatch() override;
145 // void SAL_CALL clearBatch() override;
146 // css::uno::Sequence<sal_Int32> SAL_CALL executeBatch() override;
149 void SAL_CALL
close() override
;
151 // XResultSetMetaDataSupplier
152 Reference
<css::sdbc::XResultSetMetaData
> SAL_CALL
getMetaData() override
;
155 } /* connectivity::mysqlc */
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */