1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "DatabaseMetaData.hxx"
24 #include <rtl/ustrbuf.hxx>
25 #include <FDatabaseMetaDataResultSet.hxx>
27 #include <com/sun/star/sdbc/ColumnValue.hpp>
28 #include <com/sun/star/sdbc/DataType.hpp>
29 #include <com/sun/star/sdbc/IndexType.hpp>
30 #include <com/sun/star/sdbc/ResultSetType.hpp>
31 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
32 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
33 #include <com/sun/star/sdbc/XParameters.hpp>
34 #include <com/sun/star/sdbc/XRow.hpp>
35 #include <com/sun/star/sdbc/KeyRule.hpp>
36 #include <com/sun/star/sdbc/Deferrability.hpp>
37 #include <com/sun/star/sdbc/DataType.hpp>
39 using namespace connectivity::firebird
;
40 using namespace com::sun::star
;
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
;
46 ODatabaseMetaData::ODatabaseMetaData(Connection
* _pCon
)
47 : m_pConnection(_pCon
)
49 SAL_WARN_IF(!m_pConnection
.is(), "connectivity.firebird",
50 "ODatabaseMetaData::ODatabaseMetaData: No connection set!");
53 ODatabaseMetaData::~ODatabaseMetaData()
57 //----- Catalog Info -- UNSUPPORTED -------------------------------------------
58 OUString SAL_CALL
ODatabaseMetaData::getCatalogSeparator() throw(SQLException
, RuntimeException
, std::exception
)
63 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength() throw(SQLException
, RuntimeException
, std::exception
)
68 OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm() throw(SQLException
, RuntimeException
, std::exception
)
73 sal_Bool SAL_CALL
ODatabaseMetaData::isCatalogAtStart() throw(SQLException
, RuntimeException
, std::exception
)
78 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInTableDefinitions() throw(SQLException
, RuntimeException
, std::exception
)
83 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions() throw(SQLException
, RuntimeException
, std::exception
)
88 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException
, RuntimeException
, std::exception
)
93 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCatalogs() throw(SQLException
, RuntimeException
, std::exception
)
95 OSL_FAIL("Not implemented yet!");
97 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eCatalogs
);
100 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls() throw(SQLException
, RuntimeException
, std::exception
)
105 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions() throw(SQLException
, RuntimeException
, std::exception
)
110 //----- Schema Info -- UNSUPPORTED --------------------------------------------
111 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls()
112 throw(SQLException
, RuntimeException
, std::exception
)
117 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions()
118 throw(SQLException
, RuntimeException
, std::exception
)
123 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInDataManipulation()
124 throw(SQLException
, RuntimeException
, std::exception
)
129 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions()
130 throw(SQLException
, RuntimeException
, std::exception
)
135 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInTableDefinitions()
136 throw(SQLException
, RuntimeException
, std::exception
)
141 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength()
142 throw(SQLException
, RuntimeException
, std::exception
)
147 OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm()
148 throw(SQLException
, RuntimeException
, std::exception
)
153 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getSchemas()
154 throw(SQLException
, RuntimeException
, std::exception
)
156 OSL_FAIL("Not implemented yet!");
158 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eSchemas
);
161 //----- Max Sizes/Lengths -----------------------------------------------------
162 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength() throw(SQLException
, RuntimeException
, std::exception
)
167 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize() throw(SQLException
, RuntimeException
, std::exception
)
172 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength() throw(SQLException
, RuntimeException
, std::exception
)
177 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength() throw(SQLException
, RuntimeException
, std::exception
)
182 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex() throw(SQLException
, RuntimeException
, std::exception
)
185 // See: http://www.firebirdsql.org/en/firebird-technical-specifications/
189 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength() throw(SQLException
, RuntimeException
, std::exception
)
194 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections() throw(SQLException
, RuntimeException
, std::exception
)
196 return 100; // Arbitrary
199 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable() throw(SQLException
, RuntimeException
, std::exception
)
201 // May however be smaller.
202 // See: http://www.firebirdsql.org/en/firebird-technical-specifications/
206 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength() throw(SQLException
, RuntimeException
, std::exception
)
211 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength() throw(SQLException
, RuntimeException
, std::exception
)
216 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException
, RuntimeException
, std::exception
)
218 sal_Int32 nValue
= 0; // 0 means no limit
223 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException
, RuntimeException
, std::exception
)
228 // ---- Identifiers -----------------------------------------------------------
229 // Only quoted identifiers are case sensitive, unquoted are case insensitive
230 OUString SAL_CALL
ODatabaseMetaData::getIdentifierQuoteString()
231 throw(SQLException
, RuntimeException
, std::exception
)
237 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException
, RuntimeException
, std::exception
)
242 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers()
243 throw(SQLException
, RuntimeException
, std::exception
)
248 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseQuotedIdentifiers()
249 throw(SQLException
, RuntimeException
, std::exception
)
251 // TODO: confirm this -- the documentation is highly ambiguous
252 // However it seems this should be true as quoted identifiers ARE
253 // stored mixed case.
257 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers()
258 throw(SQLException
, RuntimeException
, std::exception
)
263 // ---- Unquoted Identifiers -------------------------------------------------
264 // All unquoted identifiers are stored upper case.
265 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers()
266 throw(SQLException
, RuntimeException
, std::exception
)
271 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers()
272 throw(SQLException
, RuntimeException
, std::exception
)
277 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers()
278 throw(SQLException
, RuntimeException
, std::exception
)
283 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers()
284 throw(SQLException
, RuntimeException
, std::exception
)
289 // ---- SQL Feature Support ---------------------------------------------------
290 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar()
291 throw(SQLException
, RuntimeException
, std::exception
)
296 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar()
297 throw(SQLException
, RuntimeException
, std::exception
)
302 sal_Bool SAL_CALL
ODatabaseMetaData::supportsAlterTableWithAddColumn()
303 throw(SQLException
, RuntimeException
, std::exception
)
308 sal_Bool SAL_CALL
ODatabaseMetaData::supportsAlterTableWithDropColumn()
309 throw(SQLException
, RuntimeException
, std::exception
)
314 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete()
315 throw(SQLException
, RuntimeException
, std::exception
)
320 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate()
321 throw(SQLException
, RuntimeException
, std::exception
)
326 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins()
327 throw(SQLException
, RuntimeException
, std::exception
)
332 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate()
333 throw(SQLException
, RuntimeException
, std::exception
)
338 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable()
339 throw(SQLException
, RuntimeException
, std::exception
)
341 // TODO: true if embedded, but unsure about remote server
345 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert(sal_Int32 fromType
,
347 throw(SQLException
, RuntimeException
, std::exception
)
354 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion()
355 throw(SQLException
, RuntimeException
, std::exception
)
360 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing()
361 throw(SQLException
, RuntimeException
, std::exception
)
366 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames()
367 throw(SQLException
, RuntimeException
, std::exception
)
372 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException
, RuntimeException
, std::exception
)
374 sal_Int32 nValue
= 0; // 0 means no limit
378 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException
, RuntimeException
, std::exception
)
383 OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException
, RuntimeException
, std::exception
)
389 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException
, RuntimeException
, std::exception
)
393 // ---- Data definition stuff -------------------------------------------------
394 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions()
395 throw(SQLException
, RuntimeException
, std::exception
)
400 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit()
401 throw(SQLException
, RuntimeException
, std::exception
)
406 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly()
407 throw(SQLException
, RuntimeException
, std::exception
)
412 sal_Bool SAL_CALL
ODatabaseMetaData::
413 supportsDataDefinitionAndDataManipulationTransactions()
414 throw(SQLException
, RuntimeException
, std::exception
)
418 //----- Transaction Support --------------------------------------------------
419 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions()
420 throw(SQLException
, RuntimeException
, std::exception
)
425 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback()
426 throw(SQLException
, RuntimeException
, std::exception
)
431 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit()
432 throw(SQLException
, RuntimeException
, std::exception
)
437 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit()
438 throw(SQLException
, RuntimeException
, std::exception
)
443 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback()
444 throw(SQLException
, RuntimeException
, std::exception
)
449 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions()
450 throw(SQLException
, RuntimeException
, std::exception
)
455 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel(
457 throw(SQLException
, RuntimeException
, std::exception
)
459 return aLevel
== TransactionIsolation::READ_UNCOMMITTED
460 || aLevel
== TransactionIsolation::READ_COMMITTED
461 || aLevel
== TransactionIsolation::REPEATABLE_READ
462 || aLevel
== TransactionIsolation::SERIALIZABLE
;
465 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation()
466 throw(SQLException
, RuntimeException
, std::exception
)
468 return TransactionIsolation::REPEATABLE_READ
;
472 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException
, RuntimeException
, std::exception
)
477 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException
, RuntimeException
, std::exception
)
479 return true; // should be supported at least
482 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException
, RuntimeException
, std::exception
)
487 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatements( ) throw(SQLException
, RuntimeException
, std::exception
)
489 sal_Int32 nValue
= 0; // 0 means no limit
493 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException
, RuntimeException
, std::exception
)
495 sal_Int32 nValue
= 31; // TODO: confirm
499 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException
, RuntimeException
, std::exception
)
504 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException
, RuntimeException
, std::exception
)
509 sal_Bool SAL_CALL
ODatabaseMetaData::isReadOnly( ) throw(SQLException
, RuntimeException
, std::exception
)
511 return m_pConnection
->isReadOnly();
514 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( ) throw(SQLException
, RuntimeException
, std::exception
)
516 return m_pConnection
->isEmbedded();
519 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException
, RuntimeException
, std::exception
)
524 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException
, RuntimeException
, std::exception
)
529 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException
, RuntimeException
, std::exception
)
534 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( ) throw(SQLException
, RuntimeException
, std::exception
)
539 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException
, RuntimeException
, std::exception
)
545 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException
, RuntimeException
, std::exception
)
552 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException
, RuntimeException
, std::exception
)
557 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException
, RuntimeException
, std::exception
)
562 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException
, RuntimeException
, std::exception
)
567 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( ) throw(SQLException
, RuntimeException
, std::exception
)
572 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( ) throw(SQLException
, RuntimeException
, std::exception
)
577 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException
, RuntimeException
, std::exception
)
582 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException
, RuntimeException
, std::exception
)
587 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException
, RuntimeException
, std::exception
)
592 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException
, RuntimeException
, std::exception
)
597 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException
, RuntimeException
, std::exception
)
602 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException
, RuntimeException
, std::exception
)
607 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException
, RuntimeException
, std::exception
)
612 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException
, RuntimeException
, std::exception
)
617 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException
, RuntimeException
, std::exception
)
622 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException
, RuntimeException
, std::exception
)
627 OUString SAL_CALL
ODatabaseMetaData::getURL() throw(SQLException
, RuntimeException
, std::exception
)
629 return m_pConnection
->getConnectionURL();
632 OUString SAL_CALL
ODatabaseMetaData::getUserName( ) throw(SQLException
, RuntimeException
, std::exception
)
638 OUString SAL_CALL
ODatabaseMetaData::getDriverName( ) throw(SQLException
, RuntimeException
, std::exception
)
644 OUString SAL_CALL
ODatabaseMetaData::getDriverVersion() throw(SQLException
, RuntimeException
, std::exception
)
650 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException
, RuntimeException
, std::exception
)
656 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException
, RuntimeException
, std::exception
)
662 OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( ) throw(SQLException
, RuntimeException
, std::exception
)
668 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException
, std::exception
)
673 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException
, std::exception
)
678 OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( ) throw(SQLException
, RuntimeException
, std::exception
)
684 OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException
, RuntimeException
, std::exception
)
690 OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( ) throw(SQLException
, RuntimeException
, std::exception
)
695 OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException
, RuntimeException
, std::exception
)
700 OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( ) throw(SQLException
, RuntimeException
, std::exception
)
705 OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( ) throw(SQLException
, RuntimeException
, std::exception
)
710 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException
, RuntimeException
, std::exception
)
715 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException
, RuntimeException
, std::exception
)
720 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException
, RuntimeException
, std::exception
)
725 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException
, RuntimeException
, std::exception
)
727 sal_Int32 nValue
= 0; // 0 means no limit
731 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException
, RuntimeException
, std::exception
)
733 sal_Int32 nValue
= 0; // 0 means no limit
737 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException
, RuntimeException
, std::exception
)
739 sal_Int32 nValue
= 0; // 0 means no limit
743 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException
, RuntimeException
, std::exception
)
748 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType(sal_Int32 setType
)
749 throw(SQLException
, RuntimeException
, std::exception
)
753 case ResultSetType::FORWARD_ONLY
:
760 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency(
761 sal_Int32 aResultSetType
,
762 sal_Int32 aConcurrency
)
763 throw(SQLException
, RuntimeException
, std::exception
)
765 if (aResultSetType
== ResultSetType::FORWARD_ONLY
766 && aConcurrency
== ResultSetConcurrency::READ_ONLY
)
772 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
778 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
784 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
790 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
796 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
802 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
808 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
814 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
820 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32 setType
) throw(SQLException
, RuntimeException
, std::exception
)
826 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates()
827 throw(SQLException
, RuntimeException
, std::exception
)
829 // No batch support in firebird
833 uno::Reference
< XConnection
> SAL_CALL
ODatabaseMetaData::getConnection()
834 throw(SQLException
, RuntimeException
, std::exception
)
836 return uno::Reference
<XConnection
>(m_pConnection
.get());
839 // here follow all methods which return a resultset
840 // the first methods is an example implementation how to use this resultset
841 // of course you could implement it on your and you should do this because
842 // the general way is more memory expensive
844 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( ) throw(SQLException
, RuntimeException
, std::exception
)
846 ODatabaseMetaDataResultSet
* pResultSet
= new
847 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
848 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
850 ODatabaseMetaDataResultSet::ORows aResults
;
851 ODatabaseMetaDataResultSet::ORow
aRow(2);
853 aRow
[0] = new ORowSetValueDecorator(); // unused
855 // TODO Put these statics to one place
856 // like postgreSQL's Statics class.
858 aRow
[1] = new ORowSetValueDecorator(OUString("TABLE"));
859 aResults
.push_back(aRow
);
861 aRow
[1] = new ORowSetValueDecorator(OUString("VIEW"));
862 aResults
.push_back(aRow
);
864 aRow
[1] = new ORowSetValueDecorator(OUString("SYSTEM TABLE"));
865 aResults
.push_back(aRow
);
867 pResultSet
->setRows(aResults
);
871 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTypeInfo()
872 throw(SQLException
, RuntimeException
, std::exception
)
874 SAL_INFO("connectivity.firebird", "getTypeInfo()");
876 // this returns an empty resultset where the column-names are already set
877 // in special the metadata of the resultset already returns the right columns
878 ODatabaseMetaDataResultSet
* pResultSet
=
879 new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
880 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
881 static ODatabaseMetaDataResultSet::ORows aResults
;
885 ODatabaseMetaDataResultSet::ORow
aRow(19);
888 aRow
[4] = ODatabaseMetaDataResultSet::getQuoteValue(); // Literal quote marks
889 aRow
[5] = ODatabaseMetaDataResultSet::getQuoteValue(); // Literal quote marks
890 aRow
[7] = new ORowSetValueDecorator(true); // Nullable
891 aRow
[8] = new ORowSetValueDecorator(true); // Case sensitive
892 aRow
[10] = new ORowSetValueDecorator(false); // Is unsigned
893 // FIXED_PREC_SCALE: docs state "can it be a money value? " however
894 // in reality this causes Base to treat all numbers as money formatted
895 // by default which is wrong (and formatting as money value is still
896 // possible for all values).
897 aRow
[11] = new ORowSetValueDecorator(false);
898 // Localised Type Name -- TODO: implement (but can be null):
899 aRow
[13] = new ORowSetValueDecorator();
900 aRow
[16] = new ORowSetValueDecorator(); // Unused
901 aRow
[17] = new ORowSetValueDecorator(); // Unused
902 aRow
[18] = new ORowSetValueDecorator(sal_Int16(10));// Radix
905 aRow
[1] = new ORowSetValueDecorator(OUString("CHAR"));
906 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_TEXT
, 0));
907 aRow
[3] = new ORowSetValueDecorator(sal_Int16(32765)); // Prevision = max length
908 aRow
[6] = new ORowSetValueDecorator(OUString("length")); // Create Params
909 aRow
[9] = new ORowSetValueDecorator(
910 sal_Int16(ColumnSearch::FULL
)); // Searchable
911 aRow
[12] = new ORowSetValueDecorator(false); // Autoincrement
912 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
913 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
914 aResults
.push_back(aRow
);
917 aRow
[1] = new ORowSetValueDecorator(OUString("VARCHAR"));
918 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_VARYING
, 0));
919 aRow
[3] = new ORowSetValueDecorator(sal_Int16(32765)); // Prevision = max length
920 aRow
[6] = new ORowSetValueDecorator(OUString("length")); // Create Params
921 aRow
[9] = new ORowSetValueDecorator(
922 sal_Int16(ColumnSearch::FULL
)); // Searchable
923 aRow
[12] = new ORowSetValueDecorator(false); // Autoincrement
924 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
925 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
926 aResults
.push_back(aRow
);
928 // Integer Types common
930 aRow
[6] = new ORowSetValueDecorator(); // Create Params
931 aRow
[9] = new ORowSetValueDecorator(
932 sal_Int16(ColumnSearch::FULL
)); // Searchable
933 aRow
[12] = new ORowSetValueDecorator(true); // Autoincrement
934 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
935 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
938 aRow
[1] = new ORowSetValueDecorator(OUString("SMALLINT"));
939 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_SHORT
, 0));
940 aRow
[3] = new ORowSetValueDecorator(sal_Int16(5)); // Prevision
941 aResults
.push_back(aRow
);
943 aRow
[1] = new ORowSetValueDecorator(OUString("INTEGER"));
944 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_LONG
, 0));
945 aRow
[3] = new ORowSetValueDecorator(sal_Int16(10)); // Precision
946 aResults
.push_back(aRow
);
948 aRow
[1] = new ORowSetValueDecorator(OUString("BIGINT"));
949 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_INT64
, 0));
950 aRow
[3] = new ORowSetValueDecorator(sal_Int16(20)); // Precision
951 aResults
.push_back(aRow
);
953 // Decimal Types common
955 aRow
[9] = new ORowSetValueDecorator(
956 sal_Int16(ColumnSearch::FULL
)); // Searchable
957 aRow
[12] = new ORowSetValueDecorator(true); // Autoincrement
960 aRow
[6] = new ORowSetValueDecorator(OUString("PRECISION,SCALE")); // Create params
962 aRow
[1] = new ORowSetValueDecorator(OUString("NUMERIC"));
963 aRow
[2] = new ORowSetValueDecorator(DataType::NUMERIC
);
964 aRow
[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
965 aRow
[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
966 aRow
[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
967 aResults
.push_back(aRow
);
969 aRow
[1] = new ORowSetValueDecorator(OUString("DECIMAL"));
970 aRow
[2] = new ORowSetValueDecorator(DataType::DECIMAL
);
971 aRow
[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
972 aRow
[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
973 aRow
[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
974 aResults
.push_back(aRow
);
976 aRow
[6] = new ORowSetValueDecorator(); // Create Params
978 aRow
[1] = new ORowSetValueDecorator(OUString("FLOAT"));
979 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_FLOAT
, 0));
980 aRow
[3] = new ORowSetValueDecorator(sal_Int16(7)); // Precision
981 aRow
[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
982 aRow
[15] = new ORowSetValueDecorator(sal_Int16(7)); // Max scale
983 aResults
.push_back(aRow
);
985 aRow
[1] = new ORowSetValueDecorator(OUString("DOUBLE PRECISION"));
986 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_DOUBLE
, 0));
987 aRow
[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
988 aRow
[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
989 aRow
[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
990 aResults
.push_back(aRow
);
993 // aRow[1] = new ORowSetValueDecorator(getColumnTypeNameFromFBType(SQL_D_FLOAT, 0));
994 // aRow[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_D_FLOAT, 0));
995 // aRow[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
996 // aRow[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
997 // aRow[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
998 // aResults.push_back(aRow);
999 // TODO: no idea whether D_FLOAT corresponds to an sql type
1003 aRow
[1] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
1004 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_TIMESTAMP
, 0));
1005 aRow
[3] = new ORowSetValueDecorator(sal_Int32(8)); // Prevision = max length
1006 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1007 aRow
[9] = new ORowSetValueDecorator(
1008 sal_Int16(ColumnSearch::FULL
)); // Searchable
1009 aRow
[12] = new ORowSetValueDecorator(false); // Autoincrement
1010 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1011 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1012 aResults
.push_back(aRow
);
1016 aRow
[1] = new ORowSetValueDecorator(OUString("TIME"));
1017 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_TYPE_TIME
, 0));
1018 aRow
[3] = new ORowSetValueDecorator(sal_Int32(8)); // Prevision = max length
1019 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1020 aRow
[9] = new ORowSetValueDecorator(
1021 sal_Int16(ColumnSearch::FULL
)); // Searchable
1022 aRow
[12] = new ORowSetValueDecorator(false); // Autoincrement
1023 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1024 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1025 aResults
.push_back(aRow
);
1029 aRow
[1] = new ORowSetValueDecorator(OUString("DATE"));
1030 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_TYPE_DATE
, 0));
1031 aRow
[3] = new ORowSetValueDecorator(sal_Int32(8)); // Prevision = max length
1032 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1033 aRow
[9] = new ORowSetValueDecorator(
1034 sal_Int16(ColumnSearch::FULL
)); // Searchable
1035 aRow
[12] = new ORowSetValueDecorator(false); // Autoincrement
1036 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1037 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1038 aResults
.push_back(aRow
);
1042 aRow
[1] = new ORowSetValueDecorator(OUString("BLOB"));
1043 aRow
[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_BLOB
, 0));
1044 aRow
[3] = new ORowSetValueDecorator(sal_Int32(0)); // Prevision = max length
1045 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1046 aRow
[9] = new ORowSetValueDecorator(
1047 sal_Int16(ColumnSearch::NONE
)); // Searchable
1048 aRow
[12] = new ORowSetValueDecorator(false); // Autoincrement
1049 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1050 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1051 aResults
.push_back(aRow
);
1056 // case SQL_QUAD: // Is a "Blob ID" according to the docs
1058 pResultSet
->setRows(aResults
);
1062 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumnPrivileges(
1063 const Any
& /*aCatalog*/,
1064 const OUString
& /*sSchema*/,
1065 const OUString
& sTable
,
1066 const OUString
& sColumnNamePattern
)
1067 throw(SQLException
, RuntimeException
, std::exception
)
1069 SAL_INFO("connectivity.firebird", "getColumnPrivileges() with "
1071 << " & ColumnNamePattern: " << sColumnNamePattern
);
1073 ODatabaseMetaDataResultSet
* pResultSet
= new
1074 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumnPrivileges
);
1075 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
1076 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1078 static const char wld
[] = "%";
1079 OUStringBuffer
queryBuf(
1081 "priv.RDB$RELATION_NAME, " // 1 Table name
1082 "priv.RDB$GRANTOR," // 2
1083 "priv.RDB$USER, " // 3 Grantee
1084 "priv.RDB$PRIVILEGE, " // 4
1085 "priv.RDB$GRANT_OPTION, " // 5 is Grantable
1086 "priv.RDB$FIELD_NAME " // 6 Column name
1087 "FROM RDB$USER_PRIVILEGES priv ");
1090 OUString sAppend
= "WHERE priv.RDB$RELATION_NAME = '%' ";
1091 queryBuf
.append(sAppend
.replaceAll("%", sTable
));
1093 if (!sColumnNamePattern
.isEmpty())
1096 if (sColumnNamePattern
.match(wld
))
1097 sAppend
= "AND priv.RDB$FIELD_NAME LIKE '%' ";
1099 sAppend
= "AND priv.RDB$FIELD_NAME = '%' ";
1101 queryBuf
.append(sAppend
.replaceAll(wld
, sColumnNamePattern
));
1104 queryBuf
.append(" ORDER BY priv.RDB$FIELD, "
1105 "priv.RDB$PRIVILEGE");
1107 OUString query
= queryBuf
.makeStringAndClear();
1109 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
.getStr());
1110 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1111 ODatabaseMetaDataResultSet::ORows aResults
;
1113 ODatabaseMetaDataResultSet::ORow
aCurrentRow(8);
1114 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused
1115 aCurrentRow
[1] = new ORowSetValueDecorator(); // 1. TABLE_CAT Unsupported
1116 aCurrentRow
[2] = new ORowSetValueDecorator(); // 1. TABLE_SCHEM Unsupported
1121 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1123 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(6)));
1124 aCurrentRow
[5] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2))); // 5. GRANTOR
1125 aCurrentRow
[6] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(3))); // 6. GRANTEE
1126 aCurrentRow
[7] = new ORowSetValueDecorator(xRow
->getString(4)); // 7. Privilege
1127 aCurrentRow
[7] = new ORowSetValueDecorator(xRow
->getBoolean(5)); // 8. Grantable
1129 aResults
.push_back(aCurrentRow
);
1132 pResultSet
->setRows( aResults
);
1137 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
1138 const Any
& /*catalog*/,
1139 const OUString
& /*schemaPattern*/,
1140 const OUString
& tableNamePattern
,
1141 const OUString
& columnNamePattern
)
1142 throw(SQLException
, RuntimeException
, std::exception
)
1144 SAL_INFO("connectivity.firebird", "getColumns() with "
1145 "TableNamePattern: " << tableNamePattern
<<
1146 " & ColumnNamePattern: " << columnNamePattern
);
1148 OUStringBuffer
queryBuf("SELECT "
1149 "relfields.RDB$RELATION_NAME, " // 1
1150 "relfields.RDB$FIELD_NAME, " // 2
1151 "relfields.RDB$DESCRIPTION," // 3
1152 "relfields.RDB$DEFAULT_VALUE, " // 4
1153 "relfields.RDB$FIELD_POSITION, "// 5
1154 "fields.RDB$FIELD_TYPE, " // 6
1155 "fields.RDB$FIELD_SUB_TYPE, " // 7
1156 "fields.RDB$FIELD_LENGTH, " // 8
1157 "fields.RDB$FIELD_PRECISION, " // 9
1158 "fields.RDB$FIELD_SCALE, " // 10
1159 // Specifically use relfields null flag -- the one in fields is used
1160 // for domains, whether a specific field is nullable is set in relfields,
1161 // this is also the one we manually fiddle when changin NULL/NOT NULL
1163 "relfields.RDB$NULL_FLAG " // 11
1164 "FROM RDB$RELATION_FIELDS relfields "
1165 "JOIN RDB$FIELDS fields "
1166 "on (fields.RDB$FIELD_NAME = relfields.RDB$FIELD_SOURCE) "
1169 if (!tableNamePattern
.isEmpty())
1172 if (tableNamePattern
.match("%"))
1173 sAppend
= "AND relfields.RDB$RELATION_NAME LIKE '%' ";
1175 sAppend
= "AND relfields.RDB$RELATION_NAME = '%' ";
1177 queryBuf
.append(sAppend
.replaceAll("%", tableNamePattern
));
1180 if (!columnNamePattern
.isEmpty())
1183 if (columnNamePattern
.match("%"))
1184 sAppend
= "AND relfields.RDB$FIELD_NAME LIKE '%' ";
1186 sAppend
= "AND relfields.RDB$FIELD_NAME = '%' ";
1188 queryBuf
.append(sAppend
.replaceAll("%", columnNamePattern
));
1191 OUString query
= queryBuf
.makeStringAndClear();
1193 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1194 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
.getStr());
1195 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1197 ODatabaseMetaDataResultSet::ORows aResults
;
1198 ODatabaseMetaDataResultSet::ORow
aCurrentRow(19);
1200 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused -- numbering starts from 0
1201 aCurrentRow
[1] = new ORowSetValueDecorator(); // Catalog - can be null
1202 aCurrentRow
[2] = new ORowSetValueDecorator(); // Schema - can be null
1203 aCurrentRow
[8] = new ORowSetValueDecorator(); // Unused
1204 aCurrentRow
[10] = new ORowSetValueDecorator(sal_Int32(10)); // Radix: fixed in FB
1205 aCurrentRow
[14] = new ORowSetValueDecorator(); // Unused
1206 aCurrentRow
[15] = new ORowSetValueDecorator(); // Unused
1211 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1213 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2)));
1215 short aType
= getFBTypeFromBlrType(xRow
->getShort(6));
1216 short aSubType
= xRow
->getShort(7);
1217 aCurrentRow
[5] = new ORowSetValueDecorator(getColumnTypeFromFBType(aType
, aSubType
));
1218 // 6. Typename (SQL_*)
1219 aCurrentRow
[6] = new ORowSetValueDecorator(getColumnTypeNameFromFBType(aType
, aSubType
));
1223 sal_Int32 aColumnSize
= 0;
1228 aColumnSize
= xRow
->getShort(8);
1237 aColumnSize
= xRow
->getShort(9);
1248 aCurrentRow
[7] = new ORowSetValueDecorator(aColumnSize
);
1251 // 9. Decimal digits (scale)
1252 // fb stores a negative number
1253 aCurrentRow
[9] = new ORowSetValueDecorator( (sal_Int16
) -(xRow
->getShort(10)) );
1256 if (xRow
->getShort(11))
1258 aCurrentRow
[11] = new ORowSetValueDecorator(ColumnValue::NO_NULLS
);
1262 aCurrentRow
[11] = new ORowSetValueDecorator(ColumnValue::NULLABLE
);
1264 // 12. Comments -- may be omitted
1266 OUString aDescription
;
1267 uno::Reference
< XBlob
> xDescriptionBlob
= xRow
->getBlob(3);
1268 if (xDescriptionBlob
.is())
1270 sal_Int32 aBlobLength
= (sal_Int32
) xDescriptionBlob
->length();
1271 aDescription
= OUString(reinterpret_cast<char*>(xDescriptionBlob
->getBytes(0, aBlobLength
).getArray()),
1273 RTL_TEXTENCODING_UTF8
);
1275 aCurrentRow
[12] = new ORowSetValueDecorator(aDescription
);
1277 // 13. Default -- may be omitted.
1279 uno::Reference
< XBlob
> xDefaultValueBlob
= xRow
->getBlob(4);
1280 if (xDefaultValueBlob
.is())
1284 aCurrentRow
[13] = new ORowSetValueDecorator();
1287 // 16. Bytes in Column for char
1288 if (aType
== SQL_TEXT
)
1290 aCurrentRow
[16] = new ORowSetValueDecorator(xRow
->getShort(8));
1292 else if (aType
== SQL_VARYING
)
1294 aCurrentRow
[16] = new ORowSetValueDecorator(sal_Int32(32767));
1298 aCurrentRow
[16] = new ORowSetValueDecorator(sal_Int32(0));
1300 // 17. Index of column
1302 short nColumnNumber
= xRow
->getShort(5);
1303 // Firebird stores column numbers beginning with 0 internally
1304 // SDBC expects column numbering to begin with 1.
1305 aCurrentRow
[17] = new ORowSetValueDecorator(sal_Int32(nColumnNumber
+ 1));
1308 if (xRow
->getShort(9))
1310 aCurrentRow
[18] = new ORowSetValueDecorator(OUString("NO"));
1314 aCurrentRow
[18] = new ORowSetValueDecorator(OUString("YES"));
1317 aResults
.push_back(aCurrentRow
);
1319 ODatabaseMetaDataResultSet
* pResultSet
= new
1320 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns
);
1321 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
1322 pResultSet
->setRows( aResults
);
1327 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
1328 const Any
& /*catalog*/,
1329 const OUString
& /*schemaPattern*/,
1330 const OUString
& tableNamePattern
,
1331 const Sequence
< OUString
>& types
)
1332 throw(SQLException
, RuntimeException
, std::exception
)
1334 SAL_INFO("connectivity.firebird", "getTables() with "
1335 "TableNamePattern: " << tableNamePattern
);
1337 ODatabaseMetaDataResultSet
* pResultSet
= new
1338 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables
);
1339 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
1340 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1342 static const char wld
[] = "%";
1343 OUStringBuffer
queryBuf(
1345 "RDB$RELATION_NAME, "
1347 "RDB$RELATION_TYPE, "
1350 "FROM RDB$RELATIONS "
1353 // TODO: GLOBAL TEMPORARY, LOCAL TEMPORARY, ALIAS, SYNONYM
1354 if ((types
.getLength() == 0) || (types
.getLength() == 1 && types
[0].match(wld
)))
1356 // All table types? I.e. includes system tables.
1357 queryBuf
.append("(RDB$RELATION_TYPE = 0 OR RDB$RELATION_TYPE = 1) ");
1361 queryBuf
.append("( (0 = 1) ");
1362 for (int i
= 0; i
< types
.getLength(); i
++)
1364 if (types
[i
] == "SYSTEM TABLE")
1365 queryBuf
.append("OR (RDB$SYSTEM_FLAG = 1 AND RDB$VIEW_BLR IS NULL) ");
1366 else if (types
[i
] == "TABLE")
1367 queryBuf
.append("OR (RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NULL) ");
1368 else if (types
[i
] == "VIEW")
1369 queryBuf
.append("OR (RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NOT NULL) ");
1371 throw SQLException(); // TODO: implement other types, see above.
1373 queryBuf
.append(") ");
1376 if (!tableNamePattern
.isEmpty())
1379 if (tableNamePattern
.match(wld
))
1380 sAppend
= "AND RDB$RELATION_NAME LIKE '%' ";
1382 sAppend
= "AND RDB$RELATION_NAME = '%' ";
1384 queryBuf
.append(sAppend
.replaceAll(wld
, tableNamePattern
));
1387 queryBuf
.append(" ORDER BY RDB$RELATION_TYPE, RDB$RELATION_NAME");
1389 OUString query
= queryBuf
.makeStringAndClear();
1391 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
.getStr());
1392 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1393 ODatabaseMetaDataResultSet::ORows aResults
;
1395 ODatabaseMetaDataResultSet::ORow
aCurrentRow(6);
1396 aCurrentRow
[0] = new ORowSetValueDecorator(); // 0. Unused
1397 aCurrentRow
[1] = new ORowSetValueDecorator(); // 1. Table_Cat Unsupported
1398 aCurrentRow
[2] = new ORowSetValueDecorator(); // 2. Table_Schem Unsupported
1403 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1406 // TODO: check this as the docs are a bit unclear.
1407 sal_Int16 nSystemFlag
= xRow
->getShort(2);
1408 sal_Int16 nTableType
= xRow
->getShort(3);
1409 xRow
->getBlob(5); // We have to retrieve a column to verify it is null.
1410 bool aIsView
= !xRow
->wasNull();
1411 OUString sTableType
;
1413 if (nSystemFlag
== 1)
1415 sTableType
= "SYSTEM TABLE";
1419 sTableType
= "VIEW";
1423 if (nTableType
== 0)
1424 sTableType
= "TABLE";
1427 aCurrentRow
[4] = new ORowSetValueDecorator(sTableType
);
1431 uno::Reference
< XBlob
> xBlob
= xRow
->getBlob(4);
1432 OUString sDescription
;
1436 // TODO: we should actually be using CLOB here instead.
1437 // However we haven't implemented CLOB yet, so use BLOB.
1438 sal_Int32 aBlobLength
= (sal_Int32
) xBlob
->length();
1439 sDescription
= OUString(reinterpret_cast<char*>(xBlob
->getBytes(0, aBlobLength
).getArray()),
1441 RTL_TEXTENCODING_UTF8
);
1444 aCurrentRow
[5] = new ORowSetValueDecorator(sDescription
);
1447 aResults
.push_back(aCurrentRow
);
1450 pResultSet
->setRows( aResults
);
1455 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedureColumns(
1456 const Any
& catalog
, const OUString
& schemaPattern
,
1457 const OUString
& procedureNamePattern
, const OUString
& columnNamePattern
) throw(SQLException
, RuntimeException
, std::exception
)
1459 SAL_WARN("connectivity.firebird", "Not yet implemented");
1461 (void) schemaPattern
;
1462 (void) procedureNamePattern
;
1463 (void) columnNamePattern
;
1464 OSL_FAIL("Not implemented yet!");
1466 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eProcedureColumns
);
1469 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedures(
1470 const Any
& catalog
, const OUString
& schemaPattern
,
1471 const OUString
& procedureNamePattern
) throw(SQLException
, RuntimeException
, std::exception
)
1473 SAL_WARN("connectivity.firebird", "Not yet implemented");
1475 (void) schemaPattern
;
1476 (void) procedureNamePattern
;
1477 OSL_FAIL("Not implemented yet!");
1479 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eProcedures
);
1482 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getVersionColumns(
1483 const Any
& catalog
, const OUString
& schema
, const OUString
& table
) throw(SQLException
, RuntimeException
, std::exception
)
1485 SAL_WARN("connectivity.firebird", "Not yet implemented");
1489 OSL_FAIL("Not implemented yet!");
1491 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eVersionColumns
);
1494 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getExportedKeys(
1495 const Any
& catalog
, const OUString
& schema
, const OUString
& table
) throw(SQLException
, RuntimeException
, std::exception
)
1497 // List the columns in a table which are foreign keys. This is actually
1498 // never used anywhere in the LO codebase currently. Retrieval from firebird
1499 // requires using a 5-table join.
1500 SAL_WARN("connectivity.firebird", "Not yet implemented");
1504 OSL_FAIL("Not implemented yet!");
1506 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eExportedKeys
);
1509 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getImportedKeys(
1510 const Any
& catalog
, const OUString
& schema
, const OUString
& table
) throw(SQLException
, RuntimeException
, std::exception
)
1515 ODatabaseMetaDataResultSet
* pResultSet
= new
1516 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eImportedKeys
);
1517 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
1519 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1523 "RDB$REF_CONSTRAINTS.RDB$UPDATE_RULE, " // 1 update rule
1524 "RDB$REF_CONSTRAINTS.RDB$DELETE_RULE, " // 2 delete rule
1525 "RDB$REF_CONSTRAINTS.RDB$CONST_NAME_UQ, " // 3 primary or unique key name
1526 "RDB$REF_CONSTRAINTS.RDB$CONSTRAINT_NAME, " // 4 foreign key name
1527 "PRIM.RDB$DEFERRABLE, " // 5 deferrability
1528 "PRIM.RDB$INITIALLY_DEFERRED, " // 6 deferrability
1529 "PRIM.RDB$RELATION_NAME, " // 7 PK table name
1530 "PRIMARY_INDEX.RDB$FIELD_NAME, " // 8 PK column name
1531 "PRIMARY_INDEX.RDB$FIELD_POSITION, " // 9 PK sequence number
1532 "FOREI.RDB$RELATION_NAME, " // 10 FK table name
1533 "FOREIGN_INDEX.RDB$FIELD_NAME " // 11 FK column name
1534 "FROM RDB$REF_CONSTRAINTS "
1535 "INNER JOIN RDB$RELATION_CONSTRAINTS AS PRIM "
1536 "ON RDB$REF_CONSTRAINTS.RDB$CONST_NAME_UQ = PRIM.RDB$CONSTRAINT_NAME "
1537 "INNER JOIN RDB$RELATION_CONSTRAINTS AS FOREI "
1538 "ON RDB$REF_CONSTRAINTS.RDB$CONSTRAINT_NAME = FOREI.RDB$CONSTRAINT_NAME "
1539 "INNER JOIN RDB$INDEX_SEGMENTS AS PRIMARY_INDEX "
1540 "ON PRIM.RDB$INDEX_NAME = PRIMARY_INDEX.RDB$INDEX_NAME "
1541 "INNER JOIN RDB$INDEX_SEGMENTS AS FOREIGN_INDEX "
1542 "ON FOREI.RDB$INDEX_NAME = FOREIGN_INDEX.RDB$INDEX_NAME "
1543 "WHERE FOREI.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY' "
1544 "AND FOREI.RDB$RELATION_NAME = '"+ table
+"'";
1546 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(sSQL
);
1547 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1549 ODatabaseMetaDataResultSet::ORows aResults
;
1550 ODatabaseMetaDataResultSet::ORow
aCurrentRow(15);
1552 // TODO is it necessary to initialize these?
1553 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused
1554 aCurrentRow
[1] = new ORowSetValueDecorator(); // PKTABLE_CAT unsupported
1555 aCurrentRow
[2] = new ORowSetValueDecorator(); // PKTABLE_SCHEM unsupported
1556 aCurrentRow
[5] = new ORowSetValueDecorator(); // FKTABLE_CAT unsupported
1557 aCurrentRow
[6] = new ORowSetValueDecorator(); // FKTABLE_SCHEM unsupported
1559 ::std::map
< OUString
,sal_Int32
> aRuleMap
;
1560 aRuleMap
[ OUString("CASCADE")] = KeyRule::CASCADE
;
1561 aRuleMap
[ OUString("RESTRICT")] = KeyRule::RESTRICT
;
1562 aRuleMap
[ OUString("SET NULL")] = KeyRule::SET_NULL
;
1563 aRuleMap
[ OUString("SET DEFAULT")] = KeyRule::SET_DEFAULT
;
1564 aRuleMap
[ OUString("NO ACTION")] = KeyRule::NO_ACTION
;
1568 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(7))); // PK table
1569 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(8))); // PK column
1570 aCurrentRow
[7] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(10))); // FK table
1571 aCurrentRow
[8] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(11))); // FK column
1573 aCurrentRow
[9] = new ORowSetValueDecorator(xRow
->getShort(9)); // PK sequence number
1574 aCurrentRow
[10] = new ORowSetValueDecorator(aRuleMap
[sanitizeIdentifier(xRow
->getString(1))]); // update role
1575 aCurrentRow
[11] = new ORowSetValueDecorator(aRuleMap
[sanitizeIdentifier(xRow
->getString(2))]); // delete role
1577 aCurrentRow
[12] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(4))); // FK name
1578 aCurrentRow
[13] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(3))); // PK name
1580 aCurrentRow
[14] = new ORowSetValueDecorator(Deferrability::NONE
); // deferrability
1582 // deferrability is currently not supported, but may be supported in the future.
1584 aCurrentRow[14] = (xRow->getString(5).compareTo(OUString("NO") == 0 ?
1585 new ORowSetValueDecorator(Deferrability::NONE)
1586 : (xRow->getString(6).compareTo(OUString("NO") == 0 ?
1587 new ORowSetValueDecorator(Deferrability::INITIALLY_IMMEDIATE)
1588 : new ORowSetValueDecorator(Deferrability::INITIALLY_DEFERRED));
1591 aResults
.push_back(aCurrentRow
);
1594 pResultSet
->setRows( aResults
);
1598 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getPrimaryKeys(
1599 const Any
& /*aCatalog*/,
1600 const OUString
& /*sSchema*/,
1601 const OUString
& sTable
)
1602 throw(SQLException
, RuntimeException
, std::exception
)
1604 SAL_INFO("connectivity.firebird", "getPrimaryKeys() with "
1605 "Table: " << sTable
);
1607 OUStringBuffer
aQueryBuf("SELECT "
1608 "constr.RDB$RELATION_NAME, " // 1. Table Name
1609 "inds.RDB$FIELD_NAME, " // 2. Column Name
1610 "inds.RDB$FIELD_POSITION, " // 3. Sequence Number
1611 "constr.RDB$CONSTRAINT_NAME " // 4 Constraint name
1612 "FROM RDB$RELATION_CONSTRAINTS constr "
1613 "JOIN RDB$INDEX_SEGMENTS inds "
1614 "on (constr.RDB$INDEX_NAME = inds.RDB$INDEX_NAME) ");
1616 OUString sAppend
= "WHERE constr.RDB$RELATION_NAME = '%' ";
1617 aQueryBuf
.append(sAppend
.replaceAll("%", sTable
));
1619 aQueryBuf
.append("AND constr.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' "
1620 "ORDER BY inds.RDB$FIELD_NAME");
1622 OUString sQuery
= aQueryBuf
.makeStringAndClear();
1624 uno::Reference
< XStatement
> xStatement
= m_pConnection
->createStatement();
1625 uno::Reference
< XResultSet
> xRs
= xStatement
->executeQuery(sQuery
);
1626 uno::Reference
< XRow
> xRow( xRs
, UNO_QUERY_THROW
);
1628 ODatabaseMetaDataResultSet::ORows aResults
;
1629 ODatabaseMetaDataResultSet::ORow
aCurrentRow(7);
1631 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused -- numbering starts from 0
1632 aCurrentRow
[1] = new ORowSetValueDecorator(); // Catalog - can be null
1633 aCurrentRow
[2] = new ORowSetValueDecorator(); // Schema - can be null
1638 if (xRs
->getRow() == 1) // Table name doesn't change, so only retrieve once
1640 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1643 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2)));
1644 // 5. KEY_SEQ (which key in the sequence)
1645 aCurrentRow
[5] = new ORowSetValueDecorator(xRow
->getShort(3));
1646 // 6. Primary Key Name
1647 aCurrentRow
[6] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(4)));
1649 aResults
.push_back(aCurrentRow
);
1651 ODatabaseMetaDataResultSet
* pResultSet
= new
1652 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::ePrimaryKeys
);
1653 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
1654 pResultSet
->setRows( aResults
);
1659 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getIndexInfo(
1660 const Any
& /*aCatalog*/,
1661 const OUString
& /*sSchema*/,
1662 const OUString
& sTable
,
1664 sal_Bool bIsApproximate
)
1665 throw(SQLException
, RuntimeException
, std::exception
)
1667 // Apparently this method can also return a "tableIndexStatistic"
1668 // However this is only mentioned in XDatabaseMetaData.idl (whose comments
1669 // are duplicated in the postgresql driver), and is otherwise undocumented.
1670 SAL_INFO("connectivity.firebird", "getPrimaryKeys() with "
1671 "Table: " << sTable
);
1673 OUStringBuffer
aQueryBuf("SELECT "
1674 "indices.RDB$RELATION_NAME, " // 1. Table Name
1675 "index_segments.RDB$FIELD_NAME, " // 2. Column Name
1676 "index_segments.RDB$FIELD_POSITION, " // 3. Sequence Number
1677 "indices.RDB$INDEX_NAME, " // 4. Index name
1678 "indices.RDB$UNIQUE_FLAG, " // 5. Unique Flag
1679 "indices.RDB$INDEX_TYPE " // 6. Index Type
1680 "FROM RDB$INDICES indices "
1681 "JOIN RDB$INDEX_SEGMENTS index_segments "
1682 "on (indices.RDB$INDEX_NAME = index_segments.RDB$INDEX_NAME) "
1683 "WHERE indices.RDB$RELATION_NAME = '" + sTable
+ "' "
1684 "AND (indices.RDB$SYSTEM_FLAG = 0) ");
1685 // Not sure whether we should exclude system indices, but otoh. we never
1686 // actually deal with system tables (system indices only apply to system
1687 // tables) within the GUI.
1689 // Only filter if true (according to the docs), i.e.:
1690 // If false we return all indices, if true we return only unique indices
1692 aQueryBuf
.append("AND (indices.RDB$UNIQUE_FLAG = 1) ");
1694 // TODO: what is bIsApproximate?
1695 (void) bIsApproximate
;
1697 OUString sQuery
= aQueryBuf
.makeStringAndClear();
1699 uno::Reference
< XStatement
> xStatement
= m_pConnection
->createStatement();
1700 uno::Reference
< XResultSet
> xRs
= xStatement
->executeQuery(sQuery
);
1701 uno::Reference
< XRow
> xRow( xRs
, UNO_QUERY_THROW
);
1703 ODatabaseMetaDataResultSet::ORows aResults
;
1704 ODatabaseMetaDataResultSet::ORow
aCurrentRow(14);
1706 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused -- numbering starts from 0
1707 aCurrentRow
[1] = new ORowSetValueDecorator(); // Catalog - can be null
1708 aCurrentRow
[2] = new ORowSetValueDecorator(); // Schema - can be null
1709 aCurrentRow
[5] = new ORowSetValueDecorator(); // Index Catalog -- can be null
1710 // According to wikipedia firebird uses clustered indices.
1711 // The documentation does not specifically seem to specify this.
1712 aCurrentRow
[7] = new ORowSetValueDecorator(IndexType::CLUSTERED
); // 7. INDEX TYPE
1713 aCurrentRow
[13] = new ORowSetValueDecorator(); // Filter Condition -- can be null
1718 if (xRs
->getRow() == 1) // Table name doesn't change, so only retrieve once
1720 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1723 // 4. NON_UNIQUE -- i.e. specifically negate here.
1724 aCurrentRow
[4] = new ORowSetValueDecorator(!xRow
->getBoolean(5));
1726 aCurrentRow
[6] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(4)));
1728 // 8. ORDINAL POSITION
1729 aCurrentRow
[8] = new ORowSetValueDecorator(xRow
->getShort(3));
1731 aCurrentRow
[9] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2)));
1732 // 10. ASC(ending)/DESC(ending)
1733 if (xRow
->getShort(6) == 1)
1734 aCurrentRow
[10] = new ORowSetValueDecorator(OUString("D"));
1736 aCurrentRow
[10] = new ORowSetValueDecorator(OUString("A"));
1737 // TODO: double check this^^^, doesn't seem to be officially documented anywhere.
1739 aCurrentRow
[11] = new ORowSetValueDecorator((sal_Int32
)0); // TODO: determine how to do this
1741 aCurrentRow
[12] = new ORowSetValueDecorator((sal_Int32
)0); // TODO: determine how to do this
1743 aResults
.push_back(aCurrentRow
);
1745 ODatabaseMetaDataResultSet
* pResultSet
= new
1746 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::ePrimaryKeys
);
1747 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
1748 pResultSet
->setRows( aResults
);
1753 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getBestRowIdentifier(
1754 const Any
& catalog
, const OUString
& schema
, const OUString
& table
, sal_Int32 scope
,
1755 sal_Bool nullable
) throw(SQLException
, RuntimeException
, std::exception
)
1762 OSL_FAIL("Not implemented yet!");
1764 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eBestRowIdentifier
);
1767 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
1768 const Any
& /*aCatalog*/,
1769 const OUString
& /*sSchemaPattern*/,
1770 const OUString
& sTableNamePattern
)
1771 throw(SQLException
, RuntimeException
, std::exception
)
1773 SAL_INFO("connectivity.firebird", "getTablePrivileges() with "
1774 "TableNamePattern: " << sTableNamePattern
);
1776 ODatabaseMetaDataResultSet
* pResultSet
= new
1777 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges
);
1778 uno::Reference
< XResultSet
> xResultSet
= pResultSet
;
1779 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1781 // TODO: column specific privileges are included, we may need
1782 // to have WHERE RDB$FIELD_NAME = NULL or similar.
1783 static const char wld
[] = "%";
1784 OUStringBuffer
queryBuf(
1786 "priv.RDB$RELATION_NAME, " // 1
1787 "priv.RDB$GRANTOR," // 2
1788 "priv.RDB$USER, " // 3 Grantee
1789 "priv.RDB$PRIVILEGE, " // 4
1790 "priv.RDB$GRANT_OPTION " // 5 is Grantable
1791 "FROM RDB$USER_PRIVILEGES priv ");
1793 if (!sTableNamePattern
.isEmpty())
1796 if (sTableNamePattern
.match(wld
))
1797 sAppend
= "WHERE priv.RDB$RELATION_NAME LIKE '%' ";
1799 sAppend
= "WHERE priv.RDB$RELATION_NAME = '%' ";
1801 queryBuf
.append(sAppend
.replaceAll(wld
, sTableNamePattern
));
1803 queryBuf
.append(" ORDER BY priv.RDB$RELATION_TYPE, "
1804 "priv.RDB$RELATION_NAME, "
1805 "priv.RDB$PRIVILEGE");
1807 OUString query
= queryBuf
.makeStringAndClear();
1809 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
.getStr());
1810 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1811 ODatabaseMetaDataResultSet::ORows aResults
;
1813 ODatabaseMetaDataResultSet::ORow
aRow(8);
1814 aRow
[0] = new ORowSetValueDecorator(); // Unused
1815 aRow
[1] = new ORowSetValueDecorator(); // TABLE_CAT unsupported
1816 aRow
[2] = new ORowSetValueDecorator(); // TABLE_SCHEM unsupported.
1821 aRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1822 aRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2))); // 4. GRANTOR
1823 aRow
[5] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(3))); // 5. GRANTEE
1824 aRow
[6] = new ORowSetValueDecorator(xRow
->getString(4)); // 6. Privilege
1825 aRow
[7] = new ORowSetValueDecorator(xRow
->getBoolean(5)); // 7. Is Grantable
1827 aResults
.push_back(aRow
);
1830 pResultSet
->setRows( aResults
);
1835 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCrossReference(
1836 const Any
& primaryCatalog
, const OUString
& primarySchema
,
1837 const OUString
& primaryTable
, const Any
& foreignCatalog
,
1838 const OUString
& foreignSchema
, const OUString
& foreignTable
) throw(SQLException
, RuntimeException
, std::exception
)
1840 (void) primaryCatalog
;
1841 (void) primarySchema
;
1842 (void) primaryTable
;
1843 (void) foreignCatalog
;
1844 (void) foreignSchema
;
1845 (void) foreignTable
;
1846 OSL_FAIL("Not implemented yet!");
1848 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eCrossReference
);
1851 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getUDTs( const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& typeNamePattern
, const Sequence
< sal_Int32
>& types
) throw(SQLException
, RuntimeException
, std::exception
)
1854 (void) schemaPattern
;
1855 (void) typeNamePattern
;
1857 OSL_FAIL("Not implemented yet!");
1859 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eUDTs
);
1863 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */