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 "MDatabaseMetaData.hxx"
21 #include "FDatabaseMetaDataResultSet.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 <connectivity/dbexception.hxx>
27 #include <connectivity/FValue.hxx>
28 #include <com/sun/star/sdbc/ColumnValue.hpp>
29 #include <com/sun/star/sdbc/ColumnSearch.hpp>
30 #include "resource/common_res.hrc"
33 #if OSL_DEBUG_LEVEL > 0
34 # define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
35 #else /* OSL_DEBUG_LEVEL */
36 # define OUtoCStr( x ) ("dummy")
37 #endif /* OSL_DEBUG_LEVEL */
39 using namespace connectivity::mozab
;
40 using namespace connectivity
;
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 namespace com::sun::star::sdbcx
;
48 namespace connectivity
52 static sal_Int32
const s_nCOLUMN_SIZE
= 256;
53 static sal_Int32
const s_nDECIMAL_DIGITS
= 0;
54 static sal_Int32
const s_nNULLABLE
= 1;
55 static sal_Int32
const s_nCHAR_OCTET_LENGTH
= 65535;
60 ODatabaseMetaData::ODatabaseMetaData(OConnection
* _pCon
)
61 : ::connectivity::ODatabaseMetaDataBase(_pCon
,_pCon
->getConnectionInfo())
64 OSL_ENSURE(m_pConnection
,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
65 m_pDbMetaDataHelper
= new MDatabaseMetaDataHelper();
68 ODatabaseMetaData::~ODatabaseMetaData()
70 delete m_pDbMetaDataHelper
;
74 ODatabaseMetaDataResultSet::ORows
& SAL_CALL
ODatabaseMetaData::getColumnRows(
75 const OUString
& tableNamePattern
,
76 const OUString
& columnNamePattern
) throw(SQLException
)
78 static ODatabaseMetaDataResultSet::ORows aRows
;
79 ODatabaseMetaDataResultSet::ORow
aRow(19);
82 ::osl::MutexGuard
aGuard( m_aMutex
);
84 ::std::vector
< OUString
> tables
;
85 ::std::vector
< OUString
> types
;
86 if ( !m_pDbMetaDataHelper
->getTableStrings( m_pConnection
, tables
, types
) ) {
87 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
90 // ****************************************************
91 // Some entries in a row never change, so set them now
92 // ****************************************************
95 aRow
[1] = new ORowSetValueDecorator(OUString(""));
97 aRow
[2] = new ORowSetValueDecorator(OUString(""));
99 aRow
[5] = new ORowSetValueDecorator(static_cast<sal_Int16
>(DataType::VARCHAR
));
100 // TYPE_NAME, not used
101 aRow
[6] = new ORowSetValueDecorator(OUString("VARCHAR"));
103 aRow
[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE
);
104 // BUFFER_LENGTH, not used
105 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
107 aRow
[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS
);
109 aRow
[10] = new ORowSetValueDecorator((sal_Int32
)10);
111 aRow
[11] = new ORowSetValueDecorator(s_nNULLABLE
);
113 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
114 // COULUMN_DEF, not used
115 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
116 // SQL_DATA_TYPE, not used
117 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
118 // SQL_DATETIME_SUB, not used
119 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
120 // CHAR_OCTET_LENGTH, refer to [5]
121 aRow
[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH
);
123 aRow
[18] = new ORowSetValueDecorator(OUString("YES"));
125 const OColumnAlias
& colNames
= m_pConnection
->getColumnAlias();
127 // Iterate over all tables
128 for(size_t j
= 0; j
< tables
.size(); j
++ ) {
129 if(match(tableNamePattern
, tables
[j
],'\0')) {
131 aRow
[3] = new ORowSetValueDecorator( tables
[j
] );
133 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables
[j
] ));
135 // Iterate over all collumns in the table.
136 for ( OColumnAlias::AliasMap::const_iterator compare
= colNames
.begin();
137 compare
!= colNames
.end();
141 if ( match( columnNamePattern
, compare
->first
, '\0' ) )
143 OSL_TRACE( "\t\t\tColumnName = %s;", OUtoCStr( compare
->first
) );
145 aRow
[4] = new ORowSetValueDecorator( compare
->first
);
147 aRow
[17] = new ORowSetValueDecorator( static_cast< sal_Int32
>( compare
->second
.columnPosition
) + 1 );
148 aRows
.push_back(aRow
);
156 OUString
ODatabaseMetaData::impl_getCatalogSeparator_throw( )
161 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
163 sal_Int32 nValue
= 65535; // 0 means no limit
167 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
169 sal_Int32 nValue
= 0; // 0 means no limit
173 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
175 sal_Int32 nValue
= 0; // 0 means no limit
179 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
181 sal_Int32 nValue
= 254; // 0 means no limit
185 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
187 sal_Int32 nValue
= 20; // 0 means no limit
191 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
193 sal_Int32 nValue
= 0; // 0 means no limit
197 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
199 sal_Int32 nValue
= 0; // 0 means no limit
203 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
205 sal_Int32 nValue
= 0; // 0 means no limit
209 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
211 sal_Int32 nValue
= 0; // 0 means no limit
215 sal_Int32
ODatabaseMetaData::impl_getMaxStatements_throw( )
220 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
222 sal_Int32 nValue
= 0; // 0 means no limit
226 sal_Int32
ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
228 // We only support a single table
233 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
238 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
243 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
248 bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
253 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
258 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
263 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
268 bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
273 bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
278 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
280 sal_Int32 nValue
= 0; // 0 means no limit
284 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
289 OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
295 OUString
ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
297 // normally this is "
298 return OUString("\"");
301 OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
307 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
312 bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
317 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
322 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
327 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
329 //We support create table
333 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
338 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
343 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
348 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
353 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
358 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
363 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
368 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
/*level*/ ) throw(SQLException
, RuntimeException
)
373 bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
378 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
383 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
385 return sal_True
; // should be supported at least
388 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
393 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
398 bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
403 bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
408 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
413 bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
418 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
423 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
425 return 0;// 0 means no limit
428 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
430 sal_Int32 nValue
= 0; // 0 means no limit
434 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
436 sal_Int32 nValue
= 0; // 0 means no limit
440 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
445 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
450 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
455 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
460 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
462 // We allow you to select from any table.
466 sal_Bool SAL_CALL
ODatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
)
468 //we support insert/update/delete now
469 //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
470 //entry to the popup menu. We should avoid them.
474 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
479 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
484 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
489 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
494 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
496 // Support added for this.
500 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
505 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ ) throw(SQLException
, RuntimeException
)
510 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
515 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
520 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
525 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
530 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
535 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
540 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
545 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
550 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
555 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
560 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
565 bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
567 // Any case may be used
571 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
576 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
581 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
586 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
591 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
596 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
601 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
606 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
611 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
616 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
621 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
626 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
631 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
636 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
641 OUString SAL_CALL
ODatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
643 ::osl::MutexGuard
aGuard( m_aMutex
);
645 return m_pConnection
->getURL();
648 OUString SAL_CALL
ODatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
654 OUString SAL_CALL
ODatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
660 OUString SAL_CALL
ODatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
)
662 return OUString( "1" );
665 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
667 return OUString( "0" );
670 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
676 OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
682 OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
688 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
693 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
695 return TransactionIsolation::NONE
;
698 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
703 OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
709 OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
715 OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
720 OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
725 OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
730 OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
735 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
740 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
745 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
750 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
755 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
760 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
762 sal_Int32 nValue
= 0; // 0 means no limit
766 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
768 sal_Int32 nValue
= 0; // 0 means no limit
772 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
774 sal_Int32 nValue
= 0; // 0 means no limit
778 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
780 sal_Int32 nValue
= 0; // 0 means no limit
784 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
789 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ ) throw(SQLException
, RuntimeException
)
794 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
799 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
804 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
809 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
814 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
819 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
824 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
829 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
834 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
839 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
844 // here follow all methods which return a resultset
845 // the first methods is an example implementation how to use this resultset
846 // of course you could implement it on your and you should do this because
847 // the general way is more memory expensive
849 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
851 // there exists no possibility to get table types so we have to check
852 static OUString sTableTypes
[] =
856 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
858 // OUString("SYSTEM TABLE"),
859 // OUString("GLOBAL TEMPORARY"),
860 // OUString("LOCAL TEMPORARY"),
861 // OUString("ALIAS"),
862 // OUString("SYNONYM")
864 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
865 Reference
< XResultSet
> xRef
= pResult
;
867 // here we fill the rows which should be visible when ask for data from the resultset returned here
868 const sal_Int32 nSize
= sizeof(sTableTypes
) / sizeof(OUString
);
869 ODatabaseMetaDataResultSet::ORows aRows
;
870 for(sal_Int32 i
=0;i
< nSize
;++i
)
872 ODatabaseMetaDataResultSet::ORow aRow
;
873 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
874 aRow
.push_back(new ORowSetValueDecorator(sTableTypes
[i
]));
876 aRows
.push_back(aRow
);
878 // here we set the rows at the resultset
879 pResult
->setRows(aRows
);
883 Reference
< XResultSet
> ODatabaseMetaData::impl_getTypeInfo_throw( )
885 // this returns an empty resultset where the column-names are already set
886 // in special the metadata of the resultset already returns the right columns
887 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
888 Reference
< XResultSet
> xResultSet
= pResultSet
;
889 static ODatabaseMetaDataResultSet::ORows aRows
;
893 ODatabaseMetaDataResultSet::ORow aRow
;
895 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
896 aRow
.push_back(new ORowSetValueDecorator(OUString("VARCHAR")));
897 aRow
.push_back(new ORowSetValueDecorator(DataType::VARCHAR
));
898 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)s_nCHAR_OCTET_LENGTH
));
899 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
900 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
901 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
902 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
903 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
904 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
905 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)ColumnSearch::CHAR
));
906 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
907 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
908 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
909 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
910 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
911 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
912 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
913 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
914 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)10));
916 aRows
.push_back(aRow
);
919 pResultSet
->setRows(aRows
);
923 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
924 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& tableNamePattern
,
925 const OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
927 // this returns an empty resultset where the column-names are already set
928 // in special the metadata of the resultset already returns the right columns
929 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns
);
930 Reference
< XResultSet
> xResultSet
= pResultSet
;
931 pResultSet
->setRows( getColumnRows( tableNamePattern
, columnNamePattern
));
935 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
936 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/,
937 const OUString
& tableNamePattern
, const Sequence
< OUString
>& types
) throw(SQLException
, RuntimeException
)
939 // this returns an empty resultset where the column-names are already set
940 // in special the metadata of the resultset already returns the right columns
941 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables
);
942 Reference
< XResultSet
> xResultSet
= pResultSet
;
944 // ODatabaseMetaDataResultSet::ORows aRows;
945 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
946 // pResultSet->setRows( aRows );
947 ODatabaseMetaDataResultSet::ORows _rRows
;
948 if ( !m_pDbMetaDataHelper
->getTables( m_pConnection
, tableNamePattern
, types
,_rRows
) ) {
949 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
951 pResultSet
->setRows( _rRows
);
956 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
957 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& tableNamePattern
) throw(SQLException
, RuntimeException
)
959 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges
);
961 Reference
< XResultSet
> xRef
= pResult
;
963 ::std::vector
< OUString
> tables
;
964 ::std::vector
< OUString
> types
;
965 if ( !m_pDbMetaDataHelper
->getTableStrings( m_pConnection
, tables
, types
) )
966 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
968 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows
;
969 ::connectivity::ODatabaseMetaDataResultSet::ORow
aRow(8);
971 aRow
[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
972 aRow
[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
973 aRow
[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
974 aRow
[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
975 aRow
[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
976 aRow
[7] = new ::connectivity::ORowSetValueDecorator(OUString("NO"));
979 // Iterate over all tables
980 for(size_t j
= 0; j
< tables
.size(); j
++ ) {
981 if(match(tableNamePattern
, tables
[j
],'\0'))
984 aRow
[2] = new ORowSetValueDecorator( tables
[j
] );
986 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables
[j
] ));
988 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
989 aRows
.push_back(aRow
);
990 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
991 aRows
.push_back(aRow
);
992 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
993 aRows
.push_back(aRow
);
994 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
995 aRows
.push_back(aRow
);
996 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
997 aRows
.push_back(aRow
);
998 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
999 aRows
.push_back(aRow
);
1000 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1001 aRows
.push_back(aRow
);
1002 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1003 aRows
.push_back(aRow
);
1006 pResult
->setRows(aRows
);
1011 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getUDTs( const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& /*typeNamePattern*/, const Sequence
< sal_Int32
>& /*types*/ ) throw(SQLException
, RuntimeException
)
1019 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */