Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / mozab / MDatabaseMetaData.cxx
blobe0b0d72e9f7362b86e1e358a9946231d9eee0db2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "MDatabaseMetaData.hxx"
30 #include "FDatabaseMetaDataResultSet.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>
39 #include "resource/common_res.hrc"
40 #include <vector>
42 #if OSL_DEBUG_LEVEL > 0
43 # define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
44 #else /* OSL_DEBUG_LEVEL */
45 # define OUtoCStr( x ) ("dummy")
46 #endif /* OSL_DEBUG_LEVEL */
48 using namespace connectivity::mozab;
49 using namespace connectivity;
50 using namespace com::sun::star::uno;
51 using namespace com::sun::star::lang;
52 using namespace com::sun::star::beans;
53 using namespace com::sun::star::sdbc;
54 using namespace com::sun::star::sdbcx;
57 namespace connectivity
59 namespace mozab
61 static sal_Int32 const s_nCOLUMN_SIZE = 256;
62 static sal_Int32 const s_nDECIMAL_DIGITS = 0;
63 static sal_Int32 const s_nNULLABLE = 1;
64 static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
69 ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
70 : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
71 ,m_pConnection(_pCon)
73 OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
74 m_pDbMetaDataHelper = new MDatabaseMetaDataHelper();
76 // -------------------------------------------------------------------------
77 ODatabaseMetaData::~ODatabaseMetaData()
79 delete m_pDbMetaDataHelper;
82 // -------------------------------------------------------------------------
83 ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows(
84 const ::rtl::OUString& tableNamePattern,
85 const ::rtl::OUString& columnNamePattern ) throw(SQLException)
87 static ODatabaseMetaDataResultSet::ORows aRows;
88 ODatabaseMetaDataResultSet::ORow aRow(19);
89 aRows.clear();
91 ::osl::MutexGuard aGuard( m_aMutex );
93 ::std::vector< ::rtl::OUString > tables;
94 ::std::vector< ::rtl::OUString > types;
95 if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types) ) {
96 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
99 // ****************************************************
100 // Some entries in a row never change, so set them now
101 // ****************************************************
103 // Catalog
104 aRow[1] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
105 // Schema
106 aRow[2] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
107 // DATA_TYPE
108 aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR));
109 // TYPE_NAME, not used
110 aRow[6] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR")));
111 // COLUMN_SIZE
112 aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
113 // BUFFER_LENGTH, not used
114 aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
115 // DECIMAL_DIGITS.
116 aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
117 // NUM_PREC_RADIX
118 aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
119 // NULLABLE
120 aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
121 // REMARKS
122 aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
123 // COULUMN_DEF, not used
124 aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
125 // SQL_DATA_TYPE, not used
126 aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
127 // SQL_DATETIME_SUB, not used
128 aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
129 // CHAR_OCTET_LENGTH, refer to [5]
130 aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
131 // IS_NULLABLE
132 aRow[18] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("YES")));
134 const OColumnAlias& colNames = m_pConnection->getColumnAlias();
136 // Iterate over all tables
137 for(size_t j = 0; j < tables.size(); j++ ) {
138 if(match(tableNamePattern, tables[j],'\0')) {
139 // TABLE_NAME
140 aRow[3] = new ORowSetValueDecorator( tables[j] );
142 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables[j] ));
144 // Iterate over all collumns in the table.
145 for ( OColumnAlias::AliasMap::const_iterator compare = colNames.begin();
146 compare != colNames.end();
147 ++compare
150 if ( match( columnNamePattern, compare->first, '\0' ) )
152 OSL_TRACE( "\t\t\tColumnName = %s;", OUtoCStr( compare->first ) );
153 // COLUMN_NAME
154 aRow[4] = new ORowSetValueDecorator( compare->first );
155 // ORDINAL_POSITION
156 aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( compare->second.columnPosition ) + 1 );
157 aRows.push_back(aRow);
162 return( aRows );
164 // -------------------------------------------------------------------------
165 ::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
167 return ::rtl::OUString();
169 // -------------------------------------------------------------------------
170 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
172 sal_Int32 nValue = 65535; // 0 means no limit
173 return nValue;
175 // -------------------------------------------------------------------------
176 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
178 sal_Int32 nValue = 0; // 0 means no limit
179 return nValue;
181 // -------------------------------------------------------------------------
182 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
184 sal_Int32 nValue = 0; // 0 means no limit
185 return nValue;
187 // -------------------------------------------------------------------------
188 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
190 sal_Int32 nValue = 254; // 0 means no limit
191 return nValue;
193 // -------------------------------------------------------------------------
194 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
196 sal_Int32 nValue = 20; // 0 means no limit
197 return nValue;
199 // -------------------------------------------------------------------------
200 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
202 sal_Int32 nValue = 0; // 0 means no limit
203 return nValue;
205 // -------------------------------------------------------------------------
206 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
208 sal_Int32 nValue = 0; // 0 means no limit
209 return nValue;
211 // -------------------------------------------------------------------------
212 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
214 sal_Int32 nValue = 0; // 0 means no limit
215 return nValue;
217 // -------------------------------------------------------------------------
218 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
220 sal_Int32 nValue = 0; // 0 means no limit
221 return nValue;
223 // -------------------------------------------------------------------------
224 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
226 return 0;
228 // -------------------------------------------------------------------------
229 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
231 sal_Int32 nValue = 0; // 0 means no limit
232 return nValue;
234 // -------------------------------------------------------------------------
235 sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
237 // We only support a single table
238 return 1;
240 // -------------------------------------------------------------------------
241 // -------------------------------------------------------------------------
242 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
244 return sal_False;
246 // -------------------------------------------------------------------------
247 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
249 return sal_False;
251 // -------------------------------------------------------------------------
252 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
254 return sal_False;
256 // -------------------------------------------------------------------------
257 sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
259 return sal_False;
261 // -------------------------------------------------------------------------
262 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
264 return sal_False;
266 // -------------------------------------------------------------------------
267 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
269 return sal_False;
271 // -------------------------------------------------------------------------
272 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
274 return sal_False;
276 // -------------------------------------------------------------------------
277 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
279 return sal_False;
281 // -------------------------------------------------------------------------
282 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
284 return sal_False;
286 // -------------------------------------------------------------------------
287 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
289 sal_Int32 nValue = 0; // 0 means no limit
290 return nValue;
292 // -------------------------------------------------------------------------
293 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
295 return sal_False;
297 // -------------------------------------------------------------------------
298 ::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
300 ::rtl::OUString aVal;
301 return aVal;
303 // -------------------------------------------------------------------------
304 ::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
306 // normally this is "
307 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
309 // -------------------------------------------------------------------------
310 ::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
312 ::rtl::OUString aVal;
313 return aVal;
315 // -------------------------------------------------------------------------
316 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
318 return sal_True;
320 // -------------------------------------------------------------------------
321 sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
323 return sal_True;
325 // -------------------------------------------------------------------------
326 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
328 return sal_True;
330 // -------------------------------------------------------------------------
331 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
333 return sal_True;
335 // -------------------------------------------------------------------------
336 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
338 //We support create table
339 return sal_False;
341 // -------------------------------------------------------------------------
342 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
344 return sal_False;
346 // -------------------------------------------------------------------------
347 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
349 return sal_False;
351 // -------------------------------------------------------------------------
352 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
354 return sal_False;
356 // -------------------------------------------------------------------------
357 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
359 return sal_False;
361 // -------------------------------------------------------------------------
362 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
364 return sal_False;
366 // -------------------------------------------------------------------------
367 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
369 return sal_False;
371 // -------------------------------------------------------------------------
372 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
374 return sal_False;
376 // -------------------------------------------------------------------------
377 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
379 return sal_False;
381 // -------------------------------------------------------------------------
382 sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
384 return sal_False;
386 // -------------------------------------------------------------------------
387 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
389 return sal_False;
391 // -------------------------------------------------------------------------
392 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
394 return sal_True; // should be supported at least
396 // -------------------------------------------------------------------------
397 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
399 return sal_False;
401 // -------------------------------------------------------------------------
402 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
404 return sal_False;
406 // -------------------------------------------------------------------------
407 sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
409 return sal_False;
411 // -------------------------------------------------------------------------
412 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
414 return sal_False;
416 // -------------------------------------------------------------------------
417 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
419 return sal_False;
421 // -------------------------------------------------------------------------
422 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
424 return sal_False;
426 // -------------------------------------------------------------------------
427 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
429 return sal_False;
431 // -------------------------------------------------------------------------
432 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
434 return 0;// 0 means no limit
436 // -------------------------------------------------------------------------
437 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
439 sal_Int32 nValue = 0; // 0 means no limit
440 return nValue;
442 // -------------------------------------------------------------------------
443 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
445 sal_Int32 nValue = 0; // 0 means no limit
446 return nValue;
448 // -------------------------------------------------------------------------
449 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
451 return sal_False;
453 // -------------------------------------------------------------------------
454 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
456 return sal_False;
458 // -------------------------------------------------------------------------
459 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
461 return sal_False;
463 // -------------------------------------------------------------------------
464 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
466 return sal_False;
468 // -------------------------------------------------------------------------
469 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
471 // We allow you to select from any table.
472 return sal_True;
474 // -------------------------------------------------------------------------
475 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
477 //we support insert/update/delete now
478 //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
479 //entry to the popup menu. We should avoid them.
480 return sal_True;
482 // -------------------------------------------------------------------------
483 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
485 return sal_False;
487 // -------------------------------------------------------------------------
488 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
490 return sal_False;
492 // -------------------------------------------------------------------------
493 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
495 return sal_False;
497 // -------------------------------------------------------------------------
498 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
500 return sal_False;
502 // -------------------------------------------------------------------------
503 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
505 // Support added for this.
506 return sal_True;
508 // -------------------------------------------------------------------------
509 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
511 return sal_False;
513 // -------------------------------------------------------------------------
514 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
516 return sal_False;
518 // -------------------------------------------------------------------------
519 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
521 return sal_False;
523 // -------------------------------------------------------------------------
524 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
526 return sal_False;
528 // -------------------------------------------------------------------------
529 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
531 return sal_False;
533 // -------------------------------------------------------------------------
534 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
536 return sal_False;
538 // -------------------------------------------------------------------------
539 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
541 return sal_False;
543 // -------------------------------------------------------------------------
544 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
546 return sal_False;
548 // -------------------------------------------------------------------------
549 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
551 return sal_False;
553 // -------------------------------------------------------------------------
554 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
556 return sal_False;
558 // -------------------------------------------------------------------------
559 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
561 return sal_False;
563 // -------------------------------------------------------------------------
564 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
566 return sal_False;
568 // -------------------------------------------------------------------------
569 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
571 return sal_True;
573 // -------------------------------------------------------------------------
574 sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
576 // Any case may be used
577 return sal_True;
579 // -------------------------------------------------------------------------
580 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
582 return sal_False;
584 // -------------------------------------------------------------------------
585 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
587 return sal_True;
589 // -------------------------------------------------------------------------
590 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
592 return sal_False;
594 // -------------------------------------------------------------------------
595 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
597 return sal_True;
599 // -------------------------------------------------------------------------
600 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
602 return sal_False;
604 // -------------------------------------------------------------------------
605 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
607 return sal_False;
609 // -------------------------------------------------------------------------
610 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
612 return sal_False;
614 // -------------------------------------------------------------------------
615 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
617 return sal_False;
619 // -------------------------------------------------------------------------
620 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
622 return sal_False;
624 // -------------------------------------------------------------------------
625 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
627 return sal_False;
629 // -------------------------------------------------------------------------
630 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
632 return sal_False;
634 // -------------------------------------------------------------------------
635 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
637 return sal_False;
639 // -------------------------------------------------------------------------
640 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
642 return sal_False;
644 // -------------------------------------------------------------------------
645 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
647 return sal_False;
649 // -------------------------------------------------------------------------
650 ::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
652 ::osl::MutexGuard aGuard( m_aMutex );
654 return m_pConnection->getURL();
656 // -------------------------------------------------------------------------
657 ::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
659 ::rtl::OUString aValue;
660 return aValue;
662 // -------------------------------------------------------------------------
663 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
665 ::rtl::OUString aValue;
666 return aValue;
668 // -------------------------------------------------------------------------
669 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
671 ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)1);
672 return aValue;
674 // -------------------------------------------------------------------------
675 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
677 ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)0);
678 return aValue;
680 // -------------------------------------------------------------------------
681 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
683 ::rtl::OUString aValue;
684 return aValue;
686 // -------------------------------------------------------------------------
687 ::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
689 ::rtl::OUString aValue;
690 return aValue;
692 // -------------------------------------------------------------------------
693 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
695 ::rtl::OUString aValue;
696 return aValue;
698 // -------------------------------------------------------------------------
699 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
701 return 1;
703 // -------------------------------------------------------------------------
704 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
706 return TransactionIsolation::NONE;
708 // -------------------------------------------------------------------------
709 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
711 return 0;
713 // -------------------------------------------------------------------------
714 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
716 ::rtl::OUString aValue;
717 return aValue;
719 // -------------------------------------------------------------------------
720 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
722 ::rtl::OUString aValue;
723 return aValue;
725 // -------------------------------------------------------------------------
726 ::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
728 return ::rtl::OUString();
730 // -------------------------------------------------------------------------
731 ::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
733 return ::rtl::OUString();
735 // -------------------------------------------------------------------------
736 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
738 return ::rtl::OUString();
740 // -------------------------------------------------------------------------
741 ::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
743 return ::rtl::OUString();
745 // -------------------------------------------------------------------------
746 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
748 return sal_False;
750 // -------------------------------------------------------------------------
751 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
753 return sal_False;
755 // -------------------------------------------------------------------------
756 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
758 return sal_True;
760 // -------------------------------------------------------------------------
761 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
763 return sal_False;
765 // -------------------------------------------------------------------------
766 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
768 return sal_False;
770 // -------------------------------------------------------------------------
771 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
773 sal_Int32 nValue = 0; // 0 means no limit
774 return nValue;
776 // -------------------------------------------------------------------------
777 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
779 sal_Int32 nValue = 0; // 0 means no limit
780 return nValue;
782 // -------------------------------------------------------------------------
783 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
785 sal_Int32 nValue = 0; // 0 means no limit
786 return nValue;
788 // -------------------------------------------------------------------------
789 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
791 sal_Int32 nValue = 0; // 0 means no limit
792 return nValue;
794 // -------------------------------------------------------------------------
795 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
797 return sal_False;
799 // -------------------------------------------------------------------------
800 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
802 return sal_False;
804 // -------------------------------------------------------------------------
805 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
807 return sal_True;
809 // -------------------------------------------------------------------------
810 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
812 return sal_True;
814 // -------------------------------------------------------------------------
815 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
817 return sal_True;
819 // -------------------------------------------------------------------------
820 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
822 return sal_False;
824 // -------------------------------------------------------------------------
825 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
827 return sal_False;
829 // -------------------------------------------------------------------------
830 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
832 return sal_False;
834 // -------------------------------------------------------------------------
835 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
837 return sal_True;
839 // -------------------------------------------------------------------------
840 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
842 return sal_True;
844 // -------------------------------------------------------------------------
845 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
847 return sal_True;
849 // -------------------------------------------------------------------------
850 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
852 return sal_False;
854 // -------------------------------------------------------------------------
855 // here follow all methods which return a resultset
856 // the first methods is an example implementation how to use this resultset
857 // of course you could implement it on your and you should do this because
858 // the general way is more memory expensive
859 // -------------------------------------------------------------------------
860 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
862 // there exists no possibility to get table types so we have to check
863 static ::rtl::OUString sTableTypes[] =
865 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")),
866 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW"))
867 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
869 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEM TABLE")),
870 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("GLOBAL TEMPORARY")),
871 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LOCAL TEMPORARY")),
872 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ALIAS")),
873 // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYNONYM"))
875 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
876 Reference< XResultSet > xRef = pResult;
878 // here we fill the rows which should be visible when ask for data from the resultset returned here
879 const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
880 ODatabaseMetaDataResultSet::ORows aRows;
881 for(sal_Int32 i=0;i < nSize;++i)
883 ODatabaseMetaDataResultSet::ORow aRow;
884 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
885 aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
886 // bound row
887 aRows.push_back(aRow);
889 // here we set the rows at the resultset
890 pResult->setRows(aRows);
891 return xRef;
893 // -------------------------------------------------------------------------
894 Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
896 // this returns an empty resultset where the column-names are already set
897 // in special the metadata of the resultset already returns the right columns
898 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
899 Reference< XResultSet > xResultSet = pResultSet;
900 static ODatabaseMetaDataResultSet::ORows aRows;
902 if(aRows.empty())
904 ODatabaseMetaDataResultSet::ORow aRow;
905 aRow.reserve(19);
906 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
907 aRow.push_back(new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR"))));
908 aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
909 aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
910 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
911 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
912 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
913 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
914 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
915 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
916 aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
917 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
918 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
919 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
920 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
921 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
922 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
923 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
924 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
925 aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
927 aRows.push_back(aRow);
930 pResultSet->setRows(aRows);
931 return xResultSet;
933 // -------------------------------------------------------------------------
934 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
935 const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
936 const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
938 // this returns an empty resultset where the column-names are already set
939 // in special the metadata of the resultset already returns the right columns
940 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns);
941 Reference< XResultSet > xResultSet = pResultSet;
942 pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ));
943 return xResultSet;
945 // -------------------------------------------------------------------------
946 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
947 const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
948 const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
950 // this returns an empty resultset where the column-names are already set
951 // in special the metadata of the resultset already returns the right columns
952 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
953 Reference< XResultSet > xResultSet = pResultSet;
955 // ODatabaseMetaDataResultSet::ORows aRows;
956 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
957 // pResultSet->setRows( aRows );
958 ODatabaseMetaDataResultSet::ORows _rRows;
959 if ( !m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern, types,_rRows ) ) {
960 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
962 pResultSet->setRows( _rRows );
964 return xResultSet;
966 // -------------------------------------------------------------------------
967 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
968 const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
970 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges);
971 Reference< XResultSet > xRef = NULL;
973 xRef = pResult;
975 ::std::vector< ::rtl::OUString > tables;
976 ::std::vector< ::rtl::OUString > types;
977 if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types ) )
978 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
980 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
981 ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
982 aRows.reserve(8);
983 aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
984 aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
985 aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
986 aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
987 aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
988 aRow[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NO")));
991 // Iterate over all tables
992 for(size_t j = 0; j < tables.size(); j++ ) {
993 if(match(tableNamePattern, tables[j],'\0'))
995 // TABLE_NAME
996 aRow[2] = new ORowSetValueDecorator( tables[j] );
998 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables[j] ));
1000 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
1001 aRows.push_back(aRow);
1002 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
1003 aRows.push_back(aRow);
1004 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
1005 aRows.push_back(aRow);
1006 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
1007 aRows.push_back(aRow);
1008 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
1009 aRows.push_back(aRow);
1010 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
1011 aRows.push_back(aRow);
1012 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1013 aRows.push_back(aRow);
1014 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1015 aRows.push_back(aRow);
1018 pResult->setRows(aRows);
1019 return xRef;
1022 // -------------------------------------------------------------------------
1023 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)
1025 return NULL;
1027 // -----------------------------------------------------------------------------
1031 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */