~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/open_tables_state.h

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
mergeĀ lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
 
21
 
#ifndef DRIZZLED_OPEN_TABLES_STATE_H
22
 
#define DRIZZLED_OPEN_TABLES_STATE_H
23
 
 
24
 
#include "drizzled/lock.h"
25
 
#include "drizzled/query_id.h"
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
class CachedDirectory;
 
20
#pragma once
 
21
 
 
22
#include <drizzled/common_fwd.h>
 
23
#include <drizzled/lock.h>
 
24
 
 
25
namespace drizzled {
 
26
 
 
27
extern uint64_t g_refresh_version;
31
28
 
32
29
/**
33
30
  Class that holds information about tables which were opened and locked
34
 
  by the thread. It is also used to save/restore this information in
35
 
  push_open_tables_state()/pop_open_tables_state().
 
31
  by the thread.
36
32
*/
37
33
 
38
34
class Open_tables_state
42
38
    List of regular tables in use by this thread. Contains temporary and
43
39
    base tables that were opened with @see open_tables().
44
40
  */
45
 
  Table *open_tables;
 
41
  Table *open_tables_;
46
42
 
47
43
  /**
48
44
    List of temporary tables used by this thread. Contains user-level
51
47
    or for an intermediate table used in ALTER.
52
48
    XXX Why are internal temporary tables added to this list?
53
49
  */
54
 
private:
55
50
  Table *temporary_tables;
56
51
 
57
 
public:
58
 
 
59
52
  Table *getTemporaryTables()
60
53
  {
61
54
    return temporary_tables;
71
64
            is not reset until the HANDLER is closed.
72
65
  */
73
66
  void mark_temp_tables_as_free_for_reuse();
74
 
 
75
 
protected:
76
67
  void close_temporary_tables();
77
 
 
78
 
public:
79
 
  void close_temporary_table(Table *table);
80
 
  
81
 
private:
82
 
  // The method below just handles the de-allocation of the table. In
83
 
  // a better memory type world, this would not be needed.
84
 
  void nukeTable(Table *table);
85
 
 
86
 
public:
 
68
  void close_temporary_table(Table*);
 
69
  void nukeTable(Table*);
 
70
  void close_open_tables();
 
71
  bool free_cached_table();
 
72
 
87
73
  /* Work with temporary tables */
88
74
  Table *find_temporary_table(const identifier::Table &identifier);
89
75
 
90
76
  void dumpTemporaryTableNames(const char *id);
91
 
  int drop_temporary_table(const drizzled::identifier::Table &identifier);
92
 
  bool rm_temporary_table(plugin::StorageEngine *base, const identifier::Table &identifier);
93
 
  bool rm_temporary_table(const drizzled::identifier::Table &identifier, bool best_effort= false);
94
 
  Table *open_temporary_table(const drizzled::identifier::Table &identifier,
95
 
                              bool link_in_list= true);
96
 
 
97
 
  virtual query_id_t getQueryId()  const= 0;
 
77
  int drop_temporary_table(const identifier::Table&);
 
78
  bool rm_temporary_table(plugin::StorageEngine&, const identifier::Table&);
 
79
  bool rm_temporary_table(const identifier::Table &identifier, bool best_effort= false);
98
80
 
99
81
private:
100
82
  Table *derived_tables;
113
95
 
114
96
  void clearDerivedTables()
115
97
  {
116
 
    if (derived_tables)
117
 
      derived_tables= NULL; // They should all be invalid by this point
 
98
    derived_tables= NULL; // They should all be invalid by this point
118
99
  }
119
100
 
120
101
  /*
142
123
  uint64_t version;
143
124
  uint32_t current_tablenr;
144
125
 
145
 
  /*
146
 
    This constructor serves for creation of Open_tables_state instances
147
 
    which are used as backup storage.
148
 
  */
149
 
  Open_tables_state() :
150
 
    open_tables(0),
151
 
    temporary_tables(0),
152
 
    derived_tables(0),
153
 
    lock(0),
154
 
    extra_lock(0),
155
 
    version(0),
156
 
    current_tablenr(0)
157
 
  { }
158
 
  virtual ~Open_tables_state() {}
159
 
 
160
 
  void doGetTableNames(CachedDirectory &directory,
161
 
                       const identifier::Schema &schema_identifier,
162
 
                       std::set<std::string>& set_of_names);
163
 
  void doGetTableNames(const identifier::Schema &schema_identifier,
164
 
                       std::set<std::string>& set_of_names);
165
 
 
166
 
  void doGetTableIdentifiers(CachedDirectory &directory,
167
 
                             const identifier::Schema &schema_identifier,
168
 
                             identifier::Table::vector &set_of_identifiers);
169
 
  void doGetTableIdentifiers(const identifier::Schema &schema_identifier,
170
 
                             identifier::Table::vector &set_of_identifiers);
171
 
 
172
 
  int doGetTableDefinition(const drizzled::identifier::Table &identifier,
173
 
                           message::Table &table_proto);
174
 
  bool doDoesTableExist(const drizzled::identifier::Table &identifier);
175
 
 
176
 
 
177
 
  Open_tables_state(uint64_t version_arg);
 
126
  Open_tables_state(Session&, uint64_t version_arg);
 
127
  void doGetTableNames(CachedDirectory&, const identifier::Schema&, std::set<std::string>&);
 
128
  void doGetTableNames(const identifier::Schema&, std::set<std::string>&);
 
129
  void doGetTableIdentifiers(CachedDirectory&, const identifier::Schema&, identifier::table::vector&);
 
130
  void doGetTableIdentifiers(const identifier::Schema&, identifier::table::vector&);
 
131
  int doGetTableDefinition(const drizzled::identifier::Table&, message::Table&);
 
132
  bool doDoesTableExist(const drizzled::identifier::Table&);
 
133
private:
 
134
  Session& session_;
178
135
};
179
136
 
180
137
} /* namespace drizzled */
181
138
 
182
 
#endif /* DRIZZLED_OPEN_TABLES_STATE_H */