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 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 // ****************************************************
272 aRow
[1] = new ORowSetValueDecorator(OUString());
274 aRow
[2] = new ORowSetValueDecorator(OUString());
276 aRow
[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE
);
277 // BUFFER_LENGTH, not used
278 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
280 aRow
[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS
);
282 aRow
[10] = new ORowSetValueDecorator(sal_Int32(10));
284 aRow
[11] = new ORowSetValueDecorator(s_nNULLABLE
);
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
);
296 aRow
[18] = new ORowSetValueDecorator(OUString("YES"));
299 aRow
[3] = new ORowSetValueDecorator(OUString("TABLE"));
300 ::osl::MutexGuard
aGuard( m_aMutex
);
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
) );
311 aRow
[4] = new ORowSetValueDecorator( getFieldName( i
) );
313 aRow
[17] = new ORowSetValueDecorator( sal_Int32(i
) );
314 aRows
.push_back( aRow
);
318 pResultSet
->setRows(std::move(aRows
));
323 OUString
OEvoabDatabaseMetaData::impl_getCatalogSeparator_throw( )
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
390 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
395 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
400 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesLowerCaseIdentifiers( )
405 bool OEvoabDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
410 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesMixedCaseIdentifiers( )
415 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
420 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesUpperCaseIdentifiers( )
425 bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
430 bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
435 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxIndexLength( )
437 return 0;// 0 means no limit
440 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsNonNullableColumns( )
445 OUString SAL_CALL
OEvoabDatabaseMetaData::getCatalogTerm( )
450 OUString
OEvoabDatabaseMetaData::impl_getIdentifierQuoteString_throw( )
452 // normally this is "
456 OUString SAL_CALL
OEvoabDatabaseMetaData::getExtraNameCharacters( )
461 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDifferentTableCorrelationNames( )
466 bool OEvoabDatabaseMetaData::impl_isCatalogAtStart_throw( )
471 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::dataDefinitionIgnoredInTransactions( )
476 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::dataDefinitionCausesTransactionCommit( )
481 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDataManipulationTransactionsOnly( )
486 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
491 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsPositionedDelete( )
496 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsPositionedUpdate( )
501 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenStatementsAcrossRollback( )
506 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenStatementsAcrossCommit( )
511 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenCursorsAcrossCommit( )
516 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenCursorsAcrossRollback( )
521 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
/*level*/ )
526 bool OEvoabDatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
531 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92FullSQL( )
536 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92EntryLevelSQL( )
538 return true; // should be supported at least
541 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsIntegrityEnhancementFacility( )
546 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInIndexDefinitions( )
551 bool OEvoabDatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
556 bool OEvoabDatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
561 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInIndexDefinitions( )
566 bool OEvoabDatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
571 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOuterJoins( )
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( )
596 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::allProceduresAreCallable( )
601 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsStoredProcedures( )
606 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSelectForUpdate( )
611 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::allTablesAreSelectable( )
613 // We allow you to select from any table.
617 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::isReadOnly( )
619 // For now definitely read-only, no support for update/delete
623 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::usesLocalFiles( )
628 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::usesLocalFilePerTable( )
633 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTypeConversion( )
638 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullPlusNonNullIsNull( )
643 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsColumnAliasing( )
645 // todo add Support for this.
649 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTableCorrelationNames( )
654 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ )
659 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsExpressionsInOrderBy( )
664 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupBy( )
669 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupByBeyondSelect( )
674 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupByUnrelated( )
679 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMultipleTransactions( )
684 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMultipleResultSets( )
689 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsLikeEscapeClause( )
694 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOrderByUnrelated( )
699 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsUnion( )
704 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsUnionAll( )
709 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMixedCaseIdentifiers( )
714 bool OEvoabDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
716 // Any case may be used
720 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedAtEnd( )
725 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedAtStart( )
730 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedHigh( )
735 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedLow( )
740 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInProcedureCalls( )
745 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
750 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInProcedureCalls( )
755 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
760 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCorrelatedSubqueries( )
765 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInComparisons( )
770 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInExists( )
775 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInIns( )
780 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInQuantifieds( )
785 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92IntermediateSQL( )
790 OUString SAL_CALL
OEvoabDatabaseMetaData::getURL( )
792 ::osl::MutexGuard
aGuard( m_aMutex
);
794 return m_pConnection
->getURL();
797 OUString SAL_CALL
OEvoabDatabaseMetaData::getUserName( )
802 OUString SAL_CALL
OEvoabDatabaseMetaData::getDriverName( )
807 OUString SAL_CALL
OEvoabDatabaseMetaData::getDriverVersion()
812 OUString SAL_CALL
OEvoabDatabaseMetaData::getDatabaseProductVersion( )
817 OUString SAL_CALL
OEvoabDatabaseMetaData::getDatabaseProductName( )
822 OUString SAL_CALL
OEvoabDatabaseMetaData::getProcedureTerm( )
827 OUString SAL_CALL
OEvoabDatabaseMetaData::getSchemaTerm( )
832 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDriverMajorVersion( )
837 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDefaultTransactionIsolation( )
839 return TransactionIsolation::NONE
;
842 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDriverMinorVersion( )
847 OUString SAL_CALL
OEvoabDatabaseMetaData::getSQLKeywords( )
852 OUString SAL_CALL
OEvoabDatabaseMetaData::getSearchStringEscape( )
857 OUString SAL_CALL
OEvoabDatabaseMetaData::getStringFunctions( )
862 OUString SAL_CALL
OEvoabDatabaseMetaData::getTimeDateFunctions( )
867 OUString SAL_CALL
OEvoabDatabaseMetaData::getSystemFunctions( )
872 OUString SAL_CALL
OEvoabDatabaseMetaData::getNumericFunctions( )
877 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsExtendedSQLGrammar( )
882 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCoreSQLGrammar( )
887 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMinimumSQLGrammar( )
892 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsFullOuterJoins( )
897 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsLimitedOuterJoins( )
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*/ )
927 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ )
932 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32
/*setType*/ )
937 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownDeletesAreVisible( sal_Int32
/*setType*/ )
942 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownInsertsAreVisible( sal_Int32
/*setType*/ )
947 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32
/*setType*/ )
952 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersDeletesAreVisible( sal_Int32
/*setType*/ )
957 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersInsertsAreVisible( sal_Int32
/*setType*/ )
962 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::updatesAreDetected( sal_Int32
/*setType*/ )
967 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::deletesAreDetected( sal_Int32
/*setType*/ )
972 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::insertsAreDetected( sal_Int32
/*setType*/ )
977 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsBatchUpdates( )
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
)
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
));
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
);
1053 pResultSet
->setRows(std::move(aRows
));
1057 bool isSourceBackend(ESource
*pSource
, const char *backendname
)
1059 if (!pSource
|| !e_source_has_extension (pSource
, E_SOURCE_EXTENSION_ADDRESS_BOOK
))
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();
1083 bTableFound
= false;
1085 const OUString
* pBegin
= types
.getConstArray();
1086 const OUString
* pEnd
= pBegin
+ nLength
;
1087 for(;pBegin
!= pEnd
;++pBegin
)
1089 if(*pBegin
== aTable
)
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
);
1107 switch (m_pConnection
->getSDBCAddressType())
1109 case SDBCAddress::EVO_GWISE
:
1110 can
= isSourceBackend( pSource
, "groupwise"); // not supported in evo/eds 3.6.x+, somehow
1112 case SDBCAddress::EVO_LOCAL
:
1113 can
= isSourceBackend( pSource
, "local");
1115 case SDBCAddress::EVO_LDAP
:
1116 can
= isSourceBackend( pSource
, "ldap");
1118 case SDBCAddress::Unknown
:
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
));
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 );
1157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */