1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <sal/log.hxx>
26 #include <FDatabaseMetaDataResultSet.hxx>
28 #include <com/sun/star/sdbc/ColumnSearch.hpp>
29 #include <com/sun/star/sdbc/ColumnValue.hpp>
30 #include <com/sun/star/sdbc/DataType.hpp>
31 #include <com/sun/star/sdbc/IndexType.hpp>
32 #include <com/sun/star/sdbc/ResultSetType.hpp>
33 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
34 #include <com/sun/star/sdbc/SQLException.hpp>
35 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
36 #include <com/sun/star/sdbc/XRow.hpp>
37 #include <com/sun/star/sdbc/KeyRule.hpp>
38 #include <com/sun/star/sdbc/Deferrability.hpp>
40 using namespace connectivity::firebird
;
41 using namespace com::sun::star
;
42 using namespace com::sun::star::uno
;
43 using namespace com::sun::star::lang
;
44 using namespace com::sun::star::beans
;
45 using namespace com::sun::star::sdbc
;
47 ODatabaseMetaData::ODatabaseMetaData(Connection
* _pCon
)
48 : m_pConnection(_pCon
)
50 SAL_WARN_IF(!m_pConnection
.is(), "connectivity.firebird",
51 "ODatabaseMetaData::ODatabaseMetaData: No connection set!");
54 ODatabaseMetaData::~ODatabaseMetaData()
58 //----- Catalog Info -- UNSUPPORTED -------------------------------------------
59 OUString SAL_CALL
ODatabaseMetaData::getCatalogSeparator()
64 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCatalogNameLength()
69 OUString SAL_CALL
ODatabaseMetaData::getCatalogTerm()
74 sal_Bool SAL_CALL
ODatabaseMetaData::isCatalogAtStart()
79 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInTableDefinitions()
84 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInIndexDefinitions()
89 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInDataManipulation( )
94 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCatalogs()
96 OSL_FAIL("Not implemented yet!");
98 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eCatalogs
);
101 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInProcedureCalls()
106 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions()
111 //----- Schema Info -- UNSUPPORTED --------------------------------------------
112 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInProcedureCalls()
117 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions()
122 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInDataManipulation()
127 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInIndexDefinitions()
132 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSchemasInTableDefinitions()
137 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxSchemaNameLength()
142 OUString SAL_CALL
ODatabaseMetaData::getSchemaTerm()
147 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getSchemas()
149 OSL_FAIL("Not implemented yet!");
151 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eSchemas
);
154 //----- Max Sizes/Lengths -----------------------------------------------------
155 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxBinaryLiteralLength()
160 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxRowSize()
165 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCharLiteralLength()
170 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnNameLength()
175 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInIndex()
178 // See: http://www.firebirdsql.org/en/firebird-technical-specifications/
182 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxCursorNameLength()
187 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxConnections()
189 return 100; // Arbitrary
192 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInTable()
194 // May however be smaller.
195 // See: http://www.firebirdsql.org/en/firebird-technical-specifications/
199 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatementLength()
204 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTableNameLength()
209 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxTablesInSelect( )
211 return 0; // 0 means no limit
215 sal_Bool SAL_CALL
ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
220 // ---- Identifiers -----------------------------------------------------------
221 // Only quoted identifiers are case sensitive, unquoted are case insensitive
222 OUString SAL_CALL
ODatabaseMetaData::getIdentifierQuoteString()
227 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( )
232 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseQuotedIdentifiers()
237 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseQuotedIdentifiers()
239 // TODO: confirm this -- the documentation is highly ambiguous
240 // However it seems this should be true as quoted identifiers ARE
241 // stored mixed case.
245 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseQuotedIdentifiers()
250 // ---- Unquoted Identifiers -------------------------------------------------
251 // All unquoted identifiers are stored upper case.
252 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMixedCaseIdentifiers()
257 sal_Bool SAL_CALL
ODatabaseMetaData::storesLowerCaseIdentifiers()
262 sal_Bool SAL_CALL
ODatabaseMetaData::storesMixedCaseIdentifiers()
267 sal_Bool SAL_CALL
ODatabaseMetaData::storesUpperCaseIdentifiers()
272 // ---- SQL Feature Support ---------------------------------------------------
273 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCoreSQLGrammar()
278 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMinimumSQLGrammar()
283 sal_Bool SAL_CALL
ODatabaseMetaData::supportsAlterTableWithAddColumn()
288 sal_Bool SAL_CALL
ODatabaseMetaData::supportsAlterTableWithDropColumn()
293 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedDelete()
298 sal_Bool SAL_CALL
ODatabaseMetaData::supportsPositionedUpdate()
303 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOuterJoins()
308 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSelectForUpdate()
313 sal_Bool SAL_CALL
ODatabaseMetaData::allTablesAreSelectable()
315 // TODO: true if embedded, but unsure about remote server
319 sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvert(sal_Int32
,
325 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTypeConversion()
330 sal_Bool SAL_CALL
ODatabaseMetaData::supportsColumnAliasing()
335 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTableCorrelationNames()
340 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxIndexLength( )
342 return 0; // 0 means no limit
345 sal_Bool SAL_CALL
ODatabaseMetaData::supportsNonNullableColumns( )
350 OUString SAL_CALL
ODatabaseMetaData::getExtraNameCharacters( )
355 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDifferentTableCorrelationNames( )
359 // ---- Data definition stuff -------------------------------------------------
360 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionIgnoredInTransactions()
365 sal_Bool SAL_CALL
ODatabaseMetaData::dataDefinitionCausesTransactionCommit()
370 sal_Bool SAL_CALL
ODatabaseMetaData::supportsDataManipulationTransactionsOnly()
375 sal_Bool SAL_CALL
ODatabaseMetaData::
376 supportsDataDefinitionAndDataManipulationTransactions()
380 //----- Transaction Support --------------------------------------------------
381 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactions()
386 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossRollback()
391 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenStatementsAcrossCommit()
396 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossCommit()
401 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOpenCursorsAcrossRollback()
406 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleTransactions()
411 sal_Bool SAL_CALL
ODatabaseMetaData::supportsTransactionIsolationLevel(
414 return aLevel
== TransactionIsolation::READ_UNCOMMITTED
415 || aLevel
== TransactionIsolation::READ_COMMITTED
416 || aLevel
== TransactionIsolation::REPEATABLE_READ
417 || aLevel
== TransactionIsolation::SERIALIZABLE
;
420 sal_Int32 SAL_CALL
ODatabaseMetaData::getDefaultTransactionIsolation()
422 return TransactionIsolation::REPEATABLE_READ
;
426 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92FullSQL( )
431 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92EntryLevelSQL( )
433 return true; // should be supported at least
436 sal_Bool SAL_CALL
ODatabaseMetaData::supportsIntegrityEnhancementFacility( )
441 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxStatements( )
443 return 0; // 0 means no limit
446 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxProcedureNameLength( )
448 return 31; // TODO: confirm
451 sal_Bool SAL_CALL
ODatabaseMetaData::allProceduresAreCallable( )
456 sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredProcedures( )
461 sal_Bool SAL_CALL
ODatabaseMetaData::isReadOnly( )
463 return m_pConnection
->isReadOnly();
466 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFiles( )
468 return m_pConnection
->isEmbedded();
471 sal_Bool SAL_CALL
ODatabaseMetaData::usesLocalFilePerTable( )
476 sal_Bool SAL_CALL
ODatabaseMetaData::nullPlusNonNullIsNull( )
481 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExpressionsInOrderBy( )
486 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupBy( )
491 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByBeyondSelect( )
497 sal_Bool SAL_CALL
ODatabaseMetaData::supportsGroupByUnrelated( )
504 sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleResultSets( )
509 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLikeEscapeClause( )
514 sal_Bool SAL_CALL
ODatabaseMetaData::supportsOrderByUnrelated( )
519 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnion( )
524 sal_Bool SAL_CALL
ODatabaseMetaData::supportsUnionAll( )
529 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtEnd( )
534 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedAtStart( )
539 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedHigh( )
544 sal_Bool SAL_CALL
ODatabaseMetaData::nullsAreSortedLow( )
549 sal_Bool SAL_CALL
ODatabaseMetaData::supportsCorrelatedSubqueries( )
554 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInComparisons( )
559 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInExists( )
564 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInIns( )
569 sal_Bool SAL_CALL
ODatabaseMetaData::supportsSubqueriesInQuantifieds( )
574 sal_Bool SAL_CALL
ODatabaseMetaData::supportsANSI92IntermediateSQL( )
579 OUString SAL_CALL
ODatabaseMetaData::getURL()
581 return m_pConnection
->getConnectionURL();
584 OUString SAL_CALL
ODatabaseMetaData::getUserName( )
589 OUString SAL_CALL
ODatabaseMetaData::getDriverName( )
594 OUString SAL_CALL
ODatabaseMetaData::getDriverVersion()
599 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductVersion( )
601 uno::Reference
< XStatement
> xSelect
= m_pConnection
->createStatement();
603 uno::Reference
< XResultSet
> xRs
= xSelect
->executeQuery(u
"SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') as version from rdb$database"_ustr
);
604 (void)xRs
->next(); // first and only row
605 uno::Reference
< XRow
> xRow( xRs
, UNO_QUERY_THROW
);
606 return xRow
->getString(1);
609 OUString SAL_CALL
ODatabaseMetaData::getDatabaseProductName( )
611 return u
"Firebird (engine12)"_ustr
;
614 OUString SAL_CALL
ODatabaseMetaData::getProcedureTerm( )
619 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMajorVersion( )
624 sal_Int32 SAL_CALL
ODatabaseMetaData::getDriverMinorVersion( )
629 OUString SAL_CALL
ODatabaseMetaData::getSQLKeywords( )
634 OUString SAL_CALL
ODatabaseMetaData::getSearchStringEscape( )
639 OUString SAL_CALL
ODatabaseMetaData::getStringFunctions( )
641 return u
"ASCII_CHAR,ASCII_VAL,BIT_LENGTH,CHAR_LENGTH,CHAR_TO_UUID,CHARACTER_LENGTH,"
642 "GEN_UUID,HASH,LEFT,LOWER,LPAD,OCTET_LENGTH,OVERLAY,POSITION,REPLACE,REVERSE,"
643 "RIGHT,RPAD,SUBSTRING,TRIM,UPPER,UUID_TO_CHAR"_ustr
;
646 OUString SAL_CALL
ODatabaseMetaData::getTimeDateFunctions( )
648 return u
"CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,DATEADD, DATEDIFF,"
649 "EXTRACT,'NOW','TODAY','TOMORROW','YESTERDAY'"_ustr
;
652 OUString SAL_CALL
ODatabaseMetaData::getSystemFunctions( )
657 OUString SAL_CALL
ODatabaseMetaData::getNumericFunctions( )
659 return u
"ABS,ACOS,ASIN,ATAN,ATAN2,BIN_AND,BIN_NOT,BIN_OR,BIN_SHL,"
660 "BIN_SHR,BIN_XOR,CEIL,CEILING,COS,COSH,COT,EXP,FLOOR,LN,"
661 "LOG,LOG10,MOD,PI,POWER,RAND,ROUND,SIGN,SIN,SINH,SQRT,TAN,TANH,TRUNC"_ustr
;
664 sal_Bool SAL_CALL
ODatabaseMetaData::supportsExtendedSQLGrammar( )
669 sal_Bool SAL_CALL
ODatabaseMetaData::supportsFullOuterJoins( )
674 sal_Bool SAL_CALL
ODatabaseMetaData::supportsLimitedOuterJoins( )
679 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInGroupBy( )
681 return 0; // 0 means no limit
684 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInOrderBy( )
686 return 0; // 0 means no limit
689 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxColumnsInSelect( )
691 return 0; // 0 means no limit
694 sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxUserNameLength( )
699 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetType(sal_Int32 setType
)
703 case ResultSetType::FORWARD_ONLY
:
710 sal_Bool SAL_CALL
ODatabaseMetaData::supportsResultSetConcurrency(
711 sal_Int32 aResultSetType
,
712 sal_Int32 aConcurrency
)
714 if (aResultSetType
== ResultSetType::FORWARD_ONLY
715 && aConcurrency
== ResultSetConcurrency::READ_ONLY
)
721 sal_Bool SAL_CALL
ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32
)
726 sal_Bool SAL_CALL
ODatabaseMetaData::ownDeletesAreVisible( sal_Int32
)
731 sal_Bool SAL_CALL
ODatabaseMetaData::ownInsertsAreVisible( sal_Int32
)
736 sal_Bool SAL_CALL
ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32
)
741 sal_Bool SAL_CALL
ODatabaseMetaData::othersDeletesAreVisible( sal_Int32
)
746 sal_Bool SAL_CALL
ODatabaseMetaData::othersInsertsAreVisible( sal_Int32
)
751 sal_Bool SAL_CALL
ODatabaseMetaData::updatesAreDetected( sal_Int32
)
756 sal_Bool SAL_CALL
ODatabaseMetaData::deletesAreDetected( sal_Int32
)
761 sal_Bool SAL_CALL
ODatabaseMetaData::insertsAreDetected( sal_Int32
)
766 sal_Bool SAL_CALL
ODatabaseMetaData::supportsBatchUpdates()
768 // No batch support in firebird
772 uno::Reference
< XConnection
> SAL_CALL
ODatabaseMetaData::getConnection()
774 return m_pConnection
;
777 ::css::uno::Sequence
< ::css::beans::PropertyValue
> SAL_CALL
ODatabaseMetaData::getConnectionInfo()
780 return Sequence
< ::css::beans::PropertyValue
>();
783 sal_Bool SAL_CALL
ODatabaseMetaData::autoCommitFailureClosesAllResultSets()
789 sal_Bool SAL_CALL
ODatabaseMetaData::generatedKeyAlwaysReturned()
795 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getAttributes( const ::rtl::OUString
& /* catalog */,
796 const ::rtl::OUString
& /* schemaPattern */,
797 const ::rtl::OUString
& /* typeNamePattern */,
798 const ::rtl::OUString
& /* attributeNamePattern */)
804 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getClientInfoProperties()
810 ::sal_Int32 SAL_CALL
ODatabaseMetaData::getDatabaseMajorVersion()
816 ::sal_Int32 SAL_CALL
ODatabaseMetaData::getDatabaseMinorVersion()
822 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getFunctions( const ::rtl::OUString
& /* catalog */, const ::rtl::OUString
& /* schemaPattern */, const ::rtl::OUString
& functionNamePattern
)
826 " null as FUNCTION_CAT,"
827 "RDB$FUNCTION_NAME as FUNCTION_NAME,"
828 "RDB$DESCRIPTION as REMARKS,"
829 "cast(null as blob sub_type text) as JB_FUNCTION_SOURCE,"
830 "'UDF' as JB_FUNCTION_KIND,"
831 "trim(trailing from RDB$MODULE_NAME) as JB_MODULE_NAME,"
832 "trim(trailing from RDB$ENTRYPOINT) as JB_ENTRYPOINT,"
833 "cast(null as varchar(255)) as JB_ENGINE_NAME "
834 "FROM RDB$FUNCTIONS "
835 "WHERE RDB$FUNCTION_NAME = '" + functionNamePattern
+ "'");
837 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
838 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(strQuery
);
842 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getFunctionColumns( const ::rtl::OUString
& /* catalog */, const ::rtl::OUString
& /* schemaPattern */, const ::rtl::OUString
& /* functionNamePattern */, const ::rtl::OUString
& /* columnNamePattern */ )
848 ::sal_Int32 SAL_CALL
ODatabaseMetaData::getMaxLogicalLobSize()
854 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getPseudoColumns( const ::rtl::OUString
& /* catalog */,
855 const ::rtl::OUString
& /* schemaPattern */,
856 const ::rtl::OUString
& /* tableNamePattern */,
857 const ::rtl::OUString
& /* columnNamePattern */)
863 ::sal_Int32 SAL_CALL
ODatabaseMetaData::getResultSetHoldability()
869 ::sal_Int32 SAL_CALL
ODatabaseMetaData::getRowIdLifetime()
875 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getSchemasFiltered( const ::css::beans::Optional
< ::rtl::OUString
>& /* catalog */,
876 const ::css::beans::Optional
< ::rtl::OUString
>& /* schemaPattern */)
882 ::sal_Int32 SAL_CALL
ODatabaseMetaData::getSQLStateType()
888 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getSuperTables( const ::rtl::OUString
& /* catalog */,
889 const ::rtl::OUString
& /* schemaPattern */, const ::rtl::OUString
& /* tableNamePattern */)
895 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getSuperTypes( const ::rtl::OUString
& /* catalog */,
896 const ::rtl::OUString
& /* schemaPattern */,
897 const ::rtl::OUString
& /* typeNamePattern */)
903 ::sal_Bool SAL_CALL
ODatabaseMetaData::locatorsUpdateCopy()
909 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsConvertInGeneral()
915 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsGetGeneratedKeys()
921 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsMultipleOpenResults()
927 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsNamedParameters()
933 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsRefCursors()
939 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsSavepoints()
945 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsSharding()
951 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsStatementPooling()
957 ::sal_Bool SAL_CALL
ODatabaseMetaData::supportsStoredFunctionsUsingCallSyntax()
963 // here follow all methods which return a resultset
964 // the first methods is an example implementation how to use this resultset
965 // of course you could implement it on your and you should do this because
966 // the general way is more memory expensive
968 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTableTypes( )
970 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
971 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes
);
973 ODatabaseMetaDataResultSet::ORows aResults
;
974 ODatabaseMetaDataResultSet::ORow
aRow(2);
976 aRow
[0] = new ORowSetValueDecorator(); // unused
978 // TODO Put these statics to one place
979 // like postgreSQL's Statics class.
981 aRow
[1] = new ORowSetValueDecorator(u
"TABLE"_ustr
);
982 aResults
.push_back(aRow
);
984 aRow
[1] = new ORowSetValueDecorator(u
"VIEW"_ustr
);
985 aResults
.push_back(aRow
);
987 aRow
[1] = new ORowSetValueDecorator(u
"SYSTEM TABLE"_ustr
);
988 aResults
.push_back(aRow
);
990 pResultSet
->setRows(std::move(aResults
));
994 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTypeInfo()
996 SAL_INFO("connectivity.firebird", "getTypeInfo()");
998 // this returns an empty resultset where the column-names are already set
999 // in special the metadata of the resultset already returns the right columns
1000 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
=
1001 new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo
);
1002 static ODatabaseMetaDataResultSet::ORows aResults
= []()
1004 ODatabaseMetaDataResultSet::ORows tmp
;
1005 ODatabaseMetaDataResultSet::ORow
aRow(19);
1008 aRow
[4] = ODatabaseMetaDataResultSet::getQuoteValue(); // Literal quote marks
1009 aRow
[5] = ODatabaseMetaDataResultSet::getQuoteValue(); // Literal quote marks
1010 aRow
[7] = new ORowSetValueDecorator(ORowSetValue(true)); // Nullable
1011 aRow
[8] = new ORowSetValueDecorator(ORowSetValue(true)); // Case sensitive
1012 aRow
[10] = new ORowSetValueDecorator(ORowSetValue(false)); // Is unsigned
1013 // FIXED_PREC_SCALE: docs state "can it be a money value? " however
1014 // in reality this causes Base to treat all numbers as money formatted
1015 // by default which is wrong (and formatting as money value is still
1016 // possible for all values).
1017 aRow
[11] = new ORowSetValueDecorator(ORowSetValue(false));
1018 // Localised Type Name -- TODO: implement (but can be null):
1019 aRow
[13] = new ORowSetValueDecorator();
1020 aRow
[16] = new ORowSetValueDecorator(); // Unused
1021 aRow
[17] = new ORowSetValueDecorator(); // Unused
1022 aRow
[18] = new ORowSetValueDecorator(sal_Int16(10));// Radix
1025 aRow
[1] = new ORowSetValueDecorator(u
"CHAR"_ustr
);
1026 aRow
[2] = new ORowSetValueDecorator(DataType::CHAR
);
1027 aRow
[3] = new ORowSetValueDecorator(sal_Int16(32765)); // Prevision = max length
1028 aRow
[6] = new ORowSetValueDecorator(u
"length"_ustr
); // Create Params
1029 aRow
[9] = new ORowSetValueDecorator(
1030 sal_Int16(ColumnSearch::FULL
)); // Searchable
1031 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1032 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1033 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1034 tmp
.push_back(aRow
);
1037 aRow
[1] = new ORowSetValueDecorator(u
"VARCHAR"_ustr
);
1038 aRow
[2] = new ORowSetValueDecorator(DataType::VARCHAR
);
1039 aRow
[3] = new ORowSetValueDecorator(sal_Int16(32765)); // Prevision = max length
1040 aRow
[6] = new ORowSetValueDecorator(u
"length"_ustr
); // Create Params
1041 aRow
[9] = new ORowSetValueDecorator(
1042 sal_Int16(ColumnSearch::FULL
)); // Searchable
1043 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1044 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1045 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1046 tmp
.push_back(aRow
);
1048 // Binary (CHAR); we use the Firebird synonym CHARACTER
1049 // to fool LO into seeing it as different types.
1050 // It is distinguished from Text type by its character set OCTETS;
1051 // that will be added by Tables::createStandardColumnPart
1052 aRow
[1] = new ORowSetValueDecorator(u
"CHARACTER"_ustr
);
1053 aRow
[2] = new ORowSetValueDecorator(DataType::BINARY
);
1054 aRow
[3] = new ORowSetValueDecorator(sal_Int16(32765)); // Prevision = max length
1055 aRow
[6] = new ORowSetValueDecorator(u
"length"_ustr
); // Create Params
1056 aRow
[9] = new ORowSetValueDecorator(
1057 sal_Int16(ColumnSearch::NONE
)); // Searchable
1058 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1059 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1060 tmp
.push_back(aRow
);
1062 // Varbinary (VARCHAR); see comment above about BINARY
1063 aRow
[1] = new ORowSetValueDecorator(u
"CHARACTER VARYING"_ustr
);
1064 aRow
[2] = new ORowSetValueDecorator(DataType::VARBINARY
);
1065 aRow
[3] = new ORowSetValueDecorator(sal_Int16(32765)); // Prevision = max length
1066 aRow
[6] = new ORowSetValueDecorator(u
"length"_ustr
); // Create Params
1067 aRow
[9] = new ORowSetValueDecorator(
1068 sal_Int16(ColumnSearch::NONE
)); // Searchable
1071 aRow
[1] = new ORowSetValueDecorator(u
"BLOB SUB_TYPE TEXT"_ustr
); // BLOB, with subtype 1
1072 aRow
[2] = new ORowSetValueDecorator(DataType::CLOB
);
1073 aRow
[3] = new ORowSetValueDecorator(sal_Int32(2147483647)); // Precision = max length
1074 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1075 aRow
[9] = new ORowSetValueDecorator(
1076 sal_Int16(ColumnSearch::FULL
)); // Searchable
1077 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1078 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1079 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1080 tmp
.push_back(aRow
);
1082 // Longvarbinary (SQL_BLOB)
1083 // Distinguished from simple blob with a user-defined subtype.
1084 aRow
[1] = new ORowSetValueDecorator(OUString("BLOB SUB_TYPE " + OUString::number(static_cast<short>(BlobSubtype::Image
))) ); // BLOB, with subtype 0
1085 aRow
[2] = new ORowSetValueDecorator(DataType::LONGVARBINARY
);
1086 tmp
.push_back(aRow
);
1088 // Integer Types common
1090 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1091 aRow
[9] = new ORowSetValueDecorator(
1092 sal_Int16(ColumnSearch::FULL
)); // Searchable
1093 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(true)); // Autoincrement
1094 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1095 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1097 // Smallint (SQL_SHORT)
1098 aRow
[1] = new ORowSetValueDecorator(u
"SMALLINT"_ustr
);
1099 aRow
[2] = new ORowSetValueDecorator(DataType::SMALLINT
);
1100 aRow
[3] = new ORowSetValueDecorator(sal_Int16(5)); // Prevision
1101 tmp
.push_back(aRow
);
1102 // Integer (SQL_LONG)
1103 aRow
[1] = new ORowSetValueDecorator(u
"INTEGER"_ustr
);
1104 aRow
[2] = new ORowSetValueDecorator(DataType::INTEGER
);
1105 aRow
[3] = new ORowSetValueDecorator(sal_Int16(10)); // Precision
1106 tmp
.push_back(aRow
);
1107 // Bigint (SQL_INT64)
1108 aRow
[1] = new ORowSetValueDecorator(u
"BIGINT"_ustr
);
1109 aRow
[2] = new ORowSetValueDecorator(DataType::BIGINT
);
1110 aRow
[3] = new ORowSetValueDecorator(sal_Int16(20)); // Precision
1111 tmp
.push_back(aRow
);
1113 // Decimal Types common
1115 aRow
[9] = new ORowSetValueDecorator(
1116 sal_Int16(ColumnSearch::FULL
)); // Searchable
1117 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(true)); // Autoincrement
1120 aRow
[6] = new ORowSetValueDecorator(u
"PRECISION,SCALE"_ustr
); // Create params
1122 aRow
[1] = new ORowSetValueDecorator(u
"NUMERIC"_ustr
);
1123 aRow
[2] = new ORowSetValueDecorator(DataType::NUMERIC
);
1124 aRow
[3] = new ORowSetValueDecorator(sal_Int16(18)); // Precision
1125 aRow
[14] = new ORowSetValueDecorator(sal_Int16(0)); // Minimum scale
1126 aRow
[15] = new ORowSetValueDecorator(sal_Int16(18)); // Max scale
1127 tmp
.push_back(aRow
);
1129 aRow
[1] = new ORowSetValueDecorator(u
"DECIMAL"_ustr
);
1130 aRow
[2] = new ORowSetValueDecorator(DataType::DECIMAL
);
1131 aRow
[3] = new ORowSetValueDecorator(sal_Int16(18)); // Precision
1132 aRow
[14] = new ORowSetValueDecorator(sal_Int16(0)); // Minimum scale
1133 aRow
[15] = new ORowSetValueDecorator(sal_Int16(18)); // Max scale
1134 tmp
.push_back(aRow
);
1136 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1137 // Float (SQL_FLOAT)
1138 aRow
[1] = new ORowSetValueDecorator(u
"FLOAT"_ustr
);
1139 aRow
[2] = new ORowSetValueDecorator(DataType::FLOAT
);
1140 aRow
[3] = new ORowSetValueDecorator(sal_Int16(7)); // Precision
1141 aRow
[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
1142 aRow
[15] = new ORowSetValueDecorator(sal_Int16(7)); // Max scale
1143 tmp
.push_back(aRow
);
1144 // Double (SQL_DOUBLE)
1145 aRow
[1] = new ORowSetValueDecorator(u
"DOUBLE PRECISION"_ustr
);
1146 aRow
[2] = new ORowSetValueDecorator(DataType::DOUBLE
);
1147 aRow
[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
1148 aRow
[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
1149 aRow
[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
1150 tmp
.push_back(aRow
);
1152 // TODO: no idea whether D_FLOAT corresponds to an sql type
1155 aRow
[1] = new ORowSetValueDecorator(u
"TIMESTAMP"_ustr
);
1156 aRow
[2] = new ORowSetValueDecorator(DataType::TIMESTAMP
);
1157 aRow
[3] = new ORowSetValueDecorator(sal_Int32(8)); // Prevision = max length
1158 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1159 aRow
[9] = new ORowSetValueDecorator(
1160 sal_Int16(ColumnSearch::FULL
)); // Searchable
1161 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1162 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1163 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1164 tmp
.push_back(aRow
);
1167 aRow
[1] = new ORowSetValueDecorator(u
"TIME"_ustr
);
1168 aRow
[2] = new ORowSetValueDecorator(DataType::TIME
);
1169 aRow
[3] = new ORowSetValueDecorator(sal_Int32(8)); // Prevision = max length
1170 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1171 aRow
[9] = new ORowSetValueDecorator(
1172 sal_Int16(ColumnSearch::FULL
)); // Searchable
1173 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1174 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1175 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1176 tmp
.push_back(aRow
);
1179 aRow
[1] = new ORowSetValueDecorator(u
"DATE"_ustr
);
1180 aRow
[2] = new ORowSetValueDecorator(DataType::DATE
);
1181 aRow
[3] = new ORowSetValueDecorator(sal_Int32(8)); // Prevision = max length
1182 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1183 aRow
[9] = new ORowSetValueDecorator(
1184 sal_Int16(ColumnSearch::FULL
)); // Searchable
1185 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1186 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1187 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1188 tmp
.push_back(aRow
);
1191 aRow
[1] = new ORowSetValueDecorator(u
"BLOB SUB_TYPE BINARY"_ustr
);
1192 aRow
[2] = new ORowSetValueDecorator(DataType::BLOB
);
1193 aRow
[3] = new ORowSetValueDecorator(sal_Int32(0)); // Prevision = max length
1194 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1195 aRow
[9] = new ORowSetValueDecorator(
1196 sal_Int16(ColumnSearch::NONE
)); // Searchable
1197 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1198 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1199 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1200 tmp
.push_back(aRow
);
1203 aRow
[1] = new ORowSetValueDecorator(u
"BOOLEAN"_ustr
);
1204 aRow
[2] = new ORowSetValueDecorator(DataType::BOOLEAN
);
1205 aRow
[3] = new ORowSetValueDecorator(sal_Int32(1)); // Prevision = max length
1206 aRow
[6] = new ORowSetValueDecorator(); // Create Params
1207 aRow
[9] = new ORowSetValueDecorator(
1208 sal_Int16(ColumnSearch::BASIC
)); // Searchable
1209 aRow
[12] = new ORowSetValueDecorator(ORowSetValue(false)); // Autoincrement
1210 aRow
[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
1211 aRow
[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
1212 tmp
.push_back(aRow
);
1215 // [-loplugin:redundantfcast] false positive:
1216 pResultSet
->setRows(ODatabaseMetaDataResultSet::ORows(aResults
));
1220 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumnPrivileges(
1221 const Any
& /*aCatalog*/,
1222 const OUString
& /*sSchema*/,
1223 const OUString
& sTable
,
1224 const OUString
& sColumnNamePattern
)
1226 SAL_INFO("connectivity.firebird", "getColumnPrivileges() with "
1228 << " & ColumnNamePattern: " << sColumnNamePattern
);
1230 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
1231 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumnPrivileges
);
1232 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1234 static const char wld
[] = "%";
1235 OUStringBuffer
queryBuf(
1237 "priv.RDB$RELATION_NAME, " // 1 Table name
1238 "priv.RDB$GRANTOR," // 2
1239 "priv.RDB$USER, " // 3 Grantee
1240 "priv.RDB$PRIVILEGE, " // 4
1241 "priv.RDB$GRANT_OPTION, " // 5 is Grantable
1242 "priv.RDB$FIELD_NAME " // 6 Column name
1243 "FROM RDB$USER_PRIVILEGES priv ");
1246 OUString sAppend
= u
"WHERE priv.RDB$RELATION_NAME = '%' "_ustr
;
1247 queryBuf
.append(sAppend
.replaceAll("%", sTable
));
1249 if (!sColumnNamePattern
.isEmpty())
1252 if (sColumnNamePattern
.match(wld
))
1253 sAppend
= "AND priv.RDB$FIELD_NAME LIKE '%' ";
1255 sAppend
= "AND priv.RDB$FIELD_NAME = '%' ";
1257 queryBuf
.append(sAppend
.replaceAll(wld
, sColumnNamePattern
));
1260 queryBuf
.append(" ORDER BY priv.RDB$FIELD, "
1261 "priv.RDB$PRIVILEGE");
1263 OUString query
= queryBuf
.makeStringAndClear();
1265 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
);
1266 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1267 ODatabaseMetaDataResultSet::ORows aResults
;
1269 ODatabaseMetaDataResultSet::ORow
aCurrentRow(9);
1270 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused
1271 aCurrentRow
[1] = new ORowSetValueDecorator(); // 1. TABLE_CAT Unsupported
1272 aCurrentRow
[2] = new ORowSetValueDecorator(); // 1. TABLE_SCHEM Unsupported
1277 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1279 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(6)));
1280 aCurrentRow
[5] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2))); // 5. GRANTOR
1281 aCurrentRow
[6] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(3))); // 6. GRANTEE
1282 aCurrentRow
[7] = new ORowSetValueDecorator(xRow
->getString(4)); // 7. Privilege
1283 aCurrentRow
[8] = new ORowSetValueDecorator( ( xRow
->getShort(5) == 1 ) ?
1284 u
"YES"_ustr
: u
"NO"_ustr
); // 8. Grantable
1286 aResults
.push_back(aCurrentRow
);
1289 pResultSet
->setRows( std::move(aResults
) );
1294 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getColumns(
1295 const Any
& /*catalog*/,
1296 const OUString
& /*schemaPattern*/,
1297 const OUString
& tableNamePattern
,
1298 const OUString
& columnNamePattern
)
1300 SAL_INFO("connectivity.firebird", "getColumns() with "
1301 "TableNamePattern: " << tableNamePattern
<<
1302 " & ColumnNamePattern: " << columnNamePattern
);
1304 OUStringBuffer
queryBuf("SELECT "
1305 "relfields.RDB$RELATION_NAME, " // 1
1306 "relfields.RDB$FIELD_NAME, " // 2
1307 "relfields.RDB$DESCRIPTION," // 3
1308 "relfields.RDB$DEFAULT_VALUE, " // 4
1309 "relfields.RDB$FIELD_POSITION, "// 5
1310 "fields.RDB$FIELD_TYPE, " // 6
1311 "fields.RDB$FIELD_SUB_TYPE, " // 7
1312 "fields.RDB$FIELD_LENGTH, " // 8
1313 "fields.RDB$FIELD_PRECISION, " // 9
1314 "fields.RDB$FIELD_SCALE, " // 10
1315 // Specifically use relfields null flag -- the one in fields is used
1316 // for domains, whether a specific field is nullable is set in relfields,
1317 // this is also the one we manually fiddle when changing NULL/NOT NULL
1319 "relfields.RDB$NULL_FLAG, " // 11
1320 "fields.RDB$CHARACTER_LENGTH, " // 12
1321 "charset.RDB$CHARACTER_SET_NAME " // 13
1322 "FROM RDB$RELATION_FIELDS relfields "
1323 "JOIN RDB$FIELDS fields "
1324 "on (fields.RDB$FIELD_NAME = relfields.RDB$FIELD_SOURCE) "
1325 "LEFT JOIN RDB$CHARACTER_SETS charset "
1326 "on (fields.RDB$CHARACTER_SET_ID = charset.RDB$CHARACTER_SET_ID) "
1329 if (!tableNamePattern
.isEmpty())
1332 if (tableNamePattern
.match("%"))
1333 sAppend
= "AND relfields.RDB$RELATION_NAME LIKE '%' ";
1335 sAppend
= "AND relfields.RDB$RELATION_NAME = '%' ";
1337 queryBuf
.append(sAppend
.replaceAll("%", tableNamePattern
));
1340 if (!columnNamePattern
.isEmpty())
1343 if (columnNamePattern
.match("%"))
1344 sAppend
= "AND relfields.RDB$FIELD_NAME LIKE '%' ";
1346 sAppend
= "AND relfields.RDB$FIELD_NAME = '%' ";
1348 queryBuf
.append(sAppend
.replaceAll("%", columnNamePattern
));
1351 OUString query
= queryBuf
.makeStringAndClear();
1353 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1354 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
);
1355 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1357 ODatabaseMetaDataResultSet::ORows aResults
;
1358 ODatabaseMetaDataResultSet::ORow
aCurrentRow(19);
1360 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused -- numbering starts from 0
1361 aCurrentRow
[1] = new ORowSetValueDecorator(); // Catalog - can be null
1362 aCurrentRow
[2] = new ORowSetValueDecorator(); // Schema - can be null
1363 aCurrentRow
[8] = new ORowSetValueDecorator(); // Unused
1364 aCurrentRow
[10] = new ORowSetValueDecorator(sal_Int32(10)); // Radix: fixed in FB
1365 aCurrentRow
[14] = new ORowSetValueDecorator(); // Unused
1366 aCurrentRow
[15] = new ORowSetValueDecorator(); // Unused
1371 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1373 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2)));
1375 short aType
= getFBTypeFromBlrType(xRow
->getShort(6));
1376 short aScale
= xRow
->getShort(10);
1377 OUString sCharsetName
= xRow
->getString(13);
1378 // result field may be filled with spaces
1379 sCharsetName
= sCharsetName
.trim();
1380 ColumnTypeInfo
aInfo(aType
, xRow
->getShort(7), aScale
,
1383 aCurrentRow
[5] = new ORowSetValueDecorator(aInfo
.getSdbcType());
1384 // 6. Typename (SQL_*)
1385 aCurrentRow
[6] = new ORowSetValueDecorator(aInfo
.getColumnTypeName());
1389 sal_Int32 aColumnSize
= 0;
1394 aColumnSize
= xRow
->getShort(12);
1403 aColumnSize
= xRow
->getShort(9);
1414 aCurrentRow
[7] = new ORowSetValueDecorator(aColumnSize
);
1417 // 9. Decimal digits (scale)
1418 // fb stores a negative number
1419 aCurrentRow
[9] = new ORowSetValueDecorator( static_cast<sal_Int16
>(-aScale
) );
1422 if (xRow
->getShort(11))
1424 aCurrentRow
[11] = new ORowSetValueDecorator(ColumnValue::NO_NULLS
);
1428 aCurrentRow
[11] = new ORowSetValueDecorator(ColumnValue::NULLABLE
);
1430 // 12. Comments -- may be omitted
1432 OUString aDescription
;
1433 uno::Reference
< XBlob
> xBlob
= xRow
->getBlob(3);
1436 const sal_Int64 aBlobLength
= xBlob
->length();
1437 if (aBlobLength
> SAL_MAX_INT32
)
1439 SAL_WARN("connectivity.firebird", "getBytes can't return " << aBlobLength
<< " bytes but only max " << SAL_MAX_INT32
);
1440 aDescription
= OUString(reinterpret_cast<char*>(xBlob
->getBytes(1, SAL_MAX_INT32
).getArray()),
1442 RTL_TEXTENCODING_UTF8
);
1446 aDescription
= OUString(reinterpret_cast<char*>(xBlob
->getBytes(1, static_cast<sal_Int32
>(aBlobLength
)).getArray()),
1448 RTL_TEXTENCODING_UTF8
);
1451 aCurrentRow
[12] = new ORowSetValueDecorator(aDescription
);
1453 // 13. Default -- may be omitted.
1455 uno::Reference
< XBlob
> xDefaultValueBlob
= xRow
->getBlob(4);
1456 if (xDefaultValueBlob
.is())
1460 aCurrentRow
[13] = new ORowSetValueDecorator();
1463 // 16. Bytes in Column for char
1464 if (aType
== SQL_TEXT
)
1466 aCurrentRow
[16] = new ORowSetValueDecorator(xRow
->getShort(8));
1468 else if (aType
== SQL_VARYING
)
1470 aCurrentRow
[16] = new ORowSetValueDecorator(sal_Int32(32767));
1474 aCurrentRow
[16] = new ORowSetValueDecorator(sal_Int32(0));
1476 // 17. Index of column
1478 short nColumnNumber
= xRow
->getShort(5);
1479 // Firebird stores column numbers beginning with 0 internally
1480 // SDBC expects column numbering to begin with 1.
1481 aCurrentRow
[17] = new ORowSetValueDecorator(sal_Int32(nColumnNumber
+ 1));
1484 if (xRow
->getShort(9))
1486 aCurrentRow
[18] = new ORowSetValueDecorator(u
"NO"_ustr
);
1490 aCurrentRow
[18] = new ORowSetValueDecorator(u
"YES"_ustr
);
1493 aResults
.push_back(aCurrentRow
);
1495 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
1496 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns
);
1497 pResultSet
->setRows( std::move(aResults
) );
1502 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTables(
1503 const Any
& /*catalog*/,
1504 const OUString
& /*schemaPattern*/,
1505 const OUString
& tableNamePattern
,
1506 const Sequence
< OUString
>& types
)
1508 SAL_INFO("connectivity.firebird", "getTables() with "
1509 "TableNamePattern: " << tableNamePattern
);
1511 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
1512 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables
);
1513 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1515 static const char wld
[] = "%";
1516 OUStringBuffer
queryBuf(
1518 "RDB$RELATION_NAME, "
1520 "RDB$RELATION_TYPE, "
1523 "FROM RDB$RELATIONS "
1526 // TODO: GLOBAL TEMPORARY, LOCAL TEMPORARY, ALIAS, SYNONYM
1527 if (!types
.hasElements() || (types
.getLength() == 1 && types
[0].match(wld
)))
1529 // from Firebird: src/jrd/constants.h
1530 // rel_persistent = 0, rel_view = 1, rel_external = 2
1531 // All table types? I.e. includes system tables.
1532 queryBuf
.append("(RDB$RELATION_TYPE = 0 OR RDB$RELATION_TYPE = 1 OR RDB$RELATION_TYPE = 2) ");
1536 queryBuf
.append("( (0 = 1) ");
1537 for (OUString
const & t
: types
)
1539 if (t
== "SYSTEM TABLE")
1540 queryBuf
.append("OR (RDB$SYSTEM_FLAG = 1 AND RDB$VIEW_BLR IS NULL) ");
1541 else if (t
== "TABLE")
1542 queryBuf
.append("OR (RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NULL) ");
1543 else if (t
== "VIEW")
1544 queryBuf
.append("OR (RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NOT NULL) ");
1546 throw SQLException(); // TODO: implement other types, see above.
1548 queryBuf
.append(") ");
1551 if (!tableNamePattern
.isEmpty())
1554 if (tableNamePattern
.match(wld
))
1555 sAppend
= "AND RDB$RELATION_NAME LIKE '%' ";
1557 sAppend
= "AND RDB$RELATION_NAME = '%' ";
1559 queryBuf
.append(sAppend
.replaceAll(wld
, tableNamePattern
));
1562 queryBuf
.append(" ORDER BY RDB$RELATION_TYPE, RDB$RELATION_NAME");
1564 OUString query
= queryBuf
.makeStringAndClear();
1566 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
);
1567 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1568 ODatabaseMetaDataResultSet::ORows aResults
;
1570 ODatabaseMetaDataResultSet::ORow
aCurrentRow(6);
1571 aCurrentRow
[0] = new ORowSetValueDecorator(); // 0. Unused
1572 aCurrentRow
[1] = new ORowSetValueDecorator(); // 1. Table_Cat Unsupported
1573 aCurrentRow
[2] = new ORowSetValueDecorator(); // 2. Table_Schem Unsupported
1578 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1581 // TODO: check this as the docs are a bit unclear.
1582 sal_Int16 nSystemFlag
= xRow
->getShort(2);
1583 sal_Int16 nTableType
= xRow
->getShort(3);
1584 xRow
->getBlob(5); // We have to retrieve a column to verify it is null.
1585 bool aIsView
= !xRow
->wasNull();
1586 OUString sTableType
;
1588 if (nSystemFlag
== 1)
1590 sTableType
= "SYSTEM TABLE";
1594 sTableType
= "VIEW";
1598 // see above about src/jrd/constants.h
1599 if (nTableType
== 0 || nTableType
== 2)
1600 sTableType
= "TABLE";
1603 aCurrentRow
[4] = new ORowSetValueDecorator(sTableType
);
1607 uno::Reference
< XClob
> xClob
= xRow
->getClob(4);
1610 aCurrentRow
[5] = new ORowSetValueDecorator(xClob
->getSubString(1, xClob
->length()));
1614 aResults
.push_back(aCurrentRow
);
1617 pResultSet
->setRows( std::move(aResults
) );
1622 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedureColumns(
1623 const Any
&, const OUString
&,
1624 const OUString
&, const OUString
& )
1626 SAL_WARN("connectivity.firebird", "Not yet implemented");
1627 OSL_FAIL("Not implemented yet!");
1629 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eProcedureColumns
);
1632 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getProcedures(
1633 const Any
&, const OUString
&,
1636 SAL_WARN("connectivity.firebird", "Not yet implemented");
1637 OSL_FAIL("Not implemented yet!");
1639 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eProcedures
);
1642 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getVersionColumns(
1643 const Any
&, const OUString
&, const OUString
& )
1645 SAL_WARN("connectivity.firebird", "Not yet implemented");
1646 OSL_FAIL("Not implemented yet!");
1648 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eVersionColumns
);
1651 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getExportedKeys(
1652 const Any
&, const OUString
&, const OUString
& table
)
1654 return ODatabaseMetaData::lcl_getKeys(false, table
);
1657 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getImportedKeys(
1658 const Any
&, const OUString
&, const OUString
& table
)
1660 return ODatabaseMetaData::lcl_getKeys(true, table
);
1663 uno::Reference
< XResultSet
> ODatabaseMetaData::lcl_getKeys(const bool bIsImport
, std::u16string_view table
)
1665 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
1666 ODatabaseMetaDataResultSet(bIsImport
?ODatabaseMetaDataResultSet::eImportedKeys
:ODatabaseMetaDataResultSet::eExportedKeys
);
1668 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1670 OUString sSQL
= u
"SELECT "
1671 "RDB$REF_CONSTRAINTS.RDB$UPDATE_RULE, " // 1 update rule
1672 "RDB$REF_CONSTRAINTS.RDB$DELETE_RULE, " // 2 delete rule
1673 "RDB$REF_CONSTRAINTS.RDB$CONST_NAME_UQ, " // 3 primary or unique key name
1674 "RDB$REF_CONSTRAINTS.RDB$CONSTRAINT_NAME, " // 4 foreign key name
1675 "PRIM.RDB$DEFERRABLE, " // 5 deferrability
1676 "PRIM.RDB$INITIALLY_DEFERRED, " // 6 deferrability
1677 "PRIM.RDB$RELATION_NAME, " // 7 PK table name
1678 "PRIMARY_INDEX.RDB$FIELD_NAME, " // 8 PK column name
1679 "PRIMARY_INDEX.RDB$FIELD_POSITION, " // 9 PK sequence number
1680 "FOREI.RDB$RELATION_NAME, " // 10 FK table name
1681 "FOREIGN_INDEX.RDB$FIELD_NAME " // 11 FK column name
1682 "FROM RDB$REF_CONSTRAINTS "
1683 "INNER JOIN RDB$RELATION_CONSTRAINTS AS PRIM "
1684 "ON RDB$REF_CONSTRAINTS.RDB$CONST_NAME_UQ = PRIM.RDB$CONSTRAINT_NAME "
1685 "INNER JOIN RDB$RELATION_CONSTRAINTS AS FOREI "
1686 "ON RDB$REF_CONSTRAINTS.RDB$CONSTRAINT_NAME = FOREI.RDB$CONSTRAINT_NAME "
1687 "INNER JOIN RDB$INDEX_SEGMENTS AS PRIMARY_INDEX "
1688 "ON PRIM.RDB$INDEX_NAME = PRIMARY_INDEX.RDB$INDEX_NAME "
1689 "INNER JOIN RDB$INDEX_SEGMENTS AS FOREIGN_INDEX "
1690 "ON FOREI.RDB$INDEX_NAME = FOREIGN_INDEX.RDB$INDEX_NAME "
1691 "WHERE FOREI.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY' "_ustr
;
1693 sSQL
+= OUString::Concat("AND FOREI.RDB$RELATION_NAME = '")+ table
+"'";
1695 sSQL
+= OUString::Concat("AND PRIM.RDB$RELATION_NAME = '")+ table
+"'";
1697 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(sSQL
);
1698 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1700 ODatabaseMetaDataResultSet::ORows aResults
;
1701 ODatabaseMetaDataResultSet::ORow
aCurrentRow(15);
1703 // TODO is it necessary to initialize these?
1704 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused
1705 aCurrentRow
[1] = new ORowSetValueDecorator(); // PKTABLE_CAT unsupported
1706 aCurrentRow
[2] = new ORowSetValueDecorator(); // PKTABLE_SCHEM unsupported
1707 aCurrentRow
[5] = new ORowSetValueDecorator(); // FKTABLE_CAT unsupported
1708 aCurrentRow
[6] = new ORowSetValueDecorator(); // FKTABLE_SCHEM unsupported
1710 std::map
< OUString
,sal_Int32
> aRuleMap
;
1711 aRuleMap
[ u
"CASCADE"_ustr
] = KeyRule::CASCADE
;
1712 aRuleMap
[ u
"RESTRICT"_ustr
] = KeyRule::RESTRICT
;
1713 aRuleMap
[ u
"SET NULL"_ustr
] = KeyRule::SET_NULL
;
1714 aRuleMap
[ u
"SET DEFAULT"_ustr
] = KeyRule::SET_DEFAULT
;
1715 aRuleMap
[ u
"NO ACTION"_ustr
] = KeyRule::NO_ACTION
;
1719 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(7))); // PK table
1720 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(8))); // PK column
1721 aCurrentRow
[7] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(10))); // FK table
1722 aCurrentRow
[8] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(11))); // FK column
1724 aCurrentRow
[9] = new ORowSetValueDecorator(xRow
->getShort(9)); // PK sequence number
1725 aCurrentRow
[10] = new ORowSetValueDecorator(aRuleMap
[sanitizeIdentifier(xRow
->getString(1))]); // update role
1726 aCurrentRow
[11] = new ORowSetValueDecorator(aRuleMap
[sanitizeIdentifier(xRow
->getString(2))]); // delete role
1728 aCurrentRow
[12] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(4))); // FK name
1729 aCurrentRow
[13] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(3))); // PK name
1731 aCurrentRow
[14] = new ORowSetValueDecorator(Deferrability::NONE
); // deferrability
1733 // deferrability is currently not supported, but may be supported in the future.
1735 aCurrentRow[14] = (xRow->getString(5) == "NO" ?
1736 new ORowSetValueDecorator(Deferrability::NONE)
1737 : (xRow->getString(6) == "NO" ?
1738 new ORowSetValueDecorator(Deferrability::INITIALLY_IMMEDIATE)
1739 : new ORowSetValueDecorator(Deferrability::INITIALLY_DEFERRED));
1742 aResults
.push_back(aCurrentRow
);
1745 pResultSet
->setRows( std::move(aResults
) );
1749 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getPrimaryKeys(
1750 const Any
& /*aCatalog*/,
1751 const OUString
& /*sSchema*/,
1752 const OUString
& sTable
)
1754 SAL_INFO("connectivity.firebird", "getPrimaryKeys() with "
1755 "Table: " << sTable
);
1757 OUString sAppend
= u
"WHERE constr.RDB$RELATION_NAME = '%' "_ustr
;
1758 OUString sQuery
= "SELECT "
1759 "constr.RDB$RELATION_NAME, " // 1. Table Name
1760 "inds.RDB$FIELD_NAME, " // 2. Column Name
1761 "inds.RDB$FIELD_POSITION, " // 3. Sequence Number
1762 "constr.RDB$CONSTRAINT_NAME " // 4 Constraint name
1763 "FROM RDB$RELATION_CONSTRAINTS constr "
1764 "JOIN RDB$INDEX_SEGMENTS inds "
1765 "on (constr.RDB$INDEX_NAME = inds.RDB$INDEX_NAME) " +
1766 sAppend
.replaceAll("%", sTable
) +
1767 "AND constr.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' "
1768 "ORDER BY inds.RDB$FIELD_NAME";
1770 uno::Reference
< XStatement
> xStatement
= m_pConnection
->createStatement();
1771 uno::Reference
< XResultSet
> xRs
= xStatement
->executeQuery(sQuery
);
1772 uno::Reference
< XRow
> xRow( xRs
, UNO_QUERY_THROW
);
1774 ODatabaseMetaDataResultSet::ORows aResults
;
1775 ODatabaseMetaDataResultSet::ORow
aCurrentRow(7);
1777 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused -- numbering starts from 0
1778 aCurrentRow
[1] = new ORowSetValueDecorator(); // Catalog - can be null
1779 aCurrentRow
[2] = new ORowSetValueDecorator(); // Schema - can be null
1784 if (xRs
->getRow() == 1) // Table name doesn't change, so only retrieve once
1786 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1789 aCurrentRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2)));
1790 // 5. KEY_SEQ (which key in the sequence)
1791 aCurrentRow
[5] = new ORowSetValueDecorator(xRow
->getShort(3));
1792 // 6. Primary Key Name
1793 aCurrentRow
[6] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(4)));
1795 aResults
.push_back(aCurrentRow
);
1797 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
1798 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::ePrimaryKeys
);
1799 pResultSet
->setRows( std::move(aResults
) );
1804 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getIndexInfo(
1805 const Any
& /*aCatalog*/,
1806 const OUString
& /*sSchema*/,
1807 const OUString
& sTable
,
1809 sal_Bool
) // TODO: what is bIsApproximate?
1812 // Apparently this method can also return a "tableIndexStatistic"
1813 // However this is only mentioned in XDatabaseMetaData.idl (whose comments
1814 // are duplicated in the postgresql driver), and is otherwise undocumented.
1815 SAL_INFO("connectivity.firebird", "getPrimaryKeys() with "
1816 "Table: " << sTable
);
1818 OUStringBuffer
aQueryBuf("SELECT "
1819 "indices.RDB$RELATION_NAME, " // 1. Table Name
1820 "index_segments.RDB$FIELD_NAME, " // 2. Column Name
1821 "index_segments.RDB$FIELD_POSITION, " // 3. Sequence Number
1822 "indices.RDB$INDEX_NAME, " // 4. Index name
1823 "indices.RDB$UNIQUE_FLAG, " // 5. Unique Flag
1824 "indices.RDB$INDEX_TYPE " // 6. Index Type
1825 "FROM RDB$INDICES indices "
1826 "JOIN RDB$INDEX_SEGMENTS index_segments "
1827 "on (indices.RDB$INDEX_NAME = index_segments.RDB$INDEX_NAME) "
1828 "WHERE indices.RDB$RELATION_NAME = '" + sTable
+ "' "
1829 "AND (indices.RDB$SYSTEM_FLAG = 0) ");
1830 // Not sure whether we should exclude system indices, but otoh. we never
1831 // actually deal with system tables (system indices only apply to system
1832 // tables) within the GUI.
1834 // Only filter if true (according to the docs), i.e.:
1835 // If false we return all indices, if true we return only unique indices
1837 aQueryBuf
.append("AND (indices.RDB$UNIQUE_FLAG = 1) ");
1839 OUString sQuery
= aQueryBuf
.makeStringAndClear();
1841 uno::Reference
< XStatement
> xStatement
= m_pConnection
->createStatement();
1842 uno::Reference
< XResultSet
> xRs
= xStatement
->executeQuery(sQuery
);
1843 uno::Reference
< XRow
> xRow( xRs
, UNO_QUERY_THROW
);
1845 ODatabaseMetaDataResultSet::ORows aResults
;
1846 ODatabaseMetaDataResultSet::ORow
aCurrentRow(14);
1848 aCurrentRow
[0] = new ORowSetValueDecorator(); // Unused -- numbering starts from 0
1849 aCurrentRow
[1] = new ORowSetValueDecorator(); // Catalog - can be null
1850 aCurrentRow
[2] = new ORowSetValueDecorator(); // Schema - can be null
1851 aCurrentRow
[5] = new ORowSetValueDecorator(); // Index Catalog -- can be null
1852 // Wikipedia indicates:
1853 // 'Firebird makes all indices of the database behave like well-tuned "clustered indexes" used by other architectures.'
1854 // but it's not "CLUSTERED", neither "STATISTIC" nor "HASHED" (the other specific types from offapi/com/sun/star/sdbc/IndexType.idl)
1855 // According to https://www.ibphoenix.com/resources/documents/design/doc_18,
1856 // it seems another type => OTHER
1857 aCurrentRow
[7] = new ORowSetValueDecorator(IndexType::OTHER
); // 7. INDEX TYPE
1858 aCurrentRow
[13] = new ORowSetValueDecorator(); // Filter Condition -- can be null
1863 if (xRs
->getRow() == 1) // Table name doesn't change, so only retrieve once
1865 aCurrentRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1868 // 4. NON_UNIQUE -- i.e. specifically negate here.
1869 aCurrentRow
[4] = new ORowSetValueDecorator(ORowSetValue(xRow
->getShort(5) == 0));
1871 aCurrentRow
[6] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(4)));
1873 // 8. ORDINAL POSITION
1874 aCurrentRow
[8] = new ORowSetValueDecorator(xRow
->getShort(3));
1876 aCurrentRow
[9] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2)));
1877 // 10. ASC(ending)/DESC(ending)
1878 if (xRow
->getShort(6) == 1)
1879 aCurrentRow
[10] = new ORowSetValueDecorator(u
"D"_ustr
);
1881 aCurrentRow
[10] = new ORowSetValueDecorator(u
"A"_ustr
);
1882 // TODO: double check this^^^, doesn't seem to be officially documented anywhere.
1884 aCurrentRow
[11] = new ORowSetValueDecorator(sal_Int32(0)); // TODO: determine how to do this
1886 aCurrentRow
[12] = new ORowSetValueDecorator(sal_Int32(0)); // TODO: determine how to do this
1888 aResults
.push_back(aCurrentRow
);
1890 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
1891 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eIndexInfo
);
1892 pResultSet
->setRows( std::move(aResults
) );
1897 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getBestRowIdentifier(
1898 const Any
&, const OUString
&, const OUString
&, sal_Int32
,
1901 OSL_FAIL("Not implemented yet!");
1903 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eBestRowIdentifier
);
1906 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getTablePrivileges(
1907 const Any
& /*aCatalog*/,
1908 const OUString
& /*sSchemaPattern*/,
1909 const OUString
& sTableNamePattern
)
1911 SAL_INFO("connectivity.firebird", "getTablePrivileges() with "
1912 "TableNamePattern: " << sTableNamePattern
);
1914 rtl::Reference
<ODatabaseMetaDataResultSet
> pResultSet
= new
1915 ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges
);
1916 uno::Reference
< XStatement
> statement
= m_pConnection
->createStatement();
1918 // TODO: column specific privileges are included, we may need
1919 // to have WHERE RDB$FIELD_NAME = NULL or similar.
1920 static const char wld
[] = "%";
1921 OUStringBuffer
queryBuf(
1923 "priv.RDB$RELATION_NAME, " // 1
1924 "priv.RDB$GRANTOR," // 2
1925 "priv.RDB$USER, " // 3 Grantee
1926 "priv.RDB$PRIVILEGE, " // 4
1927 "priv.RDB$GRANT_OPTION " // 5 is Grantable
1928 "FROM RDB$USER_PRIVILEGES priv ");
1930 if (!sTableNamePattern
.isEmpty())
1933 if (sTableNamePattern
.match(wld
))
1934 sAppend
= "WHERE priv.RDB$RELATION_NAME LIKE '%' ";
1936 sAppend
= "WHERE priv.RDB$RELATION_NAME = '%' ";
1938 queryBuf
.append(sAppend
.replaceAll(wld
, sTableNamePattern
));
1940 queryBuf
.append(" ORDER BY priv.RDB$RELATION_TYPE, "
1941 "priv.RDB$RELATION_NAME, "
1942 "priv.RDB$PRIVILEGE");
1944 OUString query
= queryBuf
.makeStringAndClear();
1946 uno::Reference
< XResultSet
> rs
= statement
->executeQuery(query
);
1947 uno::Reference
< XRow
> xRow( rs
, UNO_QUERY_THROW
);
1948 ODatabaseMetaDataResultSet::ORows aResults
;
1950 ODatabaseMetaDataResultSet::ORow
aRow(8);
1951 aRow
[0] = new ORowSetValueDecorator(); // Unused
1952 aRow
[1] = new ORowSetValueDecorator(); // TABLE_CAT unsupported
1953 aRow
[2] = new ORowSetValueDecorator(); // TABLE_SCHEM unsupported.
1958 aRow
[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(1)));
1959 aRow
[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(2))); // 4. GRANTOR
1960 aRow
[5] = new ORowSetValueDecorator(sanitizeIdentifier(xRow
->getString(3))); // 5. GRANTEE
1961 aRow
[6] = new ORowSetValueDecorator(xRow
->getString(4)); // 6. Privilege
1962 aRow
[7] = new ORowSetValueDecorator(ORowSetValue(bool(xRow
->getBoolean(5)))); // 7. Is Grantable
1964 aResults
.push_back(aRow
);
1967 pResultSet
->setRows( std::move(aResults
) );
1972 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getCrossReference(
1973 const Any
&, const OUString
&,
1974 const OUString
&, const Any
&,
1975 const OUString
&, const OUString
& )
1977 OSL_FAIL("Not implemented yet!");
1979 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eCrossReference
);
1982 uno::Reference
< XResultSet
> SAL_CALL
ODatabaseMetaData::getUDTs( const Any
&, const OUString
&, const OUString
&, const Sequence
< sal_Int32
>& )
1984 OSL_FAIL("Not implemented yet!");
1986 return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eUDTs
);
1989 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */