merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / mozab / MDatabaseMetaData.cxx
blobecfe0ea9c39ca2eaaa0b948d82b7104c93319134
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MDatabaseMetaData.cxx,v $
10 * $Revision: 1.16.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "MDatabaseMetaData.hxx"
34 #include "FDatabaseMetaDataResultSet.hxx"
35 #include <com/sun/star/sdbc/DataType.hpp>
36 #include <com/sun/star/sdbc/ResultSetType.hpp>
37 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
38 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
39 #include <connectivity/dbexception.hxx>
40 #include <connectivity/FValue.hxx>
41 #include <com/sun/star/sdbc/ColumnValue.hpp>
42 #include <com/sun/star/sdbc/ColumnSearch.hpp>
43 #include "resource/common_res.hrc"
44 #include <vector>
46 #if OSL_DEBUG_LEVEL > 0
47 # define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
48 #else /* OSL_DEBUG_LEVEL */
49 # define OUtoCStr( x ) ("dummy")
50 #endif /* OSL_DEBUG_LEVEL */
52 using namespace connectivity::mozab;
53 using namespace connectivity;
54 using namespace com::sun::star::uno;
55 using namespace com::sun::star::lang;
56 using namespace com::sun::star::beans;
57 using namespace com::sun::star::sdbc;
58 using namespace com::sun::star::sdbcx;
61 namespace connectivity
63 namespace mozab
65 static sal_Int32 const s_nCOLUMN_SIZE = 256;
66 static sal_Int32 const s_nDECIMAL_DIGITS = 0;
67 static sal_Int32 const s_nNULLABLE = 1;
68 static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
73 ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
74 : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
75 ,m_pConnection(_pCon)
77 OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
78 m_pDbMetaDataHelper = new MDatabaseMetaDataHelper();
80 // -------------------------------------------------------------------------
81 ODatabaseMetaData::~ODatabaseMetaData()
83 delete m_pDbMetaDataHelper;
86 // -------------------------------------------------------------------------
87 ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows(
88 const ::rtl::OUString& tableNamePattern,
89 const ::rtl::OUString& columnNamePattern ) throw(SQLException)
91 static ODatabaseMetaDataResultSet::ORows aRows;
92 ODatabaseMetaDataResultSet::ORow aRow(19);
93 aRows.clear();
95 ::osl::MutexGuard aGuard( m_aMutex );
97 ::std::vector< ::rtl::OUString > tables;
98 ::std::vector< ::rtl::OUString > types;
99 if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types) ) {
100 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
103 // ****************************************************
104 // Some entries in a row never change, so set them now
105 // ****************************************************
107 // Catalog
108 aRow[1] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
109 // Schema
110 aRow[2] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
111 // DATA_TYPE
112 aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR));
113 // TYPE_NAME, not used
114 aRow[6] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR")));
115 // COLUMN_SIZE
116 aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
117 // BUFFER_LENGTH, not used
118 aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
119 // DECIMAL_DIGITS.
120 aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
121 // NUM_PREC_RADIX
122 aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
123 // NULLABLE
124 aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
125 // REMARKS
126 aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
127 // COULUMN_DEF, not used
128 aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
129 // SQL_DATA_TYPE, not used
130 aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
131 // SQL_DATETIME_SUB, not used
132 aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
133 // CHAR_OCTET_LENGTH, refer to [5]
134 aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
135 // IS_NULLABLE
136 aRow[18] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("YES")));
138 const OColumnAlias& colNames = m_pConnection->getColumnAlias();
140 // Iterate over all tables
141 for(size_t j = 0; j < tables.size(); j++ ) {
142 if(match(tableNamePattern, tables[j],'\0')) {
143 // TABLE_NAME
144 aRow[3] = new ORowSetValueDecorator( tables[j] );
146 OSL_TRACE( "\t\tTableName = %s;\n",OUtoCStr( tables[j] ));
148 // Iterate over all collumns in the table.
149 for ( OColumnAlias::AliasMap::const_iterator compare = colNames.begin();
150 compare != colNames.end();
151 ++compare
154 if ( match( columnNamePattern, compare->first, '\0' ) )
156 OSL_TRACE( "\t\t\tColumnName = %s;\n", OUtoCStr( compare->first ) );
157 // COLUMN_NAME
158 aRow[4] = new ORowSetValueDecorator( compare->first );
159 // ORDINAL_POSITION
160 aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( compare->second.columnPosition ) + 1 );
161 aRows.push_back(aRow);
166 return( aRows );
168 // -------------------------------------------------------------------------
169 ::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
171 return ::rtl::OUString();
173 // -------------------------------------------------------------------------
174 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
176 sal_Int32 nValue = 65535; // 0 means no limit
177 return nValue;
179 // -------------------------------------------------------------------------
180 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
182 sal_Int32 nValue = 0; // 0 means no limit
183 return nValue;
185 // -------------------------------------------------------------------------
186 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
188 sal_Int32 nValue = 0; // 0 means no limit
189 return nValue;
191 // -------------------------------------------------------------------------
192 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
194 sal_Int32 nValue = 254; // 0 means no limit
195 return nValue;
197 // -------------------------------------------------------------------------
198 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
200 sal_Int32 nValue = 20; // 0 means no limit
201 return nValue;
203 // -------------------------------------------------------------------------
204 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
206 sal_Int32 nValue = 0; // 0 means no limit
207 return nValue;
209 // -------------------------------------------------------------------------
210 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
212 sal_Int32 nValue = 0; // 0 means no limit
213 return nValue;
215 // -------------------------------------------------------------------------
216 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
218 sal_Int32 nValue = 0; // 0 means no limit
219 return nValue;
221 // -------------------------------------------------------------------------
222 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
224 sal_Int32 nValue = 0; // 0 means no limit
225 return nValue;
227 // -------------------------------------------------------------------------
228 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
230 return 0;
232 // -------------------------------------------------------------------------
233 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
235 sal_Int32 nValue = 0; // 0 means no limit
236 return nValue;
238 // -------------------------------------------------------------------------
239 sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
241 // We only support a single table
242 return 1;
244 // -------------------------------------------------------------------------
245 // -------------------------------------------------------------------------
246 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
248 return sal_False;
250 // -------------------------------------------------------------------------
251 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
253 return sal_False;
255 // -------------------------------------------------------------------------
256 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
258 return sal_False;
260 // -------------------------------------------------------------------------
261 sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
263 return sal_False;
265 // -------------------------------------------------------------------------
266 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
268 return sal_False;
270 // -------------------------------------------------------------------------
271 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
273 return sal_False;
275 // -------------------------------------------------------------------------
276 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
278 return sal_False;
280 // -------------------------------------------------------------------------
281 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
283 return sal_False;
285 // -------------------------------------------------------------------------
286 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
288 return sal_False;
290 // -------------------------------------------------------------------------
291 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
293 sal_Int32 nValue = 0; // 0 means no limit
294 return nValue;
296 // -------------------------------------------------------------------------
297 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
299 return sal_False;
301 // -------------------------------------------------------------------------
302 ::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
304 ::rtl::OUString aVal;
305 return aVal;
307 // -------------------------------------------------------------------------
308 ::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
310 // normally this is "
311 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
313 // -------------------------------------------------------------------------
314 ::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
316 ::rtl::OUString aVal;
317 return aVal;
319 // -------------------------------------------------------------------------
320 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
322 return sal_True;
324 // -------------------------------------------------------------------------
325 sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
327 return sal_True;
329 // -------------------------------------------------------------------------
330 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
332 return sal_True;
334 // -------------------------------------------------------------------------
335 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
337 return sal_True;
339 // -------------------------------------------------------------------------
340 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
342 //We support create table
343 return sal_False;
345 // -------------------------------------------------------------------------
346 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
348 return sal_False;
350 // -------------------------------------------------------------------------
351 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
353 return sal_False;
355 // -------------------------------------------------------------------------
356 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
358 return sal_False;
360 // -------------------------------------------------------------------------
361 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
363 return sal_False;
365 // -------------------------------------------------------------------------
366 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
368 return sal_False;
370 // -------------------------------------------------------------------------
371 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
373 return sal_False;
375 // -------------------------------------------------------------------------
376 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
378 return sal_False;
380 // -------------------------------------------------------------------------
381 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
383 return sal_False;
385 // -------------------------------------------------------------------------
386 sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
388 return sal_False;
390 // -------------------------------------------------------------------------
391 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
393 return sal_False;
395 // -------------------------------------------------------------------------
396 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
398 return sal_True; // should be supported at least
400 // -------------------------------------------------------------------------
401 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
403 return sal_False;
405 // -------------------------------------------------------------------------
406 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
408 return sal_False;
410 // -------------------------------------------------------------------------
411 sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
413 return sal_False;
415 // -------------------------------------------------------------------------
416 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
418 return sal_False;
420 // -------------------------------------------------------------------------
421 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
423 return sal_False;
425 // -------------------------------------------------------------------------
426 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
428 return sal_False;
430 // -------------------------------------------------------------------------
431 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
433 return sal_False;
435 // -------------------------------------------------------------------------
436 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
438 return 0;// 0 means no limit
440 // -------------------------------------------------------------------------
441 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
443 sal_Int32 nValue = 0; // 0 means no limit
444 return nValue;
446 // -------------------------------------------------------------------------
447 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
449 sal_Int32 nValue = 0; // 0 means no limit
450 return nValue;
452 // -------------------------------------------------------------------------
453 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
455 return sal_False;
457 // -------------------------------------------------------------------------
458 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
460 return sal_False;
462 // -------------------------------------------------------------------------
463 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
465 return sal_False;
467 // -------------------------------------------------------------------------
468 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
470 return sal_False;
472 // -------------------------------------------------------------------------
473 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
475 // We allow you to select from any table.
476 return sal_True;
478 // -------------------------------------------------------------------------
479 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
481 //we support insert/update/delete now
482 //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
483 //entry to the popup menu. We should avoid them.
484 return sal_True;
486 // -------------------------------------------------------------------------
487 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
489 return sal_False;
491 // -------------------------------------------------------------------------
492 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
494 return sal_False;
496 // -------------------------------------------------------------------------
497 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
499 return sal_False;
501 // -------------------------------------------------------------------------
502 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
504 return sal_False;
506 // -------------------------------------------------------------------------
507 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
509 // Support added for this.
510 return sal_True;
512 // -------------------------------------------------------------------------
513 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
515 return sal_False;
517 // -------------------------------------------------------------------------
518 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
520 return sal_False;
522 // -------------------------------------------------------------------------
523 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
525 return sal_False;
527 // -------------------------------------------------------------------------
528 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
530 return sal_False;
532 // -------------------------------------------------------------------------
533 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
535 return sal_False;
537 // -------------------------------------------------------------------------
538 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
540 return sal_False;
542 // -------------------------------------------------------------------------
543 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
545 return sal_False;
547 // -------------------------------------------------------------------------
548 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
550 return sal_False;
552 // -------------------------------------------------------------------------
553 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
555 return sal_False;
557 // -------------------------------------------------------------------------
558 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
560 return sal_False;
562 // -------------------------------------------------------------------------
563 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
565 return sal_False;
567 // -------------------------------------------------------------------------
568 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
570 return sal_False;
572 // -------------------------------------------------------------------------
573 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
575 return sal_True;
577 // -------------------------------------------------------------------------
578 sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
580 // Any case may be used
581 return sal_True;
583 // -------------------------------------------------------------------------
584 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
586 return sal_False;
588 // -------------------------------------------------------------------------
589 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
591 return sal_True;
593 // -------------------------------------------------------------------------
594 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
596 return sal_False;
598 // -------------------------------------------------------------------------
599 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
601 return sal_True;
603 // -------------------------------------------------------------------------
604 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
606 return sal_False;
608 // -------------------------------------------------------------------------
609 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
611 return sal_False;
613 // -------------------------------------------------------------------------
614 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
616 return sal_False;
618 // -------------------------------------------------------------------------
619 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
621 return sal_False;
623 // -------------------------------------------------------------------------
624 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
626 return sal_False;
628 // -------------------------------------------------------------------------
629 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
631 return sal_False;
633 // -------------------------------------------------------------------------
634 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
636 return sal_False;
638 // -------------------------------------------------------------------------
639 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
641 return sal_False;
643 // -------------------------------------------------------------------------
644 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
646 return sal_False;
648 // -------------------------------------------------------------------------
649 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
651 return sal_False;
653 // -------------------------------------------------------------------------
654 ::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
656 ::osl::MutexGuard aGuard( m_aMutex );
658 return m_pConnection->getURL();
660 // -------------------------------------------------------------------------
661 ::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
663 ::rtl::OUString aValue;
664 return aValue;
666 // -------------------------------------------------------------------------
667 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
669 ::rtl::OUString aValue;
670 return aValue;
672 // -------------------------------------------------------------------------
673 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
675 ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)1);
676 return aValue;
678 // -------------------------------------------------------------------------
679 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
681 ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)0);
682 return aValue;
684 // -------------------------------------------------------------------------
685 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
687 ::rtl::OUString aValue;
688 return aValue;
690 // -------------------------------------------------------------------------
691 ::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
693 ::rtl::OUString aValue;
694 return aValue;
696 // -------------------------------------------------------------------------
697 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
699 ::rtl::OUString aValue;
700 return aValue;
702 // -------------------------------------------------------------------------
703 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
705 return 1;
707 // -------------------------------------------------------------------------
708 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
710 return TransactionIsolation::NONE;
712 // -------------------------------------------------------------------------
713 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
715 return 0;
717 // -------------------------------------------------------------------------
718 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
720 ::rtl::OUString aValue;
721 return aValue;
723 // -------------------------------------------------------------------------
724 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
726 ::rtl::OUString aValue;
727 return aValue;
729 // -------------------------------------------------------------------------
730 ::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
732 return ::rtl::OUString();
734 // -------------------------------------------------------------------------
735 ::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
737 return ::rtl::OUString();
739 // -------------------------------------------------------------------------
740 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
742 return ::rtl::OUString();
744 // -------------------------------------------------------------------------
745 ::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
747 return ::rtl::OUString();
749 // -------------------------------------------------------------------------
750 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
752 return sal_False;
754 // -------------------------------------------------------------------------
755 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
757 return sal_False;
759 // -------------------------------------------------------------------------
760 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
762 return sal_True;
764 // -------------------------------------------------------------------------
765 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
767 return sal_False;
769 // -------------------------------------------------------------------------
770 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
772 return sal_False;
774 // -------------------------------------------------------------------------
775 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
777 sal_Int32 nValue = 0; // 0 means no limit
778 return nValue;
780 // -------------------------------------------------------------------------
781 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
783 sal_Int32 nValue = 0; // 0 means no limit
784 return nValue;
786 // -------------------------------------------------------------------------
787 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
789 sal_Int32 nValue = 0; // 0 means no limit
790 return nValue;
792 // -------------------------------------------------------------------------
793 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
795 sal_Int32 nValue = 0; // 0 means no limit
796 return nValue;
798 // -------------------------------------------------------------------------
799 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
801 return sal_False;
803 // -------------------------------------------------------------------------
804 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
806 return sal_False;
808 // -------------------------------------------------------------------------
809 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
811 return sal_True;
813 // -------------------------------------------------------------------------
814 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
816 return sal_True;
818 // -------------------------------------------------------------------------
819 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
821 return sal_True;
823 // -------------------------------------------------------------------------
824 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
826 return sal_False;
828 // -------------------------------------------------------------------------
829 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
831 return sal_False;
833 // -------------------------------------------------------------------------
834 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
836 return sal_False;
838 // -------------------------------------------------------------------------
839 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
841 return sal_True;
843 // -------------------------------------------------------------------------
844 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
846 return sal_True;
848 // -------------------------------------------------------------------------
849 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
851 return sal_True;
853 // -------------------------------------------------------------------------
854 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
856 return sal_False;
858 // -------------------------------------------------------------------------
859 // here follow all methods which return a resultset
860 // the first methods is an example implementation how to use this resultset
861 // of course you could implement it on your and you should do this because
862 // the general way is more memory expensive
863 // -------------------------------------------------------------------------
864 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
866 // there exists no possibility to get table types so we have to check
867 static ::rtl::OUString sTableTypes[] =
869 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")),
870 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW"))
871 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
873 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEM TABLE")),
874 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("GLOBAL TEMPORARY")),
875 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LOCAL TEMPORARY")),
876 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ALIAS")),
877 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYNONYM"))
879 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
880 Reference< XResultSet > xRef = pResult;
882 // here we fill the rows which should be visible when ask for data from the resultset returned here
883 const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
884 ODatabaseMetaDataResultSet::ORows aRows;
885 for(sal_Int32 i=0;i < nSize;++i)
887 ODatabaseMetaDataResultSet::ORow aRow;
888 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
889 aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
890 // bound row
891 aRows.push_back(aRow);
893 // here we set the rows at the resultset
894 pResult->setRows(aRows);
895 return xRef;
897 // -------------------------------------------------------------------------
898 Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
900 // this returns an empty resultset where the column-names are already set
901 // in special the metadata of the resultset already returns the right columns
902 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
903 Reference< XResultSet > xResultSet = pResultSet;
904 static ODatabaseMetaDataResultSet::ORows aRows;
906 if(aRows.empty())
908 ODatabaseMetaDataResultSet::ORow aRow;
909 aRow.reserve(19);
910 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
911 aRow.push_back(new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR"))));
912 aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
913 aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
914 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
915 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
916 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
917 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
918 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
919 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
920 aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
921 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
922 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
923 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
924 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
925 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
926 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
927 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
928 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
929 aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
931 aRows.push_back(aRow);
934 pResultSet->setRows(aRows);
935 return xResultSet;
937 // -------------------------------------------------------------------------
938 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
939 const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
940 const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
942 // this returns an empty resultset where the column-names are already set
943 // in special the metadata of the resultset already returns the right columns
944 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns);
945 Reference< XResultSet > xResultSet = pResultSet;
946 pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ));
947 return xResultSet;
949 // -------------------------------------------------------------------------
950 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
951 const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
952 const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
954 // this returns an empty resultset where the column-names are already set
955 // in special the metadata of the resultset already returns the right columns
956 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
957 Reference< XResultSet > xResultSet = pResultSet;
959 // ODatabaseMetaDataResultSet::ORows aRows;
960 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
961 // pResultSet->setRows( aRows );
962 ODatabaseMetaDataResultSet::ORows _rRows;
963 if ( !m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern, types,_rRows ) ) {
964 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
966 pResultSet->setRows( _rRows );
968 return xResultSet;
970 // -------------------------------------------------------------------------
971 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
972 const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
974 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges);
975 Reference< XResultSet > xRef = NULL;
977 xRef = pResult;
979 ::std::vector< ::rtl::OUString > tables;
980 ::std::vector< ::rtl::OUString > types;
981 if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types ) )
982 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
984 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
985 ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
986 aRows.reserve(8);
987 aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
988 aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
989 aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
990 aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
991 aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
992 aRow[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NO")));
995 // Iterate over all tables
996 for(size_t j = 0; j < tables.size(); j++ ) {
997 if(match(tableNamePattern, tables[j],'\0'))
999 // TABLE_NAME
1000 aRow[2] = new ORowSetValueDecorator( tables[j] );
1002 OSL_TRACE( "\t\tTableName = %s;\n",OUtoCStr( tables[j] ));
1004 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
1005 aRows.push_back(aRow);
1006 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
1007 aRows.push_back(aRow);
1008 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
1009 aRows.push_back(aRow);
1010 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
1011 aRows.push_back(aRow);
1012 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
1013 aRows.push_back(aRow);
1014 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
1015 aRows.push_back(aRow);
1016 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1017 aRows.push_back(aRow);
1018 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1019 aRows.push_back(aRow);
1022 pResult->setRows(aRows);
1023 return xRef;
1026 // -------------------------------------------------------------------------
1027 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
1029 return NULL;
1031 // -----------------------------------------------------------------------------