1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *************************************************************************/
36 #include "SDatabaseMetaData.hxx"
37 #include <com/sun/star/sdbc/DataType.hpp>
38 #include <com/sun/star/sdbc/ResultSetType.hpp>
39 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
40 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
42 using namespace connectivity::skeleton
;
43 using namespace com::sun::star::uno
;
44 using namespace com::sun::star::lang
;
45 using namespace com::sun::star::beans
;
46 using namespace com::sun::star::sdbc
;
48 ODatabaseMetaData::ODatabaseMetaData(OConnection
* _pCon
)
49 : m_pConnection(_pCon
)
50 , m_bUseCatalog(sal_True
)
52 OSL_ENSURE(m_pConnection
,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
53 if(!m_pConnection
->isCatalogUsed())
55 osl_atomic_increment( &m_refCount
);
56 m_bUseCatalog
= !(usesLocalFiles() || usesLocalFilePerTable());
57 osl_atomic_decrement( &m_refCount
);
61 ODatabaseMetaData::~ODatabaseMetaData()
65 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getCatalogSeparator( )
69 { // do some special here for you database
75 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength( )
77 sal_Int32 nValue
= 0; // 0 means no limit
81 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize( )
83 sal_Int32 nValue
= 0; // 0 means no limit
87 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength( )
89 sal_Int32 nValue
= 0; // 0 means no limit
93 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength( )
95 sal_Int32 nValue
= 0; // 0 means no limit
99 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength( )
101 sal_Int32 nValue
= 0; // 0 means no limit
105 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex( )
107 sal_Int32 nValue
= 0; // 0 means no limit
111 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength( )
113 sal_Int32 nValue
= 0; // 0 means no limit
117 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections( )
119 sal_Int32 nValue
= 0; // 0 means no limit
123 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable( )
125 sal_Int32 nValue
= 0; // 0 means no limit
129 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength( )
131 sal_Int32 nValue
= 0; // 0 means no limit
135 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength( )
137 sal_Int32 nValue
= 0; // 0 means no limit
141 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTablesInSelect( )
143 sal_Int32 nValue
= 0; // 0 means no limit
148 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
153 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
158 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers( )
163 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseQuotedIdentifiers( )
168 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers( )
173 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
178 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers( )
183 sal_Bool SAL_CALL
ODatabaseMetaData::supportsAlterTableWithAddColumn( )
188 sal_Bool SAL_CALL
ODatabaseMetaData::supportsAlterTableWithDropColumn( )
193 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( )
195 sal_Int32 nValue
= 0; // 0 means no limit
199 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( )
204 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm( )
206 ::rtl::OUString aVal
;
213 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getIdentifierQuoteString( )
215 // normally this is "
216 ::rtl::OUString
aVal("\"");
220 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( )
222 ::rtl::OUString aVal
;
226 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( )
231 sal_Bool SAL_CALL
ODatabaseMetaData::isCatalogAtStart( )
233 sal_Bool bValue
= sal_False
;
240 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions( )
245 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit( )
250 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly( )
255 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
260 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete( )
265 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate( )
270 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback( )
275 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit( )
280 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit( )
285 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback( )
290 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level
)
295 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInDataManipulation( )
300 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( )
305 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( )
307 return sal_True
; // should be supported at least
310 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( )
315 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions( )
320 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInTableDefinitions( )
325 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInTableDefinitions( )
330 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions( )
335 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInDataManipulation( )
340 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins( )
345 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatements( )
347 sal_Int32 nValue
= 0; // 0 means no limit
351 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( )
353 sal_Int32 nValue
= 0; // 0 means no limit
357 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength( )
359 sal_Int32 nValue
= 0; // 0 means no limit
363 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions( )
368 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( )
373 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( )
378 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate( )
383 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable( )
388 sal_Bool SAL_CALL
ODatabaseMetaData::isReadOnly( )
393 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( )
398 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( )
403 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion( )
408 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( )
413 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing( )
418 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames( )
423 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert( sal_Int32 fromType
, sal_Int32 toType
)
428 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( )
433 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( )
438 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( )
443 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( )
448 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions( )
453 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( )
458 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( )
463 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( )
468 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( )
473 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( )
478 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers( )
483 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( )
488 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( )
493 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( )
498 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( )
503 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( )
508 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls( )
513 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
518 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls( )
523 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
528 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( )
533 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( )
538 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( )
543 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( )
548 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( )
553 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( )
558 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getURL( )
560 ::rtl::OUString
aValue("sdbc:skeleton:");
564 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getUserName( )
566 ::rtl::OUString aValue
;
570 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDriverName( )
572 ::rtl::OUString aValue
;
576 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDriverVersion()
578 ::rtl::OUString aValue
;
582 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( )
584 ::rtl::OUString aValue
;
588 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( )
590 ::rtl::OUString aValue
;
594 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( )
596 ::rtl::OUString aValue
;
600 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm( )
602 ::rtl::OUString aValue
;
606 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( )
611 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation( )
613 return TransactionIsolation::NONE
;
616 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( )
621 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( )
623 ::rtl::OUString aValue
;
627 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( )
629 ::rtl::OUString aValue
;
633 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( )
635 return ::rtl::OUString();
638 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( )
640 return ::rtl::OUString();
643 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( )
645 return ::rtl::OUString();
648 ::rtl::OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( )
650 return ::rtl::OUString();
653 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( )
658 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar( )
663 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar( )
668 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( )
673 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( )
678 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( )
680 sal_Int32 nValue
= 0; // 0 means no limit
684 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( )
686 sal_Int32 nValue
= 0; // 0 means no limit
690 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( )
692 sal_Int32 nValue
= 0; // 0 means no limit
696 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( )
698 sal_Int32 nValue
= 0; // 0 means no limit
702 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType( sal_Int32 setType
)
707 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType
, sal_Int32 concurrency
)
712 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType
)
717 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType
)
722 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType
)
727 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType
)
732 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType
)
737 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType
)
742 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32 setType
)
747 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32 setType
)
752 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32 setType
)
757 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates( )
762 Reference
< XConnection
> SAL_CALL
ODatabaseMetaData::getConnection( )
764 return (Reference
< XConnection
>)m_pConnection
;//new OConnection(m_aConnectionHandle);
767 // here follow all methods which return a resultset
768 // the first methods is an example implementation how to use this resultset
769 // of course you could implement it on your and you should do this because
770 // the general way is more memory expensive
772 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( )
777 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTypeInfo( )
782 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCatalogs( )
787 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getSchemas( )
792 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumnPrivileges(
793 const Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
,
794 const ::rtl::OUString
& columnNamePattern
)
799 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
800 const Any
& catalog
, const ::rtl::OUString
& schemaPattern
, const ::rtl::OUString
& tableNamePattern
,
801 const ::rtl::OUString
& columnNamePattern
)
806 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
807 const Any
& catalog
, const ::rtl::OUString
& schemaPattern
,
808 const ::rtl::OUString
& tableNamePattern
, const Sequence
< ::rtl::OUString
>& types
)
813 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedureColumns(
814 const Any
& catalog
, const ::rtl::OUString
& schemaPattern
,
815 const ::rtl::OUString
& procedureNamePattern
, const ::rtl::OUString
& columnNamePattern
)
820 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedures(
821 const Any
& catalog
, const ::rtl::OUString
& schemaPattern
,
822 const ::rtl::OUString
& procedureNamePattern
)
827 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getVersionColumns(
828 const Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
)
833 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getExportedKeys(
834 const Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
)
839 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getImportedKeys(
840 const Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
)
845 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getPrimaryKeys(
846 const Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
)
851 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getIndexInfo(
852 const Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
,
853 sal_Bool unique
, sal_Bool approximate
)
858 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getBestRowIdentifier(
859 const Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
, sal_Int32 scope
,
865 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
866 const Any
& catalog
, const ::rtl::OUString
& schemaPattern
, const ::rtl::OUString
& tableNamePattern
)
871 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCrossReference(
872 const Any
& primaryCatalog
, const ::rtl::OUString
& primarySchema
,
873 const ::rtl::OUString
& primaryTable
, const Any
& foreignCatalog
,
874 const ::rtl::OUString
& foreignSchema
, const ::rtl::OUString
& foreignTable
)
879 Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getUDTs( const Any
& catalog
, const ::rtl::OUString
& schemaPattern
, const ::rtl::OUString
& typeNamePattern
, const Sequence
< sal_Int32
>& types
)
881 OSL_FAIL("Not implemented yet!");
882 throw SQLException();
887 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */