1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "MacabDatabaseMetaData.hxx"
22 #include "MacabAddressBook.hxx"
23 #include "MacabHeader.hxx"
24 #include "MacabGroup.hxx"
25 #include "macabutilities.hxx"
27 #include "MacabDriver.hxx"
28 #include "FDatabaseMetaDataResultSet.hxx"
29 #include "OTypeInfo.hxx"
30 #include <com/sun/star/sdbc/ColumnValue.hpp>
31 #include <com/sun/star/sdbc/ResultSetType.hpp>
32 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
36 using namespace connectivity::macab
;
37 using namespace com::sun::star::uno
;
38 using namespace com::sun::star::lang
;
39 using namespace com::sun::star::beans
;
40 using namespace com::sun::star::sdbc
;
42 MacabDatabaseMetaData::MacabDatabaseMetaData(MacabConnection
* _pCon
)
43 : m_xConnection(_pCon
),
44 m_bUseCatalog(sal_True
)
46 OSL_ENSURE(_pCon
,"MacabDatabaseMetaData::MacabDatabaseMetaData: No connection set!");
48 osl_atomic_increment( &m_refCount
);
49 m_bUseCatalog
= !(usesLocalFiles() || usesLocalFilePerTable());
50 osl_atomic_decrement( &m_refCount
);
53 MacabDatabaseMetaData::~MacabDatabaseMetaData()
57 OUString SAL_CALL
MacabDatabaseMetaData::getCatalogSeparator( ) throw(SQLException
, RuntimeException
)
61 { // do some special here for you database
67 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
69 sal_Int32 nValue
= 0; // 0 means no limit
73 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
75 sal_Int32 nValue
= 0; // 0 means no limit
79 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
81 sal_Int32 nValue
= 0; // 0 means no limit
85 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
87 sal_Int32 nValue
= 0; // 0 means no limit
91 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
93 sal_Int32 nValue
= 0; // 0 means no limit
97 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
99 sal_Int32 nValue
= 0; // 0 means no limit
103 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
105 sal_Int32 nValue
= 0; // 0 means no limit
109 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
111 sal_Int32 nValue
= 0; // 0 means no limit
115 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
117 sal_Int32 nValue
= 0; // 0 means no limit
121 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
123 sal_Int32 nValue
= 0; // 0 means no limit
127 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
129 sal_Int32 nValue
= 0; // 0 means no limit
133 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException
, RuntimeException
)
135 // MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement,
136 // currently, the resultset/statement implementations can cope with one table only
137 sal_Int32 nValue
= 1;
141 sal_Bool SAL_CALL
MacabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
146 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
151 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
156 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
161 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
166 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
171 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
176 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException
, RuntimeException
)
181 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException
, RuntimeException
)
186 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
188 sal_Int32 nValue
= 0; // 0 means no limit
192 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
197 OUString SAL_CALL
MacabDatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
206 OUString SAL_CALL
MacabDatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException
, RuntimeException
)
208 // normally this is "
213 OUString SAL_CALL
MacabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
219 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
224 sal_Bool SAL_CALL
MacabDatabaseMetaData::isCatalogAtStart( ) throw(SQLException
, RuntimeException
)
226 sal_Bool bValue
= sal_False
;
233 sal_Bool SAL_CALL
MacabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
238 sal_Bool SAL_CALL
MacabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
243 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
248 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
253 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
258 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
263 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
268 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
273 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
278 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
283 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
) throw(SQLException
, RuntimeException
)
288 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException
, RuntimeException
)
293 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
298 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
300 return sal_True
; // should be supported at least
303 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
308 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
313 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException
, RuntimeException
)
318 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException
, RuntimeException
)
323 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
328 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException
, RuntimeException
)
333 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
338 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxStatements( ) throw(SQLException
, RuntimeException
)
340 sal_Int32 nValue
= 0; // 0 means no limit
344 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
346 sal_Int32 nValue
= 0; // 0 means no limit
350 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
352 sal_Int32 nValue
= 0; // 0 means no limit
356 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
361 sal_Bool SAL_CALL
MacabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
366 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
371 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
376 sal_Bool SAL_CALL
MacabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
381 sal_Bool SAL_CALL
MacabDatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
)
383 // for the moment, we have read-only addresses, but this might change in the future
387 sal_Bool SAL_CALL
MacabDatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
392 sal_Bool SAL_CALL
MacabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
397 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
402 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
407 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
412 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
417 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsConvert( sal_Int32
, sal_Int32
) throw(SQLException
, RuntimeException
)
422 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
427 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
432 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
437 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
442 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
447 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
452 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
457 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
462 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
467 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
472 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
477 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
482 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
487 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
492 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
497 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
502 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
507 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
512 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
517 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
522 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
527 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
532 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
537 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
542 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
547 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
552 OUString SAL_CALL
MacabDatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
554 // if someday we support more than the default address book,
555 // this method should return the URL which was used to create it
556 OUString
aValue( "sdbc:address:macab:" );
560 OUString SAL_CALL
MacabDatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
566 OUString SAL_CALL
MacabDatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
568 OUString
aValue( "macab" );
572 OUString SAL_CALL
MacabDatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
)
574 OUString
aValue(MACAB_DRIVER_VERSION
);
578 OUString SAL_CALL
MacabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
584 OUString SAL_CALL
MacabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
590 OUString SAL_CALL
MacabDatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
596 OUString SAL_CALL
MacabDatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
602 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
604 return MACAB_DRIVER_VERSION_MAJOR
;
607 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
609 return TransactionIsolation::NONE
;
612 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
614 return MACAB_DRIVER_VERSION_MINOR
;
617 OUString SAL_CALL
MacabDatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
623 OUString SAL_CALL
MacabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
629 OUString SAL_CALL
MacabDatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
634 OUString SAL_CALL
MacabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
639 OUString SAL_CALL
MacabDatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
644 OUString SAL_CALL
MacabDatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
649 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
654 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
659 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
664 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
669 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
674 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
676 sal_Int32 nValue
= 0; // 0 means no limit
680 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
682 sal_Int32 nValue
= 0; // 0 means no limit
686 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
688 sal_Int32 nValue
= 0; // 0 means no limit
692 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
694 sal_Int32 nValue
= 0; // 0 means no limit
698 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsResultSetType( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
702 case ResultSetType::FORWARD_ONLY
:
703 case ResultSetType::SCROLL_INSENSITIVE
:
709 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType
, sal_Int32
) throw(SQLException
, RuntimeException
)
713 case ResultSetType::FORWARD_ONLY
:
714 case ResultSetType::SCROLL_INSENSITIVE
:
720 sal_Bool SAL_CALL
MacabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
725 sal_Bool SAL_CALL
MacabDatabaseMetaData::ownDeletesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
730 sal_Bool SAL_CALL
MacabDatabaseMetaData::ownInsertsAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
735 sal_Bool SAL_CALL
MacabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
740 sal_Bool SAL_CALL
MacabDatabaseMetaData::othersDeletesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
745 sal_Bool SAL_CALL
MacabDatabaseMetaData::othersInsertsAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
750 sal_Bool SAL_CALL
MacabDatabaseMetaData::updatesAreDetected( sal_Int32
) throw(SQLException
, RuntimeException
)
755 sal_Bool SAL_CALL
MacabDatabaseMetaData::deletesAreDetected( sal_Int32
) throw(SQLException
, RuntimeException
)
760 sal_Bool SAL_CALL
MacabDatabaseMetaData::insertsAreDetected( sal_Int32
) throw(SQLException
, RuntimeException
)
765 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
770 Reference
< XConnection
> SAL_CALL
MacabDatabaseMetaData::getConnection( ) throw(SQLException
, RuntimeException
)
772 return (Reference
< XConnection
>) m_xConnection
.get();
775 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
777 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
778 Reference
< XResultSet
> xRef
= pResult
;
780 static ODatabaseMetaDataResultSet::ORows aRows
;
781 static const OUString
aTable("TABLE");
785 ODatabaseMetaDataResultSet::ORow
aRow(2);
786 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
787 aRow
[1] = new ORowSetValueDecorator(aTable
);
788 aRows
.push_back(aRow
);
790 pResult
->setRows(aRows
);
794 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTypeInfo( ) throw(SQLException
, RuntimeException
)
796 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
797 Reference
< XResultSet
> xRef
= pResult
;
799 static ODatabaseMetaDataResultSet::ORows aRows
;
802 ODatabaseMetaDataResultSet::ORow
aRow(19);
804 // We support four types: char, timestamp, integer, float
805 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
806 aRow
[1] = new ORowSetValueDecorator(OUString("CHAR"));
807 aRow
[2] = new ORowSetValueDecorator(DataType::CHAR
);
808 aRow
[3] = new ORowSetValueDecorator((sal_Int32
) 254);
809 aRow
[4] = ODatabaseMetaDataResultSet::getQuoteValue();
810 aRow
[5] = ODatabaseMetaDataResultSet::getQuoteValue();
811 aRow
[6] = ODatabaseMetaDataResultSet::getEmptyValue();
812 aRow
[7] = new ORowSetValueDecorator((sal_Int32
) ColumnValue::NULLABLE
);
813 aRow
[8] = ODatabaseMetaDataResultSet::get1Value();
814 aRow
[9] = new ORowSetValueDecorator((sal_Int32
) ColumnSearch::CHAR
);
815 aRow
[10] = ODatabaseMetaDataResultSet::get1Value();
816 aRow
[11] = ODatabaseMetaDataResultSet::get0Value();
817 aRow
[12] = ODatabaseMetaDataResultSet::get0Value();
818 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
819 aRow
[14] = ODatabaseMetaDataResultSet::get0Value();
820 aRow
[15] = ODatabaseMetaDataResultSet::get0Value();
821 aRow
[16] = ODatabaseMetaDataResultSet::getEmptyValue();
822 aRow
[17] = ODatabaseMetaDataResultSet::getEmptyValue();
823 aRow
[18] = new ORowSetValueDecorator((sal_Int32
) 10);
825 aRows
.push_back(aRow
);
827 aRow
[1] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
828 aRow
[2] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
829 aRow
[3] = new ORowSetValueDecorator((sal_Int32
)19);
830 aRow
[4] = ODatabaseMetaDataResultSet::getQuoteValue();
831 aRow
[5] = ODatabaseMetaDataResultSet::getQuoteValue();
832 aRows
.push_back(aRow
);
834 aRow
[1] = new ORowSetValueDecorator(OUString("INTEGER"));
835 aRow
[2] = new ORowSetValueDecorator(DataType::INTEGER
);
836 aRow
[3] = new ORowSetValueDecorator((sal_Int32
)20);
837 aRow
[15] = new ORowSetValueDecorator((sal_Int32
)20);
838 aRows
.push_back(aRow
);
840 aRow
[1] = new ORowSetValueDecorator(OUString("FLOAT"));
841 aRow
[2] = new ORowSetValueDecorator(DataType::FLOAT
);
842 aRow
[3] = new ORowSetValueDecorator((sal_Int32
)20);
843 aRow
[15] = new ORowSetValueDecorator((sal_Int32
)15);
844 aRows
.push_back(aRow
);
846 pResult
->setRows(aRows
);
850 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getCatalogs( ) throw(SQLException
, RuntimeException
)
852 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs
);
855 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getSchemas( ) throw(SQLException
, RuntimeException
)
857 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas
);
860 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getColumnPrivileges(
861 const Any
&, const OUString
&, const OUString
&,
862 const OUString
& ) throw(SQLException
, RuntimeException
)
864 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges
);
867 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getColumns(
870 const OUString
& tableNamePattern
,
871 const OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
873 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns
);
874 Reference
< XResultSet
> xRef
= pResult
;
875 MacabRecords
*aRecords
;
878 aRecords
= m_xConnection
->getAddressBook()->getMacabRecordsMatch(tableNamePattern
);
880 ODatabaseMetaDataResultSet::ORows aRows
;
883 MacabHeader
*aHeader
= aRecords
->getHeader();
884 sTableName
= aRecords
->getName();
886 ODatabaseMetaDataResultSet::ORow
aRow(19);
888 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
889 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
890 aRow
[2] = ODatabaseMetaDataResultSet::getEmptyValue();
891 aRow
[3] = new ORowSetValueDecorator(sTableName
);
892 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
893 aRow
[9] = ODatabaseMetaDataResultSet::get0Value();
894 aRow
[10] = new ORowSetValueDecorator((sal_Int32
) 10);
895 aRow
[11] = ODatabaseMetaDataResultSet::get1Value();
896 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
897 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
898 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
899 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
900 aRow
[16] = new ORowSetValueDecorator((sal_Int32
) 254);
901 aRow
[18] = new ORowSetValueDecorator(OUString("YES"));
903 sal_Int32 nPosition
= 1;
906 MacabHeader::iterator aField
;
908 for ( aField
= aHeader
->begin();
909 aField
!= aHeader
->end();
910 ++aField
, ++nPosition
)
913 sName
= CFStringToOUString((CFStringRef
) (*aField
)->value
);
914 if (match(columnNamePattern
, sName
, '\0'))
916 aRow
[4] = new ORowSetValueDecorator(sName
);
917 aRow
[17] = new ORowSetValueDecorator(nPosition
);
918 switch((*aField
)->type
)
920 case kABStringProperty
:
921 aRow
[5] = new ORowSetValueDecorator(DataType::CHAR
);
922 aRow
[6] = new ORowSetValueDecorator(OUString("CHAR"));
923 aRow
[7] = new ORowSetValueDecorator((sal_Int32
) 256);
924 aRows
.push_back(aRow
);
926 case kABDateProperty
:
927 aRow
[5] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
928 aRow
[6] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
929 aRows
.push_back(aRow
);
931 case kABIntegerProperty
:
932 aRow
[5] = new ORowSetValueDecorator(DataType::INTEGER
);
933 aRow
[6] = new ORowSetValueDecorator(OUString("INTEGER"));
934 aRow
[7] = new ORowSetValueDecorator((sal_Int32
) 20);
935 aRows
.push_back(aRow
);
937 case kABRealProperty
:
938 aRow
[5] = new ORowSetValueDecorator(DataType::FLOAT
);
939 aRow
[6] = new ORowSetValueDecorator(OUString("FLOAT"));
940 aRow
[7] = new ORowSetValueDecorator((sal_Int32
) 15);
941 aRows
.push_back(aRow
);
945 // shouldn't happen -- throw an error...?
950 pResult
->setRows(aRows
);
954 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTables(
958 const Sequence
< OUString
>& types
) throw(SQLException
, RuntimeException
)
960 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables
);
961 Reference
< XResultSet
> xRef
= pResult
;
963 // check whether we have tables in the requested types
964 // for the moment, we answer only the "TABLE" table type
965 // when no types are given at all, we return all the tables
966 static const OUString
aTable("TABLE");
967 sal_Bool bTableFound
= sal_False
;
968 const OUString
* p
= types
.getConstArray(),
969 * pEnd
= p
+ types
.getLength();
973 bTableFound
= sal_True
;
975 else while (p
< pEnd
)
977 if (match(*p
, aTable
, '\0'))
979 bTableFound
= sal_True
;
987 static ODatabaseMetaDataResultSet::ORows aRows
;
991 ODatabaseMetaDataResultSet::ORow
aRow(6);
993 MacabRecords
*xRecords
= m_xConnection
->getAddressBook()->getMacabRecords();
994 ::std::vector
<MacabGroup
*> xGroups
= m_xConnection
->getAddressBook()->getMacabGroups();
995 sal_Int32 i
, nGroups
;
996 nGroups
= xGroups
.size();
998 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
999 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
1000 aRow
[2] = ODatabaseMetaDataResultSet::getEmptyValue();
1001 aRow
[3] = new ORowSetValueDecorator(xRecords
->getName());
1002 aRow
[4] = new ORowSetValueDecorator(aTable
);
1003 aRow
[5] = ODatabaseMetaDataResultSet::getEmptyValue();
1004 aRows
.push_back(aRow
);
1006 for(i
= 0; i
< nGroups
; i
++)
1008 aRow
[3] = new ORowSetValueDecorator(xGroups
[i
]->getName());
1009 aRows
.push_back(aRow
);
1012 pResult
->setRows(aRows
);
1016 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getProcedureColumns(
1017 const Any
&, const OUString
&,
1018 const OUString
&, const OUString
& ) throw(SQLException
, RuntimeException
)
1020 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns
);
1023 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getProcedures(
1024 const Any
&, const OUString
&,
1025 const OUString
& ) throw(SQLException
, RuntimeException
)
1027 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures
);
1030 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getVersionColumns(
1031 const Any
&, const OUString
&, const OUString
& table
) throw(SQLException
, RuntimeException
)
1033 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns
);
1034 Reference
< XResultSet
> xRef
= pResult
;
1036 ODatabaseMetaDataResultSet::ORows aRows
;
1038 if (m_xConnection
->getAddressBook()->getMacabRecords(table
) != NULL
)
1040 ODatabaseMetaDataResultSet::ORow
aRow( 9 );
1042 OUString sName
= CFStringToOUString(kABModificationDateProperty
);
1044 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
1045 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
1046 aRow
[2] = new ORowSetValueDecorator(sName
);
1047 aRow
[3] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
1048 aRow
[4] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
1050 aRow
[5] = ODatabaseMetaDataResultSet::getEmptyValue();
1051 aRow
[6] = ODatabaseMetaDataResultSet::getEmptyValue();
1052 aRow
[7] = ODatabaseMetaDataResultSet::getEmptyValue();
1053 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
1055 aRows
.push_back(aRow
);
1057 pResult
->setRows(aRows
);
1061 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getExportedKeys(
1062 const Any
&, const OUString
&, const OUString
& ) throw(SQLException
, RuntimeException
)
1064 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys
);
1067 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getImportedKeys(
1068 const Any
&, const OUString
&, const OUString
& ) throw(SQLException
, RuntimeException
)
1070 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys
);
1073 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getPrimaryKeys(
1074 const Any
&, const OUString
&, const OUString
& ) throw(SQLException
, RuntimeException
)
1076 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys
);
1079 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getIndexInfo(
1080 const Any
&, const OUString
&, const OUString
&,
1081 sal_Bool
, sal_Bool
) throw(SQLException
, RuntimeException
)
1083 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo
);
1086 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getBestRowIdentifier(
1087 const Any
&, const OUString
&, const OUString
&, sal_Int32
,
1088 sal_Bool
) throw(SQLException
, RuntimeException
)
1090 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier
);
1093 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTablePrivileges(
1094 const Any
&, const OUString
&, const OUString
& ) throw(SQLException
, RuntimeException
)
1096 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges
);
1099 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getCrossReference(
1100 const Any
&, const OUString
&,
1101 const OUString
&, const Any
&,
1102 const OUString
&, const OUString
& ) throw(SQLException
, RuntimeException
)
1104 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference
);
1107 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getUDTs( const Any
&, const OUString
&, const OUString
&, const Sequence
< sal_Int32
>& ) throw(SQLException
, RuntimeException
)
1109 OSL_FAIL("Not implemented yet!");
1110 throw SQLException();
1114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */