summaryrefslogtreecommitdiff
path: root/ndb/src/old_files/client/odbc/common/ConnArea.hpp
blob: 36367a39bae0dd4b77c96aab9408f40842268431 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef ODBC_COMMON_ConnArea_hpp
#define ODBC_COMMON_ConnArea_hpp

#include <common/common.hpp>

class Ctx;
class Ndb;
class NdbSchemaCon;
class NdbConnection;
class DictCatalog;
class DictSchema;

/**
 * @class ConnArea
 * @brief Public part of connection handle
 */
class ConnArea {
public:
    // state between ODBC function calls
    enum State {
	Free = 1,		// not in use, no Ndb object
	Connected = 2,		// has Ndb object but no Ndb connection
	Transacting = 3		// has Ndb connection
    };
    State getState() const;
    DictCatalog& dictCatalog() const;
    DictSchema& dictSchema() const;
    Ndb* ndbObject() const;
    NdbSchemaCon* ndbSchemaCon() const;
    NdbConnection* ndbConnection() const;
    // called from StmtArea
    bool useSchemaCon(Ctx& ctx, bool use);
    bool useConnection(Ctx& ctx, bool use);
    // these just get and set the flag - no semantics
    bool autocommit() const;
    void autocommit(bool flag);
    bool uncommitted() const;
    void uncommitted(bool flag);
protected:
    ConnArea();
    ~ConnArea();
    State m_state;
    DictCatalog* m_catalog;
    DictSchema* m_schema;
    Ndb* m_ndbObject;
    NdbSchemaCon* m_ndbSchemaCon;
    NdbConnection* m_ndbConnection;
    unsigned m_useSchemaCon;
    unsigned m_useConnection;
    bool m_autocommit;
    bool m_uncommitted;		// has uncommitted changes
};

inline ConnArea::State
ConnArea::getState() const
{
    return m_state;
}

inline DictCatalog&
ConnArea::dictCatalog() const
{
    ctx_assert(m_catalog != 0);
    return *m_catalog;
}

inline DictSchema&
ConnArea::dictSchema() const
{
    ctx_assert(m_schema != 0);
    return *m_schema;
}

inline Ndb*
ConnArea::ndbObject() const
{
    ctx_assert(m_ndbObject != 0);
    return m_ndbObject;
}

inline NdbSchemaCon*
ConnArea::ndbSchemaCon() const
{
    ctx_assert(m_ndbSchemaCon != 0);
    return m_ndbSchemaCon;
}

inline NdbConnection*
ConnArea::ndbConnection() const
{
    ctx_assert(m_ndbConnection != 0);
    return m_ndbConnection;
}

inline bool
ConnArea::autocommit() const
{
    return m_autocommit;
}

inline void
ConnArea::autocommit(bool flag)
{
    m_autocommit = flag;
}

inline bool
ConnArea::uncommitted() const
{
    return m_uncommitted;
}

inline void
ConnArea::uncommitted(bool flag)
{
    m_uncommitted = flag;
}

#endif