~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/open_tables_state.h

  • Committer: Brian Aker
  • Date: 2010-02-07 01:33:54 UTC
  • Revision ID: brian@gaz-20100207013354-d2pg1n68u5c09pgo
Remove giant include header to its own file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
 
 
21
#ifndef DRIZZLED_OPEN_TABLES_STATE_H
 
22
#define DRIZZLED_OPEN_TABLES_STATE_H
 
23
 
 
24
#include "drizzled/lock.h"
 
25
 
 
26
namespace drizzled
 
27
{
 
28
 
 
29
/**
 
30
  Class that holds information about tables which were opened and locked
 
31
  by the thread. It is also used to save/restore this information in
 
32
  push_open_tables_state()/pop_open_tables_state().
 
33
*/
 
34
 
 
35
class Open_tables_state
 
36
{
 
37
public:
 
38
  /**
 
39
    List of regular tables in use by this thread. Contains temporary and
 
40
    base tables that were opened with @see open_tables().
 
41
  */
 
42
  Table *open_tables;
 
43
  /**
 
44
    List of temporary tables used by this thread. Contains user-level
 
45
    temporary tables, created with CREATE TEMPORARY TABLE, and
 
46
    internal temporary tables, created, e.g., to resolve a SELECT,
 
47
    or for an intermediate table used in ALTER.
 
48
    XXX Why are internal temporary tables added to this list?
 
49
  */
 
50
  Table *temporary_tables;
 
51
 
 
52
  Table *derived_tables;
 
53
  /*
 
54
    During a MySQL session, one can lock tables in two modes: automatic
 
55
    or manual. In automatic mode all necessary tables are locked just before
 
56
    statement execution, and all acquired locks are stored in 'lock'
 
57
    member. Unlocking takes place automatically as well, when the
 
58
    statement ends.
 
59
    Manual mode comes into play when a user issues a 'LOCK TABLES'
 
60
    statement. In this mode the user can only use the locked tables.
 
61
    Trying to use any other tables will give an error. The locked tables are
 
62
    stored in 'locked_tables' member.  Manual locking is described in
 
63
    the 'LOCK_TABLES' chapter of the MySQL manual.
 
64
    See also lock_tables() for details.
 
65
  */
 
66
  DRIZZLE_LOCK *lock;
 
67
 
 
68
  /*
 
69
    CREATE-SELECT keeps an extra lock for the table being
 
70
    created. This field is used to keep the extra lock available for
 
71
    lower level routines, which would otherwise miss that lock.
 
72
   */
 
73
  DRIZZLE_LOCK *extra_lock;
 
74
 
 
75
  uint64_t version;
 
76
  uint32_t current_tablenr;
 
77
 
 
78
  /*
 
79
    Flags with information about the open tables state.
 
80
  */
 
81
  bool backups_available;
 
82
 
 
83
  /*
 
84
    This constructor serves for creation of Open_tables_state instances
 
85
    which are used as backup storage.
 
86
  */
 
87
  Open_tables_state() : backups_available(false) { }
 
88
  virtual ~Open_tables_state() {}
 
89
 
 
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
  }
 
103
};
 
104
 
 
105
} /* namespace drizzled */
 
106
 
 
107
#endif /* DRIZZLED_OPEN_TABLES_STATE_H */