Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / connectivity / source / drivers / evoab2 / NDatabaseMetaData.cxx
blob4589a636d9514af1c97f84ef3017d88d88fbe21b
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 .
20 #include "NDatabaseMetaData.hxx"
21 #include <com/sun/star/sdbc/DataType.hpp>
22 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
23 #include <connectivity/dbexception.hxx>
24 #include <connectivity/FValue.hxx>
25 #include <com/sun/star/sdbc/ColumnSearch.hpp>
26 #include <rtl/ref.hxx>
28 #include <cstddef>
29 #include <string.h>
30 #include <string_view>
32 #include "EApi.h"
34 using namespace connectivity::evoab;
35 using namespace connectivity;
36 using namespace com::sun::star::uno;
37 using namespace com::sun::star::lang;
38 using namespace com::sun::star::beans;
39 using namespace com::sun::star::sdbc;
40 using namespace com::sun::star::sdbcx;
42 namespace
44 bool equal(const char *str1, const char *str2)
46 return str1 == nullptr || str2 == nullptr ? str1 == str2 : strcmp(str1, str2) == 0;
50 namespace connectivity::evoab
52 sal_Int32 const s_nCOLUMN_SIZE = 256;
53 sal_Int32 const s_nDECIMAL_DIGITS = 0;
54 sal_Int32 const s_nNULLABLE = 1;
55 sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
57 static ColumnProperty **pFields=nullptr;
58 static guint nFields = 0;
60 static const char *pDenyList[] =
62 "id",
63 "list-show-addresses",
64 "address-label-home",
65 "address-label-work",
66 "address-label-other"
69 const SplitEvoColumns* get_evo_addr()
71 static const SplitEvoColumns evo_addr[] = {
72 {"addr-line1",DEFAULT_ADDR_LINE1},{"addr-line2",DEFAULT_ADDR_LINE2},{"city",DEFAULT_CITY},{"state",DEFAULT_STATE},{"country",DEFAULT_COUNTRY},{"zip",DEFAULT_ZIP},
73 {"work-addr-line1",WORK_ADDR_LINE1},{"work-addr-line2",WORK_ADDR_LINE2},{"work-city",WORK_CITY},{"work-state",WORK_STATE},{"work-country",WORK_COUNTRY},{"work-zip",WORK_ZIP},
74 {"home-addr-line1",HOME_ADDR_LINE1},{"home-addr-line2",HOME_ADDR_LINE2},{"home-addr-City",HOME_CITY},{"home-state",HOME_STATE},{"home-country",HOME_COUNTRY},{"home-zip",HOME_ZIP},
75 {"other-addr-line1",OTHER_ADDR_LINE1},{"other-addr-line2",OTHER_ADDR_LINE2},{"other-addr-city",OTHER_CITY},{"other-addr-state",OTHER_STATE},{"other-addr-country",OTHER_COUNTRY},{"other-addr-zip",OTHER_ZIP}
77 return evo_addr;
80 static void
81 splitColumn (ColumnProperty **pToBeFields)
83 const SplitEvoColumns* evo_addr( get_evo_addr() );
84 for (int i = 0; i < OTHER_ZIP; i++)
86 pToBeFields[nFields] = g_new0(ColumnProperty,1);
87 pToBeFields[nFields]->bIsSplittedValue = true;
88 pToBeFields[nFields]->pField = g_param_spec_ref(g_param_spec_string (evo_addr[i].pColumnName,evo_addr[i].pColumnName,"",nullptr,G_PARAM_WRITABLE));
89 nFields++;
93 static void
94 initFields()
96 if( pFields )
97 return;
99 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
100 if( pFields )
101 return;
103 guint nProps;
104 ColumnProperty **pToBeFields;
105 GParamSpec **pProps;
106 nFields = 0;
107 pProps = g_object_class_list_properties
108 ( static_cast<GObjectClass *>(g_type_class_ref( E_TYPE_CONTACT )),
109 &nProps );
110 pToBeFields = g_new0(ColumnProperty *, (nProps + OTHER_ZIP)/* new column(s)*/ );
111 for ( guint i = 0; i < nProps; i++ )
113 switch (pProps[i]->value_type)
115 case G_TYPE_STRING:
116 case G_TYPE_BOOLEAN:
118 bool bAdd = true;
119 const char *pName = g_param_spec_get_name( pProps[i] );
120 for (unsigned int j = 0; j < G_N_ELEMENTS( pDenyList ); j++ )
122 if( !strcmp( pDenyList[j], pName ) )
124 bAdd = false;
125 break;
128 if( bAdd )
130 pToBeFields[nFields]= g_new0(ColumnProperty,1);
131 pToBeFields[nFields]->bIsSplittedValue=false;
132 pToBeFields[ nFields++ ]->pField = g_param_spec_ref( pProps[i] );
134 break;
136 default:
137 break;
141 splitColumn(pToBeFields);
142 pFields = pToBeFields;
146 const ColumnProperty *
147 getField(guint n)
149 initFields();
150 if( n < nFields )
151 return pFields[n];
152 else
153 return nullptr;
156 GType
157 getGFieldType( guint nCol )
159 initFields();
161 if ( nCol < nFields )
162 return pFields[nCol]->pField->value_type;
163 return G_TYPE_STRING;
166 sal_Int32
167 getFieldType( guint nCol )
169 sal_Int32 nType = getGFieldType( nCol );
170 return nType == G_TYPE_STRING ? DataType::VARCHAR : DataType::BIT;
173 guint findEvoabField(std::u16string_view aColName)
175 guint nRet = guint(-1);
176 bool bFound = false;
177 initFields();
178 for (guint i=0;(i < nFields) && !bFound;i++)
180 OUString aName = getFieldName(i);
181 if (aName == aColName)
183 nRet = i;
184 bFound = true;
187 return nRet;
190 OUString
191 getFieldTypeName( guint nCol )
193 switch( getFieldType( nCol ) )
195 case DataType::BIT:
196 return "BIT";
197 case DataType::VARCHAR:
198 return "VARCHAR";
199 default:
200 break;
202 return OUString();
205 OUString
206 getFieldName( guint nCol )
208 const GParamSpec *pSpec = getField( nCol )->pField;
209 OUString aName;
210 initFields();
212 if( pSpec )
214 aName = OStringToOUString( g_param_spec_get_name( const_cast<GParamSpec *>(pSpec) ),
215 RTL_TEXTENCODING_UTF8 );
216 aName = aName.replace( '-', '_' );
218 return aName;
221 void
222 free_column_resources()
224 for (int i=nFields-1;i > 0;i--)
226 if (pFields && pFields[i] )
228 if (pFields[i]->pField)
229 g_param_spec_unref(pFields[i]->pField);
230 g_free(pFields[i]);
233 if(pFields)
235 g_free(pFields);
236 pFields=nullptr;
245 OEvoabDatabaseMetaData::OEvoabDatabaseMetaData(OEvoabConnection* _pCon)
246 : ::connectivity::ODatabaseMetaDataBase(_pCon, _pCon->getConnectionInfo())
247 ,m_pConnection(_pCon)
249 OSL_ENSURE(m_pConnection,"OEvoabDatabaseMetaData::OEvoabDatabaseMetaData: No connection set!");
251 OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData()
256 Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns(
257 const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*tableNamePattern*/,
258 const OUString& columnNamePattern )
260 // this returns an empty resultset where the column-names are already set
261 // in special the metadata of the resultset already returns the right columns
262 rtl::Reference<ODatabaseMetaDataResultSet> pResultSet = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns );
264 ODatabaseMetaDataResultSet::ORows aRows;
265 ODatabaseMetaDataResultSet::ORow aRow(19);
267 // ****************************************************
268 // Some entries in a row never change, so set them now
269 // ****************************************************
271 // Catalog
272 aRow[1] = new ORowSetValueDecorator(OUString());
273 // Schema
274 aRow[2] = new ORowSetValueDecorator(OUString());
275 // COLUMN_SIZE
276 aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
277 // BUFFER_LENGTH, not used
278 aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
279 // DECIMAL_DIGITS.
280 aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
281 // NUM_PREC_RADIX
282 aRow[10] = new ORowSetValueDecorator(sal_Int32(10));
283 // NULLABLE
284 aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
285 // REMARKS
286 aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
287 // COLUMN_DEF, not used
288 aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
289 // SQL_DATA_TYPE, not used
290 aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
291 // SQL_DATETIME_SUB, not used
292 aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
293 // CHAR_OCTET_LENGTH, refer to [5]
294 aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
295 // IS_NULLABLE
296 aRow[18] = new ORowSetValueDecorator(OUString("YES"));
299 aRow[3] = new ORowSetValueDecorator(OUString("TABLE"));
300 ::osl::MutexGuard aGuard( m_aMutex );
302 initFields();
303 for (guint i = 0; i < nFields; i++)
305 if( match( columnNamePattern, getFieldName( i ), '\0' ) )
307 aRow[5] = new ORowSetValueDecorator( static_cast<sal_Int16>( getFieldType( i ) ) );
308 aRow[6] = new ORowSetValueDecorator( getFieldTypeName( i ) );
310 // COLUMN_NAME
311 aRow[4] = new ORowSetValueDecorator( getFieldName( i ) );
312 // ORDINAL_POSITION
313 aRow[17] = new ORowSetValueDecorator( sal_Int32(i) );
314 aRows.push_back( aRow );
318 pResultSet->setRows(std::move(aRows));
320 return pResultSet;
323 OUString OEvoabDatabaseMetaData::impl_getCatalogSeparator_throw( )
325 return OUString();
328 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxBinaryLiteralLength( )
330 return 0;// 0 means no limit
333 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxRowSize( )
335 return 0;// 0 means no limit
338 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxCatalogNameLength( )
340 return 0;// 0 means no limit
343 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxCharLiteralLength( )
345 return 0;// 0 means no limit
348 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnNameLength( )
350 return 0;// 0 means no limit
353 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInIndex( )
355 return 0;// 0 means no limit
358 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxCursorNameLength( )
360 return 0;// 0 means no limit
363 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxConnections( )
365 return 0;// 0 means no limit
368 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInTable( )
370 return 0;// 0 means no limit
373 sal_Int32 OEvoabDatabaseMetaData::impl_getMaxStatements_throw( )
375 return 0;// 0 means no limit
378 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxTableNameLength( )
380 return 0;// 0 means no limit
383 sal_Int32 OEvoabDatabaseMetaData::impl_getMaxTablesInSelect_throw( )
385 // We only support a single table
386 return 1;
390 sal_Bool SAL_CALL OEvoabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
392 return false;
395 sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
397 return false;
400 sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesLowerCaseIdentifiers( )
402 return false;
405 bool OEvoabDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
407 return false;
410 sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesMixedCaseIdentifiers( )
412 return false;
415 sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
417 return false;
420 sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesUpperCaseIdentifiers( )
422 return false;
425 bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
427 return false;
430 bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
432 return false;
435 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxIndexLength( )
437 return 0;// 0 means no limit
440 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsNonNullableColumns( )
442 return false;
445 OUString SAL_CALL OEvoabDatabaseMetaData::getCatalogTerm( )
447 return OUString();
450 OUString OEvoabDatabaseMetaData::impl_getIdentifierQuoteString_throw( )
452 // normally this is "
453 return "\"";
456 OUString SAL_CALL OEvoabDatabaseMetaData::getExtraNameCharacters( )
458 return OUString();
461 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsDifferentTableCorrelationNames( )
463 return false;
466 bool OEvoabDatabaseMetaData::impl_isCatalogAtStart_throw( )
468 return false;
471 sal_Bool SAL_CALL OEvoabDatabaseMetaData::dataDefinitionIgnoredInTransactions( )
473 return true;
476 sal_Bool SAL_CALL OEvoabDatabaseMetaData::dataDefinitionCausesTransactionCommit( )
478 return true;
481 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsDataManipulationTransactionsOnly( )
483 return true;
486 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
488 return true;
491 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsPositionedDelete( )
493 return false;
496 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsPositionedUpdate( )
498 return false;
501 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenStatementsAcrossRollback( )
503 return false;
506 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenStatementsAcrossCommit( )
508 return false;
511 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenCursorsAcrossCommit( )
513 return false;
516 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenCursorsAcrossRollback( )
518 return false;
521 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ )
523 return false;
526 bool OEvoabDatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
528 return false;
531 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsANSI92FullSQL( )
533 return false;
536 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsANSI92EntryLevelSQL( )
538 return true; // should be supported at least
541 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsIntegrityEnhancementFacility( )
543 return false;
546 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSchemasInIndexDefinitions( )
548 return false;
551 bool OEvoabDatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
553 return false;
556 bool OEvoabDatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
558 return false;
561 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCatalogsInIndexDefinitions( )
563 return false;
566 bool OEvoabDatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
568 return false;
571 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOuterJoins( )
573 return false;
576 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxStatementLength( )
578 return 0;// 0 means no limit
581 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxProcedureNameLength( )
583 return 0;// 0 means no limit
586 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxSchemaNameLength( )
588 return 0;// 0 means no limit
591 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTransactions( )
593 return false;
596 sal_Bool SAL_CALL OEvoabDatabaseMetaData::allProceduresAreCallable( )
598 return false;
601 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsStoredProcedures( )
603 return false;
606 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSelectForUpdate( )
608 return false;
611 sal_Bool SAL_CALL OEvoabDatabaseMetaData::allTablesAreSelectable( )
613 // We allow you to select from any table.
614 return true;
617 sal_Bool SAL_CALL OEvoabDatabaseMetaData::isReadOnly( )
619 // For now definitely read-only, no support for update/delete
620 return true;
623 sal_Bool SAL_CALL OEvoabDatabaseMetaData::usesLocalFiles( )
625 return false;
628 sal_Bool SAL_CALL OEvoabDatabaseMetaData::usesLocalFilePerTable( )
630 return false;
633 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTypeConversion( )
635 return false;
638 sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullPlusNonNullIsNull( )
640 return false;
643 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsColumnAliasing( )
645 // todo add Support for this.
646 return false;
649 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTableCorrelationNames( )
651 return false;
654 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ )
656 return false;
659 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsExpressionsInOrderBy( )
661 return false;
664 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsGroupBy( )
666 return false;
669 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsGroupByBeyondSelect( )
671 return false;
674 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsGroupByUnrelated( )
676 return false;
679 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMultipleTransactions( )
681 return false;
684 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMultipleResultSets( )
686 return false;
689 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsLikeEscapeClause( )
691 return false;
694 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOrderByUnrelated( )
696 return false;
699 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsUnion( )
701 return false;
704 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsUnionAll( )
706 return false;
709 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMixedCaseIdentifiers( )
711 return false;
714 bool OEvoabDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
716 // Any case may be used
717 return true;
720 sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedAtEnd( )
722 return false;
725 sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedAtStart( )
727 return true;
730 sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedHigh( )
732 return false;
735 sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedLow( )
737 return true;
740 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSchemasInProcedureCalls( )
742 return false;
745 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
747 return false;
750 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCatalogsInProcedureCalls( )
752 return false;
755 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
757 return false;
760 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCorrelatedSubqueries( )
762 return false;
765 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInComparisons( )
767 return false;
770 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInExists( )
772 return false;
775 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInIns( )
777 return false;
780 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInQuantifieds( )
782 return false;
785 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsANSI92IntermediateSQL( )
787 return false;
790 OUString SAL_CALL OEvoabDatabaseMetaData::getURL( )
792 ::osl::MutexGuard aGuard( m_aMutex );
794 return m_pConnection->getURL();
797 OUString SAL_CALL OEvoabDatabaseMetaData::getUserName( )
799 return OUString();
802 OUString SAL_CALL OEvoabDatabaseMetaData::getDriverName( )
804 return OUString();
807 OUString SAL_CALL OEvoabDatabaseMetaData::getDriverVersion()
809 return "1";
812 OUString SAL_CALL OEvoabDatabaseMetaData::getDatabaseProductVersion( )
814 return "0";
817 OUString SAL_CALL OEvoabDatabaseMetaData::getDatabaseProductName( )
819 return OUString();
822 OUString SAL_CALL OEvoabDatabaseMetaData::getProcedureTerm( )
824 return OUString();
827 OUString SAL_CALL OEvoabDatabaseMetaData::getSchemaTerm( )
829 return OUString();
832 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getDriverMajorVersion( )
834 return 1;
837 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getDefaultTransactionIsolation( )
839 return TransactionIsolation::NONE;
842 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getDriverMinorVersion( )
844 return 0;
847 OUString SAL_CALL OEvoabDatabaseMetaData::getSQLKeywords( )
849 return OUString();
852 OUString SAL_CALL OEvoabDatabaseMetaData::getSearchStringEscape( )
854 return OUString();
857 OUString SAL_CALL OEvoabDatabaseMetaData::getStringFunctions( )
859 return OUString();
862 OUString SAL_CALL OEvoabDatabaseMetaData::getTimeDateFunctions( )
864 return OUString();
867 OUString SAL_CALL OEvoabDatabaseMetaData::getSystemFunctions( )
869 return OUString();
872 OUString SAL_CALL OEvoabDatabaseMetaData::getNumericFunctions( )
874 return OUString();
877 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsExtendedSQLGrammar( )
879 return false;
882 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCoreSQLGrammar( )
884 return false;
887 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMinimumSQLGrammar( )
889 return true;
892 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsFullOuterJoins( )
894 return false;
897 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsLimitedOuterJoins( )
899 return false;
902 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInGroupBy( )
904 return 0;// 0 means no limit
907 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInOrderBy( )
909 return 0;// 0 means no limit
912 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInSelect( )
914 return 0;// 0 means no limit
917 sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxUserNameLength( )
919 return 0;// 0 means no limit
922 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ )
924 return false;
927 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ )
929 return false;
932 sal_Bool SAL_CALL OEvoabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ )
934 return false;
937 sal_Bool SAL_CALL OEvoabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ )
939 return false;
942 sal_Bool SAL_CALL OEvoabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ )
944 return false;
947 sal_Bool SAL_CALL OEvoabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ )
949 return false;
952 sal_Bool SAL_CALL OEvoabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ )
954 return false;
957 sal_Bool SAL_CALL OEvoabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ )
959 return false;
962 sal_Bool SAL_CALL OEvoabDatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ )
964 return false;
967 sal_Bool SAL_CALL OEvoabDatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ )
969 return false;
972 sal_Bool SAL_CALL OEvoabDatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ )
974 return false;
977 sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsBatchUpdates( )
979 return false;
982 // here follow all methods which return a resultset
983 // the first methods is an example implementation how to use this resultset
984 // of course you could implement it on your and you should do this because
985 // the general way is more memory expensive
987 Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( )
989 /* Don't need to change as evoab driver supports only table */
991 // there exists no possibility to get table types so we have to check
992 static const std::u16string_view sTableTypes[] =
994 u"TABLE" // Currently we only support a 'TABLE' nothing more complex
996 rtl::Reference<::connectivity::ODatabaseMetaDataResultSet> pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
998 // here we fill the rows which should be visible when ask for data from the resultset returned here
999 auto nNbTypes = std::size(sTableTypes);
1000 ODatabaseMetaDataResultSet::ORows aRows;
1001 for(std::size_t i=0;i < nNbTypes;++i)
1003 // bound row
1004 aRows.push_back( { ODatabaseMetaDataResultSet::getEmptyValue(), new ORowSetValueDecorator(OUString(sTableTypes[i])) });
1006 // here we set the rows at the resultset
1007 pResult->setRows(std::move(aRows));
1008 return pResult;
1011 Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( )
1014 * Return the proper type information required by evo driver
1017 rtl::Reference<ODatabaseMetaDataResultSet> pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
1019 static ODatabaseMetaDataResultSet::ORows aRows = []()
1021 ODatabaseMetaDataResultSet::ORows tmp;
1022 ODatabaseMetaDataResultSet::ORow aRow
1024 ODatabaseMetaDataResultSet::getEmptyValue() ,
1025 new ORowSetValueDecorator(OUString("VARCHAR")) ,
1026 new ORowSetValueDecorator(DataType::VARCHAR) ,
1027 new ORowSetValueDecorator(sal_Int32(s_nCHAR_OCTET_LENGTH)) ,
1028 ODatabaseMetaDataResultSet::getQuoteValue() ,
1029 ODatabaseMetaDataResultSet::getQuoteValue() ,
1030 ODatabaseMetaDataResultSet::getEmptyValue() ,
1031 ODatabaseMetaDataResultSet::get1Value() ,
1032 ODatabaseMetaDataResultSet::get1Value() ,
1033 new ORowSetValueDecorator(sal_Int32(ColumnSearch::FULL)) ,
1034 ODatabaseMetaDataResultSet::get1Value() ,
1035 ODatabaseMetaDataResultSet::get0Value() ,
1036 ODatabaseMetaDataResultSet::get0Value() ,
1037 ODatabaseMetaDataResultSet::getEmptyValue() ,
1038 ODatabaseMetaDataResultSet::get0Value() ,
1039 ODatabaseMetaDataResultSet::get0Value() ,
1040 ODatabaseMetaDataResultSet::getEmptyValue() ,
1041 ODatabaseMetaDataResultSet::getEmptyValue() ,
1042 new ORowSetValueDecorator(sal_Int32(10))
1045 tmp.push_back(aRow);
1047 aRow[1] = new ORowSetValueDecorator(OUString("VARCHAR"));
1048 aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR);
1049 aRow[3] = new ORowSetValueDecorator(sal_Int32(65535));
1050 tmp.push_back(aRow);
1051 return tmp;
1052 }();
1053 pResultSet->setRows(std::move(aRows));
1054 return pResultSet;
1057 bool isSourceBackend(ESource *pSource, const char *backendname)
1059 if (!pSource || !e_source_has_extension (pSource, E_SOURCE_EXTENSION_ADDRESS_BOOK))
1060 return false;
1062 gpointer extension = e_source_get_extension (pSource, E_SOURCE_EXTENSION_ADDRESS_BOOK);
1063 return extension && equal(e_source_backend_get_backend_name (extension), backendname);
1066 Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables(
1067 const Any& /*catalog*/, const OUString& /*schemaPattern*/,
1068 const OUString& /*tableNamePattern*/, const Sequence< OUString >& types )
1070 ::osl::MutexGuard aGuard( m_aMutex );
1072 rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
1074 // check if any type is given
1075 // when no types are given then we have to return all tables e.g. TABLE
1077 static const OUStringLiteral aTable(u"TABLE");
1079 bool bTableFound = true;
1080 sal_Int32 nLength = types.getLength();
1081 if(nLength)
1083 bTableFound = false;
1085 const OUString* pBegin = types.getConstArray();
1086 const OUString* pEnd = pBegin + nLength;
1087 for(;pBegin != pEnd;++pBegin)
1089 if(*pBegin == aTable)
1091 bTableFound = true;
1092 break;
1096 if(!bTableFound)
1097 return pResult;
1099 ODatabaseMetaDataResultSet::ORows aRows;
1101 GList *pSources = e_source_registry_list_sources(get_e_source_registry(), E_SOURCE_EXTENSION_ADDRESS_BOOK);
1103 for (GList* liter = pSources; liter; liter = liter->next)
1105 ESource *pSource = E_SOURCE (liter->data);
1106 bool can = false;
1107 switch (m_pConnection->getSDBCAddressType())
1109 case SDBCAddress::EVO_GWISE:
1110 can = isSourceBackend( pSource, "groupwise"); // not supported in evo/eds 3.6.x+, somehow
1111 break;
1112 case SDBCAddress::EVO_LOCAL:
1113 can = isSourceBackend( pSource, "local");
1114 break;
1115 case SDBCAddress::EVO_LDAP:
1116 can = isSourceBackend( pSource, "ldap");
1117 break;
1118 case SDBCAddress::Unknown:
1119 can = true;
1120 break;
1122 if (!can)
1123 continue;
1125 OUString aHumanName = OStringToOUString( e_source_get_display_name( pSource ),
1126 RTL_TEXTENCODING_UTF8 );
1127 OUString aUID = OStringToOUString( e_source_get_uid( pSource ),
1128 RTL_TEXTENCODING_UTF8 );
1129 ODatabaseMetaDataResultSet::ORow aRow{
1130 ORowSetValueDecoratorRef(),
1131 ORowSetValueDecoratorRef(),
1132 ORowSetValueDecoratorRef(),
1133 new ORowSetValueDecorator(aHumanName), //tablename
1134 new ORowSetValueDecorator(ORowSetValue(aTable)),
1135 new ORowSetValueDecorator(aUID)}; //comment
1136 //I'd prefer to swap the comment and the human name and
1137 //just use e_source_registry_ref_source(get_e_source_registry(), aUID);
1138 //in open book rather than search for the name again
1139 aRows.push_back(aRow);
1142 g_list_foreach (pSources, reinterpret_cast<GFunc>(g_object_unref), nullptr);
1143 g_list_free (pSources);
1145 pResult->setRows(std::move(aRows));
1147 return pResult;
1150 Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getUDTs( const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ )
1152 ::dbtools::throwFeatureNotImplementedSQLException( "XDatabaseMetaDaza::getUDTs", *this );
1153 return nullptr;
1157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */