1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: KDatabaseMetaData.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #include "KDatabaseMetaData.hxx"
35 #include "kfields.hxx"
37 #include <vcl/kde_headers.h>
38 #include "FDatabaseMetaDataResultSet.hxx"
39 #include "OTypeInfo.hxx"
40 #include <com/sun/star/sdbc/ColumnValue.hpp>
41 #include <com/sun/star/sdbc/ResultSetType.hpp>
42 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
44 using namespace connectivity::kab
;
45 using namespace com::sun::star::uno
;
46 using namespace com::sun::star::lang
;
47 using namespace com::sun::star::beans
;
48 using namespace com::sun::star::sdbc
;
50 KabDatabaseMetaData::KabDatabaseMetaData(KabConnection
* _pCon
)
51 : m_xConnection(_pCon
),
52 m_bUseCatalog(sal_True
)
54 OSL_ENSURE(_pCon
,"KabDatabaseMetaData::KabDatabaseMetaData: No connection set!");
56 osl_incrementInterlockedCount( &m_refCount
);
57 m_bUseCatalog
= !(usesLocalFiles() || usesLocalFilePerTable());
58 osl_decrementInterlockedCount( &m_refCount
);
60 // -------------------------------------------------------------------------
61 KabDatabaseMetaData::~KabDatabaseMetaData()
64 // -------------------------------------------------------------------------
65 const ::rtl::OUString
& KabDatabaseMetaData::getAddressBookTableName()
67 static const ::rtl::OUString aAddressBookTableName
68 (::rtl::OUString::createFromAscii( i18n("Address Book") ));
70 return aAddressBookTableName
;
72 // -------------------------------------------------------------------------
73 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getCatalogSeparator( ) throw(SQLException
, RuntimeException
)
77 { // do some special here for you database
82 // -------------------------------------------------------------------------
83 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
85 sal_Int32 nValue
= 0; // 0 means no limit
88 // -------------------------------------------------------------------------
89 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
91 sal_Int32 nValue
= 0; // 0 means no limit
94 // -------------------------------------------------------------------------
95 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
97 sal_Int32 nValue
= 0; // 0 means no limit
100 // -------------------------------------------------------------------------
101 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
103 sal_Int32 nValue
= 0; // 0 means no limit
106 // -------------------------------------------------------------------------
107 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
109 sal_Int32 nValue
= 0; // 0 means no limit
112 // -------------------------------------------------------------------------
113 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
115 sal_Int32 nValue
= 0; // 0 means no limit
118 // -------------------------------------------------------------------------
119 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
121 sal_Int32 nValue
= 0; // 0 means no limit
124 // -------------------------------------------------------------------------
125 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
127 sal_Int32 nValue
= 0; // 0 means no limit
130 // -------------------------------------------------------------------------
131 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
133 sal_Int32 nValue
= 0; // 0 means no limit
136 // -------------------------------------------------------------------------
137 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
139 sal_Int32 nValue
= 0; // 0 means no limit
142 // -------------------------------------------------------------------------
143 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
145 sal_Int32 nValue
= 0; // 0 means no limit
148 // -------------------------------------------------------------------------
149 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException
, RuntimeException
)
151 // MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement,
152 // currently, the resultset/statement implementations can cope with one table only
153 sal_Int32 nValue
= 1;
156 // -------------------------------------------------------------------------
157 sal_Bool SAL_CALL
KabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
161 // -------------------------------------------------------------------------
162 sal_Bool SAL_CALL
KabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
166 // -------------------------------------------------------------------------
167 sal_Bool SAL_CALL
KabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
171 // -------------------------------------------------------------------------
172 sal_Bool SAL_CALL
KabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
176 // -------------------------------------------------------------------------
177 sal_Bool SAL_CALL
KabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
181 // -------------------------------------------------------------------------
182 sal_Bool SAL_CALL
KabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
186 // -------------------------------------------------------------------------
187 sal_Bool SAL_CALL
KabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
191 // -------------------------------------------------------------------------
192 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException
, RuntimeException
)
196 // -------------------------------------------------------------------------
197 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException
, RuntimeException
)
201 // -------------------------------------------------------------------------
202 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
204 sal_Int32 nValue
= 0; // 0 means no limit
207 // -------------------------------------------------------------------------
208 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
212 // -------------------------------------------------------------------------
213 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
215 ::rtl::OUString aVal
;
221 // -------------------------------------------------------------------------
222 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException
, RuntimeException
)
224 // normally this is "
225 ::rtl::OUString aVal
= ::rtl::OUString::createFromAscii("\"");
228 // -------------------------------------------------------------------------
229 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
231 ::rtl::OUString aVal
;
234 // -------------------------------------------------------------------------
235 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
239 // -------------------------------------------------------------------------
240 sal_Bool SAL_CALL
KabDatabaseMetaData::isCatalogAtStart( ) throw(SQLException
, RuntimeException
)
242 sal_Bool bValue
= sal_False
;
248 // -------------------------------------------------------------------------
249 sal_Bool SAL_CALL
KabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
253 // -------------------------------------------------------------------------
254 sal_Bool SAL_CALL
KabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
258 // -------------------------------------------------------------------------
259 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
263 // -------------------------------------------------------------------------
264 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
268 // -------------------------------------------------------------------------
269 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
273 // -------------------------------------------------------------------------
274 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
278 // -------------------------------------------------------------------------
279 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
283 // -------------------------------------------------------------------------
284 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
288 // -------------------------------------------------------------------------
289 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
293 // -------------------------------------------------------------------------
294 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
298 // -------------------------------------------------------------------------
299 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
) throw(SQLException
, RuntimeException
)
303 // -------------------------------------------------------------------------
304 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException
, RuntimeException
)
308 // -------------------------------------------------------------------------
309 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
313 // -------------------------------------------------------------------------
314 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
316 return sal_True
; // should be supported at least
318 // -------------------------------------------------------------------------
319 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
323 // -------------------------------------------------------------------------
324 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
328 // -------------------------------------------------------------------------
329 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException
, RuntimeException
)
333 // -------------------------------------------------------------------------
334 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException
, RuntimeException
)
338 // -------------------------------------------------------------------------
339 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
343 // -------------------------------------------------------------------------
344 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException
, RuntimeException
)
348 // -------------------------------------------------------------------------
349 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
353 // -------------------------------------------------------------------------
354 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxStatements( ) throw(SQLException
, RuntimeException
)
356 sal_Int32 nValue
= 0; // 0 means no limit
359 // -------------------------------------------------------------------------
360 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
362 sal_Int32 nValue
= 0; // 0 means no limit
365 // -------------------------------------------------------------------------
366 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
368 sal_Int32 nValue
= 0; // 0 means no limit
371 // -------------------------------------------------------------------------
372 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
376 // -------------------------------------------------------------------------
377 sal_Bool SAL_CALL
KabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
381 // -------------------------------------------------------------------------
382 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
386 // -------------------------------------------------------------------------
387 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
391 // -------------------------------------------------------------------------
392 sal_Bool SAL_CALL
KabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
396 // -------------------------------------------------------------------------
397 sal_Bool SAL_CALL
KabDatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
)
399 // for the moment, we have read-only addresses, but this might change in the future
402 // -------------------------------------------------------------------------
403 sal_Bool SAL_CALL
KabDatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
407 // -------------------------------------------------------------------------
408 sal_Bool SAL_CALL
KabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
412 // -------------------------------------------------------------------------
413 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
417 // -------------------------------------------------------------------------
418 sal_Bool SAL_CALL
KabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
422 // -------------------------------------------------------------------------
423 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
427 // -------------------------------------------------------------------------
428 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
432 // -------------------------------------------------------------------------
433 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsConvert( sal_Int32
, sal_Int32
) throw(SQLException
, RuntimeException
)
437 // -------------------------------------------------------------------------
438 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
442 // -------------------------------------------------------------------------
443 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
447 // -------------------------------------------------------------------------
448 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
452 // -------------------------------------------------------------------------
453 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
457 // -------------------------------------------------------------------------
458 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
462 // -------------------------------------------------------------------------
463 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
467 // -------------------------------------------------------------------------
468 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
472 // -------------------------------------------------------------------------
473 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
477 // -------------------------------------------------------------------------
478 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
482 // -------------------------------------------------------------------------
483 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
487 // -------------------------------------------------------------------------
488 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
492 // -------------------------------------------------------------------------
493 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
497 // -------------------------------------------------------------------------
498 sal_Bool SAL_CALL
KabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
502 // -------------------------------------------------------------------------
503 sal_Bool SAL_CALL
KabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
507 // -------------------------------------------------------------------------
508 sal_Bool SAL_CALL
KabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
512 // -------------------------------------------------------------------------
513 sal_Bool SAL_CALL
KabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
517 // -------------------------------------------------------------------------
518 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
522 // -------------------------------------------------------------------------
523 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
527 // -------------------------------------------------------------------------
528 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
532 // -------------------------------------------------------------------------
533 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
537 // -------------------------------------------------------------------------
538 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
542 // -------------------------------------------------------------------------
543 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
547 // -------------------------------------------------------------------------
548 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
552 // -------------------------------------------------------------------------
553 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
557 // -------------------------------------------------------------------------
558 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
562 // -------------------------------------------------------------------------
563 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
567 // -------------------------------------------------------------------------
568 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
570 // if someday we support more than the default address book,
571 // this method should return the URL which was used to create it
572 ::rtl::OUString aValue
= ::rtl::OUString::createFromAscii("sdbc:address:kab:");
575 // -------------------------------------------------------------------------
576 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
578 ::rtl::OUString aValue
;
581 // -------------------------------------------------------------------------
582 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
584 ::rtl::OUString aValue
= ::rtl::OUString::createFromAscii("kab");
587 // -------------------------------------------------------------------------
588 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
)
590 ::rtl::OUString aValue
= ::rtl::OUString::createFromAscii(KAB_DRIVER_VERSION
);
593 // -------------------------------------------------------------------------
594 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
596 ::rtl::OUString aValue
;
599 // -------------------------------------------------------------------------
600 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
602 ::rtl::OUString aValue
;
605 // -------------------------------------------------------------------------
606 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
608 ::rtl::OUString aValue
;
611 // -------------------------------------------------------------------------
612 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
614 ::rtl::OUString aValue
;
617 // -------------------------------------------------------------------------
618 sal_Int32 SAL_CALL
KabDatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
620 return KAB_DRIVER_VERSION_MAJOR
;
622 // -------------------------------------------------------------------------
623 sal_Int32 SAL_CALL
KabDatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
625 return TransactionIsolation::NONE
;
627 // -------------------------------------------------------------------------
628 sal_Int32 SAL_CALL
KabDatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
630 return KAB_DRIVER_VERSION_MINOR
;
632 // -------------------------------------------------------------------------
633 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
635 ::rtl::OUString aValue
;
638 // -------------------------------------------------------------------------
639 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
641 ::rtl::OUString aValue
;
644 // -------------------------------------------------------------------------
645 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
647 return ::rtl::OUString();
649 // -------------------------------------------------------------------------
650 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
652 return ::rtl::OUString();
654 // -------------------------------------------------------------------------
655 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
657 return ::rtl::OUString();
659 // -------------------------------------------------------------------------
660 ::rtl::OUString SAL_CALL
KabDatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
662 return ::rtl::OUString();
664 // -------------------------------------------------------------------------
665 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
669 // -------------------------------------------------------------------------
670 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
674 // -------------------------------------------------------------------------
675 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
679 // -------------------------------------------------------------------------
680 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
684 // -------------------------------------------------------------------------
685 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
689 // -------------------------------------------------------------------------
690 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
692 sal_Int32 nValue
= 0; // 0 means no limit
695 // -------------------------------------------------------------------------
696 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
698 sal_Int32 nValue
= 0; // 0 means no limit
701 // -------------------------------------------------------------------------
702 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
704 sal_Int32 nValue
= 0; // 0 means no limit
707 // -------------------------------------------------------------------------
708 sal_Int32 SAL_CALL
KabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
710 sal_Int32 nValue
= 0; // 0 means no limit
713 // -------------------------------------------------------------------------
714 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsResultSetType( sal_Int32 setType
) throw(SQLException
, RuntimeException
)
718 case ResultSetType::FORWARD_ONLY
:
719 case ResultSetType::SCROLL_INSENSITIVE
:
724 // -------------------------------------------------------------------------
725 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType
, sal_Int32
) throw(SQLException
, RuntimeException
)
729 case ResultSetType::FORWARD_ONLY
:
730 case ResultSetType::SCROLL_INSENSITIVE
:
735 // -------------------------------------------------------------------------
736 sal_Bool SAL_CALL
KabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
740 // -------------------------------------------------------------------------
741 sal_Bool SAL_CALL
KabDatabaseMetaData::ownDeletesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
745 // -------------------------------------------------------------------------
746 sal_Bool SAL_CALL
KabDatabaseMetaData::ownInsertsAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
750 // -------------------------------------------------------------------------
751 sal_Bool SAL_CALL
KabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
755 // -------------------------------------------------------------------------
756 sal_Bool SAL_CALL
KabDatabaseMetaData::othersDeletesAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
760 // -------------------------------------------------------------------------
761 sal_Bool SAL_CALL
KabDatabaseMetaData::othersInsertsAreVisible( sal_Int32
) throw(SQLException
, RuntimeException
)
765 // -------------------------------------------------------------------------
766 sal_Bool SAL_CALL
KabDatabaseMetaData::updatesAreDetected( sal_Int32
) throw(SQLException
, RuntimeException
)
770 // -------------------------------------------------------------------------
771 sal_Bool SAL_CALL
KabDatabaseMetaData::deletesAreDetected( sal_Int32
) throw(SQLException
, RuntimeException
)
775 // -------------------------------------------------------------------------
776 sal_Bool SAL_CALL
KabDatabaseMetaData::insertsAreDetected( sal_Int32
) throw(SQLException
, RuntimeException
)
780 // -------------------------------------------------------------------------
781 sal_Bool SAL_CALL
KabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
785 // -------------------------------------------------------------------------
786 Reference
< XConnection
> SAL_CALL
KabDatabaseMetaData::getConnection( ) throw(SQLException
, RuntimeException
)
788 return (Reference
< XConnection
>) m_xConnection
.get();
790 // -------------------------------------------------------------------------
791 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
793 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes
);
794 Reference
< XResultSet
> xRef
= pResult
;
796 static ODatabaseMetaDataResultSet::ORows aRows
;
797 static const ::rtl::OUString
aTable(::rtl::OUString::createFromAscii("TABLE"));
801 ODatabaseMetaDataResultSet::ORow
aRow(2);
802 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
803 aRow
[1] = new ORowSetValueDecorator(aTable
);
804 aRows
.push_back(aRow
);
806 pResult
->setRows(aRows
);
809 // -------------------------------------------------------------------------
810 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getTypeInfo( ) throw(SQLException
, RuntimeException
)
812 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo
);
813 Reference
< XResultSet
> xRef
= pResult
;
815 static ODatabaseMetaDataResultSet::ORows aRows
;
818 ODatabaseMetaDataResultSet::ORow
aRow(19);
820 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
821 aRow
[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
822 aRow
[2] = new ORowSetValueDecorator(DataType::CHAR
);
823 aRow
[3] = new ORowSetValueDecorator((sal_Int32
) 254);
824 aRow
[4] = ODatabaseMetaDataResultSet::getQuoteValue();
825 aRow
[5] = ODatabaseMetaDataResultSet::getQuoteValue();
826 aRow
[6] = ODatabaseMetaDataResultSet::getEmptyValue();
827 aRow
[7] = new ORowSetValueDecorator((sal_Int32
) ColumnValue::NULLABLE
);
828 aRow
[8] = ODatabaseMetaDataResultSet::get1Value();
829 aRow
[9] = new ORowSetValueDecorator((sal_Int32
) ColumnSearch::CHAR
);
830 aRow
[10] = ODatabaseMetaDataResultSet::get1Value();
831 aRow
[11] = ODatabaseMetaDataResultSet::get0Value();
832 aRow
[12] = ODatabaseMetaDataResultSet::get0Value();
833 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
834 aRow
[14] = ODatabaseMetaDataResultSet::get0Value();
835 aRow
[15] = ODatabaseMetaDataResultSet::get0Value();
836 aRow
[16] = ODatabaseMetaDataResultSet::getEmptyValue();
837 aRow
[17] = ODatabaseMetaDataResultSet::getEmptyValue();
838 aRow
[18] = new ORowSetValueDecorator((sal_Int32
) 10);
839 aRows
.push_back(aRow
);
840 // Much more types might appear in KDE address books
843 pResult
->setRows(aRows
);
846 // -------------------------------------------------------------------------
847 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getCatalogs( ) throw(SQLException
, RuntimeException
)
849 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs
);
851 // -----------------------------------------------------------------------------
852 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getSchemas( ) throw(SQLException
, RuntimeException
)
854 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas
);
856 // -------------------------------------------------------------------------
857 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getColumnPrivileges(
858 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
&,
859 const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
861 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges
);
863 // -------------------------------------------------------------------------
864 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getColumns(
866 const ::rtl::OUString
&,
867 const ::rtl::OUString
& tableNamePattern
,
868 const ::rtl::OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
870 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns
);
871 Reference
< XResultSet
> xRef
= pResult
;
873 ODatabaseMetaDataResultSet::ORows aRows
;
875 if (match(tableNamePattern
, getAddressBookTableName(), '\0'))
877 ODatabaseMetaDataResultSet::ORow
aRow(19);
879 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
880 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
881 aRow
[2] = ODatabaseMetaDataResultSet::getEmptyValue();
882 aRow
[3] = new ORowSetValueDecorator(getAddressBookTableName());
883 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
884 aRow
[9] = ODatabaseMetaDataResultSet::get0Value();
885 aRow
[10] = new ORowSetValueDecorator((sal_Int32
) 10);
886 aRow
[11] = ODatabaseMetaDataResultSet::get1Value();
887 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
888 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
889 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
890 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
891 aRow
[16] = new ORowSetValueDecorator((sal_Int32
) 254);
892 aRow
[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
894 sal_Int32 nPosition
= 1;
896 ::rtl::OUString sName
;
898 aQtName
= ::KABC::Addressee::revisionLabel();
899 sName
= (const sal_Unicode
*) aQtName
.ucs2();
900 if (match(columnNamePattern
, sName
, '\0'))
902 aRow
[4] = new ORowSetValueDecorator(sName
);
903 aRow
[5] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
904 aRow
[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
905 aRow
[17] = new ORowSetValueDecorator(nPosition
++);
906 aRows
.push_back(aRow
);
909 ::KABC::Field::List aFields
= ::KABC::Field::allFields();
910 ::KABC::Field::List::iterator aField
;
912 for ( aField
= aFields
.begin();
913 aField
!= aFields
.end();
914 ++aField
, ++nPosition
)
916 aQtName
= (*aField
)->label();
917 sName
= (const sal_Unicode
*) aQtName
.ucs2();
918 if (match(columnNamePattern
, sName
, '\0'))
920 aRow
[4] = new ORowSetValueDecorator(sName
);
921 aRow
[5] = new ORowSetValueDecorator(DataType::CHAR
);
922 aRow
[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
923 aRow
[7] = new ORowSetValueDecorator((sal_Int32
) 256);
924 // Might be VARCHAR and not CHAR[256]...
925 aRow
[17] = new ORowSetValueDecorator(nPosition
);
926 aRows
.push_back(aRow
);
930 pResult
->setRows(aRows
);
933 // -------------------------------------------------------------------------
934 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getTables(
936 const ::rtl::OUString
&,
937 const ::rtl::OUString
&,
938 const Sequence
< ::rtl::OUString
>& types
) throw(SQLException
, RuntimeException
)
940 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables
);
941 Reference
< XResultSet
> xRef
= pResult
;
943 // check whether we have tables in the requested types
944 // for the moment, we answer only the "TABLE" table type
945 // when no types are given at all, we return all the tables
946 static const ::rtl::OUString
aTable(::rtl::OUString::createFromAscii("TABLE"));
947 sal_Bool bTableFound
= sal_False
;
948 const ::rtl::OUString
* p
= types
.getConstArray(),
949 * pEnd
= p
+ types
.getLength();
953 bTableFound
= sal_True
;
955 else while (p
< pEnd
)
957 if (match(*p
, aTable
, '\0'))
959 bTableFound
= sal_True
;
967 static ODatabaseMetaDataResultSet::ORows aRows
;
971 ODatabaseMetaDataResultSet::ORow
aRow(6);
973 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
974 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
975 aRow
[2] = ODatabaseMetaDataResultSet::getEmptyValue();
976 aRow
[3] = new ORowSetValueDecorator(getAddressBookTableName());
977 aRow
[4] = new ORowSetValueDecorator(aTable
);
978 aRow
[5] = ODatabaseMetaDataResultSet::getEmptyValue();
979 aRows
.push_back(aRow
);
981 pResult
->setRows(aRows
);
984 // -------------------------------------------------------------------------
985 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getProcedureColumns(
986 const Any
&, const ::rtl::OUString
&,
987 const ::rtl::OUString
&, const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
989 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns
);
991 // -------------------------------------------------------------------------
992 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getProcedures(
993 const Any
&, const ::rtl::OUString
&,
994 const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
996 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures
);
998 // -------------------------------------------------------------------------
999 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getVersionColumns(
1000 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
& table
) throw(SQLException
, RuntimeException
)
1002 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns
);
1004 Reference
< XResultSet
> xRef
= pResult
;
1006 ODatabaseMetaDataResultSet::ORows aRows
;
1008 if (table
== getAddressBookTableName())
1010 ODatabaseMetaDataResultSet::ORow
aRow( 9 );
1011 QString aQtName
= ::KABC::Addressee::revisionLabel();
1012 ::rtl::OUString sName
= (const sal_Unicode
*) aQtName
.ucs2();
1014 aRow
[0] = ODatabaseMetaDataResultSet::getEmptyValue();
1015 aRow
[1] = ODatabaseMetaDataResultSet::getEmptyValue();
1017 aRow
[2] = new ORowSetValueDecorator(sName
);
1018 aRow
[3] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
1019 aRow
[4] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
1021 aRow
[5] = ODatabaseMetaDataResultSet::getEmptyValue();
1022 aRow
[6] = ODatabaseMetaDataResultSet::getEmptyValue();
1023 aRow
[7] = ODatabaseMetaDataResultSet::getEmptyValue();
1024 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
1026 aRows
.push_back(aRow
);
1028 pResult
->setRows(aRows
);
1031 // -------------------------------------------------------------------------
1032 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getExportedKeys(
1033 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
1035 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys
);
1037 // -------------------------------------------------------------------------
1038 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getImportedKeys(
1039 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
1041 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys
);
1043 // -------------------------------------------------------------------------
1044 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getPrimaryKeys(
1045 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
1047 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys
);
1049 // -------------------------------------------------------------------------
1050 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getIndexInfo(
1051 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
&,
1052 sal_Bool
, sal_Bool
) throw(SQLException
, RuntimeException
)
1054 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo
);
1056 // -------------------------------------------------------------------------
1057 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getBestRowIdentifier(
1058 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
&, sal_Int32
,
1059 sal_Bool
) throw(SQLException
, RuntimeException
)
1061 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier
);
1063 // -------------------------------------------------------------------------
1064 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getTablePrivileges(
1065 const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
1067 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges
);
1069 // -------------------------------------------------------------------------
1070 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getCrossReference(
1071 const Any
&, const ::rtl::OUString
&,
1072 const ::rtl::OUString
&, const Any
&,
1073 const ::rtl::OUString
&, const ::rtl::OUString
& ) throw(SQLException
, RuntimeException
)
1075 return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference
);
1077 // -------------------------------------------------------------------------
1078 Reference
< XResultSet
> SAL_CALL
KabDatabaseMetaData::getUDTs( const Any
&, const ::rtl::OUString
&, const ::rtl::OUString
&, const Sequence
< sal_Int32
>& ) throw(SQLException
, RuntimeException
)
1080 OSL_ENSURE(0,"Not implemented yet!");
1081 throw SQLException();
1083 // -----------------------------------------------------------------------------