1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MDatabaseMetaData.cxx,v $
10 * $Revision: 1.16.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "MDatabaseMetaData.hxx"
34 #include "FDatabaseMetaDataResultSet.hxx"
35 #include <com/sun/star/sdbc/DataType.hpp>
36 #include <com/sun/star/sdbc/ResultSetType.hpp>
37 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
38 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
39 #include <connectivity/dbexception.hxx>
40 #include <connectivity/FValue.hxx>
41 #include <com/sun/star/sdbc/ColumnValue.hpp>
42 #include <com/sun/star/sdbc/ColumnSearch.hpp>
43 #include "resource/common_res.hrc"
46 #if OSL_DEBUG_LEVEL > 0
47 # define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
48 #else /* OSL_DEBUG_LEVEL */
49 # define OUtoCStr( x ) ("dummy")
50 #endif /* OSL_DEBUG_LEVEL */
52 using namespace connectivity::mozab
;
53 using namespace connectivity
;
54 using namespace com::sun::star::uno
;
55 using namespace com::sun::star::lang
;
56 using namespace com::sun::star::beans
;
57 using namespace com::sun::star::sdbc
;
58 using namespace com::sun::star::sdbcx
;
61 namespace connectivity
65 static sal_Int32
const s_nCOLUMN_SIZE
= 256;
66 static sal_Int32
const s_nDECIMAL_DIGITS
= 0;
67 static sal_Int32
const s_nNULLABLE
= 1;
68 static sal_Int32
const s_nCHAR_OCTET_LENGTH
= 65535;
73 ODatabaseMetaData::ODatabaseMetaData(OConnection
* _pCon
)
74 : ::connectivity::ODatabaseMetaDataBase(_pCon
,_pCon
->getConnectionInfo())
77 OSL_ENSURE(m_pConnection
,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
78 m_pDbMetaDataHelper
= new MDatabaseMetaDataHelper();
80 // -------------------------------------------------------------------------
81 ODatabaseMetaData::~ODatabaseMetaData()
83 delete m_pDbMetaDataHelper
;
86 // -------------------------------------------------------------------------
87 ODatabaseMetaDataResultSet::ORows
& SAL_CALL
ODatabaseMetaData::getColumnRows(
88 const ::rtl::OUString
& tableNamePattern
,
89 const ::rtl::OUString
& columnNamePattern
) throw(SQLException
)
91 static ODatabaseMetaDataResultSet::ORows aRows
;
92 ODatabaseMetaDataResultSet::ORow
aRow(19);
95 ::osl::MutexGuard
aGuard( m_aMutex
);
97 ::std::vector
< ::rtl::OUString
> tables
;
98 ::std::vector
< ::rtl::OUString
> types
;
99 if ( !m_pDbMetaDataHelper
->getTableStrings( m_pConnection
, tables
, types
) ) {
100 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
103 // ****************************************************
104 // Some entries in a row never change, so set them now
105 // ****************************************************
108 aRow
[1] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
110 aRow
[2] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
112 aRow
[5] = new ORowSetValueDecorator(static_cast<sal_Int16
>(DataType::VARCHAR
));
113 // TYPE_NAME, not used
114 aRow
[6] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR")));
116 aRow
[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE
);
117 // BUFFER_LENGTH, not used
118 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
120 aRow
[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS
);
122 aRow
[10] = new ORowSetValueDecorator((sal_Int32
)10);
124 aRow
[11] = new ORowSetValueDecorator(s_nNULLABLE
);
126 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
127 // COULUMN_DEF, not used
128 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
129 // SQL_DATA_TYPE, not used
130 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
131 // SQL_DATETIME_SUB, not used
132 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
133 // CHAR_OCTET_LENGTH, refer to [5]
134 aRow
[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH
);
136 aRow
[18] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("YES")));
138 const OColumnAlias
& colNames
= m_pConnection
->getColumnAlias();
140 // Iterate over all tables
141 for(size_t j
= 0; j
< tables
.size(); j
++ ) {
142 if(match(tableNamePattern
, tables
[j
],'\0')) {
144 aRow
[3] = new ORowSetValueDecorator( tables
[j
] );
146 OSL_TRACE( "\t\tTableName = %s;\n",OUtoCStr( tables
[j
] ));
148 // Iterate over all collumns in the table.
149 for ( OColumnAlias::AliasMap::const_iterator compare
= colNames
.begin();
150 compare
!= colNames
.end();
154 if ( match( columnNamePattern
, compare
->first
, '\0' ) )
156 OSL_TRACE( "\t\t\tColumnName = %s;\n", OUtoCStr( compare
->first
) );
158 aRow
[4] = new ORowSetValueDecorator( compare
->first
);
160 aRow
[17] = new ORowSetValueDecorator( static_cast< sal_Int32
>( compare
->second
.columnPosition
) + 1 );
161 aRows
.push_back(aRow
);
168 // -------------------------------------------------------------------------
169 ::rtl::OUString
ODatabaseMetaData::impl_getCatalogSeparator_throw( )
171 return ::rtl::OUString();
173 // -------------------------------------------------------------------------
174 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
176 sal_Int32 nValue
= 65535; // 0 means no limit
179 // -------------------------------------------------------------------------
180 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
182 sal_Int32 nValue
= 0; // 0 means no limit
185 // -------------------------------------------------------------------------
186 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
188 sal_Int32 nValue
= 0; // 0 means no limit
191 // -------------------------------------------------------------------------
192 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
194 sal_Int32 nValue
= 254; // 0 means no limit
197 // -------------------------------------------------------------------------
198 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
200 sal_Int32 nValue
= 20; // 0 means no limit
203 // -------------------------------------------------------------------------
204 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
206 sal_Int32 nValue
= 0; // 0 means no limit
209 // -------------------------------------------------------------------------
210 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
212 sal_Int32 nValue
= 0; // 0 means no limit
215 // -------------------------------------------------------------------------
216 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
218 sal_Int32 nValue
= 0; // 0 means no limit
221 // -------------------------------------------------------------------------
222 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
224 sal_Int32 nValue
= 0; // 0 means no limit
227 // -------------------------------------------------------------------------
228 sal_Int32
ODatabaseMetaData::impl_getMaxStatements_throw( )
232 // -------------------------------------------------------------------------
233 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
235 sal_Int32 nValue
= 0; // 0 means no limit
238 // -------------------------------------------------------------------------
239 sal_Int32
ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
241 // We only support a single table
244 // -------------------------------------------------------------------------
245 // -------------------------------------------------------------------------
246 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
250 // -------------------------------------------------------------------------
251 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
255 // -------------------------------------------------------------------------
256 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
260 // -------------------------------------------------------------------------
261 sal_Bool
ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
265 // -------------------------------------------------------------------------
266 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
270 // -------------------------------------------------------------------------
271 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
275 // -------------------------------------------------------------------------
276 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
280 // -------------------------------------------------------------------------
281 sal_Bool
ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
285 // -------------------------------------------------------------------------
286 sal_Bool
ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
290 // -------------------------------------------------------------------------
291 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
293 sal_Int32 nValue
= 0; // 0 means no limit
296 // -------------------------------------------------------------------------
297 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
301 // -------------------------------------------------------------------------
302 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
304 ::rtl::OUString aVal
;
307 // -------------------------------------------------------------------------
308 ::rtl::OUString
ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
310 // normally this is "
311 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
313 // -------------------------------------------------------------------------
314 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
316 ::rtl::OUString aVal
;
319 // -------------------------------------------------------------------------
320 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
324 // -------------------------------------------------------------------------
325 sal_Bool
ODatabaseMetaData::impl_isCatalogAtStart_throw( )
329 // -------------------------------------------------------------------------
330 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
334 // -------------------------------------------------------------------------
335 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
339 // -------------------------------------------------------------------------
340 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
342 //We support create table
345 // -------------------------------------------------------------------------
346 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
350 // -------------------------------------------------------------------------
351 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
355 // -------------------------------------------------------------------------
356 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
360 // -------------------------------------------------------------------------
361 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
365 // -------------------------------------------------------------------------
366 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
370 // -------------------------------------------------------------------------
371 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
375 // -------------------------------------------------------------------------
376 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
380 // -------------------------------------------------------------------------
381 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
/*level*/ ) throw(SQLException
, RuntimeException
)
385 // -------------------------------------------------------------------------
386 sal_Bool
ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
390 // -------------------------------------------------------------------------
391 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
395 // -------------------------------------------------------------------------
396 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
398 return sal_True
; // should be supported at least
400 // -------------------------------------------------------------------------
401 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
405 // -------------------------------------------------------------------------
406 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
410 // -------------------------------------------------------------------------
411 sal_Bool
ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
415 // -------------------------------------------------------------------------
416 sal_Bool
ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
420 // -------------------------------------------------------------------------
421 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
425 // -------------------------------------------------------------------------
426 sal_Bool
ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
430 // -------------------------------------------------------------------------
431 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
435 // -------------------------------------------------------------------------
436 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
438 return 0;// 0 means no limit
440 // -------------------------------------------------------------------------
441 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
443 sal_Int32 nValue
= 0; // 0 means no limit
446 // -------------------------------------------------------------------------
447 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
449 sal_Int32 nValue
= 0; // 0 means no limit
452 // -------------------------------------------------------------------------
453 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
457 // -------------------------------------------------------------------------
458 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
462 // -------------------------------------------------------------------------
463 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
467 // -------------------------------------------------------------------------
468 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
472 // -------------------------------------------------------------------------
473 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
475 // We allow you to select from any table.
478 // -------------------------------------------------------------------------
479 sal_Bool SAL_CALL
ODatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
)
481 //we support insert/update/delete now
482 //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
483 //entry to the popup menu. We should avoid them.
486 // -------------------------------------------------------------------------
487 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
491 // -------------------------------------------------------------------------
492 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
496 // -------------------------------------------------------------------------
497 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
501 // -------------------------------------------------------------------------
502 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
506 // -------------------------------------------------------------------------
507 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
509 // Support added for this.
512 // -------------------------------------------------------------------------
513 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
517 // -------------------------------------------------------------------------
518 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ ) throw(SQLException
, RuntimeException
)
522 // -------------------------------------------------------------------------
523 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
527 // -------------------------------------------------------------------------
528 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
532 // -------------------------------------------------------------------------
533 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
537 // -------------------------------------------------------------------------
538 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
542 // -------------------------------------------------------------------------
543 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
547 // -------------------------------------------------------------------------
548 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
552 // -------------------------------------------------------------------------
553 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
557 // -------------------------------------------------------------------------
558 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
562 // -------------------------------------------------------------------------
563 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
567 // -------------------------------------------------------------------------
568 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
572 // -------------------------------------------------------------------------
573 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
577 // -------------------------------------------------------------------------
578 sal_Bool
ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
580 // Any case may be used
583 // -------------------------------------------------------------------------
584 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
588 // -------------------------------------------------------------------------
589 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
593 // -------------------------------------------------------------------------
594 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
598 // -------------------------------------------------------------------------
599 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
603 // -------------------------------------------------------------------------
604 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
608 // -------------------------------------------------------------------------
609 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
613 // -------------------------------------------------------------------------
614 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
618 // -------------------------------------------------------------------------
619 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
623 // -------------------------------------------------------------------------
624 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
628 // -------------------------------------------------------------------------
629 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
633 // -------------------------------------------------------------------------
634 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
638 // -------------------------------------------------------------------------
639 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
643 // -------------------------------------------------------------------------
644 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
648 // -------------------------------------------------------------------------
649 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
653 // -------------------------------------------------------------------------
654 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
656 ::osl::MutexGuard
aGuard( m_aMutex
);
658 return m_pConnection
->getURL();
660 // -------------------------------------------------------------------------
661 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
663 ::rtl::OUString aValue
;
666 // -------------------------------------------------------------------------
667 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
669 ::rtl::OUString aValue
;
672 // -------------------------------------------------------------------------
673 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
)
675 ::rtl::OUString aValue
= ::rtl::OUString::valueOf((sal_Int32
)1);
678 // -------------------------------------------------------------------------
679 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
681 ::rtl::OUString aValue
= ::rtl::OUString::valueOf((sal_Int32
)0);
684 // -------------------------------------------------------------------------
685 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
687 ::rtl::OUString aValue
;
690 // -------------------------------------------------------------------------
691 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
693 ::rtl::OUString aValue
;
696 // -------------------------------------------------------------------------
697 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
699 ::rtl::OUString aValue
;
702 // -------------------------------------------------------------------------
703 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
707 // -------------------------------------------------------------------------
708 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
710 return TransactionIsolation::NONE
;
712 // -------------------------------------------------------------------------
713 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
717 // -------------------------------------------------------------------------
718 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
720 ::rtl::OUString aValue
;
723 // -------------------------------------------------------------------------
724 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
726 ::rtl::OUString aValue
;
729 // -------------------------------------------------------------------------
730 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
732 return ::rtl::OUString();
734 // -------------------------------------------------------------------------
735 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
737 return ::rtl::OUString();
739 // -------------------------------------------------------------------------
740 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
742 return ::rtl::OUString();
744 // -------------------------------------------------------------------------
745 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
747 return ::rtl::OUString();
749 // -------------------------------------------------------------------------
750 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
754 // -------------------------------------------------------------------------
755 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
759 // -------------------------------------------------------------------------
760 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
764 // -------------------------------------------------------------------------
765 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
769 // -------------------------------------------------------------------------
770 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
774 // -------------------------------------------------------------------------
775 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
777 sal_Int32 nValue
= 0; // 0 means no limit
780 // -------------------------------------------------------------------------
781 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
783 sal_Int32 nValue
= 0; // 0 means no limit
786 // -------------------------------------------------------------------------
787 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
789 sal_Int32 nValue
= 0; // 0 means no limit
792 // -------------------------------------------------------------------------
793 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
795 sal_Int32 nValue
= 0; // 0 means no limit
798 // -------------------------------------------------------------------------
799 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
803 // -------------------------------------------------------------------------
804 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ ) throw(SQLException
, RuntimeException
)
808 // -------------------------------------------------------------------------
809 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
813 // -------------------------------------------------------------------------
814 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
818 // -------------------------------------------------------------------------
819 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
823 // -------------------------------------------------------------------------
824 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
828 // -------------------------------------------------------------------------
829 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
833 // -------------------------------------------------------------------------
834 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
838 // -------------------------------------------------------------------------
839 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
843 // -------------------------------------------------------------------------
844 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
848 // -------------------------------------------------------------------------
849 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
853 // -------------------------------------------------------------------------
854 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
858 // -------------------------------------------------------------------------
859 // here follow all methods which return a resultset
860 // the first methods is an example implementation how to use this resultset
861 // of course you could implement it on your and you should do this because
862 // the general way is more memory expensive
863 // -------------------------------------------------------------------------
864 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
866 // there exists no possibility to get table types so we have to check
867 static ::rtl::OUString sTableTypes
[] =
869 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")),
870 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW"))
871 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
873 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEM TABLE")),
874 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("GLOBAL TEMPORARY")),
875 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LOCAL TEMPORARY")),
876 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ALIAS")),
877 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYNONYM"))
879 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
880 Reference
< XResultSet
> xRef
= pResult
;
882 // here we fill the rows which should be visible when ask for data from the resultset returned here
883 const sal_Int32 nSize
= sizeof(sTableTypes
) / sizeof(::rtl::OUString
);
884 ODatabaseMetaDataResultSet::ORows aRows
;
885 for(sal_Int32 i
=0;i
< nSize
;++i
)
887 ODatabaseMetaDataResultSet::ORow aRow
;
888 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
889 aRow
.push_back(new ORowSetValueDecorator(sTableTypes
[i
]));
891 aRows
.push_back(aRow
);
893 // here we set the rows at the resultset
894 pResult
->setRows(aRows
);
897 // -------------------------------------------------------------------------
898 Reference
< XResultSet
> ODatabaseMetaData::impl_getTypeInfo_throw( )
900 // this returns an empty resultset where the column-names are already set
901 // in special the metadata of the resultset already returns the right columns
902 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
903 Reference
< XResultSet
> xResultSet
= pResultSet
;
904 static ODatabaseMetaDataResultSet::ORows aRows
;
908 ODatabaseMetaDataResultSet::ORow aRow
;
910 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
911 aRow
.push_back(new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR"))));
912 aRow
.push_back(new ORowSetValueDecorator(DataType::VARCHAR
));
913 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)s_nCHAR_OCTET_LENGTH
));
914 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
915 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
916 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
917 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
918 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
919 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
920 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)ColumnSearch::CHAR
));
921 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
922 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
923 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
924 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
925 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
926 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
927 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
928 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
929 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)10));
931 aRows
.push_back(aRow
);
934 pResultSet
->setRows(aRows
);
937 // -------------------------------------------------------------------------
938 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
939 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/, const ::rtl::OUString
& tableNamePattern
,
940 const ::rtl::OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
942 // this returns an empty resultset where the column-names are already set
943 // in special the metadata of the resultset already returns the right columns
944 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns
);
945 Reference
< XResultSet
> xResultSet
= pResultSet
;
946 pResultSet
->setRows( getColumnRows( tableNamePattern
, columnNamePattern
));
949 // -------------------------------------------------------------------------
950 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
951 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/,
952 const ::rtl::OUString
& tableNamePattern
, const Sequence
< ::rtl::OUString
>& types
) throw(SQLException
, RuntimeException
)
954 // this returns an empty resultset where the column-names are already set
955 // in special the metadata of the resultset already returns the right columns
956 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables
);
957 Reference
< XResultSet
> xResultSet
= pResultSet
;
959 // ODatabaseMetaDataResultSet::ORows aRows;
960 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
961 // pResultSet->setRows( aRows );
962 ODatabaseMetaDataResultSet::ORows _rRows
;
963 if ( !m_pDbMetaDataHelper
->getTables( m_pConnection
, tableNamePattern
, types
,_rRows
) ) {
964 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
966 pResultSet
->setRows( _rRows
);
970 // -------------------------------------------------------------------------
971 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
972 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/, const ::rtl::OUString
& tableNamePattern
) throw(SQLException
, RuntimeException
)
974 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges
);
975 Reference
< XResultSet
> xRef
= NULL
;
979 ::std::vector
< ::rtl::OUString
> tables
;
980 ::std::vector
< ::rtl::OUString
> types
;
981 if ( !m_pDbMetaDataHelper
->getTableStrings( m_pConnection
, tables
, types
) )
982 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper
->getError(), *this );
984 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows
;
985 ::connectivity::ODatabaseMetaDataResultSet::ORow
aRow(8);
987 aRow
[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
988 aRow
[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
989 aRow
[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
990 aRow
[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
991 aRow
[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
992 aRow
[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NO")));
995 // Iterate over all tables
996 for(size_t j
= 0; j
< tables
.size(); j
++ ) {
997 if(match(tableNamePattern
, tables
[j
],'\0'))
1000 aRow
[2] = new ORowSetValueDecorator( tables
[j
] );
1002 OSL_TRACE( "\t\tTableName = %s;\n",OUtoCStr( tables
[j
] ));
1004 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
1005 aRows
.push_back(aRow
);
1006 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
1007 aRows
.push_back(aRow
);
1008 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
1009 aRows
.push_back(aRow
);
1010 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
1011 aRows
.push_back(aRow
);
1012 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
1013 aRows
.push_back(aRow
);
1014 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
1015 aRows
.push_back(aRow
);
1016 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1017 aRows
.push_back(aRow
);
1018 aRow
[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1019 aRows
.push_back(aRow
);
1022 pResult
->setRows(aRows
);
1026 // -------------------------------------------------------------------------
1027 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
)
1031 // -----------------------------------------------------------------------------