bump product version to 5.0.4.1
[LibreOffice.git] / mysqlc / source / mysqlc_databasemetadata.cxx
blobb35023ea9852e9607f819023c1610ec7bddc4ba8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #include "mysqlc_databasemetadata.hxx"
20 #include <boost/scoped_ptr.hpp>
21 #include <com/sun/star/sdbc/DataType.hpp>
22 #include <com/sun/star/sdbc/ResultSetType.hpp>
23 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
24 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
25 #include <com/sun/star/sdbc/KeyRule.hpp>
26 #include <com/sun/star/sdbc/Deferrability.hpp>
27 #include <com/sun/star/sdbc/IndexType.hpp>
28 #include <com/sun/star/sdbc/BestRowScope.hpp>
29 #include <com/sun/star/sdbc/ColumnType.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
33 #include "mysqlc_general.hxx"
34 #include "mysqlc_statement.hxx"
35 #include "mysqlc_driver.hxx"
36 #include "mysqlc_preparedstatement.hxx"
38 #include <stdio.h>
40 using namespace connectivity::mysqlc;
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star::lang;
43 using namespace com::sun::star::beans;
44 using namespace com::sun::star::sdbc;
45 using mysqlc_sdbc_driver::getStringFromAny;
47 #include <cppconn/connection.h>
48 #include <cppconn/resultset.h>
49 #include <cppconn/metadata.h>
50 #include <cppconn/statement.h>
51 #include <cppconn/prepared_statement.h>
53 #include <sal/macros.h>
55 static std::string wild("%");
59 void lcl_setRows_throw(const Reference< XResultSet >& _xResultSet,sal_Int32 _nType,const std::vector< std::vector< Any > >& _rRows)
61 Reference< XInitialization> xIni(_xResultSet,UNO_QUERY);
62 Sequence< Any > aArgs(2);
63 aArgs[0] <<= _nType;
65 Sequence< Sequence< Any > > aRows(_rRows.size());
67 std::vector< std::vector< Any > >::const_iterator aIter = _rRows.begin();
68 Sequence< Any > * pRowsIter = aRows.getArray();
69 Sequence< Any > * pRowsEnd = pRowsIter + aRows.getLength();
70 for (; pRowsIter != pRowsEnd;++pRowsIter,++aIter) {
71 if (!aIter->empty()) {
72 Sequence<Any> aSeq(&(*aIter->begin()),aIter->size());
73 (*pRowsIter) = aSeq;
76 aArgs[1] <<= aRows;
77 xIni->initialize(aArgs);
80 ODatabaseMetaData::ODatabaseMetaData(OConnection& _rCon)
81 :m_rConnection(_rCon)
82 ,m_bUseCatalog(true)
83 ,meta(_rCon.getConnectionSettings().cppConnection->getMetaData())
84 ,identifier_quote_string_set(false)
86 OSL_TRACE("ODatabaseMetaData::ODatabaseMetaData");
87 if (!m_rConnection.isCatalogUsed())
89 osl_atomic_increment(&m_refCount);
90 m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
91 osl_atomic_decrement(&m_refCount);
95 ODatabaseMetaData::~ODatabaseMetaData()
97 OSL_TRACE("ODatabaseMetaData::~ODatabaseMetaData");
100 rtl::OUString ODatabaseMetaData::impl_getStringMetaData(const sal_Char* _methodName, const std::string& (sql::DatabaseMetaData::*_Method)() )
102 OSL_TRACE( "mysqlc::ODatabaseMetaData::%s", _methodName);
103 rtl::OUString stringMetaData;
104 try {
105 stringMetaData = mysqlc_sdbc_driver::convert((meta->*_Method)(), m_rConnection.getConnectionEncoding());
106 } catch (const sql::MethodNotImplementedException &) {
107 mysqlc_sdbc_driver::throwFeatureNotImplementedException(_methodName, *this);
108 } catch (const sql::InvalidArgumentException &) {
109 mysqlc_sdbc_driver::throwInvalidArgumentException(_methodName, *this);
110 } catch (const sql::SQLException& e) {
111 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
113 return stringMetaData;
116 rtl::OUString ODatabaseMetaData::impl_getStringMetaData(const sal_Char* _methodName, std::string (sql::DatabaseMetaData::*_Method)() )
118 OSL_TRACE( "mysqlc::ODatabaseMetaData::%s", _methodName);
119 rtl::OUString stringMetaData;
120 try {
121 stringMetaData = mysqlc_sdbc_driver::convert((meta->*_Method)(), m_rConnection.getConnectionEncoding());
122 } catch (const sql::MethodNotImplementedException &) {
123 mysqlc_sdbc_driver::throwFeatureNotImplementedException(_methodName, *this);
124 } catch (const sql::InvalidArgumentException &) {
125 mysqlc_sdbc_driver::throwInvalidArgumentException(_methodName, *this);
126 } catch (const sql::SQLException& e) {
127 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
129 return stringMetaData;
132 rtl::OUString ODatabaseMetaData::impl_getStringMetaData(const sal_Char* _methodName, const sql::SQLString& (sql::DatabaseMetaData::*_Method)() )
134 OSL_TRACE( "mysqlc::ODatabaseMetaData::%s", _methodName);
135 rtl::OUString stringMetaData;
136 try {
137 stringMetaData = mysqlc_sdbc_driver::convert((meta->*_Method)(), m_rConnection.getConnectionEncoding());
138 } catch (const sql::MethodNotImplementedException &) {
139 mysqlc_sdbc_driver::throwFeatureNotImplementedException(_methodName, *this);
140 } catch (const sql::InvalidArgumentException &) {
141 mysqlc_sdbc_driver::throwInvalidArgumentException(_methodName, *this);
142 } catch (const sql::SQLException& e) {
143 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
145 return stringMetaData;
148 rtl::OUString ODatabaseMetaData::impl_getStringMetaData(const sal_Char* _methodName, sql::SQLString (sql::DatabaseMetaData::*_Method)() )
150 OSL_TRACE( "mysqlc::ODatabaseMetaData::%s", _methodName);
151 rtl::OUString stringMetaData;
152 try {
153 stringMetaData = mysqlc_sdbc_driver::convert((meta->*_Method)(), m_rConnection.getConnectionEncoding());
154 } catch (const sql::MethodNotImplementedException &) {
155 mysqlc_sdbc_driver::throwFeatureNotImplementedException(_methodName, *this);
156 } catch (const sql::InvalidArgumentException &) {
157 mysqlc_sdbc_driver::throwInvalidArgumentException(_methodName, *this);
158 } catch (const sql::SQLException& e) {
159 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
161 return stringMetaData;
164 sal_Int32 ODatabaseMetaData::impl_getInt32MetaData(const sal_Char* _methodName, unsigned int (sql::DatabaseMetaData::*_Method)() )
166 OSL_TRACE( "mysqlc::ODatabaseMetaData::%s", _methodName);
167 sal_Int32 int32MetaData(0);
168 try {
169 int32MetaData = (meta->*_Method)();
170 } catch (const sql::MethodNotImplementedException &) {
171 mysqlc_sdbc_driver::throwFeatureNotImplementedException(_methodName, *this);
172 } catch (const sql::InvalidArgumentException &) {
173 mysqlc_sdbc_driver::throwInvalidArgumentException(_methodName, *this);
174 } catch (const sql::SQLException& e) {
175 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
177 return int32MetaData;
180 bool ODatabaseMetaData::impl_getBoolMetaData(const sal_Char* _methodName, bool (sql::DatabaseMetaData::*_Method)() )
182 OSL_TRACE( "mysqlc::ODatabaseMetaData::%s", _methodName);
183 bool boolMetaData(false);
184 try {
185 boolMetaData = (meta->*_Method)();
186 } catch (const sql::MethodNotImplementedException &) {
187 mysqlc_sdbc_driver::throwFeatureNotImplementedException(_methodName, *this);
188 } catch (const sql::InvalidArgumentException &) {
189 mysqlc_sdbc_driver::throwInvalidArgumentException(_methodName, *this);
190 } catch (const sql::SQLException& e) {
191 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
193 return boolMetaData;
196 bool ODatabaseMetaData::impl_getBoolMetaData(const sal_Char* _methodName, bool (sql::DatabaseMetaData::*_Method)(int), sal_Int32 _arg )
198 OSL_TRACE( "mysqlc::ODatabaseMetaData::%s", _methodName);
199 bool boolMetaData(false);
200 try {
201 boolMetaData = (meta->*_Method)( _arg );
202 } catch (const sql::MethodNotImplementedException &) {
203 mysqlc_sdbc_driver::throwFeatureNotImplementedException(_methodName, *this);
204 } catch (const sql::InvalidArgumentException &) {
205 mysqlc_sdbc_driver::throwInvalidArgumentException(_methodName, *this);
206 } catch (const sql::SQLException& e) {
207 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
209 return boolMetaData;
212 bool ODatabaseMetaData::impl_getRSTypeMetaData(const sal_Char* _methodName, bool (sql::DatabaseMetaData::*_Method)(int), sal_Int32 _resultSetType )
214 int resultSetType(sql::ResultSet::TYPE_FORWARD_ONLY);
215 switch ( _resultSetType ) {
216 case ResultSetType::SCROLL_INSENSITIVE: resultSetType = sql::ResultSet::TYPE_SCROLL_INSENSITIVE; break;
217 case ResultSetType::SCROLL_SENSITIVE: resultSetType = sql::ResultSet::TYPE_SCROLL_SENSITIVE; break;
220 return impl_getBoolMetaData(_methodName, _Method, resultSetType);
223 rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator()
224 throw(SQLException, RuntimeException, std::exception)
226 return impl_getStringMetaData("getCatalogSeparator", &sql::DatabaseMetaData::getCatalogSeparator);
229 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength()
230 throw(SQLException, RuntimeException, std::exception)
232 return impl_getInt32MetaData("getMaxBinaryLiteralLength", &sql::DatabaseMetaData::getMaxBinaryLiteralLength);
235 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize()
236 throw(SQLException, RuntimeException, std::exception)
238 return impl_getInt32MetaData("getMaxRowSize", &sql::DatabaseMetaData::getMaxRowSize);
241 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength()
242 throw(SQLException, RuntimeException, std::exception)
244 return impl_getInt32MetaData("getMaxCatalogNameLength", &sql::DatabaseMetaData::getMaxCatalogNameLength);
247 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength()
248 throw(SQLException, RuntimeException, std::exception)
250 return impl_getInt32MetaData("getMaxCharLiteralLength", &sql::DatabaseMetaData::getMaxCharLiteralLength);
253 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength()
254 throw(SQLException, RuntimeException, std::exception)
256 return impl_getInt32MetaData("getMaxColumnNameLength", &sql::DatabaseMetaData::getMaxColumnNameLength);
259 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex()
260 throw(SQLException, RuntimeException, std::exception)
262 return impl_getInt32MetaData("getMaxColumnsInIndex", &sql::DatabaseMetaData::getMaxColumnsInIndex);
265 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength()
266 throw(SQLException, RuntimeException, std::exception)
268 return impl_getInt32MetaData("getMaxCursorNameLength", &sql::DatabaseMetaData::getMaxCursorNameLength);
271 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections()
272 throw(SQLException, RuntimeException, std::exception)
274 return impl_getInt32MetaData("getMaxConnections", &sql::DatabaseMetaData::getMaxConnections);
277 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable()
278 throw(SQLException, RuntimeException, std::exception)
280 return impl_getInt32MetaData("getMaxColumnsInTable", &sql::DatabaseMetaData::getMaxColumnsInTable);
283 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength()
284 throw(SQLException, RuntimeException, std::exception)
286 return impl_getInt32MetaData("getMaxStatementLength", &sql::DatabaseMetaData::getMaxStatementLength);
289 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength()
290 throw(SQLException, RuntimeException, std::exception)
292 return impl_getInt32MetaData("getMaxTableNameLength", &sql::DatabaseMetaData::getMaxTableNameLength);
295 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect()
296 throw(SQLException, RuntimeException, std::exception)
298 return impl_getInt32MetaData("getMaxTablesInSelect", &sql::DatabaseMetaData::getMaxTablesInSelect);
301 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs()
302 throw(SQLException, RuntimeException, std::exception)
304 return impl_getBoolMetaData("doesMaxRowSizeIncludeBlobs", &sql::DatabaseMetaData::doesMaxRowSizeIncludeBlobs);
307 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers()
308 throw(SQLException, RuntimeException, std::exception)
310 return impl_getBoolMetaData("storesLowerCaseQuotedIdentifiers", &sql::DatabaseMetaData::storesLowerCaseQuotedIdentifiers);
313 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers()
314 throw(SQLException, RuntimeException, std::exception)
316 return impl_getBoolMetaData("storesLowerCaseIdentifiers", &sql::DatabaseMetaData::storesLowerCaseIdentifiers);
319 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseQuotedIdentifiers()
320 throw(SQLException, RuntimeException, std::exception)
322 return impl_getBoolMetaData("storesMixedCaseQuotedIdentifiers", &sql::DatabaseMetaData::storesMixedCaseQuotedIdentifiers);
325 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers()
326 throw(SQLException, RuntimeException, std::exception)
328 return impl_getBoolMetaData("storesMixedCaseIdentifiers", &sql::DatabaseMetaData::storesMixedCaseIdentifiers);
331 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers()
332 throw(SQLException, RuntimeException, std::exception)
334 return impl_getBoolMetaData("storesUpperCaseQuotedIdentifiers", &sql::DatabaseMetaData::storesUpperCaseQuotedIdentifiers);
337 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers()
338 throw(SQLException, RuntimeException, std::exception)
340 return impl_getBoolMetaData("storesUpperCaseIdentifiers", &sql::DatabaseMetaData::storesUpperCaseIdentifiers);
343 sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithAddColumn()
344 throw(SQLException, RuntimeException, std::exception)
346 return impl_getBoolMetaData("supportsAlterTableWithAddColumn", &sql::DatabaseMetaData::supportsAlterTableWithAddColumn);
349 sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithDropColumn()
350 throw(SQLException, RuntimeException, std::exception)
352 return impl_getBoolMetaData("supportsAlterTableWithDropColumn", &sql::DatabaseMetaData::supportsAlterTableWithDropColumn);
355 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength()
356 throw(SQLException, RuntimeException, std::exception)
358 return impl_getInt32MetaData("getMaxIndexLength", &sql::DatabaseMetaData::getMaxIndexLength);
361 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns()
362 throw(SQLException, RuntimeException, std::exception)
364 return impl_getBoolMetaData("supportsNonNullableColumns", &sql::DatabaseMetaData::supportsNonNullableColumns);
367 rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm()
368 throw(SQLException, RuntimeException, std::exception)
370 return impl_getStringMetaData("getCatalogTerm", &sql::DatabaseMetaData::getCatalogTerm);
373 rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString()
374 throw(SQLException, RuntimeException, std::exception)
376 if (!identifier_quote_string_set) {
377 identifier_quote_string = impl_getStringMetaData("getIdentifierQuoteString", &sql::DatabaseMetaData::getIdentifierQuoteString);
378 identifier_quote_string_set = true;
380 return identifier_quote_string;
383 rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters()
384 throw(SQLException, RuntimeException, std::exception)
386 return impl_getStringMetaData("getExtraNameCharacters", &sql::DatabaseMetaData::getExtraNameCharacters);
389 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames()
390 throw(SQLException, RuntimeException, std::exception)
392 return impl_getBoolMetaData("supportsDifferentTableCorrelationNames", &sql::DatabaseMetaData::supportsDifferentTableCorrelationNames);
395 sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart()
396 throw(SQLException, RuntimeException, std::exception)
398 return impl_getBoolMetaData("isCatalogAtStart", &sql::DatabaseMetaData::isCatalogAtStart);
401 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions()
402 throw(SQLException, RuntimeException, std::exception)
404 return impl_getBoolMetaData("dataDefinitionIgnoredInTransactions", &sql::DatabaseMetaData::dataDefinitionIgnoredInTransactions);
407 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit()
408 throw(SQLException, RuntimeException, std::exception)
410 return impl_getBoolMetaData("dataDefinitionCausesTransactionCommit", &sql::DatabaseMetaData::dataDefinitionCausesTransactionCommit);
413 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly()
414 throw(SQLException, RuntimeException, std::exception)
416 return impl_getBoolMetaData("supportsDataManipulationTransactionsOnly", &sql::DatabaseMetaData::supportsDataManipulationTransactionsOnly);
419 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions()
420 throw(SQLException, RuntimeException, std::exception)
422 return impl_getBoolMetaData("supportsDataDefinitionAndDataManipulationTransactions", &sql::DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions);
425 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete()
426 throw(SQLException, RuntimeException, std::exception)
428 return impl_getBoolMetaData("supportsPositionedDelete", &sql::DatabaseMetaData::supportsPositionedDelete);
431 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate()
432 throw(SQLException, RuntimeException, std::exception)
434 return impl_getBoolMetaData("supportsPositionedUpdate", &sql::DatabaseMetaData::supportsPositionedUpdate);
437 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback()
438 throw(SQLException, RuntimeException, std::exception)
440 return impl_getBoolMetaData("supportsOpenStatementsAcrossRollback", &sql::DatabaseMetaData::supportsOpenStatementsAcrossRollback);
443 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit()
444 throw(SQLException, RuntimeException, std::exception)
446 return impl_getBoolMetaData("supportsOpenStatementsAcrossCommit", &sql::DatabaseMetaData::supportsOpenStatementsAcrossCommit);
449 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit()
450 throw(SQLException, RuntimeException, std::exception)
452 return impl_getBoolMetaData("supportsOpenCursorsAcrossCommit", &sql::DatabaseMetaData::supportsOpenCursorsAcrossCommit);
455 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback()
456 throw(SQLException, RuntimeException, std::exception)
458 return impl_getBoolMetaData("supportsOpenCursorsAcrossRollback", &sql::DatabaseMetaData::supportsOpenCursorsAcrossRollback);
461 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel(sal_Int32 level)
462 throw(SQLException, RuntimeException, std::exception)
464 return impl_getBoolMetaData("supportsTransactionIsolationLevel", &sql::DatabaseMetaData::supportsTransactionIsolationLevel, level);
467 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInDataManipulation()
468 throw(SQLException, RuntimeException, std::exception)
470 return impl_getBoolMetaData("supportsSchemasInDataManipulation", &sql::DatabaseMetaData::supportsSchemasInDataManipulation);
473 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL()
474 throw(SQLException, RuntimeException, std::exception)
476 return impl_getBoolMetaData("supportsANSI92FullSQL", &sql::DatabaseMetaData::supportsANSI92FullSQL);
479 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL()
480 throw(SQLException, RuntimeException, std::exception)
482 return impl_getBoolMetaData("supportsANSI92EntryLevelSQL", &sql::DatabaseMetaData::supportsANSI92EntryLevelSQL);
485 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility()
486 throw(SQLException, RuntimeException, std::exception)
488 return impl_getBoolMetaData("supportsIntegrityEnhancementFacility", &sql::DatabaseMetaData::supportsIntegrityEnhancementFacility);
491 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions()
492 throw(SQLException, RuntimeException, std::exception)
494 return impl_getBoolMetaData("supportsSchemasInIndexDefinitions", &sql::DatabaseMetaData::supportsSchemasInIndexDefinitions);
497 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions()
498 throw(SQLException, RuntimeException, std::exception)
500 return impl_getBoolMetaData("supportsSchemasInTableDefinitions", &sql::DatabaseMetaData::supportsSchemasInTableDefinitions);
503 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions()
504 throw(SQLException, RuntimeException, std::exception)
506 return impl_getBoolMetaData("supportsCatalogsInTableDefinitions", &sql::DatabaseMetaData::supportsCatalogsInTableDefinitions);
509 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions()
510 throw(SQLException, RuntimeException, std::exception)
512 return impl_getBoolMetaData("supportsCatalogsInIndexDefinitions", &sql::DatabaseMetaData::supportsCatalogsInIndexDefinitions);
515 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation()
516 throw(SQLException, RuntimeException, std::exception)
518 return impl_getBoolMetaData("supportsCatalogsInDataManipulation", &sql::DatabaseMetaData::supportsCatalogsInDataManipulation);
521 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins()
522 throw(SQLException, RuntimeException, std::exception)
524 return impl_getBoolMetaData("supportsOuterJoins", &sql::DatabaseMetaData::supportsOuterJoins);
527 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatements()
528 throw(SQLException, RuntimeException, std::exception)
530 return impl_getInt32MetaData("getMaxStatements", &sql::DatabaseMetaData::getMaxStatements);
533 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength()
534 throw(SQLException, RuntimeException, std::exception)
536 return impl_getInt32MetaData("getMaxProcedureNameLength", &sql::DatabaseMetaData::getMaxProcedureNameLength);
539 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength()
540 throw(SQLException, RuntimeException, std::exception)
542 return impl_getInt32MetaData("getMaxSchemaNameLength", &sql::DatabaseMetaData::getMaxSchemaNameLength);
545 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions()
546 throw(SQLException, RuntimeException, std::exception)
548 return impl_getBoolMetaData("supportsTransactions", &sql::DatabaseMetaData::supportsTransactions);
551 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable()
552 throw(SQLException, RuntimeException, std::exception)
554 return impl_getBoolMetaData("allProceduresAreCallable", &sql::DatabaseMetaData::allProceduresAreCallable);
557 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures()
558 throw(SQLException, RuntimeException, std::exception)
560 return impl_getBoolMetaData("supportsStoredProcedures", &sql::DatabaseMetaData::supportsStoredProcedures);
563 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate()
564 throw(SQLException, RuntimeException, std::exception)
566 return impl_getBoolMetaData("supportsSelectForUpdate", &sql::DatabaseMetaData::supportsSelectForUpdate);
569 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable()
570 throw(SQLException, RuntimeException, std::exception)
572 return impl_getBoolMetaData("allTablesAreSelectable", &sql::DatabaseMetaData::allTablesAreSelectable);
575 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly()
576 throw(SQLException, RuntimeException, std::exception)
578 return impl_getBoolMetaData("isReadOnly", &sql::DatabaseMetaData::isReadOnly);
581 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles()
582 throw(SQLException, RuntimeException, std::exception)
584 return impl_getBoolMetaData("usesLocalFiles", &sql::DatabaseMetaData::usesLocalFiles);
587 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable()
588 throw(SQLException, RuntimeException, std::exception)
590 return impl_getBoolMetaData("usesLocalFilePerTable", &sql::DatabaseMetaData::usesLocalFilePerTable);
593 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion()
594 throw(SQLException, RuntimeException, std::exception)
596 return impl_getBoolMetaData("supportsTypeConversion", &sql::DatabaseMetaData::supportsTypeConversion);
599 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull()
600 throw(SQLException, RuntimeException, std::exception)
602 return impl_getBoolMetaData("nullPlusNonNullIsNull", &sql::DatabaseMetaData::nullPlusNonNullIsNull);
605 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing()
606 throw(SQLException, RuntimeException, std::exception)
608 return impl_getBoolMetaData("supportsColumnAliasing", &sql::DatabaseMetaData::supportsColumnAliasing);
611 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames()
612 throw(SQLException, RuntimeException, std::exception)
614 return impl_getBoolMetaData("supportsTableCorrelationNames", &sql::DatabaseMetaData::supportsTableCorrelationNames);
617 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert(sal_Int32 /* fromType */, sal_Int32 /* toType */)
618 throw(SQLException, RuntimeException, std::exception)
620 OSL_TRACE("ODatabaseMetaData::supportsConvert");
621 try {
622 /* ToDo -> use supportsConvert( fromType, toType) */
623 return meta->supportsConvert()? sal_True:sal_False;
624 } catch (const sql::MethodNotImplementedException &) {
625 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::supportsConvert", *this);
626 } catch (const sql::InvalidArgumentException &) {
627 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::supportsConvert", *this);
628 } catch (const sql::SQLException& e) {
629 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
631 return sal_False;
634 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy()
635 throw(SQLException, RuntimeException, std::exception)
637 return impl_getBoolMetaData("supportsExpressionsInOrderBy", &sql::DatabaseMetaData::supportsExpressionsInOrderBy);
640 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy()
641 throw(SQLException, RuntimeException, std::exception)
643 return impl_getBoolMetaData("supportsGroupBy", &sql::DatabaseMetaData::supportsGroupBy);
646 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect()
647 throw(SQLException, RuntimeException, std::exception)
649 return impl_getBoolMetaData("supportsGroupByBeyondSelect", &sql::DatabaseMetaData::supportsGroupByBeyondSelect);
652 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated()
653 throw(SQLException, RuntimeException, std::exception)
655 return impl_getBoolMetaData("supportsGroupByUnrelated", &sql::DatabaseMetaData::supportsGroupByUnrelated);
658 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions()
659 throw(SQLException, RuntimeException, std::exception)
661 return impl_getBoolMetaData("supportsMultipleTransactions", &sql::DatabaseMetaData::supportsMultipleTransactions);
664 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets()
665 throw(SQLException, RuntimeException, std::exception)
667 return impl_getBoolMetaData("supportsMultipleResultSets", &sql::DatabaseMetaData::supportsMultipleResultSets);
670 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause()
671 throw(SQLException, RuntimeException, std::exception)
673 return impl_getBoolMetaData("supportsLikeEscapeClause", &sql::DatabaseMetaData::supportsLikeEscapeClause);
676 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated()
677 throw(SQLException, RuntimeException, std::exception)
679 return impl_getBoolMetaData("supportsOrderByUnrelated", &sql::DatabaseMetaData::supportsOrderByUnrelated);
682 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion()
683 throw(SQLException, RuntimeException, std::exception)
685 return impl_getBoolMetaData("supportsUnion", &sql::DatabaseMetaData::supportsUnion);
688 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll()
689 throw(SQLException, RuntimeException, std::exception)
691 return impl_getBoolMetaData("supportsUnionAll", &sql::DatabaseMetaData::supportsUnionAll);
694 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers()
695 throw(SQLException, RuntimeException, std::exception)
697 return impl_getBoolMetaData("supportsMixedCaseIdentifiers", &sql::DatabaseMetaData::supportsMixedCaseIdentifiers);
700 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers()
701 throw(SQLException, RuntimeException, std::exception)
703 return impl_getBoolMetaData("supportsMixedCaseQuotedIdentifiers", &sql::DatabaseMetaData::supportsMixedCaseQuotedIdentifiers);
706 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd()
707 throw(SQLException, RuntimeException, std::exception)
709 return impl_getBoolMetaData("nullsAreSortedAtEnd", &sql::DatabaseMetaData::nullsAreSortedAtEnd);
712 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart()
713 throw(SQLException, RuntimeException, std::exception)
715 return impl_getBoolMetaData("nullsAreSortedAtStart", &sql::DatabaseMetaData::nullsAreSortedAtStart);
718 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh()
719 throw(SQLException, RuntimeException, std::exception)
721 return impl_getBoolMetaData("nullsAreSortedHigh", &sql::DatabaseMetaData::nullsAreSortedHigh);
724 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow()
725 throw(SQLException, RuntimeException, std::exception)
727 return impl_getBoolMetaData("nullsAreSortedLow", &sql::DatabaseMetaData::nullsAreSortedLow);
730 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls()
731 throw(SQLException, RuntimeException, std::exception)
733 return impl_getBoolMetaData("supportsSchemasInProcedureCalls", &sql::DatabaseMetaData::supportsSchemasInProcedureCalls);
736 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions()
737 throw(SQLException, RuntimeException, std::exception)
739 return impl_getBoolMetaData("supportsSchemasInPrivilegeDefinitions", &sql::DatabaseMetaData::supportsSchemasInPrivilegeDefinitions);
742 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls()
743 throw(SQLException, RuntimeException, std::exception)
745 return impl_getBoolMetaData("supportsCatalogsInProcedureCalls", &sql::DatabaseMetaData::supportsCatalogsInProcedureCalls);
748 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions()
749 throw(SQLException, RuntimeException, std::exception)
751 return impl_getBoolMetaData("supportsCatalogsInPrivilegeDefinitions", &sql::DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions);
754 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries()
755 throw(SQLException, RuntimeException, std::exception)
757 return impl_getBoolMetaData("supportsCorrelatedSubqueries", &sql::DatabaseMetaData::supportsCorrelatedSubqueries);
760 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons()
761 throw(SQLException, RuntimeException, std::exception)
763 return impl_getBoolMetaData("supportsSubqueriesInComparisons", &sql::DatabaseMetaData::supportsSubqueriesInComparisons);
766 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists()
767 throw(SQLException, RuntimeException, std::exception)
769 return impl_getBoolMetaData("supportsSubqueriesInExists", &sql::DatabaseMetaData::supportsSubqueriesInExists);
772 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns()
773 throw(SQLException, RuntimeException, std::exception)
775 return impl_getBoolMetaData("supportsSubqueriesInIns", &sql::DatabaseMetaData::supportsSubqueriesInIns);
778 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds()
779 throw(SQLException, RuntimeException, std::exception)
781 return impl_getBoolMetaData("supportsSubqueriesInQuantifieds", &sql::DatabaseMetaData::supportsSubqueriesInQuantifieds);
784 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL()
785 throw(SQLException, RuntimeException, std::exception)
787 return impl_getBoolMetaData("supportsANSI92IntermediateSQL", &sql::DatabaseMetaData::supportsANSI92IntermediateSQL);
790 rtl::OUString SAL_CALL ODatabaseMetaData::getURL()
791 throw(SQLException, RuntimeException, std::exception)
793 OSL_TRACE("ODatabaseMetaData::getURL");
794 return m_rConnection.getConnectionSettings().connectionURL;
797 rtl::OUString SAL_CALL ODatabaseMetaData::getUserName()
798 throw(SQLException, RuntimeException, std::exception)
800 return impl_getStringMetaData("getUserName", &sql::DatabaseMetaData::getUserName);
803 rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName()
804 throw(SQLException, RuntimeException, std::exception)
806 OSL_TRACE("ODatabaseMetaData::getDriverName");
807 rtl::OUString aValue( "MySQL Connector/OO.org" );
808 return aValue;
811 rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion()
812 throw(SQLException, RuntimeException, std::exception)
814 OSL_TRACE("ODatabaseMetaData::getDriverVersion");
815 return rtl::OUString( "0.9.2" );
818 rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion()
819 throw(SQLException, RuntimeException, std::exception)
821 return impl_getStringMetaData("getDatabaseProductVersion", &sql::DatabaseMetaData::getDatabaseProductVersion);
824 rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName()
825 throw(SQLException, RuntimeException, std::exception)
827 return impl_getStringMetaData("getDatabaseProductName", &sql::DatabaseMetaData::getDatabaseProductName);
830 rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm()
831 throw(SQLException, RuntimeException, std::exception)
833 return impl_getStringMetaData("getProcedureTerm", &sql::DatabaseMetaData::getProcedureTerm);
836 rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm()
837 throw(SQLException, RuntimeException, std::exception)
839 return impl_getStringMetaData("getSchemaTerm", &sql::DatabaseMetaData::getSchemaTerm);
842 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion()
843 throw(RuntimeException, std::exception)
845 OSL_TRACE("ODatabaseMetaData::getDriverMajorVersion");
846 return MARIADBC_VERSION_MAJOR;
849 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation()
850 throw(SQLException, RuntimeException, std::exception)
852 OSL_TRACE("ODatabaseMetaData::getDefaultTransactionIsolation");
853 try {
854 switch (meta->getDefaultTransactionIsolation()) {
855 case sql::TRANSACTION_SERIALIZABLE: return TransactionIsolation::SERIALIZABLE;
856 case sql::TRANSACTION_REPEATABLE_READ: return TransactionIsolation::REPEATABLE_READ;
857 case sql::TRANSACTION_READ_COMMITTED: return TransactionIsolation::READ_COMMITTED;
858 case sql::TRANSACTION_READ_UNCOMMITTED: return TransactionIsolation::READ_UNCOMMITTED;
860 } catch (const sql::MethodNotImplementedException &) {
861 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getDriverMajorVersion", *this);
862 } catch (const sql::InvalidArgumentException &) {
863 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getDriverMajorVersion", *this);
864 } catch (const sql::SQLException& e) {
865 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
867 return TransactionIsolation::NONE;
870 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion()
871 throw(RuntimeException, std::exception)
873 OSL_TRACE("ODatabaseMetaData::getDriverMinorVersion");
874 return MARIADBC_VERSION_MINOR;
877 rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords()
878 throw(SQLException, RuntimeException, std::exception)
880 return impl_getStringMetaData("getSQLKeywords", &sql::DatabaseMetaData::getSQLKeywords);
883 rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape()
884 throw(SQLException, RuntimeException, std::exception)
886 return impl_getStringMetaData("getSearchStringEscape", &sql::DatabaseMetaData::getSearchStringEscape);
889 rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions()
890 throw(SQLException, RuntimeException, std::exception)
892 return impl_getStringMetaData("getStringFunctions", &sql::DatabaseMetaData::getStringFunctions);
895 rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions()
896 throw(SQLException, RuntimeException, std::exception)
898 return impl_getStringMetaData("getTimeDateFunctions", &sql::DatabaseMetaData::getTimeDateFunctions);
901 rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions()
902 throw(SQLException, RuntimeException, std::exception)
904 return impl_getStringMetaData("getSystemFunctions", &sql::DatabaseMetaData::getSystemFunctions);
907 rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions()
908 throw(SQLException, RuntimeException, std::exception)
910 return impl_getStringMetaData("getNumericFunctions", &sql::DatabaseMetaData::getNumericFunctions);
913 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar()
914 throw(SQLException, RuntimeException, std::exception)
916 return impl_getBoolMetaData("supportsExtendedSQLGrammar", &sql::DatabaseMetaData::supportsExtendedSQLGrammar);
919 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar()
920 throw(SQLException, RuntimeException, std::exception)
922 return impl_getBoolMetaData("supportsCoreSQLGrammar", &sql::DatabaseMetaData::supportsCoreSQLGrammar);
925 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar()
926 throw(SQLException, RuntimeException, std::exception)
928 return impl_getBoolMetaData("supportsMinimumSQLGrammar", &sql::DatabaseMetaData::supportsMinimumSQLGrammar);
931 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins()
932 throw(SQLException, RuntimeException, std::exception)
934 return impl_getBoolMetaData("supportsFullOuterJoins", &sql::DatabaseMetaData::supportsFullOuterJoins);
937 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins()
938 throw(SQLException, RuntimeException, std::exception)
940 return impl_getBoolMetaData("supportsLimitedOuterJoins", &sql::DatabaseMetaData::supportsLimitedOuterJoins);
943 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy()
944 throw(SQLException, RuntimeException, std::exception)
946 return impl_getInt32MetaData("getMaxColumnsInGroupBy", &sql::DatabaseMetaData::getMaxColumnsInGroupBy);
949 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy()
950 throw(SQLException, RuntimeException, std::exception)
952 return impl_getInt32MetaData("getMaxColumnsInOrderBy", &sql::DatabaseMetaData::getMaxColumnsInOrderBy);
955 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect()
956 throw(SQLException, RuntimeException, std::exception)
958 return impl_getInt32MetaData("getMaxColumnsInSelect", &sql::DatabaseMetaData::getMaxColumnsInSelect);
961 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength()
962 throw(SQLException, RuntimeException, std::exception)
964 return impl_getInt32MetaData("getMaxUserNameLength", &sql::DatabaseMetaData::getMaxUserNameLength);
967 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType(sal_Int32 setType)
968 throw(SQLException, RuntimeException, std::exception)
970 return impl_getRSTypeMetaData("supportsResultSetType", &sql::DatabaseMetaData::supportsResultSetType, setType);
973 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency(sal_Int32 setType, sal_Int32 concurrency)
974 throw(SQLException, RuntimeException, std::exception)
976 OSL_TRACE("ODatabaseMetaData::supportsResultSetConcurrency");
977 /* TODO: Check this out */
978 try {
979 return meta->supportsResultSetConcurrency(setType, concurrency==com::sun::star::sdbc::TransactionIsolation::READ_COMMITTED?
980 sql::TRANSACTION_READ_COMMITTED:
981 (concurrency == com::sun::star::sdbc::TransactionIsolation::SERIALIZABLE?
982 sql::TRANSACTION_SERIALIZABLE:sql::TRANSACTION_SERIALIZABLE))? sal_True:sal_False;
983 } catch (const sql::MethodNotImplementedException &) {
984 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::supportsResultSetConcurrency", *this);
985 } catch (const sql::InvalidArgumentException &) {
986 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::supportsResultSetConcurrency", *this);
987 } catch (const sql::SQLException& e) {
988 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
990 return sal_False;
993 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible(sal_Int32 setType)
994 throw(SQLException, RuntimeException, std::exception)
996 return impl_getRSTypeMetaData("ownUpdatesAreVisible", &sql::DatabaseMetaData::ownUpdatesAreVisible, setType);
999 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible(sal_Int32 setType)
1000 throw(SQLException, RuntimeException, std::exception)
1002 return impl_getRSTypeMetaData("ownDeletesAreVisible", &sql::DatabaseMetaData::ownDeletesAreVisible, setType);
1005 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible(sal_Int32 setType)
1006 throw(SQLException, RuntimeException, std::exception)
1008 return impl_getRSTypeMetaData("ownInsertsAreVisible", &sql::DatabaseMetaData::ownInsertsAreVisible, setType);
1011 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible(sal_Int32 setType)
1012 throw(SQLException, RuntimeException, std::exception)
1014 return impl_getRSTypeMetaData("othersUpdatesAreVisible", &sql::DatabaseMetaData::othersUpdatesAreVisible, setType);
1017 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible(sal_Int32 setType)
1018 throw(SQLException, RuntimeException, std::exception)
1020 return impl_getRSTypeMetaData("othersDeletesAreVisible", &sql::DatabaseMetaData::othersDeletesAreVisible, setType);
1023 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible(sal_Int32 setType)
1024 throw(SQLException, RuntimeException, std::exception)
1026 return impl_getRSTypeMetaData("othersInsertsAreVisible", &sql::DatabaseMetaData::othersInsertsAreVisible, setType);
1029 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected(sal_Int32 setType)
1030 throw(SQLException, RuntimeException, std::exception)
1032 return impl_getRSTypeMetaData("updatesAreDetected", &sql::DatabaseMetaData::updatesAreDetected, setType);
1035 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected(sal_Int32 setType)
1036 throw(SQLException, RuntimeException, std::exception)
1038 return impl_getRSTypeMetaData("deletesAreDetected", &sql::DatabaseMetaData::deletesAreDetected, setType);
1041 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected(sal_Int32 setType)
1042 throw(SQLException, RuntimeException, std::exception)
1044 return impl_getRSTypeMetaData("insertsAreDetected", &sql::DatabaseMetaData::insertsAreDetected, setType);
1047 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates()
1048 throw(SQLException, RuntimeException, std::exception)
1050 return impl_getBoolMetaData("supportsBatchUpdates", &sql::DatabaseMetaData::supportsBatchUpdates);
1053 Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection()
1054 throw(SQLException, RuntimeException, std::exception)
1056 OSL_TRACE("ODatabaseMetaData::getConnection");
1057 return &m_rConnection;
1061 Here follow all methods which return(a resultset
1062 the first methods is an example implementation how to use this resultset
1063 of course you could implement it on your and you should do this because
1064 the general way is more memory expensive
1067 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes()
1068 throw(SQLException, RuntimeException, std::exception)
1070 OSL_TRACE("ODatabaseMetaData::getTableTypes");
1071 const char * table_types[] = {"TABLE", "VIEW"};
1072 sal_Int32 requiredVersion[] = {0, 50000};
1074 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1075 std::vector< std::vector< Any > > rRows;
1076 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1078 for (sal_uInt32 i = 0; i < 2; i++) {
1079 if (m_rConnection.getMysqlVersion() >= requiredVersion[i]) {
1080 std::vector< Any > aRow(1);
1081 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(table_types[i], encoding)));
1082 rRows.push_back(aRow);
1085 lcl_setRows_throw(xResultSet, 5 ,rRows);
1086 return xResultSet;
1089 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
1090 throw(SQLException, RuntimeException, std::exception)
1092 OSL_TRACE("ODatabaseMetaData::getTypeInfo");
1093 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1095 std::vector< std::vector< Any > > rRows;
1097 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1098 unsigned int i = 0;
1099 while (mysqlc_types[i].typeName) {
1100 std::vector< Any > aRow(1);
1102 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].typeName, encoding)));
1103 aRow.push_back(makeAny(mysqlc_types[i].dataType));
1104 aRow.push_back(makeAny(mysqlc_types[i].precision));
1105 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].literalPrefix, encoding)));
1106 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].literalSuffix, encoding)));
1107 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].createParams, encoding)));
1108 aRow.push_back(makeAny(mysqlc_types[i].nullable));
1109 aRow.push_back(makeAny(mysqlc_types[i].caseSensitive));
1110 aRow.push_back(makeAny(mysqlc_types[i].searchable));
1111 aRow.push_back(makeAny(mysqlc_types[i].isUnsigned));
1112 aRow.push_back(makeAny(mysqlc_types[i].fixedPrecScale));
1113 aRow.push_back(makeAny(mysqlc_types[i].autoIncrement));
1114 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].localTypeName, encoding)));
1115 aRow.push_back(makeAny(mysqlc_types[i].minScale));
1116 aRow.push_back(makeAny(mysqlc_types[i].maxScale));
1117 aRow.push_back(makeAny(sal_Int32(0)));
1118 aRow.push_back(makeAny(sal_Int32(0)));
1119 aRow.push_back(makeAny(sal_Int32(10)));
1121 rRows.push_back(aRow);
1122 i++;
1125 lcl_setRows_throw(xResultSet, 14, rRows);
1126 return xResultSet;
1129 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs()
1130 throw(SQLException, RuntimeException, std::exception)
1132 OSL_TRACE("ODatabaseMetaData::getCatalogs");
1134 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1135 std::vector< std::vector< Any > > rRows;
1137 try {
1138 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1139 boost::scoped_ptr< sql::ResultSet> rset( meta->getCatalogs());
1140 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1141 sal_uInt32 columns = rs_meta->getColumnCount();
1142 while (rset->next()) {
1143 std::vector< Any > aRow(1);
1144 for (sal_uInt32 i = 1; i <= columns; i++) {
1145 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1147 rRows.push_back(aRow);
1149 } catch (const sql::MethodNotImplementedException &) {
1150 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getCatalogs", *this);
1151 } catch (const sql::InvalidArgumentException &) {
1152 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getCatalogs", *this);
1153 } catch (const sql::SQLException& e) {
1154 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1157 lcl_setRows_throw(xResultSet, 0, rRows);
1158 return xResultSet;
1161 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas()
1162 throw(SQLException, RuntimeException, std::exception)
1164 OSL_TRACE("ODatabaseMetaData::getSchemas");
1166 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1167 std::vector< std::vector< Any > > rRows;
1169 try {
1170 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1171 boost::scoped_ptr< sql::ResultSet> rset( meta->getSchemas());
1172 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1173 sal_uInt32 columns = rs_meta->getColumnCount();
1174 while (rset->next()) {
1175 std::vector< Any > aRow(1);
1176 bool informationSchema = false;
1177 for (sal_uInt32 i = 1; i <= columns; i++) {
1178 sql::SQLString columnStringValue = rset->getString(i);
1179 if (i == 1) { // TABLE_SCHEM
1180 informationSchema = (0 == columnStringValue.compare("information_schema"));
1182 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(columnStringValue, encoding)));
1184 if (!informationSchema ) {
1185 rRows.push_back(aRow);
1188 } catch (const sql::MethodNotImplementedException &) {
1189 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getSchemas", *this);
1190 } catch (const sql::InvalidArgumentException &) {
1191 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getSchemas", *this);
1192 } catch (const sql::SQLException& e) {
1193 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1196 lcl_setRows_throw(xResultSet, 1, rRows);
1197 return xResultSet;
1200 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
1201 const Any& catalog,
1202 const rtl::OUString& schema,
1203 const rtl::OUString& table,
1204 const rtl::OUString& columnNamePattern)
1205 throw(SQLException, RuntimeException, std::exception)
1207 OSL_TRACE("ODatabaseMetaData::getColumnPrivileges");
1208 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1209 std::vector< std::vector< Any > > rRows;
1211 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1212 sch(rtl::OUStringToOString(schema, m_rConnection.getConnectionEncoding()).getStr()),
1213 tab(rtl::OUStringToOString(table, m_rConnection.getConnectionEncoding()).getStr()),
1214 cNamePattern(rtl::OUStringToOString(columnNamePattern, m_rConnection.getConnectionEncoding()).getStr());
1215 try {
1216 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1217 boost::scoped_ptr< sql::ResultSet> rset( meta->getColumnPrivileges(cat, sch, tab, cNamePattern.compare("")? cNamePattern:wild));
1219 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1220 sal_uInt32 columns = rs_meta->getColumnCount();
1221 while (rset->next()) {
1222 std::vector< Any > aRow(1);
1223 for (sal_uInt32 i = 1; i <= columns; i++) {
1224 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1226 rRows.push_back(aRow);
1228 } catch (const sql::MethodNotImplementedException &) {
1229 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getColumnPrivileges", *this);
1230 } catch (const sql::InvalidArgumentException &) {
1231 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getColumnPrivileges", *this);
1232 } catch (const sql::SQLException& e) {
1233 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1236 lcl_setRows_throw(xResultSet, 2, rRows);
1237 return xResultSet;
1240 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
1241 const Any& catalog,
1242 const rtl::OUString& schemaPattern,
1243 const rtl::OUString& tableNamePattern,
1244 const rtl::OUString& columnNamePattern)
1245 throw(SQLException, RuntimeException, std::exception)
1247 OSL_TRACE("ODatabaseMetaData::getColumns");
1248 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1249 std::vector< std::vector< Any > > rRows;
1250 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1251 sPattern(rtl::OUStringToOString(schemaPattern, m_rConnection.getConnectionEncoding()).getStr()),
1252 tNamePattern(rtl::OUStringToOString(tableNamePattern, m_rConnection.getConnectionEncoding()).getStr()),
1253 cNamePattern(rtl::OUStringToOString(columnNamePattern, m_rConnection.getConnectionEncoding()).getStr());
1255 try {
1256 boost::scoped_ptr< sql::ResultSet> rset( meta->getColumns(cat,
1257 sPattern.compare("")? sPattern:wild,
1258 tNamePattern.compare("")? tNamePattern:wild,
1259 cNamePattern.compare("")? cNamePattern:wild));
1260 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1261 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1262 sal_uInt32 columns = rs_meta->getColumnCount();
1263 while (rset->next()) {
1264 std::vector< Any > aRow(1);
1265 for (sal_uInt32 i = 1; i <= columns; i++) {
1266 if (i == 5) { // ColumnType
1267 sal_Int32 sdbc_type = mysqlc_sdbc_driver::mysqlToOOOType(atoi(rset->getString(i).c_str()));
1268 aRow.push_back(makeAny(sdbc_type));
1269 } else {
1270 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1273 rRows.push_back(aRow);
1275 } catch (const sql::MethodNotImplementedException &) {
1276 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getColumns", *this);
1277 } catch (const sql::InvalidArgumentException &) {
1278 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getColumns", *this);
1279 } catch (const sql::SQLException& e) {
1280 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1282 lcl_setRows_throw(xResultSet, 3, rRows);
1283 return xResultSet;
1286 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
1287 const Any& catalog,
1288 const rtl::OUString& schemaPattern,
1289 const rtl::OUString& tableNamePattern,
1290 const Sequence< rtl::OUString >& types )
1291 throw(SQLException, RuntimeException, std::exception)
1293 OSL_TRACE("ODatabaseMetaData::getTables");
1294 sal_Int32 nLength = types.getLength();
1296 Reference< XResultSet > xResultSet(getOwnConnection().
1297 getDriver().getFactory()->createInstance(
1298 rtl::OUString("org.openoffice.comp.helper.DatabaseMetaDataResultSet")),UNO_QUERY);
1299 std::vector< std::vector< Any > > rRows;
1301 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1302 sPattern(rtl::OUStringToOString(schemaPattern, m_rConnection.getConnectionEncoding()).getStr()),
1303 tNamePattern(rtl::OUStringToOString(tableNamePattern, m_rConnection.getConnectionEncoding()).getStr());
1305 std::list<sql::SQLString> tabTypes;
1306 for (const rtl::OUString *pStart = types.getConstArray(), *p = pStart, *pEnd = pStart + nLength; p != pEnd; ++p) {
1307 tabTypes.push_back(rtl::OUStringToOString(*p, m_rConnection.getConnectionEncoding()).getStr());
1310 try {
1311 boost::scoped_ptr< sql::ResultSet> rset( meta->getTables(cat,
1312 sPattern.compare("")? sPattern:wild,
1313 tNamePattern.compare("")? tNamePattern:wild,
1314 tabTypes));
1316 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1317 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1318 sal_uInt32 columns = rs_meta->getColumnCount();
1319 while (rset->next()) {
1320 std::vector< Any > aRow(1);
1321 bool informationSchema = false;
1322 for (sal_uInt32 i = 1; (i <= columns) && !informationSchema; ++i) {
1323 sql::SQLString columnStringValue = rset->getString(i);
1324 if (i == 2) { // TABLE_SCHEM
1325 informationSchema = ( 0 == columnStringValue.compare("information_schema"));
1327 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(columnStringValue, encoding)));
1329 if (!informationSchema) {
1330 rRows.push_back(aRow);
1333 } catch (const sql::MethodNotImplementedException &) {
1334 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getTables", *this);
1335 } catch (const sql::InvalidArgumentException &) {
1336 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getTables", *this);
1337 } catch (const sql::SQLException& e) {
1338 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1341 lcl_setRows_throw(xResultSet, 4, rRows);
1342 return xResultSet;
1345 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
1346 const Any& /* catalog */,
1347 const rtl::OUString& /* schemaPattern */,
1348 const rtl::OUString& /* procedureNamePattern */,
1349 const rtl::OUString& /* columnNamePattern */)
1350 throw(SQLException, RuntimeException, std::exception)
1352 OSL_TRACE("ODatabaseMetaData::getProcedureColumns");
1353 // Currently there is no information available
1354 return NULL;
1357 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
1358 const Any& catalog,
1359 const rtl::OUString& schemaPattern,
1360 const rtl::OUString& procedureNamePattern)
1361 throw(SQLException, RuntimeException, std::exception)
1363 OSL_TRACE("ODatabaseMetaData::getProcedures");
1364 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1365 std::vector< std::vector< Any > > rRows;
1367 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1368 sPattern(rtl::OUStringToOString(schemaPattern, m_rConnection.getConnectionEncoding()).getStr()),
1369 pNamePattern(rtl::OUStringToOString(procedureNamePattern, m_rConnection.getConnectionEncoding()).getStr());
1372 try {
1373 boost::scoped_ptr< sql::ResultSet> rset( meta->getProcedures(cat,
1374 sPattern.compare("")? sPattern:wild,
1375 pNamePattern.compare("")? pNamePattern:wild));
1377 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1378 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1379 sal_uInt32 columns = rs_meta->getColumnCount();
1380 while (rset->next()) {
1381 std::vector< Any > aRow(1);
1382 for (sal_uInt32 i = 1; i <= columns; i++) {
1383 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1385 rRows.push_back(aRow);
1387 } catch (const sql::MethodNotImplementedException &) {
1388 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getProcedures", *this);
1389 } catch (const sql::InvalidArgumentException &) {
1390 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getProcedures", *this);
1391 } catch (const sql::SQLException& e) {
1392 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1395 lcl_setRows_throw(xResultSet, 7,rRows);
1396 return xResultSet;
1399 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
1400 const Any& /* catalog */,
1401 const rtl::OUString& /* schema */,
1402 const rtl::OUString& /* table */)
1403 throw(SQLException, RuntimeException, std::exception)
1405 OSL_TRACE("ODatabaseMetaData::getVersionColumns");
1406 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1407 std::vector< std::vector< Any > > rRows;
1408 lcl_setRows_throw(xResultSet, 16,rRows);
1409 return xResultSet;
1412 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
1413 const Any& catalog ,
1414 const rtl::OUString& schema ,
1415 const rtl::OUString& table )
1416 throw(SQLException, RuntimeException, std::exception)
1418 OSL_TRACE("ODatabaseMetaData::getExportedKeys");
1419 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1420 std::vector< std::vector< Any > > rRows;
1421 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1422 sch(rtl::OUStringToOString(schema, m_rConnection.getConnectionEncoding()).getStr()),
1423 tab(rtl::OUStringToOString(table, m_rConnection.getConnectionEncoding()).getStr());
1425 try {
1426 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1427 boost::scoped_ptr< sql::ResultSet> rset( meta->getExportedKeys(cat, sch, tab));
1428 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1429 sal_uInt32 columns = rs_meta->getColumnCount();
1430 while (rset->next()) {
1431 std::vector< Any > aRow(1);
1432 for (sal_uInt32 i = 1; i <= columns; i++) {
1433 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1435 rRows.push_back(aRow);
1437 } catch (const sql::MethodNotImplementedException &) {
1438 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getExportedKeys", *this);
1439 } catch (const sql::InvalidArgumentException &) {
1440 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getExportedKeys", *this);
1441 } catch (const sql::SQLException& e) {
1442 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1445 lcl_setRows_throw(xResultSet, 8, rRows);
1446 return xResultSet;
1449 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
1450 const Any& catalog,
1451 const rtl::OUString& schema,
1452 const rtl::OUString& table)
1453 throw(SQLException, RuntimeException, std::exception)
1455 OSL_TRACE("ODatabaseMetaData::getImportedKeys");
1457 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1458 std::vector< std::vector< Any > > rRows;
1460 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1461 sch(rtl::OUStringToOString(schema, m_rConnection.getConnectionEncoding()).getStr()),
1462 tab(rtl::OUStringToOString(table, m_rConnection.getConnectionEncoding()).getStr());
1464 try {
1465 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1466 boost::scoped_ptr< sql::ResultSet> rset( meta->getImportedKeys(cat, sch, tab));
1467 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1468 sal_uInt32 columns = rs_meta->getColumnCount();
1469 while (rset->next()) {
1470 std::vector< Any > aRow(1);
1471 for (sal_uInt32 i = 1; i <= columns; i++) {
1472 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1474 rRows.push_back(aRow);
1476 } catch (const sql::MethodNotImplementedException &) {
1477 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getImportedKeys", *this);
1478 } catch (const sql::InvalidArgumentException &) {
1479 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getImportedKeys", *this);
1480 } catch (const sql::SQLException& e) {
1481 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1484 lcl_setRows_throw(xResultSet,9,rRows);
1485 return xResultSet;
1488 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
1489 const Any& catalog,
1490 const rtl::OUString& schema,
1491 const rtl::OUString& table)
1492 throw(SQLException, RuntimeException, std::exception)
1494 OSL_TRACE("ODatabaseMetaData::getPrimaryKeys");
1495 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1496 std::vector< std::vector< Any > > rRows;
1498 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1499 sch(rtl::OUStringToOString(schema, m_rConnection.getConnectionEncoding()).getStr()),
1500 tab(rtl::OUStringToOString(table, m_rConnection.getConnectionEncoding()).getStr());
1502 try {
1503 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1504 boost::scoped_ptr< sql::ResultSet> rset( meta->getPrimaryKeys(cat, sch, tab));
1505 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1506 sal_uInt32 columns = rs_meta->getColumnCount();
1507 while (rset->next()) {
1508 std::vector< Any > aRow(1);
1509 for (sal_uInt32 i = 1; i <= columns; i++) {
1510 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1512 rRows.push_back(aRow);
1514 } catch (const sql::MethodNotImplementedException &) {
1515 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getPrimaryKeys", *this);
1516 } catch (const sql::InvalidArgumentException &) {
1517 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getPrimaryKeys", *this);
1518 } catch (const sql::SQLException& e) {
1519 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1522 lcl_setRows_throw(xResultSet, 10, rRows);
1523 return xResultSet;
1526 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
1527 const Any& catalog,
1528 const rtl::OUString& schema,
1529 const rtl::OUString& table,
1530 sal_Bool unique,
1531 sal_Bool approximate)
1532 throw(SQLException, RuntimeException, std::exception)
1534 OSL_TRACE("ODatabaseMetaData::getIndexInfo");
1535 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1536 std::vector< std::vector< Any > > rRows;
1538 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1539 sch(rtl::OUStringToOString(schema, m_rConnection.getConnectionEncoding()).getStr()),
1540 tab(rtl::OUStringToOString(table, m_rConnection.getConnectionEncoding()).getStr());
1542 try {
1543 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1544 boost::scoped_ptr< sql::ResultSet> rset( meta->getIndexInfo(cat, sch, tab, unique, approximate));
1545 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1546 sal_uInt32 columns = rs_meta->getColumnCount();
1547 while (rset->next()) {
1548 std::vector< Any > aRow(1);
1549 for (sal_uInt32 i = 1; i <= columns; i++) {
1550 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1552 rRows.push_back(aRow);
1554 } catch (const sql::MethodNotImplementedException &) {
1555 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getIndexInfo", *this);
1556 } catch (const sql::InvalidArgumentException &) {
1557 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getIndexInfo", *this);
1558 } catch (const sql::SQLException& e) {
1559 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1562 lcl_setRows_throw(xResultSet, 11, rRows);
1563 return xResultSet;
1566 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
1567 const Any& catalog,
1568 const rtl::OUString& schema,
1569 const rtl::OUString& table,
1570 sal_Int32 scope,
1571 sal_Bool nullable)
1572 throw(SQLException, RuntimeException, std::exception)
1574 OSL_TRACE("ODatabaseMetaData::getBestRowIdentifier");
1575 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1576 std::vector< std::vector< Any > > rRows;
1578 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1579 sch(rtl::OUStringToOString(schema, m_rConnection.getConnectionEncoding()).getStr()),
1580 tab(rtl::OUStringToOString(table, m_rConnection.getConnectionEncoding()).getStr());
1582 try {
1583 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1584 boost::scoped_ptr< sql::ResultSet> rset( meta->getBestRowIdentifier(cat, sch, tab, scope, nullable));
1585 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1586 sal_uInt32 columns = rs_meta->getColumnCount();
1587 while (rset->next()) {
1588 std::vector< Any > aRow(1);
1589 for (sal_uInt32 i = 1; i <= columns; i++) {
1590 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1592 rRows.push_back(aRow);
1594 } catch (const sql::MethodNotImplementedException &) {
1595 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getBestRowIdentifier", *this);
1596 } catch (const sql::InvalidArgumentException &) {
1597 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getBestRowIdentifier", *this);
1598 } catch (const sql::SQLException& e) {
1599 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1602 lcl_setRows_throw(xResultSet, 15, rRows);
1603 return xResultSet;
1606 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
1607 const Any& catalog,
1608 const rtl::OUString& schemaPattern,
1609 const rtl::OUString& tableNamePattern)
1610 throw(SQLException, RuntimeException, std::exception)
1612 OSL_TRACE("ODatabaseMetaData::getTablePrivileges");
1613 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1614 std::vector< std::vector< Any > > rRows;
1616 std::string cat(catalog.hasValue()? rtl::OUStringToOString(getStringFromAny(catalog), m_rConnection.getConnectionEncoding()).getStr():""),
1617 sPattern(rtl::OUStringToOString(schemaPattern, m_rConnection.getConnectionEncoding()).getStr()),
1618 tPattern(rtl::OUStringToOString(tableNamePattern, m_rConnection.getConnectionEncoding()).getStr());
1620 try {
1621 static bool fakeTablePrivileges = false;
1622 if (fakeTablePrivileges) {
1623 static const sal_Char* allPrivileges[] = {
1624 "ALTER", "DELETE", "DROP", "INDEX", "INSERT", "LOCK TABLES", "SELECT", "UPDATE"
1626 Any userName; userName <<= getUserName();
1627 for (size_t i = 0; i < SAL_N_ELEMENTS( allPrivileges ); ++i) {
1628 std::vector< Any > aRow;
1629 aRow.push_back(makeAny( sal_Int32( i ) ));
1630 aRow.push_back(catalog); // TABLE_CAT
1631 aRow.push_back(makeAny( schemaPattern )); // TABLE_SCHEM
1632 aRow.push_back(makeAny( tableNamePattern )); // TABLE_NAME
1633 aRow.push_back(Any()); // GRANTOR
1634 aRow.push_back(userName); // GRANTEE
1635 aRow.push_back(makeAny( rtl::OUString::createFromAscii( allPrivileges[i] ) )); // PRIVILEGE
1636 aRow.push_back(Any()); // IS_GRANTABLE
1638 rRows.push_back(aRow);
1640 } else {
1641 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1642 boost::scoped_ptr< sql::ResultSet> rset( meta->getTablePrivileges(cat, sPattern.compare("")? sPattern:wild, tPattern.compare("")? tPattern:wild));
1643 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1644 sal_uInt32 columns = rs_meta->getColumnCount();
1645 while (rset->next()) {
1646 std::vector< Any > aRow(1);
1647 for (sal_uInt32 i = 1; i <= columns; i++) {
1648 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1650 rRows.push_back(aRow);
1653 } catch (const sql::MethodNotImplementedException &) {
1654 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getTablePrivileges", *this);
1655 } catch (const sql::InvalidArgumentException &) {
1656 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getTablePrivileges", *this);
1657 } catch (const sql::SQLException& e) {
1658 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1661 lcl_setRows_throw(xResultSet,12,rRows);
1662 return xResultSet;
1665 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
1666 const Any& primaryCatalog,
1667 const rtl::OUString& primarySchema,
1668 const rtl::OUString& primaryTable,
1669 const Any& foreignCatalog,
1670 const rtl::OUString& foreignSchema,
1671 const rtl::OUString& foreignTable)
1672 throw(SQLException, RuntimeException, std::exception)
1674 OSL_TRACE("ODatabaseMetaData::getCrossReference");
1675 Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
1676 std::vector< std::vector< Any > > rRows;
1678 std::string primaryCat(primaryCatalog.hasValue()? rtl::OUStringToOString(getStringFromAny(primaryCatalog), m_rConnection.getConnectionEncoding()).getStr():""),
1679 foreignCat(foreignCatalog.hasValue()? rtl::OUStringToOString(getStringFromAny(foreignCatalog), m_rConnection.getConnectionEncoding()).getStr():""),
1680 pSchema(rtl::OUStringToOString(primarySchema, m_rConnection.getConnectionEncoding()).getStr()),
1681 pTable(rtl::OUStringToOString(primaryTable, m_rConnection.getConnectionEncoding()).getStr()),
1682 fSchema(rtl::OUStringToOString(foreignSchema, m_rConnection.getConnectionEncoding()).getStr()),
1683 fTable(rtl::OUStringToOString(foreignTable, m_rConnection.getConnectionEncoding()).getStr());
1685 try {
1686 rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
1687 boost::scoped_ptr< sql::ResultSet> rset( meta->getCrossReference(primaryCat, pSchema, pTable, foreignCat, fSchema, fTable));
1688 sql::ResultSetMetaData * rs_meta = rset->getMetaData();
1689 sal_uInt32 columns = rs_meta->getColumnCount();
1690 while (rset->next()) {
1691 std::vector< Any > aRow(1);
1692 for (sal_uInt32 i = 1; i <= columns; i++) {
1693 aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(rset->getString(i), encoding)));
1695 rRows.push_back(aRow);
1697 } catch (const sql::MethodNotImplementedException &) {
1698 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getCrossReference", *this);
1699 } catch (const sql::InvalidArgumentException &) {
1700 mysqlc_sdbc_driver::throwInvalidArgumentException("ODatabaseMetaData::getCrossReference", *this);
1701 } catch (const sql::SQLException& e) {
1702 mysqlc_sdbc_driver::translateAndThrow(e, *this, m_rConnection.getConnectionEncoding());
1705 lcl_setRows_throw(xResultSet,13,rRows);
1706 return xResultSet;
1709 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs(
1710 const Any& /* catalog */,
1711 const rtl::OUString& /* schemaPattern */,
1712 const rtl::OUString& /* typeNamePattern */,
1713 const Sequence< sal_Int32 >& /* types */)
1714 throw(SQLException, RuntimeException, std::exception)
1716 OSL_TRACE("ODatabaseMetaData::getUDTs");
1717 mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getUDTs", *this);
1718 return NULL;
1722 * Local variables:
1723 * tab-width: 4
1724 * c-basic-offset: 4
1725 * End:
1726 * vim600: noet sw=4 ts=4 fdm=marker
1727 * vim<600: noet sw=4 ts=4
1730 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */