1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "MDatabaseMetaData.hxx"
30 #include "FDatabaseMetaDataResultSet.hxx"
31 #include <com/sun/star/sdbc/DataType.hpp>
32 #include <com/sun/star/sdbc/ResultSetType.hpp>
33 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
34 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
35 #include <connectivity/dbexception.hxx>
36 #include <connectivity/FValue.hxx>
37 #include <com/sun/star/sdbc/ColumnValue.hpp>
38 #include <com/sun/star/sdbc/ColumnSearch.hpp>
39 #include "resource/common_res.hrc"
42 #if OSL_DEBUG_LEVEL > 0
43 # define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
44 #else /* OSL_DEBUG_LEVEL */
45 # define OUtoCStr( x ) ("dummy")
46 #endif /* OSL_DEBUG_LEVEL */
48 using namespace connectivity::mozab
;
49 using namespace connectivity
;
50 using namespace com::sun::star::uno
;
51 using namespace com::sun::star::lang
;
52 using namespace com::sun::star::beans
;
53 using namespace com::sun::star::sdbc
;
54 using namespace com::sun::star::sdbcx
;
57 namespace connectivity
61 static sal_Int32
const s_nCOLUMN_SIZE
= 256;
62 static sal_Int32
const s_nDECIMAL_DIGITS
= 0;
63 static sal_Int32
const s_nNULLABLE
= 1;
64 static sal_Int32
const s_nCHAR_OCTET_LENGTH
= 65535;
69 ODatabaseMetaData::ODatabaseMetaData(OConnection
* _pCon
)
70 : ::connectivity::ODatabaseMetaDataBase(_pCon
,_pCon
->getConnectionInfo())
73 OSL_ENSURE(m_pConnection
,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
74 m_pDbMetaDataHelper
= new MDatabaseMetaDataHelper();
76 // -------------------------------------------------------------------------
77 ODatabaseMetaData::~ODatabaseMetaData()
79 delete m_pDbMetaDataHelper
;
82 // -------------------------------------------------------------------------
83 ODatabaseMetaDataResultSet::ORows
& SAL_CALL
ODatabaseMetaData::getColumnRows(
84 const ::rtl::OUString
& tableNamePattern
,
85 const ::rtl::OUString
& columnNamePattern
) throw(SQLException
)
87 static ODatabaseMetaDataResultSet::ORows aRows
;
88 ODatabaseMetaDataResultSet::ORow
aRow(19);
91 ::osl::MutexGuard
aGuard( m_aMutex
);
93 ::std::vector
< ::rtl::OUString
> tables
;
94 ::std::vector
< ::rtl::OUString
> types
;
95 if ( !m_pDbMetaDataHelper
->getTableStrings( m_pConnection
, tables
, types
) ) {
96 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
99 // ****************************************************
100 // Some entries in a row never change, so set them now
101 // ****************************************************
104 aRow
[1] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
106 aRow
[2] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
108 aRow
[5] = new ORowSetValueDecorator(static_cast<sal_Int16
>(DataType::VARCHAR
));
109 // TYPE_NAME, not used
110 aRow
[6] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR")));
112 aRow
[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE
);
113 // BUFFER_LENGTH, not used
114 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
116 aRow
[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS
);
118 aRow
[10] = new ORowSetValueDecorator((sal_Int32
)10);
120 aRow
[11] = new ORowSetValueDecorator(s_nNULLABLE
);
122 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
123 // COULUMN_DEF, not used
124 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
125 // SQL_DATA_TYPE, not used
126 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
127 // SQL_DATETIME_SUB, not used
128 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
129 // CHAR_OCTET_LENGTH, refer to [5]
130 aRow
[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH
);
132 aRow
[18] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("YES")));
134 const OColumnAlias
& colNames
= m_pConnection
->getColumnAlias();
136 // Iterate over all tables
137 for(size_t j
= 0; j
< tables
.size(); j
++ ) {
138 if(match(tableNamePattern
, tables
[j
],'\0')) {
140 aRow
[3] = new ORowSetValueDecorator( tables
[j
] );
142 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables
[j
] ));
144 // Iterate over all collumns in the table.
145 for ( OColumnAlias::AliasMap::const_iterator compare
= colNames
.begin();
146 compare
!= colNames
.end();
150 if ( match( columnNamePattern
, compare
->first
, '\0' ) )
152 OSL_TRACE( "\t\t\tColumnName = %s;", OUtoCStr( compare
->first
) );
154 aRow
[4] = new ORowSetValueDecorator( compare
->first
);
156 aRow
[17] = new ORowSetValueDecorator( static_cast< sal_Int32
>( compare
->second
.columnPosition
) + 1 );
157 aRows
.push_back(aRow
);
164 // -------------------------------------------------------------------------
165 ::rtl::OUString
ODatabaseMetaData::impl_getCatalogSeparator_throw( )
167 return ::rtl::OUString();
169 // -------------------------------------------------------------------------
170 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
172 sal_Int32 nValue
= 65535; // 0 means no limit
175 // -------------------------------------------------------------------------
176 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
178 sal_Int32 nValue
= 0; // 0 means no limit
181 // -------------------------------------------------------------------------
182 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
184 sal_Int32 nValue
= 0; // 0 means no limit
187 // -------------------------------------------------------------------------
188 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
190 sal_Int32 nValue
= 254; // 0 means no limit
193 // -------------------------------------------------------------------------
194 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
196 sal_Int32 nValue
= 20; // 0 means no limit
199 // -------------------------------------------------------------------------
200 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
202 sal_Int32 nValue
= 0; // 0 means no limit
205 // -------------------------------------------------------------------------
206 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
208 sal_Int32 nValue
= 0; // 0 means no limit
211 // -------------------------------------------------------------------------
212 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
214 sal_Int32 nValue
= 0; // 0 means no limit
217 // -------------------------------------------------------------------------
218 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
220 sal_Int32 nValue
= 0; // 0 means no limit
223 // -------------------------------------------------------------------------
224 sal_Int32
ODatabaseMetaData::impl_getMaxStatements_throw( )
228 // -------------------------------------------------------------------------
229 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
231 sal_Int32 nValue
= 0; // 0 means no limit
234 // -------------------------------------------------------------------------
235 sal_Int32
ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
237 // We only support a single table
240 // -------------------------------------------------------------------------
241 // -------------------------------------------------------------------------
242 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
246 // -------------------------------------------------------------------------
247 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
251 // -------------------------------------------------------------------------
252 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
256 // -------------------------------------------------------------------------
257 sal_Bool
ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
261 // -------------------------------------------------------------------------
262 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
266 // -------------------------------------------------------------------------
267 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
271 // -------------------------------------------------------------------------
272 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
276 // -------------------------------------------------------------------------
277 sal_Bool
ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
281 // -------------------------------------------------------------------------
282 sal_Bool
ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
286 // -------------------------------------------------------------------------
287 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
289 sal_Int32 nValue
= 0; // 0 means no limit
292 // -------------------------------------------------------------------------
293 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
297 // -------------------------------------------------------------------------
298 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
300 ::rtl::OUString aVal
;
303 // -------------------------------------------------------------------------
304 ::rtl::OUString
ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
306 // normally this is "
307 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
309 // -------------------------------------------------------------------------
310 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
312 ::rtl::OUString aVal
;
315 // -------------------------------------------------------------------------
316 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
320 // -------------------------------------------------------------------------
321 sal_Bool
ODatabaseMetaData::impl_isCatalogAtStart_throw( )
325 // -------------------------------------------------------------------------
326 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
330 // -------------------------------------------------------------------------
331 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
335 // -------------------------------------------------------------------------
336 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
338 //We support create table
341 // -------------------------------------------------------------------------
342 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
346 // -------------------------------------------------------------------------
347 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
351 // -------------------------------------------------------------------------
352 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
356 // -------------------------------------------------------------------------
357 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
361 // -------------------------------------------------------------------------
362 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
366 // -------------------------------------------------------------------------
367 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
371 // -------------------------------------------------------------------------
372 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
376 // -------------------------------------------------------------------------
377 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
/*level*/ ) throw(SQLException
, RuntimeException
)
381 // -------------------------------------------------------------------------
382 sal_Bool
ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
386 // -------------------------------------------------------------------------
387 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
391 // -------------------------------------------------------------------------
392 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
394 return sal_True
; // should be supported at least
396 // -------------------------------------------------------------------------
397 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
401 // -------------------------------------------------------------------------
402 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
406 // -------------------------------------------------------------------------
407 sal_Bool
ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
411 // -------------------------------------------------------------------------
412 sal_Bool
ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
416 // -------------------------------------------------------------------------
417 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
421 // -------------------------------------------------------------------------
422 sal_Bool
ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
426 // -------------------------------------------------------------------------
427 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
431 // -------------------------------------------------------------------------
432 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
434 return 0;// 0 means no limit
436 // -------------------------------------------------------------------------
437 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
439 sal_Int32 nValue
= 0; // 0 means no limit
442 // -------------------------------------------------------------------------
443 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
445 sal_Int32 nValue
= 0; // 0 means no limit
448 // -------------------------------------------------------------------------
449 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
453 // -------------------------------------------------------------------------
454 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
458 // -------------------------------------------------------------------------
459 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
463 // -------------------------------------------------------------------------
464 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
468 // -------------------------------------------------------------------------
469 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
471 // We allow you to select from any table.
474 // -------------------------------------------------------------------------
475 sal_Bool SAL_CALL
ODatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
)
477 //we support insert/update/delete now
478 //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
479 //entry to the popup menu. We should avoid them.
482 // -------------------------------------------------------------------------
483 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
487 // -------------------------------------------------------------------------
488 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
492 // -------------------------------------------------------------------------
493 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
497 // -------------------------------------------------------------------------
498 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
502 // -------------------------------------------------------------------------
503 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
505 // Support added for this.
508 // -------------------------------------------------------------------------
509 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
513 // -------------------------------------------------------------------------
514 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ ) throw(SQLException
, RuntimeException
)
518 // -------------------------------------------------------------------------
519 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
523 // -------------------------------------------------------------------------
524 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
528 // -------------------------------------------------------------------------
529 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
533 // -------------------------------------------------------------------------
534 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
538 // -------------------------------------------------------------------------
539 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
543 // -------------------------------------------------------------------------
544 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
548 // -------------------------------------------------------------------------
549 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
553 // -------------------------------------------------------------------------
554 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
558 // -------------------------------------------------------------------------
559 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
563 // -------------------------------------------------------------------------
564 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
568 // -------------------------------------------------------------------------
569 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
573 // -------------------------------------------------------------------------
574 sal_Bool
ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
576 // Any case may be used
579 // -------------------------------------------------------------------------
580 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
584 // -------------------------------------------------------------------------
585 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
589 // -------------------------------------------------------------------------
590 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
594 // -------------------------------------------------------------------------
595 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
599 // -------------------------------------------------------------------------
600 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
604 // -------------------------------------------------------------------------
605 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
609 // -------------------------------------------------------------------------
610 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
614 // -------------------------------------------------------------------------
615 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
619 // -------------------------------------------------------------------------
620 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
624 // -------------------------------------------------------------------------
625 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
629 // -------------------------------------------------------------------------
630 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
634 // -------------------------------------------------------------------------
635 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
639 // -------------------------------------------------------------------------
640 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
644 // -------------------------------------------------------------------------
645 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
649 // -------------------------------------------------------------------------
650 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
652 ::osl::MutexGuard
aGuard( m_aMutex
);
654 return m_pConnection
->getURL();
656 // -------------------------------------------------------------------------
657 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
659 ::rtl::OUString aValue
;
662 // -------------------------------------------------------------------------
663 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
665 ::rtl::OUString aValue
;
668 // -------------------------------------------------------------------------
669 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
)
671 ::rtl::OUString aValue
= ::rtl::OUString::valueOf((sal_Int32
)1);
674 // -------------------------------------------------------------------------
675 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
677 ::rtl::OUString aValue
= ::rtl::OUString::valueOf((sal_Int32
)0);
680 // -------------------------------------------------------------------------
681 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
683 ::rtl::OUString aValue
;
686 // -------------------------------------------------------------------------
687 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
689 ::rtl::OUString aValue
;
692 // -------------------------------------------------------------------------
693 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
695 ::rtl::OUString aValue
;
698 // -------------------------------------------------------------------------
699 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
703 // -------------------------------------------------------------------------
704 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
706 return TransactionIsolation::NONE
;
708 // -------------------------------------------------------------------------
709 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
713 // -------------------------------------------------------------------------
714 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
716 ::rtl::OUString aValue
;
719 // -------------------------------------------------------------------------
720 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
722 ::rtl::OUString aValue
;
725 // -------------------------------------------------------------------------
726 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
728 return ::rtl::OUString();
730 // -------------------------------------------------------------------------
731 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
733 return ::rtl::OUString();
735 // -------------------------------------------------------------------------
736 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
738 return ::rtl::OUString();
740 // -------------------------------------------------------------------------
741 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
743 return ::rtl::OUString();
745 // -------------------------------------------------------------------------
746 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
750 // -------------------------------------------------------------------------
751 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
755 // -------------------------------------------------------------------------
756 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
760 // -------------------------------------------------------------------------
761 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
765 // -------------------------------------------------------------------------
766 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
770 // -------------------------------------------------------------------------
771 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
773 sal_Int32 nValue
= 0; // 0 means no limit
776 // -------------------------------------------------------------------------
777 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
779 sal_Int32 nValue
= 0; // 0 means no limit
782 // -------------------------------------------------------------------------
783 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
785 sal_Int32 nValue
= 0; // 0 means no limit
788 // -------------------------------------------------------------------------
789 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
791 sal_Int32 nValue
= 0; // 0 means no limit
794 // -------------------------------------------------------------------------
795 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
799 // -------------------------------------------------------------------------
800 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ ) throw(SQLException
, RuntimeException
)
804 // -------------------------------------------------------------------------
805 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
809 // -------------------------------------------------------------------------
810 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
814 // -------------------------------------------------------------------------
815 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
819 // -------------------------------------------------------------------------
820 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
824 // -------------------------------------------------------------------------
825 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
829 // -------------------------------------------------------------------------
830 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
834 // -------------------------------------------------------------------------
835 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
839 // -------------------------------------------------------------------------
840 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
844 // -------------------------------------------------------------------------
845 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
849 // -------------------------------------------------------------------------
850 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
854 // -------------------------------------------------------------------------
855 // here follow all methods which return a resultset
856 // the first methods is an example implementation how to use this resultset
857 // of course you could implement it on your and you should do this because
858 // the general way is more memory expensive
859 // -------------------------------------------------------------------------
860 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
862 // there exists no possibility to get table types so we have to check
863 static ::rtl::OUString sTableTypes
[] =
865 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")),
866 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW"))
867 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
869 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEM TABLE")),
870 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("GLOBAL TEMPORARY")),
871 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LOCAL TEMPORARY")),
872 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ALIAS")),
873 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYNONYM"))
875 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
876 Reference
< XResultSet
> xRef
= pResult
;
878 // here we fill the rows which should be visible when ask for data from the resultset returned here
879 const sal_Int32 nSize
= sizeof(sTableTypes
) / sizeof(::rtl::OUString
);
880 ODatabaseMetaDataResultSet::ORows aRows
;
881 for(sal_Int32 i
=0;i
< nSize
;++i
)
883 ODatabaseMetaDataResultSet::ORow aRow
;
884 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
885 aRow
.push_back(new ORowSetValueDecorator(sTableTypes
[i
]));
887 aRows
.push_back(aRow
);
889 // here we set the rows at the resultset
890 pResult
->setRows(aRows
);
893 // -------------------------------------------------------------------------
894 Reference
< XResultSet
> ODatabaseMetaData::impl_getTypeInfo_throw( )
896 // this returns an empty resultset where the column-names are already set
897 // in special the metadata of the resultset already returns the right columns
898 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
899 Reference
< XResultSet
> xResultSet
= pResultSet
;
900 static ODatabaseMetaDataResultSet::ORows aRows
;
904 ODatabaseMetaDataResultSet::ORow aRow
;
906 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
907 aRow
.push_back(new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR"))));
908 aRow
.push_back(new ORowSetValueDecorator(DataType::VARCHAR
));
909 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)s_nCHAR_OCTET_LENGTH
));
910 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
911 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
912 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
913 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
914 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
915 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
916 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)ColumnSearch::CHAR
));
917 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
918 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
919 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
920 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
921 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
922 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
923 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
924 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
925 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)10));
927 aRows
.push_back(aRow
);
930 pResultSet
->setRows(aRows
);
933 // -------------------------------------------------------------------------
934 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
935 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/, const ::rtl::OUString
& tableNamePattern
,
936 const ::rtl::OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
938 // this returns an empty resultset where the column-names are already set
939 // in special the metadata of the resultset already returns the right columns
940 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns
);
941 Reference
< XResultSet
> xResultSet
= pResultSet
;
942 pResultSet
->setRows( getColumnRows( tableNamePattern
, columnNamePattern
));
945 // -------------------------------------------------------------------------
946 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
947 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/,
948 const ::rtl::OUString
& tableNamePattern
, const Sequence
< ::rtl::OUString
>& types
) throw(SQLException
, RuntimeException
)
950 // this returns an empty resultset where the column-names are already set
951 // in special the metadata of the resultset already returns the right columns
952 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables
);
953 Reference
< XResultSet
> xResultSet
= pResultSet
;
955 // ODatabaseMetaDataResultSet::ORows aRows;
956 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
957 // pResultSet->setRows( aRows );
958 ODatabaseMetaDataResultSet::ORows _rRows
;
959 if ( !m_pDbMetaDataHelper
->getTables( m_pConnection
, tableNamePattern
, types
,_rRows
) ) {
960 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
962 pResultSet
->setRows( _rRows
);
966 // -------------------------------------------------------------------------
967 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
968 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/, const ::rtl::OUString
& tableNamePattern
) throw(SQLException
, RuntimeException
)
970 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges
);
971 Reference
< XResultSet
> xRef
= NULL
;
975 ::std::vector
< ::rtl::OUString
> tables
;
976 ::std::vector
< ::rtl::OUString
> types
;
977 if ( !m_pDbMetaDataHelper
->getTableStrings( m_pConnection
, tables
, types
) )
978 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
980 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows
;
981 ::connectivity::ODatabaseMetaDataResultSet::ORow
aRow(8);
983 aRow
[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
984 aRow
[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
985 aRow
[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
986 aRow
[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
987 aRow
[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
988 aRow
[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NO")));
991 // Iterate over all tables
992 for(size_t j
= 0; j
< tables
.size(); j
++ ) {
993 if(match(tableNamePattern
, tables
[j
],'\0'))
996 aRow
[2] = new ORowSetValueDecorator( tables
[j
] );
998 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables
[j
] ));
1000 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
1001 aRows
.push_back(aRow
);
1002 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
1003 aRows
.push_back(aRow
);
1004 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
1005 aRows
.push_back(aRow
);
1006 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
1007 aRows
.push_back(aRow
);
1008 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
1009 aRows
.push_back(aRow
);
1010 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
1011 aRows
.push_back(aRow
);
1012 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1013 aRows
.push_back(aRow
);
1014 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1015 aRows
.push_back(aRow
);
1018 pResult
->setRows(aRows
);
1022 // -------------------------------------------------------------------------
1023 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getUDTs( const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/, const ::rtl::OUString
& /*typeNamePattern*/, const Sequence
< sal_Int32
>& /*types*/ ) throw(SQLException
, RuntimeException
)
1027 // -----------------------------------------------------------------------------
1031 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */