Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/connectivity/source/inc/TDatabaseMetaDataBase.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#pragma once
21
22
#include <com/sun/star/sdbc/XDatabaseMetaData2.hpp>
23
#include <cppuhelper/implbase.hxx>
24
#include <cppuhelper/basemutex.hxx>
25
#include <com/sun/star/lang/XEventListener.hpp>
26
#include "FDatabaseMetaDataResultSet.hxx"
27
#include <functional>
28
#include <connectivity/dbtoolsdllapi.hxx>
29
30
namespace comphelper { class OEventListenerHelper; }
31
32
namespace connectivity
33
{
34
35
    class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataBase :
36
                                    public  cppu::BaseMutex,
37
                                    public ::cppu::WeakImplHelper< css::sdbc::XDatabaseMetaData2,
38
                                                                   css::lang::XEventListener>
39
    {
40
    private:
41
        css::uno::Sequence< css::beans::PropertyValue >   m_aConnectionInfo;
42
        ::connectivity::ODatabaseMetaDataResultSet::ORows m_aTypeInfoRows;
43
44
        // cached database information
45
        std::pair<bool,bool>              m_isCatalogAtStart;
46
        std::pair<bool,OUString>          m_sCatalogSeparator;
47
        std::pair<bool,OUString>          m_sIdentifierQuoteString;
48
        std::pair<bool,bool>              m_supportsCatalogsInTableDefinitions;
49
        std::pair<bool,bool>              m_supportsSchemasInTableDefinitions;
50
        std::pair<bool,bool>              m_supportsCatalogsInDataManipulation;
51
        std::pair<bool,bool>              m_supportsSchemasInDataManipulation;
52
        std::pair<bool,bool>              m_supportsMixedCaseQuotedIdentifiers;
53
        std::pair<bool,bool>              m_supportsAlterTableWithAddColumn;
54
        std::pair<bool,bool>              m_supportsAlterTableWithDropColumn;
55
        std::pair<bool,sal_Int32>         m_MaxStatements;
56
        std::pair<bool,sal_Int32>         m_MaxTablesInSelect;
57
        std::pair<bool,bool>              m_storesMixedCaseQuotedIdentifiers;
58
59
        template <typename T> T callImplMethod(std::pair<bool,T>& _rCache,const std::function<T(ODatabaseMetaDataBase *)>& _pImplMethod)
60
1.23M
        {
61
1.23M
            ::osl::MutexGuard aGuard( m_aMutex );
62
1.23M
            if ( !_rCache.first )
63
82.3k
            {
64
82.3k
                _rCache.second = _pImplMethod(this);
65
82.3k
                _rCache.first = true;
66
82.3k
            }
67
1.23M
            return _rCache.second;
68
1.23M
        }
rtl::OUString connectivity::ODatabaseMetaDataBase::callImplMethod<rtl::OUString>(std::__1::pair<bool, rtl::OUString>&, std::__1::function<rtl::OUString (connectivity::ODatabaseMetaDataBase*)> const&)
Line
Count
Source
60
346k
        {
61
346k
            ::osl::MutexGuard aGuard( m_aMutex );
62
346k
            if ( !_rCache.first )
63
23.5k
            {
64
23.5k
                _rCache.second = _pImplMethod(this);
65
23.5k
                _rCache.first = true;
66
23.5k
            }
67
346k
            return _rCache.second;
68
346k
        }
bool connectivity::ODatabaseMetaDataBase::callImplMethod<bool>(std::__1::pair<bool, bool>&, std::__1::function<bool (connectivity::ODatabaseMetaDataBase*)> const&)
Line
Count
Source
60
809k
        {
61
809k
            ::osl::MutexGuard aGuard( m_aMutex );
62
809k
            if ( !_rCache.first )
63
47.0k
            {
64
47.0k
                _rCache.second = _pImplMethod(this);
65
47.0k
                _rCache.first = true;
66
47.0k
            }
67
809k
            return _rCache.second;
68
809k
        }
int connectivity::ODatabaseMetaDataBase::callImplMethod<int>(std::__1::pair<bool, int>&, std::__1::function<int (connectivity::ODatabaseMetaDataBase*)> const&)
Line
Count
Source
60
81.2k
        {
61
81.2k
            ::osl::MutexGuard aGuard( m_aMutex );
62
81.2k
            if ( !_rCache.first )
63
11.7k
            {
64
11.7k
                _rCache.second = _pImplMethod(this);
65
11.7k
                _rCache.first = true;
66
11.7k
            }
67
81.2k
            return _rCache.second;
68
81.2k
        }
69
    protected:
70
        css::uno::Reference< css::sdbc::XConnection >     m_xConnection;
71
        rtl::Reference< comphelper::OEventListenerHelper> m_xListenerHelper; // forward the calls from the connection to me
72
73
        virtual ~ODatabaseMetaDataBase() override;
74
75
    protected:
76
        virtual css::uno::Reference< css::sdbc::XResultSet > impl_getTypeInfo_throw() = 0;
77
        // cached database information
78
        virtual OUString    impl_getIdentifierQuoteString_throw(  )             = 0;
79
        virtual bool        impl_isCatalogAtStart_throw(  )                     = 0;
80
        virtual OUString    impl_getCatalogSeparator_throw(  )                  = 0;
81
        virtual bool        impl_supportsCatalogsInTableDefinitions_throw(  )   = 0;
82
        virtual bool        impl_supportsSchemasInTableDefinitions_throw(  )    = 0;
83
        virtual bool        impl_supportsCatalogsInDataManipulation_throw(  )   = 0;
84
        virtual bool        impl_supportsSchemasInDataManipulation_throw(  )    = 0;
85
        virtual bool        impl_supportsMixedCaseQuotedIdentifiers_throw(  )   = 0;
86
        virtual bool        impl_supportsAlterTableWithAddColumn_throw(  )      = 0;
87
        virtual bool        impl_supportsAlterTableWithDropColumn_throw(  )     = 0;
88
        virtual sal_Int32   impl_getMaxStatements_throw(  )                     = 0;
89
        virtual sal_Int32   impl_getMaxTablesInSelect_throw(  )                 = 0;
90
        virtual bool        impl_storesMixedCaseQuotedIdentifiers_throw(  )     = 0;
91
92
93
    public:
94
95
        ODatabaseMetaDataBase(const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,const css::uno::Sequence< css::beans::PropertyValue >& _rInfo);
96
97
        // XDatabaseMetaData2
98
        virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getConnectionInfo(  ) override;
99
100
        // XEventListener
101
        virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
102
103
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTypeInfo(  ) override;
104
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedures( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern ) override;
105
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedureColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern, const OUString& columnNamePattern ) override;
106
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getSchemas(  ) override;
107
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCatalogs(  ) override;
108
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const css::uno::Any& catalog, const OUString& schema, const OUString& table, const OUString& columnNamePattern ) override;
109
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTablePrivileges( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern ) override;
110
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope, sal_Bool nullable ) override;
111
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getVersionColumns( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override;
112
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override;
113
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getImportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override;
114
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getExportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override;
115
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCrossReference( const css::uno::Any& primaryCatalog, const OUString& primarySchema, const OUString& primaryTable, const css::uno::Any& foreignCatalog, const OUString& foreignSchema, const OUString& foreignTable ) override;
116
        virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getIndexInfo( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Bool unique, sal_Bool approximate ) override;
117
118
        virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection(  ) override;
119
        // cached database information
120
        virtual OUString SAL_CALL getIdentifierQuoteString(  ) override;
121
        virtual sal_Bool SAL_CALL isCatalogAtStart(  ) override;
122
        virtual OUString SAL_CALL getCatalogSeparator(  ) override;
123
        virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions(  ) override;
124
        virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions(  ) override;
125
        virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation(  ) override;
126
        virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation(  ) override;
127
        virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers(  ) override;
128
        virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn(  ) override;
129
        virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn(  ) override;
130
        virtual sal_Int32 SAL_CALL getMaxStatements(  ) override;
131
        virtual sal_Int32 SAL_CALL getMaxTablesInSelect(  ) override;
132
        virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers(  ) override;
133
    };
134
}
135
136
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */