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 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 #include "NDatabaseMetaData.hxx"
31 #include <com/sun/star/sdbc/DataType.hpp>
32 #include <com/sun/star/sdbc/ResultSetType.hpp>
33 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
34 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
35 #include <connectivity/dbexception.hxx>
36 #include <connectivity/FValue.hxx>
37 #include <com/sun/star/sdbc/ColumnValue.hpp>
38 #include <com/sun/star/sdbc/ColumnSearch.hpp>
44 #if OSL_DEBUG_LEVEL > 0
45 # define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
46 #else /* OSL_DEBUG_LEVEL */
47 # define OUtoCStr( x ) ("dummy")
48 #endif /* OSL_DEBUG_LEVEL */
50 using namespace connectivity::evoab
;
51 using namespace connectivity
;
52 using namespace com::sun::star::uno
;
53 using namespace com::sun::star::lang
;
54 using namespace com::sun::star::beans
;
55 using namespace com::sun::star::sdbc
;
56 using namespace com::sun::star::sdbcx
;
59 namespace connectivity
63 static sal_Int32
const s_nCOLUMN_SIZE
= 256;
64 static sal_Int32
const s_nDECIMAL_DIGITS
= 0;
65 static sal_Int32
const s_nNULLABLE
= 1;
66 static sal_Int32
const s_nCHAR_OCTET_LENGTH
= 65535;
68 static ColumnProperty
**pFields
=NULL
;
69 static guint nFields
= 0;
71 static const char *pBlackList
[] =
74 "list-show-addresses",
80 const SplitEvoColumns
* get_evo_addr()
82 static const SplitEvoColumns evo_addr
[] = {
83 {"addr-line1",DEFAULT_ADDR_LINE1
},{"addr-line2",DEFAULT_ADDR_LINE2
},{"city",DEFAULT_CITY
},{"state",DEFAULT_STATE
},{"country",DEFAULT_COUNTRY
},{"zip",DEFAULT_ZIP
},
84 {"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
},
85 {"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
},
86 {"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
}
92 splitColumn (ColumnProperty
**pToBeFields
)
94 const SplitEvoColumns
* evo_addr( get_evo_addr() );
95 for (int i
= 0; i
< OTHER_ZIP
; i
++)
97 pToBeFields
[nFields
] = g_new0(ColumnProperty
,1);
98 pToBeFields
[nFields
]->bIsSplittedValue
= true;
99 pToBeFields
[nFields
]->pField
= g_param_spec_ref(g_param_spec_string (evo_addr
[i
].pColumnName
,evo_addr
[i
].pColumnName
,"",NULL
,G_PARAM_WRITABLE
));
109 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
113 ColumnProperty
**pToBeFields
;
116 pProps
= g_object_class_list_properties
117 ( (GObjectClass
*) g_type_class_ref( E_TYPE_CONTACT
),
119 pToBeFields
= g_new0(ColumnProperty
*, (nProps
+ OTHER_ZIP
)/* new column(s)*/ );
120 for ( guint i
= 0; i
< nProps
; i
++ )
122 switch (pProps
[i
]->value_type
)
128 const char *pName
= g_param_spec_get_name( pProps
[i
] );
129 for (unsigned int j
= 0; j
< G_N_ELEMENTS( pBlackList
); j
++ )
131 if( !strcmp( pBlackList
[j
], pName
) )
139 pToBeFields
[nFields
]= g_new0(ColumnProperty
,1);
140 pToBeFields
[nFields
]->bIsSplittedValue
=false;
141 pToBeFields
[ nFields
++ ]->pField
= g_param_spec_ref( pProps
[i
] );
150 splitColumn(pToBeFields
);
151 pFields
= pToBeFields
;
164 const ColumnProperty
*
175 getGFieldType( guint nCol
)
179 sal_Int32 nType
= G_TYPE_STRING
;
180 if ( nCol
< nFields
)
181 return ((GParamSpec
*)pFields
[nCol
]->pField
)->value_type
;
186 getFieldType( guint nCol
)
188 sal_Int32 nType
= getGFieldType( nCol
);
189 return nType
== G_TYPE_STRING
? DataType::VARCHAR
: DataType::BIT
;
192 guint
findEvoabField(const rtl::OUString
& aColName
)
194 guint nRet
= (guint
)-1;
195 sal_Bool bFound
= sal_False
;
197 for (guint i
=0;(i
< nFields
) && !bFound
;i
++)
199 rtl::OUString aName
= getFieldName(i
);
200 if (aName
== aColName
)
210 getFieldTypeName( guint nCol
)
212 switch( getFieldType( nCol
) )
215 return ::rtl::OUString::createFromAscii( "BIT" );
216 case DataType::VARCHAR
:
217 return ::rtl::OUString::createFromAscii( "VARCHAR" );
221 return ::rtl::OUString();
225 getFieldName( guint nCol
)
227 const GParamSpec
*pSpec
= getField( nCol
)->pField
;
232 aName
= rtl::OStringToOUString( g_param_spec_get_name( ( GParamSpec
* )pSpec
),
233 RTL_TEXTENCODING_UTF8
);
234 aName
= aName
.replace( '-', '_' );
239 free_column_resources()
241 for (int i
=nFields
-1;i
> 0;i
--)
243 if (pFields
&& pFields
[i
] )
245 if (pFields
[i
]->pField
)
246 g_param_spec_unref(pFields
[i
]->pField
);
263 OEvoabDatabaseMetaData::OEvoabDatabaseMetaData(OEvoabConnection
* _pCon
)
264 : ::connectivity::ODatabaseMetaDataBase(_pCon
, _pCon
->getConnectionInfo())
265 ,m_pConnection(_pCon
)
267 OSL_ENSURE(m_pConnection
,"OEvoabDatabaseMetaData::OEvoabDatabaseMetaData: No connection set!");
269 OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData()
273 // -------------------------------------------------------------------------
274 ODatabaseMetaDataResultSet::ORows
& OEvoabDatabaseMetaData::getColumnRows( const ::rtl::OUString
& columnNamePattern
)
276 static ODatabaseMetaDataResultSet::ORows aRows
;
277 ODatabaseMetaDataResultSet::ORow
aRow(19);
280 // ****************************************************
281 // Some entries in a row never change, so set them now
282 // ****************************************************
285 aRow
[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii(""));
287 aRow
[2] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii(""));
289 aRow
[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE
);
290 // BUFFER_LENGTH, not used
291 aRow
[8] = ODatabaseMetaDataResultSet::getEmptyValue();
293 aRow
[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS
);
295 aRow
[10] = new ORowSetValueDecorator((sal_Int32
)10);
297 aRow
[11] = new ORowSetValueDecorator(s_nNULLABLE
);
299 aRow
[12] = ODatabaseMetaDataResultSet::getEmptyValue();
300 // COULUMN_DEF, not used
301 aRow
[13] = ODatabaseMetaDataResultSet::getEmptyValue();
302 // SQL_DATA_TYPE, not used
303 aRow
[14] = ODatabaseMetaDataResultSet::getEmptyValue();
304 // SQL_DATETIME_SUB, not used
305 aRow
[15] = ODatabaseMetaDataResultSet::getEmptyValue();
306 // CHAR_OCTET_LENGTH, refer to [5]
307 aRow
[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH
);
309 aRow
[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii( "YES" ));
312 aRow
[3] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii( "TABLE" ));
313 ::osl::MutexGuard
aGuard( m_aMutex
);
316 for (sal_Int32 i
= 0; i
< (sal_Int32
) nFields
; i
++)
318 if( match( columnNamePattern
, getFieldName( i
), '\0' ) )
320 aRow
[5] = new ORowSetValueDecorator( static_cast<sal_Int16
>( getFieldType( i
) ) );
321 aRow
[6] = new ORowSetValueDecorator( getFieldTypeName( i
) );
323 OSL_TRACE( "ColumnName = '%s'", g_param_spec_get_name( pFields
[i
]->pField
) );
325 aRow
[4] = new ORowSetValueDecorator( getFieldName( i
) );
327 aRow
[17] = new ORowSetValueDecorator( i
);
328 aRows
.push_back( aRow
);
334 // -------------------------------------------------------------------------
335 ::rtl::OUString
OEvoabDatabaseMetaData::impl_getCatalogSeparator_throw( )
337 return ::rtl::OUString();
339 // -------------------------------------------------------------------------
340 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException
, RuntimeException
)
342 return 0;// 0 means no limit
344 // -------------------------------------------------------------------------
345 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxRowSize( ) throw(SQLException
, RuntimeException
)
347 return 0;// 0 means no limit
349 // -------------------------------------------------------------------------
350 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException
, RuntimeException
)
352 return 0;// 0 means no limit
354 // -------------------------------------------------------------------------
355 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException
, RuntimeException
)
357 return 0;// 0 means no limit
359 // -------------------------------------------------------------------------
360 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException
, RuntimeException
)
362 return 0;// 0 means no limit
364 // -------------------------------------------------------------------------
365 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException
, RuntimeException
)
367 return 0;// 0 means no limit
369 // -------------------------------------------------------------------------
370 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException
, RuntimeException
)
372 return 0;// 0 means no limit
374 // -------------------------------------------------------------------------
375 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxConnections( ) throw(SQLException
, RuntimeException
)
377 return 0;// 0 means no limit
379 // -------------------------------------------------------------------------
380 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException
, RuntimeException
)
382 return 0;// 0 means no limit
384 // -------------------------------------------------------------------------
385 sal_Int32
OEvoabDatabaseMetaData::impl_getMaxStatements_throw( )
387 return 0;// 0 means no limit
389 // -------------------------------------------------------------------------
390 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException
, RuntimeException
)
392 return 0;// 0 means no limit
394 // -------------------------------------------------------------------------
395 sal_Int32
OEvoabDatabaseMetaData::impl_getMaxTablesInSelect_throw( )
397 // We only support a single table
400 // -------------------------------------------------------------------------
401 // -------------------------------------------------------------------------
402 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
)
406 // -------------------------------------------------------------------------
407 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
411 // -------------------------------------------------------------------------
412 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
416 // -------------------------------------------------------------------------
417 sal_Bool
OEvoabDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
421 // -------------------------------------------------------------------------
422 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
426 // -------------------------------------------------------------------------
427 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
)
431 // -------------------------------------------------------------------------
432 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
436 // -------------------------------------------------------------------------
437 sal_Bool
OEvoabDatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
441 // -------------------------------------------------------------------------
442 sal_Bool
OEvoabDatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
446 // -------------------------------------------------------------------------
447 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
)
449 return 0;// 0 means no limit
451 // -------------------------------------------------------------------------
452 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
)
456 // -------------------------------------------------------------------------
457 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getCatalogTerm( ) throw(SQLException
, RuntimeException
)
459 ::rtl::OUString aVal
;
462 // -------------------------------------------------------------------------
463 ::rtl::OUString
OEvoabDatabaseMetaData::impl_getIdentifierQuoteString_throw( )
465 // normally this is "
466 ::rtl::OUString aVal
= ::rtl::OUString::createFromAscii("\"");
469 // -------------------------------------------------------------------------
470 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
)
472 ::rtl::OUString aVal
;
475 // -------------------------------------------------------------------------
476 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
480 // -------------------------------------------------------------------------
481 sal_Bool
OEvoabDatabaseMetaData::impl_isCatalogAtStart_throw( )
483 sal_Bool bValue
= sal_False
;
486 // -------------------------------------------------------------------------
487 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException
, RuntimeException
)
491 // -------------------------------------------------------------------------
492 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException
, RuntimeException
)
496 // -------------------------------------------------------------------------
497 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException
, RuntimeException
)
501 // -------------------------------------------------------------------------
502 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException
, RuntimeException
)
506 // -------------------------------------------------------------------------
507 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException
, RuntimeException
)
511 // -------------------------------------------------------------------------
512 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException
, RuntimeException
)
516 // -------------------------------------------------------------------------
517 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException
, RuntimeException
)
521 // -------------------------------------------------------------------------
522 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException
, RuntimeException
)
526 // -------------------------------------------------------------------------
527 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException
, RuntimeException
)
531 // -------------------------------------------------------------------------
532 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException
, RuntimeException
)
536 // -------------------------------------------------------------------------
537 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32
/*level*/ ) throw(SQLException
, RuntimeException
)
541 // -------------------------------------------------------------------------
542 sal_Bool
OEvoabDatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
546 // -------------------------------------------------------------------------
547 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
)
551 // -------------------------------------------------------------------------
552 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
)
554 return sal_True
; // should be supported at least
556 // -------------------------------------------------------------------------
557 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
)
561 // -------------------------------------------------------------------------
562 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
566 // -------------------------------------------------------------------------
567 sal_Bool
OEvoabDatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
571 // -------------------------------------------------------------------------
572 sal_Bool
OEvoabDatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
576 // -------------------------------------------------------------------------
577 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException
, RuntimeException
)
581 // -------------------------------------------------------------------------
582 sal_Bool
OEvoabDatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
586 // -------------------------------------------------------------------------
587 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException
, RuntimeException
)
591 // -------------------------------------------------------------------------
592 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException
, RuntimeException
)
594 return 0;// 0 means no limit
596 // -------------------------------------------------------------------------
597 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
)
599 return 0;// 0 means no limit
601 // -------------------------------------------------------------------------
602 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException
, RuntimeException
)
604 return 0;// 0 means no limit
606 // -------------------------------------------------------------------------
607 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTransactions( ) throw(SQLException
, RuntimeException
)
611 // -------------------------------------------------------------------------
612 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
)
616 // -------------------------------------------------------------------------
617 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
)
621 // -------------------------------------------------------------------------
622 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException
, RuntimeException
)
626 // -------------------------------------------------------------------------
627 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException
, RuntimeException
)
629 // We allow you to select from any table.
632 // -------------------------------------------------------------------------
633 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
)
635 // For now definately read-only, no support for update/delete
638 // -------------------------------------------------------------------------
639 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
)
643 // -------------------------------------------------------------------------
644 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
)
648 // -------------------------------------------------------------------------
649 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException
, RuntimeException
)
653 // -------------------------------------------------------------------------
654 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
)
658 // -------------------------------------------------------------------------
659 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException
, RuntimeException
)
661 // todo add Support for this.
664 // -------------------------------------------------------------------------
665 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException
, RuntimeException
)
669 // -------------------------------------------------------------------------
670 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsConvert( sal_Int32
/*fromType*/, sal_Int32
/*toType*/ ) throw(SQLException
, RuntimeException
)
674 // -------------------------------------------------------------------------
675 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
)
679 // -------------------------------------------------------------------------
680 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
)
684 // -------------------------------------------------------------------------
685 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
)
689 // -------------------------------------------------------------------------
690 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
)
694 // -------------------------------------------------------------------------
695 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException
, RuntimeException
)
699 // -------------------------------------------------------------------------
700 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
)
704 // -------------------------------------------------------------------------
705 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
)
709 // -------------------------------------------------------------------------
710 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
)
714 // -------------------------------------------------------------------------
715 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
)
719 // -------------------------------------------------------------------------
720 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
)
724 // -------------------------------------------------------------------------
725 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException
, RuntimeException
)
729 // -------------------------------------------------------------------------
730 sal_Bool
OEvoabDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
732 // Any case may be used
735 // -------------------------------------------------------------------------
736 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
)
740 // -------------------------------------------------------------------------
741 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
)
745 // -------------------------------------------------------------------------
746 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
)
750 // -------------------------------------------------------------------------
751 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
)
755 // -------------------------------------------------------------------------
756 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException
, RuntimeException
)
760 // -------------------------------------------------------------------------
761 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
765 // -------------------------------------------------------------------------
766 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException
, RuntimeException
)
770 // -------------------------------------------------------------------------
771 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException
, RuntimeException
)
775 // -------------------------------------------------------------------------
776 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
)
780 // -------------------------------------------------------------------------
781 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
)
785 // -------------------------------------------------------------------------
786 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
)
790 // -------------------------------------------------------------------------
791 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
)
795 // -------------------------------------------------------------------------
796 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
)
800 // -------------------------------------------------------------------------
801 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
)
805 // -------------------------------------------------------------------------
806 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getURL( ) throw(SQLException
, RuntimeException
)
808 ::osl::MutexGuard
aGuard( m_aMutex
);
810 return m_pConnection
->getURL();
812 // -------------------------------------------------------------------------
813 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
)
815 ::rtl::OUString aValue
;
818 // -------------------------------------------------------------------------
819 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
)
821 ::rtl::OUString aValue
;
824 // -------------------------------------------------------------------------
825 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
)
827 ::rtl::OUString aValue
= ::rtl::OUString::valueOf((sal_Int32
)1);
830 // -------------------------------------------------------------------------
831 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
)
833 ::rtl::OUString aValue
= ::rtl::OUString::valueOf((sal_Int32
)0);
836 // -------------------------------------------------------------------------
837 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
)
839 ::rtl::OUString aValue
;
842 // -------------------------------------------------------------------------
843 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
)
845 ::rtl::OUString aValue
;
848 // -------------------------------------------------------------------------
849 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getSchemaTerm( ) throw(SQLException
, RuntimeException
)
851 ::rtl::OUString aValue
;
854 // -------------------------------------------------------------------------
855 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
)
859 // -------------------------------------------------------------------------
860 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException
, RuntimeException
)
862 return TransactionIsolation::NONE
;
864 // -------------------------------------------------------------------------
865 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
)
869 // -------------------------------------------------------------------------
870 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
)
872 ::rtl::OUString aValue
;
875 // -------------------------------------------------------------------------
876 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
)
878 ::rtl::OUString aValue
;
881 // -------------------------------------------------------------------------
882 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
)
884 return ::rtl::OUString();
886 // -------------------------------------------------------------------------
887 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
)
889 return ::rtl::OUString();
891 // -------------------------------------------------------------------------
892 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
)
894 return ::rtl::OUString();
896 // -------------------------------------------------------------------------
897 ::rtl::OUString SAL_CALL
OEvoabDatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
)
899 return ::rtl::OUString();
901 // -------------------------------------------------------------------------
902 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
)
906 // -------------------------------------------------------------------------
907 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException
, RuntimeException
)
911 // -------------------------------------------------------------------------
912 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException
, RuntimeException
)
916 // -------------------------------------------------------------------------
917 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
)
921 // -------------------------------------------------------------------------
922 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
)
926 // -------------------------------------------------------------------------
927 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
)
929 return 0;// 0 means no limit
931 // -------------------------------------------------------------------------
932 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
)
934 return 0;// 0 means no limit
936 // -------------------------------------------------------------------------
937 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
)
939 return 0;// 0 means no limit
941 // -------------------------------------------------------------------------
942 sal_Int32 SAL_CALL
OEvoabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
)
944 return 0;// 0 means no limit
946 // -------------------------------------------------------------------------
947 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsResultSetType( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
951 // -------------------------------------------------------------------------
952 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32
/*setType*/, sal_Int32
/*concurrency*/ ) throw(SQLException
, RuntimeException
)
956 // -------------------------------------------------------------------------
957 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
961 // -------------------------------------------------------------------------
962 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
966 // -------------------------------------------------------------------------
967 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::ownInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
971 // -------------------------------------------------------------------------
972 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
976 // -------------------------------------------------------------------------
977 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersDeletesAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
981 // -------------------------------------------------------------------------
982 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::othersInsertsAreVisible( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
986 // -------------------------------------------------------------------------
987 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::updatesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
991 // -------------------------------------------------------------------------
992 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::deletesAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
996 // -------------------------------------------------------------------------
997 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::insertsAreDetected( sal_Int32
/*setType*/ ) throw(SQLException
, RuntimeException
)
1001 // -------------------------------------------------------------------------
1002 sal_Bool SAL_CALL
OEvoabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
, RuntimeException
)
1006 // -------------------------------------------------------------------------
1007 // here follow all methods which return a resultset
1008 // the first methods is an example implementation how to use this resultset
1009 // of course you could implement it on your and you should do this because
1010 // the general way is more memory expensive
1011 // -------------------------------------------------------------------------
1012 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
)
1014 /* Dont need to change as evoab driver supports only table */
1016 // there exists no possibility to get table types so we have to check
1017 static ::rtl::OUString sTableTypes
[] =
1019 ::rtl::OUString::createFromAscii("TABLE"),
1020 // Currently we only support a 'TABLE' nothing more complex
1022 ::connectivity::ODatabaseMetaDataResultSet
* pResult
= new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes
);
1023 Reference
< XResultSet
> xRef
= pResult
;
1025 // here we fill the rows which should be visible when ask for data from the resultset returned here
1026 sal_Int32 nSize
= sizeof(sTableTypes
) / sizeof(::rtl::OUString
);
1027 ODatabaseMetaDataResultSet::ORows aRows
;
1028 for(sal_Int32 i
=0;i
< nSize
;++i
)
1030 ODatabaseMetaDataResultSet::ORow aRow
;
1031 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
1032 aRow
.push_back(new ORowSetValueDecorator(sTableTypes
[i
]));
1035 aRows
.push_back(aRow
);
1037 // here we set the rows at the resultset
1038 pResult
->setRows(aRows
);
1041 // -------------------------------------------------------------------------
1042 Reference
< XResultSet
> OEvoabDatabaseMetaData::impl_getTypeInfo_throw( )
1045 * Return the proper type information required by evo driver
1048 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
1050 Reference
< XResultSet
> xResultSet
= pResultSet
;
1051 static ODatabaseMetaDataResultSet::ORows aRows
;
1055 ODatabaseMetaDataResultSet::ORow aRow
;
1057 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
1058 aRow
.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")));
1059 aRow
.push_back(new ORowSetValueDecorator(DataType::VARCHAR
));
1060 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)s_nCHAR_OCTET_LENGTH
));
1061 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
1062 aRow
.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
1063 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
1064 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
1065 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
1066 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
1067 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)ColumnSearch::FULL
));
1068 aRow
.push_back(ODatabaseMetaDataResultSet::get1Value());
1069 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
1070 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
1071 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
1072 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
1073 aRow
.push_back(ODatabaseMetaDataResultSet::get0Value());
1074 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
1075 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
1076 aRow
.push_back(new ORowSetValueDecorator((sal_Int32
)10));
1078 aRows
.push_back(aRow
);
1080 aRow
[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"));
1081 aRow
[2] = new ORowSetValueDecorator(DataType::VARCHAR
);
1082 aRow
[3] = new ORowSetValueDecorator((sal_Int32
)65535);
1083 aRows
.push_back(aRow
);
1085 pResultSet
->setRows(aRows
);
1088 // -------------------------------------------------------------------------
1089 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getColumns(
1090 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/, const ::rtl::OUString
& /*tableNamePattern*/,
1091 const ::rtl::OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
)
1093 // this returns an empty resultset where the column-names are already set
1094 // in special the metadata of the resultset already returns the right columns
1095 ODatabaseMetaDataResultSet
* pResultSet
= new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns
);
1096 Reference
< XResultSet
> xResultSet
= pResultSet
;
1097 pResultSet
->setRows( getColumnRows( columnNamePattern
) );
1100 // -------------------------------------------------------------------------
1101 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getTables(
1102 const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/,
1103 const ::rtl::OUString
& /*tableNamePattern*/, const Sequence
< ::rtl::OUString
>& types
) throw(SQLException
, RuntimeException
)
1105 ::osl::MutexGuard
aGuard( m_aMutex
);
1107 ODatabaseMetaDataResultSet
* pResult
= new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
1108 Reference
< XResultSet
> xRef
= pResult
;
1110 // check if any type is given
1111 // when no types are given then we have to return all tables e.g. TABLE
1113 const ::rtl::OUString
aTable(::rtl::OUString::createFromAscii("TABLE"));
1115 sal_Bool bTableFound
= sal_True
;
1116 sal_Int32 nLength
= types
.getLength();
1119 bTableFound
= sal_False
;
1121 const ::rtl::OUString
* pBegin
= types
.getConstArray();
1122 const ::rtl::OUString
* pEnd
= pBegin
+ nLength
;
1123 for(;pBegin
!= pEnd
;++pBegin
)
1125 if(*pBegin
== aTable
)
1127 bTableFound
= sal_True
;
1135 ODatabaseMetaDataResultSet::ORows aRows
;
1137 ESourceList
*pSourceList
;
1138 if( !e_book_get_addressbooks (&pSourceList
, NULL
) )
1142 for( g
= e_source_list_peek_groups( pSourceList
); g
; g
= g
->next
)
1145 const char *p
= e_source_group_peek_base_uri(E_SOURCE_GROUP(g
->data
));
1147 switch (m_pConnection
->getSDBCAddressType()) {
1148 case SDBCAddress::EVO_GWISE
:
1149 if (0==strncmp( "groupwise://", p
, 11 ))
1153 case SDBCAddress::EVO_LOCAL
:
1154 if (0==strncmp( "file://", p
, 6 ))
1158 case SDBCAddress::EVO_LDAP
:
1159 if (0==strncmp( "ldap://", p
, 6 ))
1163 case SDBCAddress::Unknown
:
1166 for (s
= e_source_group_peek_sources (E_SOURCE_GROUP (g
->data
)); s
; s
= s
->next
)
1168 ESource
*pSource
= E_SOURCE (s
->data
);
1170 rtl::OUString aName
= rtl::OStringToOUString( e_source_peek_name( pSource
),
1171 RTL_TEXTENCODING_UTF8
);
1173 ODatabaseMetaDataResultSet::ORow
aRow(3);
1175 aRow
.push_back(new ORowSetValueDecorator(aName
));
1176 aRow
.push_back(new ORowSetValueDecorator(aTable
));
1177 aRow
.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
1178 aRows
.push_back(aRow
);
1182 pResult
->setRows(aRows
);
1186 // -------------------------------------------------------------------------
1187 Reference
< XResultSet
> SAL_CALL
OEvoabDatabaseMetaData::getUDTs( const Any
& /*catalog*/, const ::rtl::OUString
& /*schemaPattern*/, const ::rtl::OUString
& /*typeNamePattern*/, const Sequence
< sal_Int32
>& /*types*/ ) throw(SQLException
, RuntimeException
)
1189 ::dbtools::throwFeatureNotImplementedException( "XDatabaseMetaDaza::getUDTs", *this );
1192 // -----------------------------------------------------------------------------