1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
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>
30 #include <string_view>
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
;
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
[] =
63 "list-show-addresses",
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
}
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
));
99 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
104 ColumnProperty
**pToBeFields
;
107 pProps
= g_object_class_list_properties
108 ( static_cast<GObjectClass
*>(g_type_class_ref( E_TYPE_CONTACT
)),
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
)
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
) )
130 pToBeFields
[nFields
]= g_new0(ColumnProperty
,1);
131 pToBeFields
[nFields
]->bIsSplittedValue
=false;
132 pToBeFields
[ nFields
++ ]->pField
= g_param_spec_ref( pProps
[i
] );
141 splitColumn(pToBeFields
);
142 pFields
= pToBeFields
;
146 const ColumnProperty
*
157 getGFieldType( guint nCol
)
161 if ( nCol
< nFields
)
162 return pFields
[nCol
]->pField
->value_type
;
163 return G_TYPE_STRING
;
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);
178 for (guint i
=0;(i
< nFields
) && !bFound
;i
++)
180 OUString aName
= getFieldName(i
);
181 if (aName
== aColName
)
191 getFieldTypeName( guint nCol
)
193 switch( getFieldType( nCol
) )
197 case DataType::VARCHAR
:
206 getFieldName( guint nCol
)
208 const GParamSpec
*pSpec
= getField( nCol
)->pField
;
214 aName
= OStringToOUString( g_param_spec_get_name( const_cast<GParamSpec
*>(pSpec
) ),
215 RTL_TEXTENCODING_UTF8
);
216 aName
= aName
.replace( '-', '_' );
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
);
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 ODatabaseMetaDataResultSet::ORows
OEvoabDatabaseMetaData::getColumnRows( const OUString
& columnNamePattern
)
258 ODatabaseMetaDataResultSet::ORows aRows
;
259 ODatabaseMetaDataResultSet::ORow
aRow(19);
261 // ****************************************************
262 // Some entries in a row never change, so set them now
263 // ****************************************************
266 aRow
[1] = new ORowSetValueDecorator(OUString());
268 aRow
[2] = new ORowSetValueDecorator(OUString());
270 aRow
[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE
);
271 // BUFFER_LENGTH, not used
272 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
274 aRow
[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS
);
276 aRow
[10] = new ORowSetValueDecorator(sal_Int32(10));
278 aRow
[11] = new ORowSetValueDecorator(s_nNULLABLE
);
280 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
281 // COLUMN_DEF, not used
282 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
283 // SQL_DATA_TYPE, not used
284 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
285 // SQL_DATETIME_SUB, not used
286 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
287 // CHAR_OCTET_LENGTH, refer to [5]
288 aRow
[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH
);
290 aRow
[18] = new ORowSetValueDecorator(OUString("YES"));
293 aRow
[3] = new ORowSetValueDecorator(OUString("TABLE"));
294 ::osl::MutexGuard
aGuard( m_aMutex
);
297 for (sal_Int32 i
= 0; i
< static_cast<sal_Int32
>(nFields
); i
++)
299 if( match( columnNamePattern
, getFieldName( i
), '\0' ) )
301 aRow
[5] = new ORowSetValueDecorator( static_cast<sal_Int16
>( getFieldType( i
) ) );
302 aRow
[6] = new ORowSetValueDecorator( getFieldTypeName( i
) );
305 aRow
[4] = new ORowSetValueDecorator( getFieldName( i
) );
307 aRow
[17] = new ORowSetValueDecorator( i
);
308 aRows
.push_back( aRow
);
315 OUString
OEvoabDatabaseMetaData::impl_getCatalogSeparator_throw( )
320 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxBinaryLiteralLength( )
322 return 0;// 0 means no limit
325 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxRowSize( )
327 return 0;// 0 means no limit
330 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxCatalogNameLength( )
332 return 0;// 0 means no limit
335 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxCharLiteralLength( )
337 return 0;// 0 means no limit
340 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnNameLength( )
342 return 0;// 0 means no limit
345 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInIndex( )
347 return 0;// 0 means no limit
350 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxCursorNameLength( )
352 return 0;// 0 means no limit
355 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxConnections( )
357 return 0;// 0 means no limit
360 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInTable( )
362 return 0;// 0 means no limit
365 sal_Int32
OEvoabDatabaseMetaData::impl_getMaxStatements_throw( )
367 return 0;// 0 means no limit
370 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxTableNameLength( )
372 return 0;// 0 means no limit
375 sal_Int32
OEvoabDatabaseMetaData::impl_getMaxTablesInSelect_throw( )
377 // We only support a single table
382 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
387 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
392 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesLowerCaseIdentifiers( )
397 bool OEvoabDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
402 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesMixedCaseIdentifiers( )
407 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
412 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesUpperCaseIdentifiers( )
417 bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
422 bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
427 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxIndexLength( )
429 return 0;// 0 means no limit
432 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsNonNullableColumns( )
437 OUString SAL_CALL
OEvoabDatabaseMetaData::getCatalogTerm( )
442 OUString
OEvoabDatabaseMetaData::impl_getIdentifierQuoteString_throw( )
444 // normally this is "
448 OUString SAL_CALL
OEvoabDatabaseMetaData::getExtraNameCharacters( )
453 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDifferentTableCorrelationNames( )
458 bool OEvoabDatabaseMetaData::impl_isCatalogAtStart_throw( )
463 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::dataDefinitionIgnoredInTransactions( )
468 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::dataDefinitionCausesTransactionCommit( )
473 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDataManipulationTransactionsOnly( )
478 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
483 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsPositionedDelete( )
488 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsPositionedUpdate( )
493 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenStatementsAcrossRollback( )
498 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenStatementsAcrossCommit( )
503 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenCursorsAcrossCommit( )
508 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenCursorsAcrossRollback( )
513 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
/*level*/ )
518 bool OEvoabDatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
523 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92FullSQL( )
528 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92EntryLevelSQL( )
530 return true; // should be supported at least
533 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsIntegrityEnhancementFacility( )
538 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInIndexDefinitions( )
543 bool OEvoabDatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
548 bool OEvoabDatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
553 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInIndexDefinitions( )
558 bool OEvoabDatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
563 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOuterJoins( )
568 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxStatementLength( )
570 return 0;// 0 means no limit
573 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxProcedureNameLength( )
575 return 0;// 0 means no limit
578 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxSchemaNameLength( )
580 return 0;// 0 means no limit
583 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTransactions( )
588 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::allProceduresAreCallable( )
593 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsStoredProcedures( )
598 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSelectForUpdate( )
603 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::allTablesAreSelectable( )
605 // We allow you to select from any table.
609 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::isReadOnly( )
611 // For now definitely read-only, no support for update/delete
615 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::usesLocalFiles( )
620 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::usesLocalFilePerTable( )
625 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTypeConversion( )
630 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullPlusNonNullIsNull( )
635 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsColumnAliasing( )
637 // todo add Support for this.
641 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTableCorrelationNames( )
646 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ )
651 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsExpressionsInOrderBy( )
656 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupBy( )
661 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupByBeyondSelect( )
666 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupByUnrelated( )
671 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMultipleTransactions( )
676 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMultipleResultSets( )
681 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsLikeEscapeClause( )
686 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOrderByUnrelated( )
691 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsUnion( )
696 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsUnionAll( )
701 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMixedCaseIdentifiers( )
706 bool OEvoabDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
708 // Any case may be used
712 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedAtEnd( )
717 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedAtStart( )
722 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedHigh( )
727 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedLow( )
732 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInProcedureCalls( )
737 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
742 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInProcedureCalls( )
747 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
752 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCorrelatedSubqueries( )
757 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInComparisons( )
762 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInExists( )
767 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInIns( )
772 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInQuantifieds( )
777 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92IntermediateSQL( )
782 OUString SAL_CALL
OEvoabDatabaseMetaData::getURL( )
784 ::osl::MutexGuard
aGuard( m_aMutex
);
786 return m_pConnection
->getURL();
789 OUString SAL_CALL
OEvoabDatabaseMetaData::getUserName( )
794 OUString SAL_CALL
OEvoabDatabaseMetaData::getDriverName( )
799 OUString SAL_CALL
OEvoabDatabaseMetaData::getDriverVersion()
804 OUString SAL_CALL
OEvoabDatabaseMetaData::getDatabaseProductVersion( )
809 OUString SAL_CALL
OEvoabDatabaseMetaData::getDatabaseProductName( )
814 OUString SAL_CALL
OEvoabDatabaseMetaData::getProcedureTerm( )
819 OUString SAL_CALL
OEvoabDatabaseMetaData::getSchemaTerm( )
824 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDriverMajorVersion( )
829 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDefaultTransactionIsolation( )
831 return TransactionIsolation::NONE
;
834 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDriverMinorVersion( )
839 OUString SAL_CALL
OEvoabDatabaseMetaData::getSQLKeywords( )
844 OUString SAL_CALL
OEvoabDatabaseMetaData::getSearchStringEscape( )
849 OUString SAL_CALL
OEvoabDatabaseMetaData::getStringFunctions( )
854 OUString SAL_CALL
OEvoabDatabaseMetaData::getTimeDateFunctions( )
859 OUString SAL_CALL
OEvoabDatabaseMetaData::getSystemFunctions( )
864 OUString SAL_CALL
OEvoabDatabaseMetaData::getNumericFunctions( )
869 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsExtendedSQLGrammar( )
874 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCoreSQLGrammar( )
879 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMinimumSQLGrammar( )
884 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsFullOuterJoins( )
889 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsLimitedOuterJoins( )
894 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInGroupBy( )
896 return 0;// 0 means no limit
899 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInOrderBy( )
901 return 0;// 0 means no limit
904 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInSelect( )
906 return 0;// 0 means no limit
909 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxUserNameLength( )
911 return 0;// 0 means no limit
914 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsResultSetType( sal_Int32
/*setType*/ )
919 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ )
924 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32
/*setType*/ )
929 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownDeletesAreVisible( sal_Int32
/*setType*/ )
934 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownInsertsAreVisible( sal_Int32
/*setType*/ )
939 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32
/*setType*/ )
944 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersDeletesAreVisible( sal_Int32
/*setType*/ )
949 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersInsertsAreVisible( sal_Int32
/*setType*/ )
954 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::updatesAreDetected( sal_Int32
/*setType*/ )
959 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::deletesAreDetected( sal_Int32
/*setType*/ )
964 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::insertsAreDetected( sal_Int32
/*setType*/ )
969 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsBatchUpdates( )
974 // here follow all methods which return a resultset
975 // the first methods is an example implementation how to use this resultset
976 // of course you could implement it on your and you should do this because
977 // the general way is more memory expensive
979 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getTableTypes( )
981 /* Don't need to change as evoab driver supports only table */
983 // there exists no possibility to get table types so we have to check
984 static const std::u16string_view sTableTypes
[] =
986 u
"TABLE" // Currently we only support a 'TABLE' nothing more complex
988 rtl::Reference
<::connectivity::ODatabaseMetaDataResultSet
> pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes
);
990 // here we fill the rows which should be visible when ask for data from the resultset returned here
991 auto nNbTypes
= SAL_N_ELEMENTS(sTableTypes
);
992 ODatabaseMetaDataResultSet::ORows aRows
;
993 for(std::size_t i
=0;i
< nNbTypes
;++i
)
996 aRows
.push_back( { ODatabaseMetaDataResultSet::getEmptyValue(), new ORowSetValueDecorator(OUString(sTableTypes
[i
])) });
998 // here we set the rows at the resultset
999 pResult
->setRows(aRows
);
1003 Reference
< XResultSet
> OEvoabDatabaseMetaData::impl_getTypeInfo_throw( )
1006 * Return the proper type information required by evo driver
1009 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
1011 static ODatabaseMetaDataResultSet::ORows aRows
= []()
1013 ODatabaseMetaDataResultSet::ORows tmp
;
1014 ODatabaseMetaDataResultSet::ORow aRow
1016 ODatabaseMetaDataResultSet::getEmptyValue() ,
1017 new ORowSetValueDecorator(OUString("VARCHAR")) ,
1018 new ORowSetValueDecorator(DataType::VARCHAR
) ,
1019 new ORowSetValueDecorator(sal_Int32(s_nCHAR_OCTET_LENGTH
)) ,
1020 ODatabaseMetaDataResultSet::getQuoteValue() ,
1021 ODatabaseMetaDataResultSet::getQuoteValue() ,
1022 ODatabaseMetaDataResultSet::getEmptyValue() ,
1023 ODatabaseMetaDataResultSet::get1Value() ,
1024 ODatabaseMetaDataResultSet::get1Value() ,
1025 new ORowSetValueDecorator(sal_Int32(ColumnSearch::FULL
)) ,
1026 ODatabaseMetaDataResultSet::get1Value() ,
1027 ODatabaseMetaDataResultSet::get0Value() ,
1028 ODatabaseMetaDataResultSet::get0Value() ,
1029 ODatabaseMetaDataResultSet::getEmptyValue() ,
1030 ODatabaseMetaDataResultSet::get0Value() ,
1031 ODatabaseMetaDataResultSet::get0Value() ,
1032 ODatabaseMetaDataResultSet::getEmptyValue() ,
1033 ODatabaseMetaDataResultSet::getEmptyValue() ,
1034 new ORowSetValueDecorator(sal_Int32(10))
1037 tmp
.push_back(aRow
);
1039 aRow
[1] = new ORowSetValueDecorator(OUString("VARCHAR"));
1040 aRow
[2] = new ORowSetValueDecorator(DataType::VARCHAR
);
1041 aRow
[3] = new ORowSetValueDecorator(sal_Int32(65535));
1042 tmp
.push_back(aRow
);
1045 pResultSet
->setRows(aRows
);
1049 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getColumns(
1050 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& /*tableNamePattern*/,
1051 const OUString
& columnNamePattern
)
1053 // this returns an empty resultset where the column-names are already set
1054 // in special the metadata of the resultset already returns the right columns
1055 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns
);
1056 pResultSet
->setRows( getColumnRows( columnNamePattern
) );
1061 bool isSourceBackend(ESource
*pSource
, const char *backendname
)
1063 if (!pSource
|| !e_source_has_extension (pSource
, E_SOURCE_EXTENSION_ADDRESS_BOOK
))
1066 gpointer extension
= e_source_get_extension (pSource
, E_SOURCE_EXTENSION_ADDRESS_BOOK
);
1067 return extension
&& equal(e_source_backend_get_backend_name (extension
), backendname
);
1070 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getTables(
1071 const Any
& /*catalog*/, const OUString
& /*schemaPattern*/,
1072 const OUString
& /*tableNamePattern*/, const Sequence
< OUString
>& types
)
1074 ::osl::MutexGuard
aGuard( m_aMutex
);
1076 rtl::Reference
<ODatabaseMetaDataResultSet
> pResult
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
1078 // check if any type is given
1079 // when no types are given then we have to return all tables e.g. TABLE
1081 static const OUStringLiteral
aTable(u
"TABLE");
1083 bool bTableFound
= true;
1084 sal_Int32 nLength
= types
.getLength();
1087 bTableFound
= false;
1089 const OUString
* pBegin
= types
.getConstArray();
1090 const OUString
* pEnd
= pBegin
+ nLength
;
1091 for(;pBegin
!= pEnd
;++pBegin
)
1093 if(*pBegin
== aTable
)
1103 ODatabaseMetaDataResultSet::ORows aRows
;
1105 if (eds_check_version(3, 6, 0) == nullptr)
1107 GList
*pSources
= e_source_registry_list_sources(get_e_source_registry(), E_SOURCE_EXTENSION_ADDRESS_BOOK
);
1109 for (GList
* liter
= pSources
; liter
; liter
= liter
->next
)
1111 ESource
*pSource
= E_SOURCE (liter
->data
);
1113 switch (m_pConnection
->getSDBCAddressType())
1115 case SDBCAddress::EVO_GWISE
:
1116 can
= isSourceBackend( pSource
, "groupwise"); // not supported in evo/eds 3.6.x+, somehow
1118 case SDBCAddress::EVO_LOCAL
:
1119 can
= isSourceBackend( pSource
, "local");
1121 case SDBCAddress::EVO_LDAP
:
1122 can
= isSourceBackend( pSource
, "ldap");
1124 case SDBCAddress::Unknown
:
1131 OUString aHumanName
= OStringToOUString( e_source_get_display_name( pSource
),
1132 RTL_TEXTENCODING_UTF8
);
1133 OUString aUID
= OStringToOUString( e_source_get_uid( pSource
),
1134 RTL_TEXTENCODING_UTF8
);
1135 ODatabaseMetaDataResultSet::ORow aRow
{
1136 ORowSetValueDecoratorRef(),
1137 ORowSetValueDecoratorRef(),
1138 ORowSetValueDecoratorRef(),
1139 new ORowSetValueDecorator(aHumanName
), //tablename
1140 new ORowSetValueDecorator(ORowSetValue(aTable
)),
1141 new ORowSetValueDecorator(aUID
)}; //comment
1142 //I'd prefer to swap the comment and the human name and
1143 //just use e_source_registry_ref_source(get_e_source_registry(), aUID);
1144 //in open book rather than search for the name again
1145 aRows
.push_back(aRow
);
1148 g_list_foreach (pSources
, reinterpret_cast<GFunc
>(g_object_unref
), nullptr);
1149 g_list_free (pSources
);
1153 ESourceList
*pSourceList
;
1154 if( !e_book_get_addressbooks (&pSourceList
, nullptr) )
1155 pSourceList
= nullptr;
1158 for( g
= e_source_list_peek_groups( pSourceList
); g
; g
= g
->next
)
1161 const char *p
= e_source_group_peek_base_uri(E_SOURCE_GROUP(g
->data
));
1163 switch (m_pConnection
->getSDBCAddressType()) {
1164 case SDBCAddress::EVO_GWISE
:
1165 if ( !strncmp( "groupwise://", p
, 11 ))
1169 case SDBCAddress::EVO_LOCAL
:
1170 if ( !strncmp( "file://", p
, 6 ) ||
1171 !strncmp( "local://", p
, 6 ) )
1175 case SDBCAddress::EVO_LDAP
:
1176 if ( !strncmp( "ldap://", p
, 6 ))
1180 case SDBCAddress::Unknown
:
1183 for (s
= e_source_group_peek_sources (E_SOURCE_GROUP (g
->data
)); s
; s
= s
->next
)
1185 ESource
*pSource
= E_SOURCE (s
->data
);
1187 OUString aName
= OStringToOUString( e_source_peek_name( pSource
),
1188 RTL_TEXTENCODING_UTF8
);
1192 ORowSetValueDecoratorRef(),
1193 ORowSetValueDecoratorRef(),
1194 ORowSetValueDecoratorRef(),
1195 new ORowSetValueDecorator(aName
),
1196 new ORowSetValueDecorator(ORowSetValue(aTable
)),
1197 ODatabaseMetaDataResultSet::getEmptyValue()
1204 pResult
->setRows(aRows
);
1209 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getUDTs( const Any
& /*catalog*/, const OUString
& /*schemaPattern*/, const OUString
& /*typeNamePattern*/, const Sequence
< sal_Int32
>& /*types*/ )
1211 ::dbtools::throwFeatureNotImplementedSQLException( "XDatabaseMetaDaza::getUDTs", *this );
1216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */