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 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODATABASEMETADATARESULTSET_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODATABASEMETADATARESULTSET_HXX
23 #include <com/sun/star/sdbc/ResultSetType.hpp>
24 #include <com/sun/star/sdbc/FetchDirection.hpp>
25 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
26 #include <com/sun/star/sdbc/XResultSet.hpp>
27 #include <com/sun/star/sdbc/XRow.hpp>
28 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
29 #include <com/sun/star/sdbc/XCloseable.hpp>
30 #include <com/sun/star/sdbc/XColumnLocate.hpp>
31 #include <com/sun/star/util/XCancellable.hpp>
32 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
34 #include <com/sun/star/sdbc/XRowUpdate.hpp>
35 #include <cppuhelper/compbase.hxx>
36 #include <cppuhelper/basemutex.hxx>
37 #include <comphelper/proparrhlp.hxx>
38 #include <odbc/OStatement.hxx>
39 #include <odbc/ODatabaseMetaData.hxx>
40 #include <odbc/odbcbasedllapi.hxx>
43 namespace connectivity::odbc
48 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XResultSet
,
50 css::sdbc::XResultSetMetaDataSupplier
,
51 css::util::XCancellable
,
52 css::sdbc::XWarningsSupplier
,
53 css::sdbc::XCloseable
,
54 css::sdbc::XColumnLocate
> ODatabaseMetaDataResultSet_BASE
;
56 class OOO_DLLPUBLIC_ODBCBASE ODatabaseMetaDataResultSet
:
57 public cppu::BaseMutex
,
58 public ODatabaseMetaDataResultSet_BASE
,
59 public ::cppu::OPropertySetHelper
,
60 public ::comphelper::OPropertyArrayUsageHelper
<ODatabaseMetaDataResultSet
>
62 std::vector
< sal_Int32
> m_aColMapping
; // pos 0 is unused so we don't have to decrement 1 every time
64 std::map
<sal_Int32
, ::std::map
<sal_Int32
,sal_Int32
> >
67 std::map
<sal_Int32
,SWORD
> m_aODBCColumnTypes
;
69 SQLHANDLE m_aStatementHandle
; // ... until freed
70 css::uno::WeakReferenceHelper m_aStatement
;
71 css::uno::Reference
< css::sdbc::XResultSetMetaData
>
73 std::unique_ptr
<SQLUSMALLINT
[]> m_pRowStatusArray
;
74 rtl::Reference
<OConnection
> m_pConnection
;
75 rtl_TextEncoding m_nTextEncoding
;
77 sal_Int32 m_nDriverColumnCount
; // column count of the driver which can sometimes be less than the metadata count
78 SQLRETURN m_nCurrentFetchState
;
80 bool m_bEOF
; // after last record
82 // set the columncount of the driver
83 void checkColumnCount();
84 static sal_Int32
getFetchDirection() { return css::sdbc::FetchDirection::FORWARD
; }
85 /// @throws css::sdbc::SQLException
86 /// @throws css::uno::RuntimeException
87 static sal_Int32
getFetchSize();
88 /// @throws css::sdbc::SQLException
89 /// @throws css::uno::RuntimeException
90 static OUString
getCursorName();
91 SWORD
impl_getColumnType_nothrow(sal_Int32 columnIndex
);
93 sal_Int32
mapColumn (sal_Int32 column
);
97 // OPropertyArrayUsageHelper
98 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
100 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
102 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
103 css::uno::Any
& rConvertedValue
,
104 css::uno::Any
& rOldValue
,
106 const css::uno::Any
& rValue
) override
;
107 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
) override
;
108 virtual void SAL_CALL
getFastPropertyValue( css::uno::Any
& rValue
, sal_Int32 nHandle
) const override
;
109 virtual ~ODatabaseMetaDataResultSet() override
;
110 template < typename T
, SQLSMALLINT sqlTypeId
> T
getInteger ( sal_Int32 columnIndex
);
113 // A ctor needed for returning the object
114 ODatabaseMetaDataResultSet(OConnection
* _pConnection
);
117 oslGenericFunction
getOdbcFunction(ODBC3SQLFunctionId _nIndex
) const
119 return m_pConnection
->getOdbcFunction(_nIndex
);
121 // ::cppu::OComponentHelper
122 virtual void SAL_CALL
disposing() override
;
124 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
125 virtual void SAL_CALL
acquire() throw() override
;
126 virtual void SAL_CALL
release() throw() override
;
128 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
130 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
131 css::uno::Reference
< css::uno::XInterface
> operator *()
133 return css::uno::Reference
< css::uno::XInterface
>(*static_cast<ODatabaseMetaDataResultSet_BASE
*>(this));
136 virtual sal_Bool SAL_CALL
next( ) override
;
137 virtual sal_Bool SAL_CALL
isBeforeFirst( ) override
;
138 virtual sal_Bool SAL_CALL
isAfterLast( ) override
;
139 virtual sal_Bool SAL_CALL
isFirst( ) override
;
140 virtual sal_Bool SAL_CALL
isLast( ) override
;
141 virtual void SAL_CALL
beforeFirst( ) override
;
142 virtual void SAL_CALL
afterLast( ) override
;
143 virtual sal_Bool SAL_CALL
first( ) override
;
144 virtual sal_Bool SAL_CALL
last( ) override
;
145 virtual sal_Int32 SAL_CALL
getRow( ) override
;
146 virtual sal_Bool SAL_CALL
absolute( sal_Int32 row
) override
;
147 virtual sal_Bool SAL_CALL
relative( sal_Int32 rows
) override
;
148 virtual sal_Bool SAL_CALL
previous( ) override
;
149 virtual void SAL_CALL
refreshRow( ) override
;
150 virtual sal_Bool SAL_CALL
rowUpdated( ) override
;
151 virtual sal_Bool SAL_CALL
rowInserted( ) override
;
152 virtual sal_Bool SAL_CALL
rowDeleted( ) override
;
153 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getStatement( ) override
;
155 virtual sal_Bool SAL_CALL
wasNull( ) override
;
156 virtual OUString SAL_CALL
getString( sal_Int32 columnIndex
) override
;
157 virtual sal_Bool SAL_CALL
getBoolean( sal_Int32 columnIndex
) override
;
158 virtual sal_Int8 SAL_CALL
getByte( sal_Int32 columnIndex
) override
;
159 virtual sal_Int16 SAL_CALL
getShort( sal_Int32 columnIndex
) override
;
160 virtual sal_Int32 SAL_CALL
getInt( sal_Int32 columnIndex
) override
;
161 virtual sal_Int64 SAL_CALL
getLong( sal_Int32 columnIndex
) override
;
162 virtual float SAL_CALL
getFloat( sal_Int32 columnIndex
) override
;
163 virtual double SAL_CALL
getDouble( sal_Int32 columnIndex
) override
;
164 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getBytes( sal_Int32 columnIndex
) override
;
165 virtual css::util::Date SAL_CALL
getDate( sal_Int32 columnIndex
) override
;
166 virtual css::util::Time SAL_CALL
getTime( sal_Int32 columnIndex
) override
;
167 virtual css::util::DateTime SAL_CALL
getTimestamp( sal_Int32 columnIndex
) override
;
168 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getBinaryStream( sal_Int32 columnIndex
) override
;
169 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getCharacterStream( sal_Int32 columnIndex
) override
;
170 virtual css::uno::Any SAL_CALL
getObject( sal_Int32 columnIndex
, const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
;
171 virtual css::uno::Reference
< css::sdbc::XRef
> SAL_CALL
getRef( sal_Int32 columnIndex
) override
;
172 virtual css::uno::Reference
< css::sdbc::XBlob
> SAL_CALL
getBlob( sal_Int32 columnIndex
) override
;
173 virtual css::uno::Reference
< css::sdbc::XClob
> SAL_CALL
getClob( sal_Int32 columnIndex
) override
;
174 virtual css::uno::Reference
< css::sdbc::XArray
> SAL_CALL
getArray( sal_Int32 columnIndex
) override
;
175 // XResultSetMetaDataSupplier
176 virtual css::uno::Reference
< css::sdbc::XResultSetMetaData
> SAL_CALL
getMetaData( ) override
;
178 virtual void SAL_CALL
cancel( ) override
;
180 virtual void SAL_CALL
close( ) override
;
182 virtual css::uno::Any SAL_CALL
getWarnings( ) override
;
183 virtual void SAL_CALL
clearWarnings( ) override
;
185 virtual sal_Int32 SAL_CALL
findColumn( const OUString
& columnName
) override
;
187 /// @throws css::sdbc::SQLException
188 /// @throws css::uno::RuntimeException
189 void openTablesTypes( );
190 /// @throws css::sdbc::SQLException
191 /// @throws css::uno::RuntimeException
193 /// @throws css::sdbc::SQLException
194 /// @throws css::uno::RuntimeException
196 /// @throws css::sdbc::SQLException
197 /// @throws css::uno::RuntimeException
199 /// @throws css::sdbc::SQLException
200 /// @throws css::uno::RuntimeException
201 void openTables(const css::uno::Any
& catalog
, const OUString
& schemaPattern
,
202 const OUString
& tableNamePattern
, const css::uno::Sequence
< OUString
>& types
);
203 /// @throws css::sdbc::SQLException
204 /// @throws css::uno::RuntimeException
205 void openColumnPrivileges( const css::uno::Any
& catalog
, const OUString
& schema
,
206 const OUString
& table
, const OUString
& columnNamePattern
);
207 /// @throws css::sdbc::SQLException
208 /// @throws css::uno::RuntimeException
209 void openColumns( const css::uno::Any
& catalog
, const OUString
& schemaPattern
,
210 const OUString
& tableNamePattern
, const OUString
& columnNamePattern
);
211 /// @throws css::sdbc::SQLException
212 /// @throws css::uno::RuntimeException
213 void openProcedureColumns( const css::uno::Any
& catalog
, const OUString
& schemaPattern
,
214 const OUString
& procedureNamePattern
,const OUString
& columnNamePattern
);
215 /// @throws css::sdbc::SQLException
216 /// @throws css::uno::RuntimeException
217 void openProcedures( const css::uno::Any
& catalog
, const OUString
& schemaPattern
,
218 const OUString
& procedureNamePattern
);
219 /// @throws css::sdbc::SQLException
220 /// @throws css::uno::RuntimeException
221 void openVersionColumns(const css::uno::Any
& catalog
, const OUString
& schema
,
222 const OUString
& table
);
223 /// @throws css::sdbc::SQLException
224 /// @throws css::uno::RuntimeException
225 void openBestRowIdentifier( const css::uno::Any
& catalog
, const OUString
& schema
,
226 const OUString
& table
,sal_Int32 scope
, bool nullable
);
227 /// @throws css::sdbc::SQLException
228 /// @throws css::uno::RuntimeException
229 void openForeignKeys( const css::uno::Any
& catalog
, const OUString
* schema
,const OUString
* table
,
230 const css::uno::Any
& catalog2
, const OUString
* schema2
,const OUString
* table2
);
231 /// @throws css::sdbc::SQLException
232 /// @throws css::uno::RuntimeException
233 void openExportedKeys(const css::uno::Any
& catalog
, const OUString
& schema
,const OUString
& table
);
234 /// @throws css::sdbc::SQLException
235 /// @throws css::uno::RuntimeException
236 void openImportedKeys(const css::uno::Any
& catalog
, const OUString
& schema
,const OUString
& table
);
237 /// @throws css::sdbc::SQLException
238 /// @throws css::uno::RuntimeException
239 void openPrimaryKeys(const css::uno::Any
& catalog
, const OUString
& schema
,const OUString
& table
);
240 /// @throws css::sdbc::SQLException
241 /// @throws css::uno::RuntimeException
242 void openTablePrivileges(const css::uno::Any
& catalog
, const OUString
& schemaPattern
,
243 const OUString
& tableNamePattern
);
244 /// @throws css::sdbc::SQLException
245 /// @throws css::uno::RuntimeException
246 void openSpecialColumns(bool _bRowVer
,const css::uno::Any
& catalog
, const OUString
& schema
,
247 const OUString
& table
,sal_Int32 scope
, bool nullable
);
248 /// @throws css::sdbc::SQLException
249 /// @throws css::uno::RuntimeException
250 void openIndexInfo( const css::uno::Any
& catalog
, const OUString
& schema
,
251 const OUString
& table
,bool unique
,bool approximate
);
254 using OPropertySetHelper::getFastPropertyValue
;
258 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODATABASEMETADATARESULTSET_HXX
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */