Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / macab / MacabDatabaseMetaData.cxx
blobead208d0871f1e49647d108d5641e6e6f0e8f790
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
34 #include <vector>
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)
59 OUString aVal;
60 if (m_bUseCatalog)
61 { // do some special here for you database
64 return aVal;
67 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
69 sal_Int32 nValue = 0; // 0 means no limit
70 return nValue;
73 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
75 sal_Int32 nValue = 0; // 0 means no limit
76 return nValue;
79 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
81 sal_Int32 nValue = 0; // 0 means no limit
82 return nValue;
85 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
87 sal_Int32 nValue = 0; // 0 means no limit
88 return nValue;
91 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
93 sal_Int32 nValue = 0; // 0 means no limit
94 return nValue;
97 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
99 sal_Int32 nValue = 0; // 0 means no limit
100 return nValue;
103 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
105 sal_Int32 nValue = 0; // 0 means no limit
106 return nValue;
109 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
111 sal_Int32 nValue = 0; // 0 means no limit
112 return nValue;
115 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
117 sal_Int32 nValue = 0; // 0 means no limit
118 return nValue;
121 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
123 sal_Int32 nValue = 0; // 0 means no limit
124 return nValue;
127 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
129 sal_Int32 nValue = 0; // 0 means no limit
130 return nValue;
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;
138 return nValue;
141 sal_Bool SAL_CALL MacabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
143 return sal_False;
146 sal_Bool SAL_CALL MacabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
148 return sal_False;
151 sal_Bool SAL_CALL MacabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
153 return sal_False;
156 sal_Bool SAL_CALL MacabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
158 return sal_False;
161 sal_Bool SAL_CALL MacabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
163 return sal_False;
166 sal_Bool SAL_CALL MacabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
168 return sal_False;
171 sal_Bool SAL_CALL MacabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
173 return sal_False;
176 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException)
178 return sal_False;
181 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException)
183 return sal_False;
186 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
188 sal_Int32 nValue = 0; // 0 means no limit
189 return nValue;
192 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
194 return sal_False;
197 OUString SAL_CALL MacabDatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
199 OUString aVal;
200 if (m_bUseCatalog)
203 return aVal;
206 OUString SAL_CALL MacabDatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException)
208 // normally this is "
209 OUString aVal("\"");
210 return aVal;
213 OUString SAL_CALL MacabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
215 OUString aVal;
216 return aVal;
219 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
221 return sal_False;
224 sal_Bool SAL_CALL MacabDatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException)
226 sal_Bool bValue = sal_False;
227 if (m_bUseCatalog)
230 return bValue;
233 sal_Bool SAL_CALL MacabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
235 return sal_True;
238 sal_Bool SAL_CALL MacabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
240 return sal_True;
243 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
245 return sal_True;
248 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
250 return sal_True;
253 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
255 return sal_False;
258 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
260 return sal_False;
263 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
265 return sal_False;
268 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
270 return sal_False;
273 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
275 return sal_False;
278 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
280 return sal_False;
283 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 ) throw(SQLException, RuntimeException)
285 return sal_False;
288 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException)
290 return sal_False;
293 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
295 return sal_False;
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)
305 return sal_False;
308 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
310 return sal_False;
313 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException)
315 return sal_False;
318 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException)
320 return sal_False;
323 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
325 return sal_False;
328 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException)
330 return sal_False;
333 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
335 return sal_False;
338 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException)
340 sal_Int32 nValue = 0; // 0 means no limit
341 return nValue;
344 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
346 sal_Int32 nValue = 0; // 0 means no limit
347 return nValue;
350 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
352 sal_Int32 nValue = 0; // 0 means no limit
353 return nValue;
356 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
358 return sal_False;
361 sal_Bool SAL_CALL MacabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
363 return sal_False;
366 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
368 return sal_False;
371 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
373 return sal_False;
376 sal_Bool SAL_CALL MacabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
378 return sal_False;
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
384 return sal_True;
387 sal_Bool SAL_CALL MacabDatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
389 return sal_False;
392 sal_Bool SAL_CALL MacabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
394 return sal_False;
397 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
399 return sal_False;
402 sal_Bool SAL_CALL MacabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
404 return sal_False;
407 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
409 return sal_False;
412 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
414 return sal_False;
417 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsConvert( sal_Int32, sal_Int32 ) throw(SQLException, RuntimeException)
419 return sal_False;
422 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
424 return sal_False;
427 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
429 return sal_False;
432 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
434 return sal_False;
437 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
439 return sal_False;
442 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
444 return sal_False;
447 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
449 return sal_False;
452 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
454 return sal_False;
457 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
459 return sal_False;
462 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
464 return sal_False;
467 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
469 return sal_False;
472 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
474 return sal_False;
477 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
479 return sal_False;
482 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
484 return sal_False;
487 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
489 return sal_False;
492 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
494 return sal_False;
497 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
499 return sal_False;
502 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
504 return sal_False;
507 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
509 return sal_False;
512 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
514 return sal_False;
517 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
519 return sal_False;
522 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
524 return sal_False;
527 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
529 return sal_False;
532 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
534 return sal_False;
537 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
539 return sal_False;
542 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
544 return sal_False;
547 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
549 return sal_False;
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:" );
557 return aValue;
560 OUString SAL_CALL MacabDatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
562 OUString aValue;
563 return aValue;
566 OUString SAL_CALL MacabDatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
568 OUString aValue( "macab" );
569 return aValue;
572 OUString SAL_CALL MacabDatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
574 OUString aValue(MACAB_DRIVER_VERSION);
575 return aValue;
578 OUString SAL_CALL MacabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
580 OUString aValue;
581 return aValue;
584 OUString SAL_CALL MacabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
586 OUString aValue;
587 return aValue;
590 OUString SAL_CALL MacabDatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
592 OUString aValue;
593 return aValue;
596 OUString SAL_CALL MacabDatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
598 OUString aValue;
599 return aValue;
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)
619 OUString aValue;
620 return aValue;
623 OUString SAL_CALL MacabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
625 OUString aValue;
626 return aValue;
629 OUString SAL_CALL MacabDatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
631 return OUString();
634 OUString SAL_CALL MacabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
636 return OUString();
639 OUString SAL_CALL MacabDatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
641 return OUString();
644 OUString SAL_CALL MacabDatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
646 return OUString();
649 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
651 return sal_False;
654 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
656 return sal_False;
659 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
661 return sal_True;
664 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
666 return sal_False;
669 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
671 return sal_False;
674 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
676 sal_Int32 nValue = 0; // 0 means no limit
677 return nValue;
680 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
682 sal_Int32 nValue = 0; // 0 means no limit
683 return nValue;
686 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
688 sal_Int32 nValue = 0; // 0 means no limit
689 return nValue;
692 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
694 sal_Int32 nValue = 0; // 0 means no limit
695 return nValue;
698 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
700 switch (setType)
702 case ResultSetType::FORWARD_ONLY:
703 case ResultSetType::SCROLL_INSENSITIVE:
704 return sal_True;
706 return sal_False;
709 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 ) throw(SQLException, RuntimeException)
711 switch (setType)
713 case ResultSetType::FORWARD_ONLY:
714 case ResultSetType::SCROLL_INSENSITIVE:
715 return sal_True;
717 return sal_False;
720 sal_Bool SAL_CALL MacabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
722 return sal_False;
725 sal_Bool SAL_CALL MacabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
727 return sal_False;
730 sal_Bool SAL_CALL MacabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
732 return sal_False;
735 sal_Bool SAL_CALL MacabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
737 return sal_False;
740 sal_Bool SAL_CALL MacabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
742 return sal_False;
745 sal_Bool SAL_CALL MacabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
747 return sal_False;
750 sal_Bool SAL_CALL MacabDatabaseMetaData::updatesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
752 return sal_False;
755 sal_Bool SAL_CALL MacabDatabaseMetaData::deletesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
757 return sal_False;
760 sal_Bool SAL_CALL MacabDatabaseMetaData::insertsAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
762 return sal_False;
765 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
767 return sal_False;
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");
783 if (aRows.empty())
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);
791 return xRef;
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;
800 if (aRows.empty())
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);
847 return xRef;
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(
868 const Any&,
869 const OUString&,
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;
876 OUString sTableName;
878 aRecords = m_xConnection->getAddressBook()->getMacabRecordsMatch(tableNamePattern);
880 ODatabaseMetaDataResultSet::ORows aRows;
881 if(aRecords != NULL)
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;
904 OUString sName;
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);
925 break;
926 case kABDateProperty:
927 aRow[5] = new ORowSetValueDecorator(DataType::TIMESTAMP);
928 aRow[6] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
929 aRows.push_back(aRow);
930 break;
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);
936 break;
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);
942 break;
943 default:
945 // shouldn't happen -- throw an error...?
950 pResult->setRows(aRows);
951 return xRef;
954 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables(
955 const Any&,
956 const OUString&,
957 const OUString&,
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();
971 if (p == pEnd)
973 bTableFound = sal_True;
975 else while (p < pEnd)
977 if (match(*p, aTable, '\0'))
979 bTableFound = sal_True;
980 break;
982 p++;
984 if (!bTableFound)
985 return xRef;
987 static ODatabaseMetaDataResultSet::ORows aRows;
989 if (aRows.empty())
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);
1013 return xRef;
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);
1058 return xRef;
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: */