~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/open_tables_state.h

  • Committer: Monty Taylor
  • Date: 2010-03-25 22:03:21 UTC
  • mto: This revision was merged to the branch mainline in revision 1408.
  • Revision ID: mordred@inaugust.com-20100325220321-bf5vs8tryb4a8ssh
Updated the search for libmemcached.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
22
22
#define DRIZZLED_OPEN_TABLES_STATE_H
23
23
 
24
24
#include "drizzled/lock.h"
25
 
#include "drizzled/query_id.h"
26
25
 
27
26
namespace drizzled
28
27
{
29
28
 
30
 
class CachedDirectory;
31
 
 
32
29
/**
33
30
  Class that holds information about tables which were opened and locked
34
31
  by the thread. It is also used to save/restore this information in
43
40
    base tables that were opened with @see open_tables().
44
41
  */
45
42
  Table *open_tables;
46
 
 
47
43
  /**
48
44
    List of temporary tables used by this thread. Contains user-level
49
45
    temporary tables, created with CREATE TEMPORARY TABLE, and
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
 
  Table *getTemporaryTables()
60
 
  {
61
 
    return temporary_tables;
62
 
  }
63
 
 
64
 
  /**
65
 
    Mark all temporary tables which were used by the current statement or
66
 
    substatement as free for reuse, but only if the query_id can be cleared.
67
 
 
68
 
    @param session thread context
69
 
 
70
 
    @remark For temp tables associated with a open SQL HANDLER the query_id
71
 
            is not reset until the HANDLER is closed.
72
 
  */
73
 
  void mark_temp_tables_as_free_for_reuse();
74
 
 
75
 
protected:
76
 
  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:
87
 
  /* Work with temporary tables */
88
 
  Table *find_temporary_table(const identifier::Table &identifier);
89
 
 
90
 
  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;
98
 
 
99
 
private:
100
52
  Table *derived_tables;
101
 
public:
102
 
 
103
 
 
104
 
  Table *getDerivedTables()
105
 
  {
106
 
    return derived_tables;
107
 
  }
108
 
 
109
 
  void setDerivedTables(Table *arg)
110
 
  {
111
 
    derived_tables= arg;
112
 
  }
113
 
 
114
 
  void clearDerivedTables()
115
 
  {
116
 
    if (derived_tables)
117
 
      derived_tables= NULL; // They should all be invalid by this point
118
 
  }
119
 
 
120
53
  /*
121
54
    During a MySQL session, one can lock tables in two modes: automatic
122
55
    or manual. In automatic mode all necessary tables are locked just before
130
63
    the 'LOCK_TABLES' chapter of the MySQL manual.
131
64
    See also lock_tables() for details.
132
65
  */
133
 
  DrizzleLock *lock;
 
66
  DRIZZLE_LOCK *lock;
134
67
 
135
68
  /*
136
69
    CREATE-SELECT keeps an extra lock for the table being
137
70
    created. This field is used to keep the extra lock available for
138
71
    lower level routines, which would otherwise miss that lock.
139
72
   */
140
 
  DrizzleLock *extra_lock;
 
73
  DRIZZLE_LOCK *extra_lock;
141
74
 
142
75
  uint64_t version;
143
76
  uint32_t current_tablenr;
144
77
 
145
78
  /*
 
79
    Flags with information about the open tables state.
 
80
  */
 
81
  bool backups_available;
 
82
 
 
83
  /*
146
84
    This constructor serves for creation of Open_tables_state instances
147
85
    which are used as backup storage.
148
86
  */
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
 
  { }
 
87
  Open_tables_state() : backups_available(false) { }
158
88
  virtual ~Open_tables_state() {}
159
89
 
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
90
  Open_tables_state(uint64_t version_arg);
 
91
 
 
92
  void set_open_tables_state(Open_tables_state *state)
 
93
  {
 
94
    *this= *state;
 
95
  }
 
96
 
 
97
  void reset_open_tables_state()
 
98
  {
 
99
    open_tables= temporary_tables= derived_tables= NULL;
 
100
    extra_lock= lock= NULL;
 
101
    backups_available= false;
 
102
  }
178
103
};
179
104
 
180
105
} /* namespace drizzled */