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/ColumnSearch.hpp>
31 #include <com/sun/star/sdbc/ColumnValue.hpp>
32 #include <com/sun/star/sdbc/ResultSetType.hpp>
33 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
34 #include <rtl/ref.hxx>
38 using namespace connectivity::macab
;
39 using namespace com::sun::star::uno
;
40 using namespace com::sun::star::lang
;
41 using namespace com::sun::star::beans
;
42 using namespace com::sun::star::sdbc
;
44 MacabDatabaseMetaData::MacabDatabaseMetaData(MacabConnection
* _pCon
)
45 : m_xConnection(_pCon
),
48 OSL_ENSURE(_pCon
,"MacabDatabaseMetaData::MacabDatabaseMetaData: No connection set!");
50 osl_atomic_increment( &m_refCount
);
51 m_bUseCatalog
= !(usesLocalFiles() || usesLocalFilePerTable());
52 osl_atomic_decrement( &m_refCount
);
55 MacabDatabaseMetaData::~MacabDatabaseMetaData()
59 OUString SAL_CALL
MacabDatabaseMetaData::getCatalogSeparator( )
62 { // do some special here for you database
68 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxBinaryLiteralLength( )
70 return 0; // 0 means no limit
73 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxRowSize( )
75 return 0; // 0 means no limit
78 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxCatalogNameLength( )
80 return 0; // 0 means no limit
83 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxCharLiteralLength( )
85 return 0; // 0 means no limit
88 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnNameLength( )
90 return 0; // 0 means no limit
93 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInIndex( )
95 return 0; // 0 means no limit
98 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxCursorNameLength( )
100 return 0; // 0 means no limit
103 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxConnections( )
105 return 0; // 0 means no limit
108 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInTable( )
110 return 0; // 0 means no limit
113 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxStatementLength( )
115 return 0; // 0 means no limit
118 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxTableNameLength( )
120 return 0; // 0 means no limit
123 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxTablesInSelect( )
125 // MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement,
126 // currently, the resultset/statement implementations can cope with one table only
130 sal_Bool SAL_CALL
MacabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
135 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
140 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesLowerCaseIdentifiers( )
145 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( )
150 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesMixedCaseIdentifiers( )
155 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
160 sal_Bool SAL_CALL
MacabDatabaseMetaData::storesUpperCaseIdentifiers( )
165 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsAlterTableWithAddColumn( )
170 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsAlterTableWithDropColumn( )
175 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxIndexLength( )
177 return 0; // 0 means no limit
180 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsNonNullableColumns( )
185 OUString SAL_CALL
MacabDatabaseMetaData::getCatalogTerm( )
190 OUString SAL_CALL
MacabDatabaseMetaData::getIdentifierQuoteString( )
192 // normally this is "
196 OUString SAL_CALL
MacabDatabaseMetaData::getExtraNameCharacters( )
201 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsDifferentTableCorrelationNames( )
206 sal_Bool SAL_CALL
MacabDatabaseMetaData::isCatalogAtStart( )
211 sal_Bool SAL_CALL
MacabDatabaseMetaData::dataDefinitionIgnoredInTransactions( )
216 sal_Bool SAL_CALL
MacabDatabaseMetaData::dataDefinitionCausesTransactionCommit( )
221 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsDataManipulationTransactionsOnly( )
226 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
231 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsPositionedDelete( )
236 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsPositionedUpdate( )
241 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenStatementsAcrossRollback( )
246 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenStatementsAcrossCommit( )
251 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenCursorsAcrossCommit( )
256 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOpenCursorsAcrossRollback( )
261 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
)
266 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInDataManipulation( )
271 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsANSI92FullSQL( )
276 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsANSI92EntryLevelSQL( )
278 return true; // should be supported at least
281 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsIntegrityEnhancementFacility( )
286 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInIndexDefinitions( )
291 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInTableDefinitions( )
296 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInTableDefinitions( )
301 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInIndexDefinitions( )
306 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInDataManipulation( )
311 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOuterJoins( )
316 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxStatements( )
318 return 0; // 0 means no limit
321 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxProcedureNameLength( )
323 return 0; // 0 means no limit
326 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxSchemaNameLength( )
328 return 0; // 0 means no limit
331 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTransactions( )
336 sal_Bool SAL_CALL
MacabDatabaseMetaData::allProceduresAreCallable( )
341 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsStoredProcedures( )
346 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSelectForUpdate( )
351 sal_Bool SAL_CALL
MacabDatabaseMetaData::allTablesAreSelectable( )
356 sal_Bool SAL_CALL
MacabDatabaseMetaData::isReadOnly( )
358 // for the moment, we have read-only addresses, but this might change in the future
362 sal_Bool SAL_CALL
MacabDatabaseMetaData::usesLocalFiles( )
367 sal_Bool SAL_CALL
MacabDatabaseMetaData::usesLocalFilePerTable( )
372 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTypeConversion( )
377 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullPlusNonNullIsNull( )
382 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsColumnAliasing( )
387 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsTableCorrelationNames( )
392 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsConvert( sal_Int32
, sal_Int32
)
397 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsExpressionsInOrderBy( )
402 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsGroupBy( )
407 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsGroupByBeyondSelect( )
412 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsGroupByUnrelated( )
417 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMultipleTransactions( )
422 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMultipleResultSets( )
427 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsLikeEscapeClause( )
432 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsOrderByUnrelated( )
437 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsUnion( )
442 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsUnionAll( )
447 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMixedCaseIdentifiers( )
452 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( )
457 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedAtEnd( )
462 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedAtStart( )
467 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedHigh( )
472 sal_Bool SAL_CALL
MacabDatabaseMetaData::nullsAreSortedLow( )
477 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInProcedureCalls( )
482 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
487 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInProcedureCalls( )
492 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
497 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCorrelatedSubqueries( )
502 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInComparisons( )
507 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInExists( )
512 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInIns( )
517 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsSubqueriesInQuantifieds( )
522 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsANSI92IntermediateSQL( )
527 OUString SAL_CALL
MacabDatabaseMetaData::getURL( )
529 // if someday we support more than the default address book,
530 // this method should return the URL which was used to create it
531 return "sdbc:address:macab:";
534 OUString SAL_CALL
MacabDatabaseMetaData::getUserName( )
539 OUString SAL_CALL
MacabDatabaseMetaData::getDriverName( )
544 OUString SAL_CALL
MacabDatabaseMetaData::getDriverVersion()
546 return MACAB_DRIVER_VERSION
;
549 OUString SAL_CALL
MacabDatabaseMetaData::getDatabaseProductVersion( )
554 OUString SAL_CALL
MacabDatabaseMetaData::getDatabaseProductName( )
559 OUString SAL_CALL
MacabDatabaseMetaData::getProcedureTerm( )
564 OUString SAL_CALL
MacabDatabaseMetaData::getSchemaTerm( )
569 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getDriverMajorVersion( )
571 return MACAB_DRIVER_VERSION_MAJOR
;
574 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getDefaultTransactionIsolation( )
576 return TransactionIsolation::NONE
;
579 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getDriverMinorVersion( )
581 return MACAB_DRIVER_VERSION_MINOR
;
584 OUString SAL_CALL
MacabDatabaseMetaData::getSQLKeywords( )
589 OUString SAL_CALL
MacabDatabaseMetaData::getSearchStringEscape( )
594 OUString SAL_CALL
MacabDatabaseMetaData::getStringFunctions( )
599 OUString SAL_CALL
MacabDatabaseMetaData::getTimeDateFunctions( )
604 OUString SAL_CALL
MacabDatabaseMetaData::getSystemFunctions( )
609 OUString SAL_CALL
MacabDatabaseMetaData::getNumericFunctions( )
614 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsExtendedSQLGrammar( )
619 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsCoreSQLGrammar( )
624 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsMinimumSQLGrammar( )
629 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsFullOuterJoins( )
634 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsLimitedOuterJoins( )
639 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInGroupBy( )
641 return 0; // 0 means no limit
644 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInOrderBy( )
646 return 0; // 0 means no limit
649 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxColumnsInSelect( )
651 return 0; // 0 means no limit
654 sal_Int32 SAL_CALL
MacabDatabaseMetaData::getMaxUserNameLength( )
656 return 0; // 0 means no limit
659 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsResultSetType( sal_Int32 setType
)
663 case ResultSetType::FORWARD_ONLY
:
664 case ResultSetType::SCROLL_INSENSITIVE
:
670 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType
, sal_Int32
)
674 case ResultSetType::FORWARD_ONLY
:
675 case ResultSetType::SCROLL_INSENSITIVE
:
681 sal_Bool SAL_CALL
MacabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32
)
686 sal_Bool SAL_CALL
MacabDatabaseMetaData::ownDeletesAreVisible( sal_Int32
)
691 sal_Bool SAL_CALL
MacabDatabaseMetaData::ownInsertsAreVisible( sal_Int32
)
696 sal_Bool SAL_CALL
MacabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32
)
701 sal_Bool SAL_CALL
MacabDatabaseMetaData::othersDeletesAreVisible( sal_Int32
)
706 sal_Bool SAL_CALL
MacabDatabaseMetaData::othersInsertsAreVisible( sal_Int32
)
711 sal_Bool SAL_CALL
MacabDatabaseMetaData::updatesAreDetected( sal_Int32
)
716 sal_Bool SAL_CALL
MacabDatabaseMetaData::deletesAreDetected( sal_Int32
)
721 sal_Bool SAL_CALL
MacabDatabaseMetaData::insertsAreDetected( sal_Int32
)
726 sal_Bool SAL_CALL
MacabDatabaseMetaData::supportsBatchUpdates( )
731 Reference
< XConnection
> SAL_CALL
MacabDatabaseMetaData::getConnection( )
733 return m_xConnection
;
736 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTableTypes( )
738 rtl::Reference
<::connectivity::ODatabaseMetaDataResultSet
> pResult
= new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
740 static ODatabaseMetaDataResultSet::ORows aRows
= [&]
742 static constexpr OUStringLiteral aTable
= u
"TABLE";
743 ODatabaseMetaDataResultSet::ORows tmp
;
744 ODatabaseMetaDataResultSet::ORow
aRow(2);
745 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
746 aRow
[1] = new ORowSetValueDecorator(OUString(aTable
));
750 pResult
->setRows(aRows
);
754 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTypeInfo( )
756 rtl::Reference
<ODatabaseMetaDataResultSet
> pResult
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
758 static ODatabaseMetaDataResultSet::ORows aRows
= [&]()
760 ODatabaseMetaDataResultSet::ORows tmp
;
761 ODatabaseMetaDataResultSet::ORow
aRow(19);
763 // We support four types: char, timestamp, integer, float
764 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
765 aRow
[1] = new ORowSetValueDecorator(OUString("CHAR"));
766 aRow
[2] = new ORowSetValueDecorator(DataType::CHAR
);
767 aRow
[3] = new ORowSetValueDecorator(sal_Int32(254));
768 aRow
[4] = ODatabaseMetaDataResultSet::getQuoteValue();
769 aRow
[5] = ODatabaseMetaDataResultSet::getQuoteValue();
770 aRow
[6] = ODatabaseMetaDataResultSet::getEmptyValue();
771 aRow
[7] = new ORowSetValueDecorator(sal_Int32(ColumnValue::NULLABLE
));
772 aRow
[8] = ODatabaseMetaDataResultSet::get1Value();
773 aRow
[9] = new ORowSetValueDecorator(sal_Int32(ColumnSearch::CHAR
));
774 aRow
[10] = ODatabaseMetaDataResultSet::get1Value();
775 aRow
[11] = ODatabaseMetaDataResultSet::get0Value();
776 aRow
[12] = ODatabaseMetaDataResultSet::get0Value();
777 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
778 aRow
[14] = ODatabaseMetaDataResultSet::get0Value();
779 aRow
[15] = ODatabaseMetaDataResultSet::get0Value();
780 aRow
[16] = ODatabaseMetaDataResultSet::getEmptyValue();
781 aRow
[17] = ODatabaseMetaDataResultSet::getEmptyValue();
782 aRow
[18] = new ORowSetValueDecorator(sal_Int32(10));
786 aRow
[1] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
787 aRow
[2] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
788 aRow
[3] = new ORowSetValueDecorator(sal_Int32(19));
789 aRow
[4] = ODatabaseMetaDataResultSet::getQuoteValue();
790 aRow
[5] = ODatabaseMetaDataResultSet::getQuoteValue();
793 aRow
[1] = new ORowSetValueDecorator(OUString("INTEGER"));
794 aRow
[2] = new ORowSetValueDecorator(DataType::INTEGER
);
795 aRow
[3] = new ORowSetValueDecorator(sal_Int32(20));
796 aRow
[15] = new ORowSetValueDecorator(sal_Int32(20));
799 aRow
[1] = new ORowSetValueDecorator(OUString("FLOAT"));
800 aRow
[2] = new ORowSetValueDecorator(DataType::FLOAT
);
801 aRow
[3] = new ORowSetValueDecorator(sal_Int32(20));
802 aRow
[15] = new ORowSetValueDecorator(sal_Int32(15));
807 pResult
->setRows(aRows
);
811 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getCatalogs( )
813 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs
);
816 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getSchemas( )
818 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas
);
821 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getColumnPrivileges(
822 const Any
&, const OUString
&, const OUString
&,
825 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges
);
828 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getColumns(
831 const OUString
& tableNamePattern
,
832 const OUString
& columnNamePattern
)
834 rtl::Reference
<::connectivity::ODatabaseMetaDataResultSet
> pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns
);
835 MacabRecords
*aRecords
;
838 aRecords
= m_xConnection
->getAddressBook()->getMacabRecordsMatch(tableNamePattern
);
840 ODatabaseMetaDataResultSet::ORows aRows
;
841 if(aRecords
!= nullptr)
843 MacabHeader
*aHeader
= aRecords
->getHeader();
844 sTableName
= aRecords
->getName();
846 ODatabaseMetaDataResultSet::ORow
aRow(19);
848 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
849 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
850 aRow
[2] = ODatabaseMetaDataResultSet::getEmptyValue();
851 aRow
[3] = new ORowSetValueDecorator(sTableName
);
852 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
853 aRow
[9] = ODatabaseMetaDataResultSet::get0Value();
854 aRow
[10] = new ORowSetValueDecorator(sal_Int32(10));
855 aRow
[11] = ODatabaseMetaDataResultSet::get1Value();
856 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
857 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
858 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
859 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
860 aRow
[16] = new ORowSetValueDecorator(sal_Int32(254));
861 aRow
[18] = new ORowSetValueDecorator(OUString("YES"));
863 sal_Int32 nPosition
= 1;
866 MacabHeader::iterator aField
;
868 for ( aField
= aHeader
->begin();
869 aField
!= aHeader
->end();
870 ++aField
, ++nPosition
)
873 sName
= CFStringToOUString(static_cast<CFStringRef
>((*aField
)->value
));
874 if (match(columnNamePattern
, sName
, '\0'))
876 aRow
[4] = new ORowSetValueDecorator(sName
);
877 aRow
[17] = new ORowSetValueDecorator(nPosition
);
878 switch((*aField
)->type
)
880 case kABStringProperty
:
881 aRow
[5] = new ORowSetValueDecorator(DataType::CHAR
);
882 aRow
[6] = new ORowSetValueDecorator(OUString("CHAR"));
883 aRow
[7] = new ORowSetValueDecorator(sal_Int32(256));
884 aRows
.push_back(aRow
);
886 case kABDateProperty
:
887 aRow
[5] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
888 aRow
[6] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
889 aRows
.push_back(aRow
);
891 case kABIntegerProperty
:
892 aRow
[5] = new ORowSetValueDecorator(DataType::INTEGER
);
893 aRow
[6] = new ORowSetValueDecorator(OUString("INTEGER"));
894 aRow
[7] = new ORowSetValueDecorator(sal_Int32(20));
895 aRows
.push_back(aRow
);
897 case kABRealProperty
:
898 aRow
[5] = new ORowSetValueDecorator(DataType::FLOAT
);
899 aRow
[6] = new ORowSetValueDecorator(OUString("FLOAT"));
900 aRow
[7] = new ORowSetValueDecorator(sal_Int32(15));
901 aRows
.push_back(aRow
);
905 // shouldn't happen -- throw an error...?
910 pResult
->setRows(aRows
);
914 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTables(
918 const Sequence
< OUString
>& types
)
920 rtl::Reference
<ODatabaseMetaDataResultSet
> pResult
= new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables
);
922 // check whether we have tables in the requested types
923 // for the moment, we answer only the "TABLE" table type
924 // when no types are given at all, we return all the tables
925 static constexpr OUStringLiteral aTable
= u
"TABLE";
926 bool bTableFound
= false;
927 const OUString
* p
= types
.getConstArray(),
928 * pEnd
= p
+ types
.getLength();
934 else while (p
< pEnd
)
936 if (match(*p
, aTable
, '\0'))
946 static ODatabaseMetaDataResultSet::ORows aRows
= [&]()
948 ODatabaseMetaDataResultSet::ORows tmp
;
949 ODatabaseMetaDataResultSet::ORow
aRow(6);
951 MacabRecords
*xRecords
= m_xConnection
->getAddressBook()->getMacabRecords();
952 std::vector
<MacabGroup
*> xGroups
= m_xConnection
->getAddressBook()->getMacabGroups();
953 sal_Int32 i
, nGroups
;
954 nGroups
= xGroups
.size();
956 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
957 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
958 aRow
[2] = ODatabaseMetaDataResultSet::getEmptyValue();
959 aRow
[3] = new ORowSetValueDecorator(xRecords
->getName());
960 aRow
[4] = new ORowSetValueDecorator(OUString(aTable
));
961 aRow
[5] = ODatabaseMetaDataResultSet::getEmptyValue();
964 for(i
= 0; i
< nGroups
; i
++)
966 aRow
[3] = new ORowSetValueDecorator(xGroups
[i
]->getName());
971 pResult
->setRows(aRows
);
975 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getProcedureColumns(
976 const Any
&, const OUString
&,
977 const OUString
&, const OUString
& )
979 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns
);
982 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getProcedures(
983 const Any
&, const OUString
&,
986 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures
);
989 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getVersionColumns(
990 const Any
&, const OUString
&, const OUString
& table
)
992 rtl::Reference
<::connectivity::ODatabaseMetaDataResultSet
> pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns
);
994 ODatabaseMetaDataResultSet::ORows aRows
;
996 if (m_xConnection
->getAddressBook()->getMacabRecords(table
) != nullptr)
998 ODatabaseMetaDataResultSet::ORow
aRow( 9 );
1000 OUString sName
= CFStringToOUString(kABModificationDateProperty
);
1002 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
1003 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
1004 aRow
[2] = new ORowSetValueDecorator(sName
);
1005 aRow
[3] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
1006 aRow
[4] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
1008 aRow
[5] = ODatabaseMetaDataResultSet::getEmptyValue();
1009 aRow
[6] = ODatabaseMetaDataResultSet::getEmptyValue();
1010 aRow
[7] = ODatabaseMetaDataResultSet::getEmptyValue();
1011 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
1013 aRows
.push_back(aRow
);
1015 pResult
->setRows(aRows
);
1019 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getExportedKeys(
1020 const Any
&, const OUString
&, const OUString
& )
1022 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys
);
1025 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getImportedKeys(
1026 const Any
&, const OUString
&, const OUString
& )
1028 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys
);
1031 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getPrimaryKeys(
1032 const Any
&, const OUString
&, const OUString
& )
1034 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys
);
1037 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getIndexInfo(
1038 const Any
&, const OUString
&, const OUString
&,
1039 sal_Bool
, sal_Bool
)
1041 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo
);
1044 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getBestRowIdentifier(
1045 const Any
&, const OUString
&, const OUString
&, sal_Int32
,
1048 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier
);
1051 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getTablePrivileges(
1052 const Any
&, const OUString
&, const OUString
& )
1054 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges
);
1057 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getCrossReference(
1058 const Any
&, const OUString
&,
1059 const OUString
&, const Any
&,
1060 const OUString
&, const OUString
& )
1062 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference
);
1065 Reference
< XResultSet
> SAL_CALL
MacabDatabaseMetaData::getUDTs( const Any
&, const OUString
&, const OUString
&, const Sequence
< sal_Int32
>& )
1067 OSL_FAIL("Not implemented yet!");
1068 throw SQLException();
1072 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */