update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / mozab / MDatabaseMetaData.cxx
blob6a0b27ba069e856e562465081c1299f26862e356
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();
68 ODatabaseMetaData::~ODatabaseMetaData()
70 delete m_pDbMetaDataHelper;
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;
156 OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
158 return OUString();
161 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
163 sal_Int32 nValue = 65535; // 0 means no limit
164 return nValue;
167 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
169 sal_Int32 nValue = 0; // 0 means no limit
170 return nValue;
173 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
175 sal_Int32 nValue = 0; // 0 means no limit
176 return nValue;
179 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
181 sal_Int32 nValue = 254; // 0 means no limit
182 return nValue;
185 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
187 sal_Int32 nValue = 20; // 0 means no limit
188 return nValue;
191 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
193 sal_Int32 nValue = 0; // 0 means no limit
194 return nValue;
197 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
199 sal_Int32 nValue = 0; // 0 means no limit
200 return nValue;
203 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
205 sal_Int32 nValue = 0; // 0 means no limit
206 return nValue;
209 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
211 sal_Int32 nValue = 0; // 0 means no limit
212 return nValue;
215 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
217 return 0;
220 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
222 sal_Int32 nValue = 0; // 0 means no limit
223 return nValue;
226 sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
228 // We only support a single table
229 return 1;
233 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
235 return sal_False;
238 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
240 return sal_False;
243 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
245 return sal_False;
248 bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
250 return false;
253 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
255 return sal_False;
258 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
260 return sal_False;
263 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
265 return sal_False;
268 bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
270 return false;
273 bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
275 return false;
278 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
280 sal_Int32 nValue = 0; // 0 means no limit
281 return nValue;
284 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
286 return sal_False;
289 OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
291 OUString aVal;
292 return aVal;
295 OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
297 // normally this is "
298 return OUString("\"");
301 OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
303 OUString aVal;
304 return aVal;
307 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
309 return sal_True;
312 bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
314 return true;
317 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
319 return sal_True;
322 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
324 return sal_True;
327 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
329 //We support create table
330 return sal_False;
333 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
335 return sal_False;
338 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
340 return sal_False;
343 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
345 return sal_False;
348 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
350 return sal_False;
353 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
355 return sal_False;
358 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
360 return sal_False;
363 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
365 return sal_False;
368 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
370 return sal_False;
373 bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
375 return false;
378 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
380 return sal_False;
383 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
385 return sal_True; // should be supported at least
388 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
390 return sal_False;
393 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
395 return sal_False;
398 bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
400 return false;
403 bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
405 return false;
408 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
410 return sal_False;
413 bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
415 return false;
418 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
420 return sal_False;
423 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
425 return 0;// 0 means no limit
428 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
430 sal_Int32 nValue = 0; // 0 means no limit
431 return nValue;
434 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
436 sal_Int32 nValue = 0; // 0 means no limit
437 return nValue;
440 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
442 return sal_False;
445 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
447 return sal_False;
450 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
452 return sal_False;
455 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
457 return sal_False;
460 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
462 // We allow you to select from any table.
463 return sal_True;
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;
474 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
476 return sal_False;
479 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
481 return sal_False;
484 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
486 return sal_False;
489 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
491 return sal_False;
494 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
496 // Support added for this.
497 return sal_True;
500 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
502 return sal_False;
505 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
507 return sal_False;
510 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
512 return sal_False;
515 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
517 return sal_False;
520 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
522 return sal_False;
525 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
527 return sal_False;
530 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
532 return sal_False;
535 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
537 return sal_False;
540 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
542 return sal_False;
545 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
547 return sal_False;
550 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
552 return sal_False;
555 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
557 return sal_False;
560 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
562 return sal_True;
565 bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
567 // Any case may be used
568 return true;
571 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
573 return sal_False;
576 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
578 return sal_True;
581 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
583 return sal_False;
586 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
588 return sal_True;
591 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
593 return sal_False;
596 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
598 return sal_False;
601 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
603 return sal_False;
606 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
608 return sal_False;
611 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
613 return sal_False;
616 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
618 return sal_False;
621 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
623 return sal_False;
626 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
628 return sal_False;
631 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
633 return sal_False;
636 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
638 return sal_False;
641 OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
643 ::osl::MutexGuard aGuard( m_aMutex );
645 return m_pConnection->getURL();
648 OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
650 OUString aValue;
651 return aValue;
654 OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
656 OUString aValue;
657 return aValue;
660 OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
662 return OUString( "1" );
665 OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
667 return OUString( "0" );
670 OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
672 OUString aValue;
673 return aValue;
676 OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
678 OUString aValue;
679 return aValue;
682 OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
684 OUString aValue;
685 return aValue;
688 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
690 return 1;
693 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
695 return TransactionIsolation::NONE;
698 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
700 return 0;
703 OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
705 OUString aValue;
706 return aValue;
709 OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
711 OUString aValue;
712 return aValue;
715 OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
717 return OUString();
720 OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
722 return OUString();
725 OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
727 return OUString();
730 OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
732 return OUString();
735 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
737 return sal_False;
740 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
742 return sal_False;
745 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
747 return sal_True;
750 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
752 return sal_False;
755 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
757 return sal_False;
760 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
762 sal_Int32 nValue = 0; // 0 means no limit
763 return nValue;
766 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
768 sal_Int32 nValue = 0; // 0 means no limit
769 return nValue;
772 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
774 sal_Int32 nValue = 0; // 0 means no limit
775 return nValue;
778 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
780 sal_Int32 nValue = 0; // 0 means no limit
781 return nValue;
784 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
786 return sal_False;
789 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
791 return sal_False;
794 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
796 return sal_True;
799 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
801 return sal_True;
804 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
806 return sal_True;
809 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
811 return sal_False;
814 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
816 return sal_False;
819 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
821 return sal_False;
824 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
826 return sal_True;
829 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
831 return sal_True;
834 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
836 return sal_True;
839 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
841 return sal_False;
844 // here follow all methods which return a resultset
845 // the first methods is an example implementation how to use this resultset
846 // of course you could implement it on your and you should do this because
847 // the general way is more memory expensive
849 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
851 // there exists no possibility to get table types so we have to check
852 static OUString sTableTypes[] =
854 OUString("TABLE"),
855 OUString("VIEW")
856 // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
858 // OUString("SYSTEM TABLE"),
859 // OUString("GLOBAL TEMPORARY"),
860 // OUString("LOCAL TEMPORARY"),
861 // OUString("ALIAS"),
862 // OUString("SYNONYM")
864 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
865 Reference< XResultSet > xRef = pResult;
867 // here we fill the rows which should be visible when ask for data from the resultset returned here
868 const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(OUString);
869 ODatabaseMetaDataResultSet::ORows aRows;
870 for(sal_Int32 i=0;i < nSize;++i)
872 ODatabaseMetaDataResultSet::ORow aRow;
873 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
874 aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
875 // bound row
876 aRows.push_back(aRow);
878 // here we set the rows at the resultset
879 pResult->setRows(aRows);
880 return xRef;
883 Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
885 // this returns an empty resultset where the column-names are already set
886 // in special the metadata of the resultset already returns the right columns
887 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
888 Reference< XResultSet > xResultSet = pResultSet;
889 static ODatabaseMetaDataResultSet::ORows aRows;
891 if(aRows.empty())
893 ODatabaseMetaDataResultSet::ORow aRow;
894 aRow.reserve(19);
895 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
896 aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR")));
897 aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
898 aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
899 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
900 aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
901 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
902 // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
903 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
904 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
905 aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
906 aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
907 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
908 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
909 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
910 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
911 aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
912 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
913 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
914 aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
916 aRows.push_back(aRow);
919 pResultSet->setRows(aRows);
920 return xResultSet;
923 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
924 const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern,
925 const OUString& columnNamePattern ) throw(SQLException, RuntimeException)
927 // this returns an empty resultset where the column-names are already set
928 // in special the metadata of the resultset already returns the right columns
929 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns);
930 Reference< XResultSet > xResultSet = pResultSet;
931 pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ));
932 return xResultSet;
935 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
936 const Any& /*catalog*/, const OUString& /*schemaPattern*/,
937 const OUString& tableNamePattern, const Sequence< OUString >& types ) throw(SQLException, RuntimeException)
939 // this returns an empty resultset where the column-names are already set
940 // in special the metadata of the resultset already returns the right columns
941 ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
942 Reference< XResultSet > xResultSet = pResultSet;
944 // ODatabaseMetaDataResultSet::ORows aRows;
945 // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
946 // pResultSet->setRows( aRows );
947 ODatabaseMetaDataResultSet::ORows _rRows;
948 if ( !m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern, types,_rRows ) ) {
949 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
951 pResultSet->setRows( _rRows );
953 return xResultSet;
956 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
957 const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern ) throw(SQLException, RuntimeException)
959 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges);
961 Reference< XResultSet > xRef = pResult;
963 ::std::vector< OUString > tables;
964 ::std::vector< OUString > types;
965 if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types ) )
966 getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
968 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
969 ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
970 aRows.reserve(8);
971 aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
972 aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
973 aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
974 aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
975 aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
976 aRow[7] = new ::connectivity::ORowSetValueDecorator(OUString("NO"));
979 // Iterate over all tables
980 for(size_t j = 0; j < tables.size(); j++ ) {
981 if(match(tableNamePattern, tables[j],'\0'))
983 // TABLE_NAME
984 aRow[2] = new ORowSetValueDecorator( tables[j] );
986 OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables[j] ));
988 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
989 aRows.push_back(aRow);
990 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
991 aRows.push_back(aRow);
992 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
993 aRows.push_back(aRow);
994 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
995 aRows.push_back(aRow);
996 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
997 aRows.push_back(aRow);
998 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
999 aRows.push_back(aRow);
1000 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1001 aRows.push_back(aRow);
1002 aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1003 aRows.push_back(aRow);
1006 pResult->setRows(aRows);
1007 return xRef;
1011 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
1013 return NULL;
1019 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */