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();
67 // -------------------------------------------------------------------------
68 ODatabaseMetaData::~ODatabaseMetaData()
70 delete m_pDbMetaDataHelper
;
73 // -------------------------------------------------------------------------
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
);
155 // -------------------------------------------------------------------------
156 OUString
ODatabaseMetaData::impl_getCatalogSeparator_throw( )
160 // -------------------------------------------------------------------------
161 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
163 sal_Int32 nValue
= 65535; // 0 means no limit
166 // -------------------------------------------------------------------------
167 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
169 sal_Int32 nValue
= 0; // 0 means no limit
172 // -------------------------------------------------------------------------
173 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
175 sal_Int32 nValue
= 0; // 0 means no limit
178 // -------------------------------------------------------------------------
179 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
181 sal_Int32 nValue
= 254; // 0 means no limit
184 // -------------------------------------------------------------------------
185 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
187 sal_Int32 nValue
= 20; // 0 means no limit
190 // -------------------------------------------------------------------------
191 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
193 sal_Int32 nValue
= 0; // 0 means no limit
196 // -------------------------------------------------------------------------
197 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
199 sal_Int32 nValue
= 0; // 0 means no limit
202 // -------------------------------------------------------------------------
203 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
205 sal_Int32 nValue
= 0; // 0 means no limit
208 // -------------------------------------------------------------------------
209 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
211 sal_Int32 nValue
= 0; // 0 means no limit
214 // -------------------------------------------------------------------------
215 sal_Int32
ODatabaseMetaData::impl_getMaxStatements_throw( )
219 // -------------------------------------------------------------------------
220 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
222 sal_Int32 nValue
= 0; // 0 means no limit
225 // -------------------------------------------------------------------------
226 sal_Int32
ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
228 // We only support a single table
231 // -------------------------------------------------------------------------
232 // -------------------------------------------------------------------------
233 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
237 // -------------------------------------------------------------------------
238 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
242 // -------------------------------------------------------------------------
243 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
247 // -------------------------------------------------------------------------
248 sal_Bool
ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
252 // -------------------------------------------------------------------------
253 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
257 // -------------------------------------------------------------------------
258 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
262 // -------------------------------------------------------------------------
263 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
267 // -------------------------------------------------------------------------
268 sal_Bool
ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
272 // -------------------------------------------------------------------------
273 sal_Bool
ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
277 // -------------------------------------------------------------------------
278 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
280 sal_Int32 nValue
= 0; // 0 means no limit
283 // -------------------------------------------------------------------------
284 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
288 // -------------------------------------------------------------------------
289 OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
294 // -------------------------------------------------------------------------
295 OUString
ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
297 // normally this is "
298 return OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
300 // -------------------------------------------------------------------------
301 OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
306 // -------------------------------------------------------------------------
307 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
311 // -------------------------------------------------------------------------
312 sal_Bool
ODatabaseMetaData::impl_isCatalogAtStart_throw( )
316 // -------------------------------------------------------------------------
317 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
321 // -------------------------------------------------------------------------
322 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
326 // -------------------------------------------------------------------------
327 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
329 //We support create table
332 // -------------------------------------------------------------------------
333 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
337 // -------------------------------------------------------------------------
338 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
342 // -------------------------------------------------------------------------
343 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
347 // -------------------------------------------------------------------------
348 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
352 // -------------------------------------------------------------------------
353 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
357 // -------------------------------------------------------------------------
358 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
362 // -------------------------------------------------------------------------
363 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
367 // -------------------------------------------------------------------------
368 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
/*level*/ ) throw(SQLException
, RuntimeException
)
372 // -------------------------------------------------------------------------
373 sal_Bool
ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
377 // -------------------------------------------------------------------------
378 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
382 // -------------------------------------------------------------------------
383 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
385 return sal_True
; // should be supported at least
387 // -------------------------------------------------------------------------
388 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
392 // -------------------------------------------------------------------------
393 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
397 // -------------------------------------------------------------------------
398 sal_Bool
ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
402 // -------------------------------------------------------------------------
403 sal_Bool
ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
407 // -------------------------------------------------------------------------
408 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
412 // -------------------------------------------------------------------------
413 sal_Bool
ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
417 // -------------------------------------------------------------------------
418 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
422 // -------------------------------------------------------------------------
423 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
425 return 0;// 0 means no limit
427 // -------------------------------------------------------------------------
428 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
430 sal_Int32 nValue
= 0; // 0 means no limit
433 // -------------------------------------------------------------------------
434 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
436 sal_Int32 nValue
= 0; // 0 means no limit
439 // -------------------------------------------------------------------------
440 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
444 // -------------------------------------------------------------------------
445 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
449 // -------------------------------------------------------------------------
450 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
454 // -------------------------------------------------------------------------
455 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
459 // -------------------------------------------------------------------------
460 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
462 // We allow you to select from any table.
465 // -------------------------------------------------------------------------
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.
473 // -------------------------------------------------------------------------
474 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
478 // -------------------------------------------------------------------------
479 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
483 // -------------------------------------------------------------------------
484 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
488 // -------------------------------------------------------------------------
489 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
493 // -------------------------------------------------------------------------
494 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
496 // Support added for this.
499 // -------------------------------------------------------------------------
500 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
504 // -------------------------------------------------------------------------
505 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ ) throw(SQLException
, RuntimeException
)
509 // -------------------------------------------------------------------------
510 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
514 // -------------------------------------------------------------------------
515 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
519 // -------------------------------------------------------------------------
520 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
524 // -------------------------------------------------------------------------
525 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
529 // -------------------------------------------------------------------------
530 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
534 // -------------------------------------------------------------------------
535 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
539 // -------------------------------------------------------------------------
540 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
544 // -------------------------------------------------------------------------
545 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
549 // -------------------------------------------------------------------------
550 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
554 // -------------------------------------------------------------------------
555 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
559 // -------------------------------------------------------------------------
560 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
564 // -------------------------------------------------------------------------
565 sal_Bool
ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
567 // Any case may be used
570 // -------------------------------------------------------------------------
571 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
575 // -------------------------------------------------------------------------
576 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
580 // -------------------------------------------------------------------------
581 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
585 // -------------------------------------------------------------------------
586 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
590 // -------------------------------------------------------------------------
591 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
595 // -------------------------------------------------------------------------
596 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
600 // -------------------------------------------------------------------------
601 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
605 // -------------------------------------------------------------------------
606 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
610 // -------------------------------------------------------------------------
611 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
615 // -------------------------------------------------------------------------
616 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
620 // -------------------------------------------------------------------------
621 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
625 // -------------------------------------------------------------------------
626 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
630 // -------------------------------------------------------------------------
631 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
635 // -------------------------------------------------------------------------
636 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
640 // -------------------------------------------------------------------------
641 OUString SAL_CALL
ODatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
643 ::osl::MutexGuard
aGuard( m_aMutex
);
645 return m_pConnection
->getURL();
647 // -------------------------------------------------------------------------
648 OUString SAL_CALL
ODatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
653 // -------------------------------------------------------------------------
654 OUString SAL_CALL
ODatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
659 // -------------------------------------------------------------------------
660 OUString SAL_CALL
ODatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
)
662 OUString aValue
= OUString::valueOf((sal_Int32
)1);
665 // -------------------------------------------------------------------------
666 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
668 OUString aValue
= OUString::valueOf((sal_Int32
)0);
671 // -------------------------------------------------------------------------
672 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
677 // -------------------------------------------------------------------------
678 OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
683 // -------------------------------------------------------------------------
684 OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
689 // -------------------------------------------------------------------------
690 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
694 // -------------------------------------------------------------------------
695 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
697 return TransactionIsolation::NONE
;
699 // -------------------------------------------------------------------------
700 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
704 // -------------------------------------------------------------------------
705 OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
710 // -------------------------------------------------------------------------
711 OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
716 // -------------------------------------------------------------------------
717 OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
721 // -------------------------------------------------------------------------
722 OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
726 // -------------------------------------------------------------------------
727 OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
731 // -------------------------------------------------------------------------
732 OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
736 // -------------------------------------------------------------------------
737 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
741 // -------------------------------------------------------------------------
742 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
746 // -------------------------------------------------------------------------
747 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
751 // -------------------------------------------------------------------------
752 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
756 // -------------------------------------------------------------------------
757 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
761 // -------------------------------------------------------------------------
762 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
764 sal_Int32 nValue
= 0; // 0 means no limit
767 // -------------------------------------------------------------------------
768 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
770 sal_Int32 nValue
= 0; // 0 means no limit
773 // -------------------------------------------------------------------------
774 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
776 sal_Int32 nValue
= 0; // 0 means no limit
779 // -------------------------------------------------------------------------
780 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
782 sal_Int32 nValue
= 0; // 0 means no limit
785 // -------------------------------------------------------------------------
786 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
790 // -------------------------------------------------------------------------
791 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ ) throw(SQLException
, RuntimeException
)
795 // -------------------------------------------------------------------------
796 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
800 // -------------------------------------------------------------------------
801 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
805 // -------------------------------------------------------------------------
806 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
810 // -------------------------------------------------------------------------
811 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
815 // -------------------------------------------------------------------------
816 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
820 // -------------------------------------------------------------------------
821 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
825 // -------------------------------------------------------------------------
826 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
830 // -------------------------------------------------------------------------
831 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
835 // -------------------------------------------------------------------------
836 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
840 // -------------------------------------------------------------------------
841 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
845 // -------------------------------------------------------------------------
846 // here follow all methods which return a resultset
847 // the first methods is an example implementation how to use this resultset
848 // of course you could implement it on your and you should do this because
849 // the general way is more memory expensive
850 // -------------------------------------------------------------------------
851 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
853 // there exists no possibility to get table types so we have to check
854 static OUString sTableTypes
[] =
858 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
860 // OUString("SYSTEM TABLE"),
861 // OUString("GLOBAL TEMPORARY"),
862 // OUString("LOCAL TEMPORARY"),
863 // OUString("ALIAS"),
864 // OUString("SYNONYM")
866 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
867 Reference
< XResultSet
> xRef
= pResult
;
869 // here we fill the rows which should be visible when ask for data from the resultset returned here
870 const sal_Int32 nSize
= sizeof(sTableTypes
) / sizeof(OUString
);
871 ODatabaseMetaDataResultSet::ORows aRows
;
872 for(sal_Int32 i
=0;i
< nSize
;++i
)
874 ODatabaseMetaDataResultSet::ORow aRow
;
875 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
876 aRow
.push_back(new ORowSetValueDecorator(sTableTypes
[i
]));
878 aRows
.push_back(aRow
);
880 // here we set the rows at the resultset
881 pResult
->setRows(aRows
);
884 // -------------------------------------------------------------------------
885 Reference
< XResultSet
> ODatabaseMetaData::impl_getTypeInfo_throw( )
887 // this returns an empty resultset where the column-names are already set
888 // in special the metadata of the resultset already returns the right columns
889 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
890 Reference
< XResultSet
> xResultSet
= pResultSet
;
891 static ODatabaseMetaDataResultSet::ORows aRows
;
895 ODatabaseMetaDataResultSet::ORow aRow
;
897 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
898 aRow
.push_back(new ORowSetValueDecorator(OUString("VARCHAR")));
899 aRow
.push_back(new ORowSetValueDecorator(DataType::VARCHAR
));
900 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)s_nCHAR_OCTET_LENGTH
));
901 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
902 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
903 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
904 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
905 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
906 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
907 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)ColumnSearch::CHAR
));
908 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
909 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
910 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
911 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
912 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
913 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
914 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
915 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
916 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)10));
918 aRows
.push_back(aRow
);
921 pResultSet
->setRows(aRows
);
924 // -------------------------------------------------------------------------
925 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
926 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& tableNamePattern
,
927 const OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
929 // this returns an empty resultset where the column-names are already set
930 // in special the metadata of the resultset already returns the right columns
931 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns
);
932 Reference
< XResultSet
> xResultSet
= pResultSet
;
933 pResultSet
->setRows( getColumnRows( tableNamePattern
, columnNamePattern
));
936 // -------------------------------------------------------------------------
937 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
938 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/,
939 const OUString
& tableNamePattern
, const Sequence
< OUString
>& types
) throw(SQLException
, RuntimeException
)
941 // this returns an empty resultset where the column-names are already set
942 // in special the metadata of the resultset already returns the right columns
943 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables
);
944 Reference
< XResultSet
> xResultSet
= pResultSet
;
946 // ODatabaseMetaDataResultSet::ORows aRows;
947 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
948 // pResultSet->setRows( aRows );
949 ODatabaseMetaDataResultSet::ORows _rRows
;
950 if ( !m_pDbMetaDataHelper
->getTables( m_pConnection
, tableNamePattern
, types
,_rRows
) ) {
951 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
953 pResultSet
->setRows( _rRows
);
957 // -------------------------------------------------------------------------
958 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
959 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& tableNamePattern
) throw(SQLException
, RuntimeException
)
961 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges
);
963 Reference
< XResultSet
> xRef
= pResult
;
965 ::std::vector
< OUString
> tables
;
966 ::std::vector
< OUString
> types
;
967 if ( !m_pDbMetaDataHelper
->getTableStrings( m_pConnection
, tables
, types
) )
968 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
970 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows
;
971 ::connectivity::ODatabaseMetaDataResultSet::ORow
aRow(8);
973 aRow
[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
974 aRow
[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
975 aRow
[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
976 aRow
[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
977 aRow
[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
978 aRow
[7] = new ::connectivity::ORowSetValueDecorator(OUString("NO"));
981 // Iterate over all tables
982 for(size_t j
= 0; j
< tables
.size(); j
++ ) {
983 if(match(tableNamePattern
, tables
[j
],'\0'))
986 aRow
[2] = new ORowSetValueDecorator( tables
[j
] );
988 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables
[j
] ));
990 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
991 aRows
.push_back(aRow
);
992 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
993 aRows
.push_back(aRow
);
994 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
995 aRows
.push_back(aRow
);
996 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
997 aRows
.push_back(aRow
);
998 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
999 aRows
.push_back(aRow
);
1000 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
1001 aRows
.push_back(aRow
);
1002 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1003 aRows
.push_back(aRow
);
1004 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1005 aRows
.push_back(aRow
);
1008 pResult
->setRows(aRows
);
1012 // -------------------------------------------------------------------------
1013 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getUDTs( const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& /*typeNamePattern*/, const Sequence
< sal_Int32
>& /*types*/ ) throw(SQLException
, RuntimeException
)
1017 // -----------------------------------------------------------------------------
1021 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */