851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
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 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
21 |
#pragma once
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
22 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
23 |
#include <drizzled/lock.h> |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
24 |
|
2239.1.3
by Olaf van der Spek
Refactor includes |
25 |
namespace drizzled { |
26 |
||
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
27 |
/**
|
28 |
Class that holds information about tables which were opened and locked
|
|
29 |
by the thread. It is also used to save/restore this information in
|
|
30 |
push_open_tables_state()/pop_open_tables_state().
|
|
31 |
*/
|
|
32 |
||
33 |
class Open_tables_state |
|
34 |
{
|
|
35 |
public: |
|
36 |
/**
|
|
37 |
List of regular tables in use by this thread. Contains temporary and
|
|
38 |
base tables that were opened with @see open_tables().
|
|
39 |
*/
|
|
40 |
Table *open_tables; |
|
1877.2.16
by Brian Aker
Fix dangling headers. |
41 |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
42 |
/**
|
43 |
List of temporary tables used by this thread. Contains user-level
|
|
44 |
temporary tables, created with CREATE TEMPORARY TABLE, and
|
|
45 |
internal temporary tables, created, e.g., to resolve a SELECT,
|
|
46 |
or for an intermediate table used in ALTER.
|
|
47 |
XXX Why are internal temporary tables added to this list?
|
|
48 |
*/
|
|
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
49 |
private: |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
50 |
Table *temporary_tables; |
2041.3.2
by Brian Aker
Improve on drop schema temp tables. |
51 |
|
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
52 |
public: |
53 |
||
54 |
Table *getTemporaryTables() |
|
55 |
{
|
|
56 |
return temporary_tables; |
|
57 |
}
|
|
1046.1.6
by Brian Aker
Formatting/style cleanup. |
58 |
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
59 |
/**
|
60 |
Mark all temporary tables which were used by the current statement or
|
|
61 |
substatement as free for reuse, but only if the query_id can be cleared.
|
|
62 |
||
63 |
@param session thread context
|
|
64 |
||
65 |
@remark For temp tables associated with a open SQL HANDLER the query_id
|
|
66 |
is not reset until the HANDLER is closed.
|
|
67 |
*/
|
|
68 |
void mark_temp_tables_as_free_for_reuse(); |
|
69 |
||
70 |
protected: |
|
71 |
void close_temporary_tables(); |
|
2041.3.2
by Brian Aker
Improve on drop schema temp tables. |
72 |
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
73 |
public: |
74 |
void close_temporary_table(Table *table); |
|
2041.3.2
by Brian Aker
Improve on drop schema temp tables. |
75 |
|
76 |
private: |
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
77 |
// The method below just handles the de-allocation of the table. In
|
78 |
// a better memory type world, this would not be needed.
|
|
79 |
void nukeTable(Table *table); |
|
2041.3.2
by Brian Aker
Improve on drop schema temp tables. |
80 |
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
81 |
public: |
82 |
/* Work with temporary tables */
|
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
83 |
Table *find_temporary_table(const identifier::Table &identifier); |
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
84 |
|
85 |
void dumpTemporaryTableNames(const char *id); |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
86 |
int drop_temporary_table(const drizzled::identifier::Table &identifier); |
2246.4.3
by Olaf van der Spek
Refactor Session |
87 |
bool rm_temporary_table(plugin::StorageEngine&, const identifier::Table&); |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
88 |
bool rm_temporary_table(const drizzled::identifier::Table &identifier, bool best_effort= false); |
89 |
Table *open_temporary_table(const drizzled::identifier::Table &identifier, |
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
90 |
bool link_in_list= true); |
91 |
||
92 |
virtual query_id_t getQueryId() const= 0; |
|
93 |
||
1923.1.3
by Brian Aker
Encapsulate derived tables |
94 |
private: |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
95 |
Table *derived_tables; |
1923.1.3
by Brian Aker
Encapsulate derived tables |
96 |
public: |
97 |
||
98 |
||
99 |
Table *getDerivedTables() |
|
100 |
{
|
|
101 |
return derived_tables; |
|
102 |
}
|
|
103 |
||
104 |
void setDerivedTables(Table *arg) |
|
105 |
{
|
|
106 |
derived_tables= arg; |
|
107 |
}
|
|
108 |
||
109 |
void clearDerivedTables() |
|
110 |
{
|
|
111 |
if (derived_tables) |
|
112 |
derived_tables= NULL; // They should all be invalid by this point |
|
113 |
}
|
|
114 |
||
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
115 |
/*
|
116 |
During a MySQL session, one can lock tables in two modes: automatic
|
|
117 |
or manual. In automatic mode all necessary tables are locked just before
|
|
118 |
statement execution, and all acquired locks are stored in 'lock'
|
|
119 |
member. Unlocking takes place automatically as well, when the
|
|
120 |
statement ends.
|
|
121 |
Manual mode comes into play when a user issues a 'LOCK TABLES'
|
|
122 |
statement. In this mode the user can only use the locked tables.
|
|
123 |
Trying to use any other tables will give an error. The locked tables are
|
|
124 |
stored in 'locked_tables' member. Manual locking is described in
|
|
125 |
the 'LOCK_TABLES' chapter of the MySQL manual.
|
|
126 |
See also lock_tables() for details.
|
|
127 |
*/
|
|
1711.6.1
by Brian Aker
Style on structure cleanup |
128 |
DrizzleLock *lock; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
129 |
|
130 |
/*
|
|
131 |
CREATE-SELECT keeps an extra lock for the table being
|
|
132 |
created. This field is used to keep the extra lock available for
|
|
133 |
lower level routines, which would otherwise miss that lock.
|
|
134 |
*/
|
|
1711.6.1
by Brian Aker
Style on structure cleanup |
135 |
DrizzleLock *extra_lock; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
136 |
|
1223.2.1
by Trond Norbye
Bug #485658: Compile failure on 32 bit system due to mixing ulong, uint64_t and uint32_t |
137 |
uint64_t version; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
138 |
uint32_t current_tablenr; |
139 |
||
140 |
/*
|
|
141 |
This constructor serves for creation of Open_tables_state instances
|
|
142 |
which are used as backup storage.
|
|
143 |
*/
|
|
1889.1.4
by Brian Aker
C++ warning fixes. |
144 |
Open_tables_state() : |
145 |
open_tables(0), |
|
146 |
temporary_tables(0), |
|
147 |
derived_tables(0), |
|
148 |
lock(0), |
|
149 |
extra_lock(0), |
|
150 |
version(0), |
|
151 |
current_tablenr(0) |
|
152 |
{ } |
|
1240.9.4
by Monty Taylor
destructor for base class "Open_tables_state" (declared at line 31 of "../drizzled/open_tables_state.h") is not virtual |
153 |
virtual ~Open_tables_state() {} |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
154 |
|
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
155 |
void doGetTableNames(CachedDirectory &directory, |
2087.4.1
by Brian Aker
Merge in schema identifier. |
156 |
const identifier::Schema &schema_identifier, |
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
157 |
std::set<std::string>& set_of_names); |
2087.4.1
by Brian Aker
Merge in schema identifier. |
158 |
void doGetTableNames(const identifier::Schema &schema_identifier, |
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
159 |
std::set<std::string>& set_of_names); |
160 |
||
161 |
void doGetTableIdentifiers(CachedDirectory &directory, |
|
2087.4.1
by Brian Aker
Merge in schema identifier. |
162 |
const identifier::Schema &schema_identifier, |
2252.1.9
by Olaf van der Spek
Common fwd |
163 |
identifier::table::vector &set_of_identifiers); |
2087.4.1
by Brian Aker
Merge in schema identifier. |
164 |
void doGetTableIdentifiers(const identifier::Schema &schema_identifier, |
2252.1.9
by Olaf van der Spek
Common fwd |
165 |
identifier::table::vector &set_of_identifiers); |
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
166 |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
167 |
int doGetTableDefinition(const drizzled::identifier::Table &identifier, |
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
168 |
message::Table &table_proto); |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
169 |
bool doDoesTableExist(const drizzled::identifier::Table &identifier); |
1923.1.2
by Brian Aker
Encapsulate temporary tables. |
170 |
|
171 |
||
1223.2.1
by Trond Norbye
Bug #485658: Compile failure on 32 bit system due to mixing ulong, uint64_t and uint32_t |
172 |
Open_tables_state(uint64_t version_arg); |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
173 |
};
|
174 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
175 |
} /* namespace drizzled */ |
176 |