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 #include "ado/ADatabaseMetaData.hxx"
21 #include "ado/ADatabaseMetaDataResultSet.hxx"
22 #include <com/sun/star/sdbc/DataType.hpp>
23 #include <com/sun/star/sdbc/ResultSetType.hpp>
24 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
25 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
26 #include "ado/AConnection.hxx"
27 #include "ado/adoimp.hxx"
28 #include "FDatabaseMetaDataResultSet.hxx"
29 #include <comphelper/types.hxx>
30 #include <connectivity/dbexception.hxx>
32 using namespace ::comphelper
;
34 using namespace connectivity
;
35 using namespace connectivity::ado
;
36 using namespace com::sun::star::uno
;
37 using namespace com::sun::star::lang
;
38 using namespace com::sun::star::beans
;
39 using namespace com::sun::star::sdbc
;
42 ODatabaseMetaData::ODatabaseMetaData(OConnection
* _pCon
)
43 : ::connectivity::ODatabaseMetaDataBase(_pCon
,_pCon
->getConnectionInfo())
44 ,m_pADOConnection(_pCon
->getConnection())
49 sal_Int32
ODatabaseMetaData::getInt32Property(const OUString
& _aProperty
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
51 connectivity::ado::WpADOProperties
aProps(m_pADOConnection
->get_Properties());
52 // ADOS::ThrowException(*m_pADOConnection,*this);
53 OSL_ENSURE(aProps
.IsValid(),"There are no properties at the connection");
56 if(!aVar
.isNull() && !aVar
.isEmpty())
62 sal_Bool
ODatabaseMetaData::getBoolProperty(const OUString
& _aProperty
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
64 connectivity::ado::WpADOProperties
aProps(m_pADOConnection
->get_Properties());
65 ADOS::ThrowException(*m_pADOConnection
,*this);
66 OSL_ENSURE(aProps
.IsValid(),"There are no properties at the connection");
68 return (!aVar
.isNull() && !aVar
.isEmpty() ? aVar
.getBool() : sal_False
);
71 OUString
ODatabaseMetaData::getStringProperty(const OUString
& _aProperty
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
73 connectivity::ado::WpADOProperties
aProps(m_pADOConnection
->get_Properties());
74 ADOS::ThrowException(*m_pADOConnection
,*this);
75 OSL_ENSURE(aProps
.IsValid(),"There are no properties at the connection");
79 if(!aVar
.isNull() && !aVar
.isEmpty() && aVar
.getType() == VT_BSTR
)
85 Reference
< XResultSet
> ODatabaseMetaData::impl_getTypeInfo_throw( )
87 ADORecordset
*pRecordset
= m_pADOConnection
->getTypeInfo();
89 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
90 pResult
->setTypeInfoMap(ADOS::isJetEngine(m_pConnection
->getEngineType()));
91 Reference
< XResultSet
> xRef
= pResult
;
95 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCatalogs( ) throw(SQLException
, RuntimeException
)
100 ADORecordset
*pRecordset
= NULL
;
101 m_pADOConnection
->OpenSchema(adSchemaCatalogs
,vtEmpty
,vtEmpty
,&pRecordset
);
102 ADOS::ThrowException(*m_pADOConnection
,*this);
104 Reference
< XResultSet
> xRef
;
106 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
107 pResult
->setCatalogsMap();
113 OUString
ODatabaseMetaData::impl_getCatalogSeparator_throw( )
115 return getLiteral(DBLITERAL_CATALOG_SEPARATOR
);
118 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getSchemas( ) throw(SQLException
, RuntimeException
)
123 ADORecordset
*pRecordset
= NULL
;
124 m_pADOConnection
->OpenSchema(adSchemaSchemata
,vtEmpty
,vtEmpty
,&pRecordset
);
125 ADOS::ThrowException(*m_pADOConnection
,*this);
127 Reference
< XResultSet
> xRef
;
129 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
130 pResult
->setSchemasMap();
135 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumnPrivileges(
136 const Any
& catalog
, const OUString
& schema
, const OUString
& table
,
137 const OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
139 ADORecordset
*pRecordset
= m_pADOConnection
->getColumnPrivileges(catalog
,schema
,table
,columnNamePattern
);
140 ADOS::ThrowException(*m_pADOConnection
,*this);
142 Reference
< XResultSet
> xRef
;
144 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
145 pResult
->setColumnPrivilegesMap();
150 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
151 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
,
152 const OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
154 ADORecordset
*pRecordset
= m_pADOConnection
->getColumns(catalog
,schemaPattern
,tableNamePattern
,columnNamePattern
);
155 ADOS::ThrowException(*m_pADOConnection
,*this);
157 Reference
< XResultSet
> xRef
;
159 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
160 pResult
->setColumnsMap();
166 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
167 const Any
& catalog
, const OUString
& schemaPattern
,
168 const OUString
& tableNamePattern
, const Sequence
< OUString
>& types
) throw(SQLException
, RuntimeException
)
170 ADORecordset
*pRecordset
= m_pADOConnection
->getTables(catalog
,schemaPattern
,tableNamePattern
,types
);
171 ADOS::ThrowException(*m_pADOConnection
,*this);
173 Reference
< XResultSet
> xRef
;
175 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
176 pResult
->setTablesMap();
182 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedureColumns(
183 const Any
& catalog
, const OUString
& schemaPattern
,
184 const OUString
& procedureNamePattern
, const OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
186 ADORecordset
*pRecordset
= m_pADOConnection
->getProcedureColumns(catalog
,schemaPattern
,procedureNamePattern
,columnNamePattern
);
187 ADOS::ThrowException(*m_pADOConnection
,*this);
189 Reference
< XResultSet
> xRef
;
191 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
192 pResult
->setProcedureColumnsMap();
198 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedures(
199 const Any
& catalog
, const OUString
& schemaPattern
,
200 const OUString
& procedureNamePattern
) throw(SQLException
, RuntimeException
)
202 // Create elements used in the array
203 ADORecordset
*pRecordset
= m_pADOConnection
->getProcedures(catalog
,schemaPattern
,procedureNamePattern
);
204 ADOS::ThrowException(*m_pADOConnection
,*this);
206 Reference
< XResultSet
> xRef
;
208 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
209 pResult
->setProceduresMap();
215 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
217 return getMaxSize(DBLITERAL_BINARY_LITERAL
);
220 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
222 return getInt32Property(OUString("Maximum Row Size"));
225 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
227 return getMaxSize(DBLITERAL_CATALOG_NAME
);
230 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
232 return getMaxSize(DBLITERAL_CHAR_LITERAL
);
235 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
237 return getMaxSize(DBLITERAL_COLUMN_NAME
);
240 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
245 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
247 return getMaxSize(DBLITERAL_CURSOR_NAME
);
250 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
252 return getInt32Property(OUString("Active Sessions"));
255 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
257 return getInt32Property(OUString("Max Columns in Table"));
260 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
262 return getMaxSize(DBLITERAL_TEXT_COMMAND
);
265 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
267 return getMaxSize(DBLITERAL_TABLE_NAME
);
270 sal_Int32
ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
272 return getInt32Property(OUString("Maximum Tables in SELECT"));
275 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getExportedKeys(
276 const Any
& catalog
, const OUString
& schema
, const OUString
& table
) throw(SQLException
, RuntimeException
)
278 ADORecordset
*pRecordset
= m_pADOConnection
->getExportedKeys(catalog
,schema
,table
);
279 ADOS::ThrowException(*m_pADOConnection
,*this);
281 Reference
< XResultSet
> xRef
;
282 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
283 pResult
->setCrossReferenceMap();
289 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getImportedKeys(
290 const Any
& catalog
, const OUString
& schema
, const OUString
& table
) throw(SQLException
, RuntimeException
)
292 ADORecordset
*pRecordset
= m_pADOConnection
->getImportedKeys(catalog
,schema
,table
);
293 ADOS::ThrowException(*m_pADOConnection
,*this);
295 Reference
< XResultSet
> xRef
;
297 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
298 pResult
->setCrossReferenceMap();
304 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getPrimaryKeys(
305 const Any
& catalog
, const OUString
& schema
, const OUString
& table
) throw(SQLException
, RuntimeException
)
307 ADORecordset
*pRecordset
= m_pADOConnection
->getPrimaryKeys(catalog
,schema
,table
);
308 ADOS::ThrowException(*m_pADOConnection
,*this);
310 Reference
< XResultSet
> xRef
;
312 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
313 pResult
->setPrimaryKeysMap();
319 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getIndexInfo(
320 const Any
& catalog
, const OUString
& schema
, const OUString
& table
,
321 sal_Bool unique
, sal_Bool approximate
) throw(SQLException
, RuntimeException
)
323 ADORecordset
*pRecordset
= m_pADOConnection
->getIndexInfo(catalog
,schema
,table
,unique
,approximate
);
324 ADOS::ThrowException(*m_pADOConnection
,*this);
326 Reference
< XResultSet
> xRef
;
328 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
329 pResult
->setIndexInfoMap();
335 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
336 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
) throw(SQLException
, RuntimeException
)
338 Reference
< XResultSet
> xRef
;
339 if(!ADOS::isJetEngine(m_pConnection
->getEngineType()))
340 { // the jet provider doesn't support this method
341 // Create elements used in the array
343 ADORecordset
*pRecordset
= m_pADOConnection
->getTablePrivileges(catalog
,schemaPattern
,tableNamePattern
);
344 ADOS::ThrowException(*m_pADOConnection
,*this);
346 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
347 pResult
->setTablePrivilegesMap();
352 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTablePrivileges
);
354 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows
;
355 ::connectivity::ODatabaseMetaDataResultSet::ORow
aRow(8);
358 aRow
[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
359 aRow
[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
360 aRow
[2] = new ::connectivity::ORowSetValueDecorator(tableNamePattern
);
361 aRow
[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
362 aRow
[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
363 aRow
[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
364 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
365 aRow
[7] = new ::connectivity::ORowSetValueDecorator(OUString("NO"));
367 aRows
.push_back(aRow
);
368 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
369 aRows
.push_back(aRow
);
370 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
371 aRows
.push_back(aRow
);
372 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
373 aRows
.push_back(aRow
);
374 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
375 aRows
.push_back(aRow
);
376 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
377 aRows
.push_back(aRow
);
378 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
379 aRows
.push_back(aRow
);
380 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
381 aRows
.push_back(aRow
);
382 pResult
->setRows(aRows
);
388 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCrossReference(
389 const Any
& primaryCatalog
, const OUString
& primarySchema
,
390 const OUString
& primaryTable
, const Any
& foreignCatalog
,
391 const OUString
& foreignSchema
, const OUString
& foreignTable
) throw(SQLException
, RuntimeException
)
393 ADORecordset
*pRecordset
= m_pADOConnection
->getCrossReference(primaryCatalog
,primarySchema
,primaryTable
,foreignCatalog
,foreignSchema
,foreignTable
);
394 ADOS::ThrowException(*m_pADOConnection
,*this);
396 Reference
< XResultSet
> xRef
;
398 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(pRecordset
);
399 pResult
->setCrossReferenceMap();
405 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
407 return getBoolProperty(OUString("Maximum Row Size Includes BLOB"));
410 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
412 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER
) == DBPROPVAL_IC_LOWER
;
415 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
417 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER
) == DBPROPVAL_IC_LOWER
;
420 bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
422 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED
) == DBPROPVAL_IC_MIXED
;
425 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
427 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED
) == DBPROPVAL_IC_MIXED
;
430 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
432 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER
) == DBPROPVAL_IC_UPPER
;
435 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
437 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER
) == DBPROPVAL_IC_UPPER
;
440 bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
445 bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
450 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
452 return getInt32Property(OUString("Maximum Index Size"));
455 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
457 return getInt32Property(OUString("NULL Concatenation Behavior")) == DBPROPVAL_CB_NON_NULL
;
460 OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
462 return getStringProperty(OUString("Catalog Term"));
465 OUString
ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
467 return getLiteral(DBLITERAL_QUOTE_PREFIX
);
471 OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
476 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
478 return isCapable(DBLITERAL_CORRELATION_NAME
);
481 bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
483 return getInt32Property(OUString("Catalog Location")) == DBPROPVAL_CL_START
;
486 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
488 return getInt32Property(OUString("Transaction DDL")) == DBPROPVAL_TC_DDL_IGNORE
;
491 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
493 return getInt32Property(OUString("Transaction DDL")) == DBPROPVAL_TC_DDL_COMMIT
;
496 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
498 return getInt32Property(OUString("Transaction DDL")) == DBPROPVAL_TC_DML
;
501 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
503 return getInt32Property(OUString("Transaction DDL")) == DBPROPVAL_TC_ALL
;
506 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
511 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
516 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
518 return getInt32Property(OUString("Prepare Abort Behavior")) == DBPROPVAL_CB_PRESERVE
;
521 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
523 return getInt32Property(OUString("Prepare Commit Behavior")) == DBPROPVAL_CB_PRESERVE
;
526 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
528 return (getInt32Property(OUString("Isolation Retention")) & DBPROPVAL_TR_COMMIT
) == DBPROPVAL_TR_COMMIT
;
531 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
533 return (getInt32Property(OUString("Isolation Retention")) & DBPROPVAL_TR_ABORT
) == DBPROPVAL_TR_ABORT
;
536 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level
) throw(SQLException
, RuntimeException
)
538 sal_Bool
bValue(sal_False
);
540 sal_Int32 nTxn
= getInt32Property(OUString("Isolation Levels"));
541 if(level
== TransactionIsolation::NONE
)
543 else if(level
== TransactionIsolation::READ_UNCOMMITTED
)
544 bValue
= (nTxn
& DBPROPVAL_TI_READUNCOMMITTED
) == DBPROPVAL_TI_READUNCOMMITTED
;
545 else if(level
== TransactionIsolation::READ_COMMITTED
)
546 bValue
= (nTxn
& DBPROPVAL_TI_READCOMMITTED
) == DBPROPVAL_TI_READCOMMITTED
;
547 else if(level
== TransactionIsolation::REPEATABLE_READ
)
548 bValue
= (nTxn
& DBPROPVAL_TI_REPEATABLEREAD
) == DBPROPVAL_TI_REPEATABLEREAD
;
549 else if(level
== TransactionIsolation::SERIALIZABLE
)
550 bValue
= (nTxn
& DBPROPVAL_TI_SERIALIZABLE
) == DBPROPVAL_TI_SERIALIZABLE
;
555 bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
557 return (getInt32Property(OUString("Schema Usage")) & DBPROPVAL_SU_DML_STATEMENTS
) == DBPROPVAL_SU_DML_STATEMENTS
;
560 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
562 sal_Int32 nProp
= getInt32Property(OUString("SQL Support"));
563 return (nProp
== 512) || ((nProp
& DBPROPVAL_SQL_ANSI92_FULL
) == DBPROPVAL_SQL_ANSI92_FULL
);
566 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
568 sal_Int32 nProp
= getInt32Property(OUString("SQL Support"));
569 return (nProp
== 512) || ((nProp
& DBPROPVAL_SQL_ANSI92_ENTRY
) == DBPROPVAL_SQL_ANSI92_ENTRY
);
572 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
574 sal_Int32 nProp
= getInt32Property(OUString("SQL Support"));
575 return (nProp
== 512) || ((nProp
& DBPROPVAL_SQL_ANSI89_IEF
) == DBPROPVAL_SQL_ANSI89_IEF
);
578 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
580 return (getInt32Property(OUString("Schema Usage")) & DBPROPVAL_SU_INDEX_DEFINITION
) == DBPROPVAL_SU_INDEX_DEFINITION
;
583 bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
585 return (getInt32Property(OUString("Schema Usage")) & DBPROPVAL_SU_TABLE_DEFINITION
) == DBPROPVAL_SU_TABLE_DEFINITION
;
588 bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
593 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
598 bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
603 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
605 if ( ADOS::isJetEngine(m_pConnection
->getEngineType()) )
607 return getBoolProperty(OUString("Outer Join Capabilities"));
610 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
612 return new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes
);
615 sal_Int32
ODatabaseMetaData::impl_getMaxStatements_throw( )
620 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
622 return getMaxSize(DBLITERAL_PROCEDURE_NAME
);
625 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
627 return getMaxSize(DBLITERAL_SCHEMA_NAME
);
630 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
632 return getInt32Property(OUString("Transaction DDL")) == DBPROPVAL_TC_NONE
;
635 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
640 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
645 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
650 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
655 sal_Bool SAL_CALL
ODatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
)
657 return getBoolProperty(OUString("Read-Only Data Source"));
660 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
665 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
670 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
675 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
677 return getInt32Property(OUString("NULL Concatenation Behavior")) == DBPROPVAL_CB_NULL
;
680 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
682 return isCapable(DBLITERAL_COLUMN_ALIAS
);
685 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
687 return isCapable(DBLITERAL_CORRELATION_NAME
);
690 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ ) throw(SQLException
, RuntimeException
)
692 return getBoolProperty(OUString("Rowset Conversions on Command"));
695 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
697 return getBoolProperty(OUString("ORDER BY Columns in Select List"));
700 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
702 return getInt32Property(OUString("GROUP BY Support")) != DBPROPVAL_GB_NOT_SUPPORTED
;
705 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
707 return getInt32Property(OUString("GROUP BY Support")) != DBPROPVAL_GB_CONTAINS_SELECT
;
710 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
712 return getInt32Property(OUString("GROUP BY Support")) == DBPROPVAL_GB_NO_RELATION
;
715 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
720 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
725 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
727 return isCapable(DBLITERAL_ESCAPE_PERCENT
);
730 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
732 return getBoolProperty(OUString("ORDER BY Columns in Select List"));
735 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
740 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
745 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
747 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED
) == DBPROPVAL_IC_MIXED
;
750 bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
752 return (getInt32Property(OUString("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED
) == DBPROPVAL_IC_MIXED
;
755 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
757 return (getInt32Property(OUString("NULL Collation Order")) & DBPROPVAL_NC_END
) == DBPROPVAL_NC_END
;
760 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
762 return (getInt32Property(OUString("NULL Collation Order")) & DBPROPVAL_NC_START
) == DBPROPVAL_NC_START
;
765 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
767 return (getInt32Property(OUString("NULL Collation Order")) & DBPROPVAL_NC_HIGH
) == DBPROPVAL_NC_HIGH
;
770 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
772 return (getInt32Property(OUString("NULL Collation Order")) & DBPROPVAL_NC_LOW
) == DBPROPVAL_NC_LOW
;
775 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
780 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
782 return (getInt32Property(OUString("Schema Usage")) & DBPROPVAL_SU_PRIVILEGE_DEFINITION
) == DBPROPVAL_SU_PRIVILEGE_DEFINITION
;
785 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
790 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
795 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
797 return (getInt32Property(OUString("Subquery Support")) & DBPROPVAL_SQ_CORRELATEDSUBQUERIES
) == DBPROPVAL_SQ_CORRELATEDSUBQUERIES
;
800 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
802 return (getInt32Property(OUString("Subquery Support")) & DBPROPVAL_SQ_COMPARISON
) == DBPROPVAL_SQ_COMPARISON
;
805 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
807 return (getInt32Property(OUString("Subquery Support")) & DBPROPVAL_SQ_EXISTS
) == DBPROPVAL_SQ_EXISTS
;
810 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
812 return (getInt32Property(OUString("Subquery Support")) & DBPROPVAL_SQ_IN
) == DBPROPVAL_SQ_IN
;
815 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
817 return (getInt32Property(OUString("Subquery Support")) & DBPROPVAL_SQ_QUANTIFIED
) == DBPROPVAL_SQ_QUANTIFIED
;
820 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
822 sal_Int32 nProp
= getInt32Property(OUString("SQL Support"));
823 return (nProp
== 512) || ((nProp
& DBPROPVAL_SQL_ANSI92_INTERMEDIATE
) == DBPROPVAL_SQL_ANSI92_INTERMEDIATE
);
826 OUString SAL_CALL
ODatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
828 return OUString("sdbc:ado:")+ m_pADOConnection
->GetConnectionString();
831 OUString SAL_CALL
ODatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
833 return getStringProperty(OUString("User Name"));
836 OUString SAL_CALL
ODatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
838 return getStringProperty(OUString("Provider Friendly Name"));
841 OUString SAL_CALL
ODatabaseMetaData::getDriverVersion( ) throw(SQLException
, RuntimeException
)
843 return getStringProperty(OUString("Provider Version"));
846 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
848 return getStringProperty(OUString("DBMS Version"));
851 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
853 return getStringProperty(OUString("DBMS Name"));
856 OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
858 return getStringProperty(OUString("Procedure Term"));
861 OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
863 return getStringProperty(OUString("Schema Term"));
866 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
871 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
873 sal_Int32 nRet
= TransactionIsolation::NONE
;
874 switch(m_pADOConnection
->get_IsolationLevel())
876 case adXactReadCommitted
:
877 nRet
= TransactionIsolation::READ_COMMITTED
;
879 case adXactRepeatableRead
:
880 nRet
= TransactionIsolation::REPEATABLE_READ
;
882 case adXactSerializable
:
883 nRet
= TransactionIsolation::SERIALIZABLE
;
885 case adXactReadUncommitted
:
886 nRet
= TransactionIsolation::READ_UNCOMMITTED
;
894 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
899 OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
901 ADORecordset
*pRecordset
= NULL
;
904 m_pADOConnection
->OpenSchema(adSchemaDBInfoKeywords
,vtEmpty
,vtEmpty
,&pRecordset
);
905 OSL_ENSURE(pRecordset
,"getSQLKeywords: no resultset!");
906 ADOS::ThrowException(*m_pADOConnection
,*this);
909 WpADORecordset
aRecordset(pRecordset
);
911 aRecordset
.MoveFirst();
913 OUString aRet
, aComma(",");
914 while(!aRecordset
.IsAtEOF())
916 WpOLEAppendCollection
<ADOFields
, ADOField
, WpADOField
> aFields(aRecordset
.GetFields());
917 WpADOField
aField(aFields
.GetItem(0));
918 aField
.get_Value(aValue
);
919 aRet
= aRet
+ (aValue
.operator OUString()) + aComma
;
920 aRecordset
.MoveNext();
923 if ( !aRet
.isEmpty() )
924 return aRet
.copy(0,aRet
.lastIndexOf(','));
929 OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
931 return getLiteral(DBLITERAL_ESCAPE_PERCENT
);
934 OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
937 return aValue
.copy(0,aValue
.lastIndexOf(','));
940 OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
946 OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
949 return aValue
.copy(0,aValue
.lastIndexOf(','));
952 OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
958 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
960 sal_Int32 nProp
= getInt32Property(OUString("SQL Support"));
961 return (nProp
== 512) || ((nProp
& DBPROPVAL_SQL_ODBC_EXTENDED
) == DBPROPVAL_SQL_ODBC_EXTENDED
);
964 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
966 sal_Int32 nProp
= getInt32Property(OUString("SQL Support"));
967 return (nProp
== 512) || ((nProp
& DBPROPVAL_SQL_ODBC_CORE
) == DBPROPVAL_SQL_ODBC_CORE
);
970 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
972 sal_Int32 nProp
= getInt32Property(OUString("SQL Support"));
973 return (nProp
== 512) || ((nProp
& DBPROPVAL_SQL_ODBC_MINIMUM
) == DBPROPVAL_SQL_ODBC_MINIMUM
);
976 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
978 if ( ADOS::isJetEngine(m_pConnection
->getEngineType()) )
980 return (getInt32Property(OUString("Outer Join Capabilities")) & 0x00000004L
) == 0x00000004L
;
983 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
985 return supportsFullOuterJoins( );
988 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
990 return getInt32Property(OUString("Max Columns in GROUP BY"));
993 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
995 return getInt32Property(OUString("Max Columns in ORDER BY"));
998 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
1003 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
1005 return getMaxSize(DBLITERAL_USER_NAME
);
1008 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
1013 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ ) throw(SQLException
, RuntimeException
)
1018 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1020 return ResultSetType::FORWARD_ONLY
!= setType
;
1023 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1025 return ResultSetType::FORWARD_ONLY
!= setType
;
1028 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1030 return ResultSetType::FORWARD_ONLY
!= setType
;
1033 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1035 return ResultSetType::FORWARD_ONLY
!= setType
;
1038 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1040 return ResultSetType::FORWARD_ONLY
!= setType
;
1043 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1045 return ResultSetType::FORWARD_ONLY
!= setType
;
1048 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1050 return ResultSetType::FORWARD_ONLY
!= setType
;
1053 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1055 return ResultSetType::FORWARD_ONLY
!= setType
;
1058 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
1060 return ResultSetType::FORWARD_ONLY
!= setType
;
1063 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
1068 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getUDTs( const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& /*typeNamePattern*/, const Sequence
< sal_Int32
>& /*types*/ ) throw(SQLException
, RuntimeException
)
1070 ::dbtools::throwFeatureNotImplementedException( "XDatabaseMetaData::getUDTs", *this );
1071 return Reference
< XResultSet
>();
1075 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */