bump product version to 4.1.6.2
[LibreOffice.git] / connectivity / source / drivers / mozab / MDatabaseMetaData.cxx
blobc9241a6c83bc63fa84bc71a4b0dd594303ff7241
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "MDatabaseMetaData.hxx"
21 #include "FDatabaseMetaDataResultSet.hxx"
22 #include <com/sun/star/sdbc/DataType.hpp>
23 #include <com/sun/star/sdbc/ResultSetType.hpp>
24 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
25 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
26 #include <connectivity/dbexception.hxx>
27 #include <connectivity/FValue.hxx>
28 #include <com/sun/star/sdbc/ColumnValue.hpp>
29 #include <com/sun/star/sdbc/ColumnSearch.hpp>
30 #include "resource/common_res.hrc"
31 #include <vector>
33 #if OSL_DEBUG_LEVEL > 0
34 # define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
35 #else /* OSL_DEBUG_LEVEL */
36 # define OUtoCStr( x ) ("dummy")
37 #endif /* OSL_DEBUG_LEVEL */
39 using namespace connectivity::mozab;
40 using namespace connectivity;
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star::lang;
43 using namespace com::sun::star::beans;
44 using namespace com::sun::star::sdbc;
45 using namespace com::sun::star::sdbcx;
48 namespace connectivity
50 namespace mozab
52 static sal_Int32 const s_nCOLUMN_SIZE = 256;
53 static sal_Int32 const s_nDECIMAL_DIGITS = 0;
54 static sal_Int32 const s_nNULLABLE = 1;
55 static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
60 ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
61 : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
62 ,m_pConnection(_pCon)
64 OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
65 m_pDbMetaDataHelper = new MDatabaseMetaDataHelper();
67 // -------------------------------------------------------------------------
68 ODatabaseMetaData::~ODatabaseMetaData()
70 delete m_pDbMetaDataHelper;
73 // -------------------------------------------------------------------------
74 ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows(
75 const OUString& tableNamePattern,
76 const OUString& columnNamePattern ) throw(SQLException)
78 static ODatabaseMetaDataResultSet::ORows aRows;
79 ODatabaseMetaDataResultSet::ORow aRow(19);
80 aRows.clear();
82 ::osl::MutexGuard aGuard( m_aMutex );
84 ::std::vector< OUString > tables;
85 ::std::vector< OUString > types;
86 if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types) ) {
87 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
90 // ****************************************************
91 // Some entries in a row never change, so set them now
92 // ****************************************************
94 // Catalog
95 aRow[1] = new ORowSetValueDecorator(OUString(""));
96 // Schema
97 aRow[2] = new ORowSetValueDecorator(OUString(""));
98 // DATA_TYPE
99 aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR));
100 // TYPE_NAME, not used
101 aRow[6] = new ORowSetValueDecorator(OUString("VARCHAR"));
102 // COLUMN_SIZE
103 aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
104 // BUFFER_LENGTH, not used
105 aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
106 // DECIMAL_DIGITS.
107 aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
108 // NUM_PREC_RADIX
109 aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
110 // NULLABLE
111 aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
112 // REMARKS
113 aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
114 // COULUMN_DEF, not used
115 aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
116 // SQL_DATA_TYPE, not used
117 aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
118 // SQL_DATETIME_SUB, not used
119 aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
120 // CHAR_OCTET_LENGTH, refer to [5]
121 aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
122 // IS_NULLABLE
123 aRow[18] = new ORowSetValueDecorator(OUString("YES"));
125 const OColumnAlias& colNames = m_pConnection->getColumnAlias();
127 // Iterate over all tables
128 for(size_t j = 0; j < tables.size(); j++ ) {
129 if(match(tableNamePattern, tables[j],'\0')) {
130 // TABLE_NAME
131 aRow[3] = new ORowSetValueDecorator( tables[j] );
133 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables[j] ));
135 // Iterate over all collumns in the table.
136 for ( OColumnAlias::AliasMap::const_iterator compare = colNames.begin();
137 compare != colNames.end();
138 ++compare
141 if ( match( columnNamePattern, compare->first, '\0' ) )
143 OSL_TRACE( "\t\t\tColumnName = %s;", OUtoCStr( compare->first ) );
144 // COLUMN_NAME
145 aRow[4] = new ORowSetValueDecorator( compare->first );
146 // ORDINAL_POSITION
147 aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( compare->second.columnPosition ) + 1 );
148 aRows.push_back(aRow);
153 return( aRows );
155 // -------------------------------------------------------------------------
156 OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
158 return OUString();
160 // -------------------------------------------------------------------------
161 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
163 sal_Int32 nValue = 65535; // 0 means no limit
164 return nValue;
166 // -------------------------------------------------------------------------
167 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
169 sal_Int32 nValue = 0; // 0 means no limit
170 return nValue;
172 // -------------------------------------------------------------------------
173 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
175 sal_Int32 nValue = 0; // 0 means no limit
176 return nValue;
178 // -------------------------------------------------------------------------
179 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
181 sal_Int32 nValue = 254; // 0 means no limit
182 return nValue;
184 // -------------------------------------------------------------------------
185 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
187 sal_Int32 nValue = 20; // 0 means no limit
188 return nValue;
190 // -------------------------------------------------------------------------
191 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
193 sal_Int32 nValue = 0; // 0 means no limit
194 return nValue;
196 // -------------------------------------------------------------------------
197 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
199 sal_Int32 nValue = 0; // 0 means no limit
200 return nValue;
202 // -------------------------------------------------------------------------
203 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
205 sal_Int32 nValue = 0; // 0 means no limit
206 return nValue;
208 // -------------------------------------------------------------------------
209 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
211 sal_Int32 nValue = 0; // 0 means no limit
212 return nValue;
214 // -------------------------------------------------------------------------
215 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
217 return 0;
219 // -------------------------------------------------------------------------
220 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
222 sal_Int32 nValue = 0; // 0 means no limit
223 return nValue;
225 // -------------------------------------------------------------------------
226 sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
228 // We only support a single table
229 return 1;
231 // -------------------------------------------------------------------------
232 // -------------------------------------------------------------------------
233 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
235 return sal_False;
237 // -------------------------------------------------------------------------
238 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
240 return sal_False;
242 // -------------------------------------------------------------------------
243 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
245 return sal_False;
247 // -------------------------------------------------------------------------
248 sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
250 return sal_False;
252 // -------------------------------------------------------------------------
253 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
255 return sal_False;
257 // -------------------------------------------------------------------------
258 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
260 return sal_False;
262 // -------------------------------------------------------------------------
263 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
265 return sal_False;
267 // -------------------------------------------------------------------------
268 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
270 return sal_False;
272 // -------------------------------------------------------------------------
273 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
275 return sal_False;
277 // -------------------------------------------------------------------------
278 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
280 sal_Int32 nValue = 0; // 0 means no limit
281 return nValue;
283 // -------------------------------------------------------------------------
284 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
286 return sal_False;
288 // -------------------------------------------------------------------------
289 OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
291 OUString aVal;
292 return aVal;
294 // -------------------------------------------------------------------------
295 OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
297 // normally this is "
298 return OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
300 // -------------------------------------------------------------------------
301 OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
303 OUString aVal;
304 return aVal;
306 // -------------------------------------------------------------------------
307 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
309 return sal_True;
311 // -------------------------------------------------------------------------
312 sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
314 return sal_True;
316 // -------------------------------------------------------------------------
317 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
319 return sal_True;
321 // -------------------------------------------------------------------------
322 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
324 return sal_True;
326 // -------------------------------------------------------------------------
327 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
329 //We support create table
330 return sal_False;
332 // -------------------------------------------------------------------------
333 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
335 return sal_False;
337 // -------------------------------------------------------------------------
338 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
340 return sal_False;
342 // -------------------------------------------------------------------------
343 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
345 return sal_False;
347 // -------------------------------------------------------------------------
348 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
350 return sal_False;
352 // -------------------------------------------------------------------------
353 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
355 return sal_False;
357 // -------------------------------------------------------------------------
358 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
360 return sal_False;
362 // -------------------------------------------------------------------------
363 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
365 return sal_False;
367 // -------------------------------------------------------------------------
368 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
370 return sal_False;
372 // -------------------------------------------------------------------------
373 sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
375 return sal_False;
377 // -------------------------------------------------------------------------
378 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
380 return sal_False;
382 // -------------------------------------------------------------------------
383 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
385 return sal_True; // should be supported at least
387 // -------------------------------------------------------------------------
388 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
390 return sal_False;
392 // -------------------------------------------------------------------------
393 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
395 return sal_False;
397 // -------------------------------------------------------------------------
398 sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
400 return sal_False;
402 // -------------------------------------------------------------------------
403 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
405 return sal_False;
407 // -------------------------------------------------------------------------
408 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
410 return sal_False;
412 // -------------------------------------------------------------------------
413 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
415 return sal_False;
417 // -------------------------------------------------------------------------
418 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
420 return sal_False;
422 // -------------------------------------------------------------------------
423 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
425 return 0;// 0 means no limit
427 // -------------------------------------------------------------------------
428 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
430 sal_Int32 nValue = 0; // 0 means no limit
431 return nValue;
433 // -------------------------------------------------------------------------
434 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
436 sal_Int32 nValue = 0; // 0 means no limit
437 return nValue;
439 // -------------------------------------------------------------------------
440 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
442 return sal_False;
444 // -------------------------------------------------------------------------
445 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
447 return sal_False;
449 // -------------------------------------------------------------------------
450 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
452 return sal_False;
454 // -------------------------------------------------------------------------
455 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
457 return sal_False;
459 // -------------------------------------------------------------------------
460 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
462 // We allow you to select from any table.
463 return sal_True;
465 // -------------------------------------------------------------------------
466 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
468 //we support insert/update/delete now
469 //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
470 //entry to the popup menu. We should avoid them.
471 return sal_True;
473 // -------------------------------------------------------------------------
474 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
476 return sal_False;
478 // -------------------------------------------------------------------------
479 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
481 return sal_False;
483 // -------------------------------------------------------------------------
484 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
486 return sal_False;
488 // -------------------------------------------------------------------------
489 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
491 return sal_False;
493 // -------------------------------------------------------------------------
494 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
496 // Support added for this.
497 return sal_True;
499 // -------------------------------------------------------------------------
500 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
502 return sal_False;
504 // -------------------------------------------------------------------------
505 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
507 return sal_False;
509 // -------------------------------------------------------------------------
510 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
512 return sal_False;
514 // -------------------------------------------------------------------------
515 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
517 return sal_False;
519 // -------------------------------------------------------------------------
520 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
522 return sal_False;
524 // -------------------------------------------------------------------------
525 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
527 return sal_False;
529 // -------------------------------------------------------------------------
530 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
532 return sal_False;
534 // -------------------------------------------------------------------------
535 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
537 return sal_False;
539 // -------------------------------------------------------------------------
540 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
542 return sal_False;
544 // -------------------------------------------------------------------------
545 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
547 return sal_False;
549 // -------------------------------------------------------------------------
550 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
552 return sal_False;
554 // -------------------------------------------------------------------------
555 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
557 return sal_False;
559 // -------------------------------------------------------------------------
560 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
562 return sal_True;
564 // -------------------------------------------------------------------------
565 sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
567 // Any case may be used
568 return sal_True;
570 // -------------------------------------------------------------------------
571 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
573 return sal_False;
575 // -------------------------------------------------------------------------
576 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
578 return sal_True;
580 // -------------------------------------------------------------------------
581 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
583 return sal_False;
585 // -------------------------------------------------------------------------
586 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
588 return sal_True;
590 // -------------------------------------------------------------------------
591 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
593 return sal_False;
595 // -------------------------------------------------------------------------
596 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
598 return sal_False;
600 // -------------------------------------------------------------------------
601 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
603 return sal_False;
605 // -------------------------------------------------------------------------
606 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
608 return sal_False;
610 // -------------------------------------------------------------------------
611 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
613 return sal_False;
615 // -------------------------------------------------------------------------
616 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
618 return sal_False;
620 // -------------------------------------------------------------------------
621 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
623 return sal_False;
625 // -------------------------------------------------------------------------
626 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
628 return sal_False;
630 // -------------------------------------------------------------------------
631 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
633 return sal_False;
635 // -------------------------------------------------------------------------
636 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
638 return sal_False;
640 // -------------------------------------------------------------------------
641 OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
643 ::osl::MutexGuard aGuard( m_aMutex );
645 return m_pConnection->getURL();
647 // -------------------------------------------------------------------------
648 OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
650 OUString aValue;
651 return aValue;
653 // -------------------------------------------------------------------------
654 OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
656 OUString aValue;
657 return aValue;
659 // -------------------------------------------------------------------------
660 OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
662 OUString aValue = OUString::valueOf((sal_Int32)1);
663 return aValue;
665 // -------------------------------------------------------------------------
666 OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
668 OUString aValue = OUString::valueOf((sal_Int32)0);
669 return aValue;
671 // -------------------------------------------------------------------------
672 OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
674 OUString aValue;
675 return aValue;
677 // -------------------------------------------------------------------------
678 OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
680 OUString aValue;
681 return aValue;
683 // -------------------------------------------------------------------------
684 OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
686 OUString aValue;
687 return aValue;
689 // -------------------------------------------------------------------------
690 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
692 return 1;
694 // -------------------------------------------------------------------------
695 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
697 return TransactionIsolation::NONE;
699 // -------------------------------------------------------------------------
700 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
702 return 0;
704 // -------------------------------------------------------------------------
705 OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
707 OUString aValue;
708 return aValue;
710 // -------------------------------------------------------------------------
711 OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
713 OUString aValue;
714 return aValue;
716 // -------------------------------------------------------------------------
717 OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
719 return OUString();
721 // -------------------------------------------------------------------------
722 OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
724 return OUString();
726 // -------------------------------------------------------------------------
727 OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
729 return OUString();
731 // -------------------------------------------------------------------------
732 OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
734 return OUString();
736 // -------------------------------------------------------------------------
737 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
739 return sal_False;
741 // -------------------------------------------------------------------------
742 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
744 return sal_False;
746 // -------------------------------------------------------------------------
747 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
749 return sal_True;
751 // -------------------------------------------------------------------------
752 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
754 return sal_False;
756 // -------------------------------------------------------------------------
757 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
759 return sal_False;
761 // -------------------------------------------------------------------------
762 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
764 sal_Int32 nValue = 0; // 0 means no limit
765 return nValue;
767 // -------------------------------------------------------------------------
768 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
770 sal_Int32 nValue = 0; // 0 means no limit
771 return nValue;
773 // -------------------------------------------------------------------------
774 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
776 sal_Int32 nValue = 0; // 0 means no limit
777 return nValue;
779 // -------------------------------------------------------------------------
780 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
782 sal_Int32 nValue = 0; // 0 means no limit
783 return nValue;
785 // -------------------------------------------------------------------------
786 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
788 return sal_False;
790 // -------------------------------------------------------------------------
791 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
793 return sal_False;
795 // -------------------------------------------------------------------------
796 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
798 return sal_True;
800 // -------------------------------------------------------------------------
801 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
803 return sal_True;
805 // -------------------------------------------------------------------------
806 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
808 return sal_True;
810 // -------------------------------------------------------------------------
811 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
813 return sal_False;
815 // -------------------------------------------------------------------------
816 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
818 return sal_False;
820 // -------------------------------------------------------------------------
821 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
823 return sal_False;
825 // -------------------------------------------------------------------------
826 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
828 return sal_True;
830 // -------------------------------------------------------------------------
831 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
833 return sal_True;
835 // -------------------------------------------------------------------------
836 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
838 return sal_True;
840 // -------------------------------------------------------------------------
841 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
843 return sal_False;
845 // -------------------------------------------------------------------------
846 // here follow all methods which return a resultset
847 // the first methods is an example implementation how to use this resultset
848 // of course you could implement it on your and you should do this because
849 // the general way is more memory expensive
850 // -------------------------------------------------------------------------
851 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
853 // there exists no possibility to get table types so we have to check
854 static OUString sTableTypes[] =
856 OUString("TABLE"),
857 OUString("VIEW")
858 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
860 // OUString("SYSTEM TABLE"),
861 // OUString("GLOBAL TEMPORARY"),
862 // OUString("LOCAL TEMPORARY"),
863 // OUString("ALIAS"),
864 // OUString("SYNONYM")
866 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
867 Reference< XResultSet > xRef = pResult;
869 // here we fill the rows which should be visible when ask for data from the resultset returned here
870 const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(OUString);
871 ODatabaseMetaDataResultSet::ORows aRows;
872 for(sal_Int32 i=0;i < nSize;++i)
874 ODatabaseMetaDataResultSet::ORow aRow;
875 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
876 aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
877 // bound row
878 aRows.push_back(aRow);
880 // here we set the rows at the resultset
881 pResult->setRows(aRows);
882 return xRef;
884 // -------------------------------------------------------------------------
885 Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
887 // this returns an empty resultset where the column-names are already set
888 // in special the metadata of the resultset already returns the right columns
889 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
890 Reference< XResultSet > xResultSet = pResultSet;
891 static ODatabaseMetaDataResultSet::ORows aRows;
893 if(aRows.empty())
895 ODatabaseMetaDataResultSet::ORow aRow;
896 aRow.reserve(19);
897 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
898 aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR")));
899 aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
900 aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
901 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
902 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
903 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
904 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
905 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
906 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
907 aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
908 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
909 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
910 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
911 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
912 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
913 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
914 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
915 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
916 aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
918 aRows.push_back(aRow);
921 pResultSet->setRows(aRows);
922 return xResultSet;
924 // -------------------------------------------------------------------------
925 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
926 const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern,
927 const OUString& columnNamePattern ) throw(SQLException, RuntimeException)
929 // this returns an empty resultset where the column-names are already set
930 // in special the metadata of the resultset already returns the right columns
931 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns);
932 Reference< XResultSet > xResultSet = pResultSet;
933 pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ));
934 return xResultSet;
936 // -------------------------------------------------------------------------
937 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
938 const Any& /*catalog*/, const OUString& /*schemaPattern*/,
939 const OUString& tableNamePattern, const Sequence< OUString >& types ) throw(SQLException, RuntimeException)
941 // this returns an empty resultset where the column-names are already set
942 // in special the metadata of the resultset already returns the right columns
943 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
944 Reference< XResultSet > xResultSet = pResultSet;
946 // ODatabaseMetaDataResultSet::ORows aRows;
947 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
948 // pResultSet->setRows( aRows );
949 ODatabaseMetaDataResultSet::ORows _rRows;
950 if ( !m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern, types,_rRows ) ) {
951 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
953 pResultSet->setRows( _rRows );
955 return xResultSet;
957 // -------------------------------------------------------------------------
958 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
959 const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern ) throw(SQLException, RuntimeException)
961 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges);
963 Reference< XResultSet > xRef = pResult;
965 ::std::vector< OUString > tables;
966 ::std::vector< OUString > types;
967 if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types ) )
968 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
970 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
971 ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
972 aRows.reserve(8);
973 aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
974 aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
975 aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
976 aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
977 aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
978 aRow[7] = new ::connectivity::ORowSetValueDecorator(OUString("NO"));
981 // Iterate over all tables
982 for(size_t j = 0; j < tables.size(); j++ ) {
983 if(match(tableNamePattern, tables[j],'\0'))
985 // TABLE_NAME
986 aRow[2] = new ORowSetValueDecorator( tables[j] );
988 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables[j] ));
990 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
991 aRows.push_back(aRow);
992 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
993 aRows.push_back(aRow);
994 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
995 aRows.push_back(aRow);
996 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
997 aRows.push_back(aRow);
998 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
999 aRows.push_back(aRow);
1000 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
1001 aRows.push_back(aRow);
1002 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1003 aRows.push_back(aRow);
1004 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1005 aRows.push_back(aRow);
1008 pResult->setRows(aRows);
1009 return xRef;
1012 // -------------------------------------------------------------------------
1013 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
1015 return NULL;
1017 // -----------------------------------------------------------------------------
1021 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */