390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
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; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
20 |
||
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
21 |
|
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
22 |
#ifndef DRIZZLED_TABLE_LIST_H
|
23 |
#define DRIZZLED_TABLE_LIST_H
|
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
24 |
|
353
by Brian Aker
Moved Field iterator out to its own definition. |
25 |
/*
|
26 |
Table reference in the FROM clause.
|
|
27 |
||
28 |
These table references can be of several types that correspond to
|
|
29 |
different SQL elements. Below we list all types of TableLists with
|
|
30 |
the necessary conditions to determine when a TableList instance
|
|
31 |
belongs to a certain type.
|
|
32 |
||
33 |
1) table (TableList::view == NULL)
|
|
34 |
- base table
|
|
35 |
(TableList::derived == NULL)
|
|
36 |
- subquery - TableList::table is a temp table
|
|
37 |
(TableList::derived != NULL)
|
|
38 |
- information schema table
|
|
39 |
(TableList::schema_table != NULL)
|
|
40 |
NOTICE: for schema tables TableList::field_translation may be != NULL
|
|
769
by Brian Aker
Removing dead field translator code. |
41 |
2) Was VIEW
|
353
by Brian Aker
Moved Field iterator out to its own definition. |
42 |
3) nested table reference (TableList::nested_join != NULL)
|
43 |
- table sequence - e.g. (t1, t2, t3)
|
|
44 |
TODO: how to distinguish from a JOIN?
|
|
45 |
- general JOIN
|
|
46 |
TODO: how to distinguish from a table sequence?
|
|
47 |
- NATURAL JOIN
|
|
48 |
(TableList::natural_join != NULL)
|
|
49 |
- JOIN ... USING
|
|
50 |
(TableList::join_using_fields != NULL)
|
|
51 |
- semi-join
|
|
52 |
;
|
|
53 |
*/
|
|
54 |
||
55 |
||
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
56 |
#include <drizzled/table.h> |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
57 |
|
58 |
class Index_hint; |
|
59 |
class COND_EQUAL; |
|
60 |
class Natural_join_column; |
|
61 |
class select_union; |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
62 |
class Select_Lex_Unit; |
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
63 |
class InfoSchemaTable; |
846
by Brian Aker
Removing on typedeffed class. |
64 |
class Select_Lex; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
65 |
class Tmp_Table_Param; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
66 |
class Item_subselect; |
67 |
class Table; |
|
68 |
||
553.1.3
by Monty Taylor
Split out nested_join.h. |
69 |
struct nested_join_st; |
70 |
||
327.2.4
by Brian Aker
Refactoring table.h |
71 |
class TableList |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
72 |
{
|
73 |
public: |
|
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
74 |
TableList(): |
75 |
next_local(NULL), |
|
76 |
next_global(NULL), |
|
77 |
prev_global(NULL), |
|
78 |
db(NULL), |
|
79 |
alias(NULL), |
|
80 |
table_name(NULL), |
|
81 |
schema_table_name(NULL), |
|
82 |
option(NULL), |
|
83 |
on_expr(NULL), |
|
84 |
sj_on_expr(NULL), |
|
85 |
sj_inner_tables(0), |
|
86 |
sj_in_exprs(0), |
|
87 |
table_id(0), |
|
88 |
table(NULL), |
|
89 |
prep_on_expr(NULL), |
|
90 |
cond_equal(NULL), |
|
91 |
natural_join(NULL), |
|
92 |
is_natural_join(false), |
|
93 |
is_join_columns_complete(false), |
|
94 |
straight(false), |
|
95 |
updating(false), |
|
96 |
force_index(false), |
|
97 |
ignore_leaves(false), |
|
98 |
create(false), |
|
99 |
join_using_fields(NULL), |
|
100 |
join_columns(NULL), |
|
101 |
next_name_resolution_table(NULL), |
|
102 |
index_hints(NULL), |
|
103 |
derived_result(NULL), |
|
104 |
correspondent_table(NULL), |
|
105 |
derived(NULL), |
|
106 |
schema_table(NULL), |
|
107 |
schema_select_lex(NULL), |
|
108 |
schema_table_param(NULL), |
|
109 |
select_lex(NULL), |
|
110 |
next_leaf(NULL), |
|
111 |
// lock_type
|
|
112 |
outer_join(0), |
|
113 |
shared(0), |
|
114 |
i_s_requested_object(0), |
|
115 |
db_length(0), |
|
116 |
table_name_length(0), |
|
117 |
dep_tables(0), |
|
118 |
on_expr_dep_tables(0), |
|
119 |
nested_join(NULL), |
|
120 |
embedding(NULL), |
|
121 |
join_list(NULL), |
|
122 |
db_type(NULL), |
|
123 |
// timestamp_buffer[20];
|
|
124 |
lock_timeout(0), |
|
125 |
lock_transactional(false), |
|
126 |
internal_tmp_table(false), |
|
127 |
is_alias(false), |
|
128 |
is_fqtn(false), |
|
129 |
has_db_lookup_value(false), |
|
130 |
has_table_lookup_value(false), |
|
131 |
table_open_method(0) |
|
132 |
// schema_table_state(0)
|
|
133 |
{} /* Remove gcc warning */ |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
134 |
|
135 |
/*
|
|
136 |
List of tables local to a subquery (used by SQL_LIST). Considers
|
|
137 |
views as leaves (unlike 'next_leaf' below). Created at parse time
|
|
846
by Brian Aker
Removing on typedeffed class. |
138 |
in Select_Lex::add_table_to_list() -> table_list.link_in_list().
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
139 |
*/
|
327.2.4
by Brian Aker
Refactoring table.h |
140 |
TableList *next_local; |
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
141 |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
142 |
/* link in a global list of all queries tables */
|
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
143 |
TableList *next_global; |
144 |
TableList **prev_global; |
|
145 |
||
146 |
char *db; |
|
1039.1.4
by Brian Aker
Modified alias to being const. |
147 |
const char *alias; |
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
148 |
char *table_name; |
149 |
char *schema_table_name; |
|
150 |
char *option; /* Used by cache index */ |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
151 |
Item *on_expr; /* Used with outer join */ |
152 |
Item *sj_on_expr; |
|
153 |
/*
|
|
154 |
(Valid only for semi-join nests) Bitmap of tables that are within the
|
|
155 |
semi-join (this is different from bitmap of all nest's children because
|
|
156 |
tables that were pulled out of the semi-join nest remain listed as
|
|
157 |
nest's children).
|
|
158 |
*/
|
|
159 |
table_map sj_inner_tables; |
|
160 |
/* Number of IN-compared expressions */
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
161 |
uint32_t sj_in_exprs; |
1030.1.2
by Brian Aker
More alignment for structures |
162 |
uint32_t table_id; /* table id (from binlog) for opened table */ |
163 |
Table *table; /* opened table */ |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
164 |
/*
|
165 |
The structure of ON expression presented in the member above
|
|
166 |
can be changed during certain optimizations. This member
|
|
167 |
contains a snapshot of AND-OR structure of the ON expression
|
|
168 |
made after permanent transformations of the parse tree, and is
|
|
169 |
used to restore ON clause before every reexecution of a prepared
|
|
170 |
statement or stored procedure.
|
|
171 |
*/
|
|
172 |
Item *prep_on_expr; |
|
173 |
COND_EQUAL *cond_equal; /* Used with outer join */ |
|
174 |
/*
|
|
175 |
During parsing - left operand of NATURAL/USING join where 'this' is
|
|
176 |
the right operand. After parsing (this->natural_join == this) iff
|
|
177 |
'this' represents a NATURAL or USING join operation. Thus after
|
|
178 |
parsing 'this' is a NATURAL/USING join iff (natural_join != NULL).
|
|
179 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
180 |
TableList *natural_join; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
181 |
/*
|
182 |
True if 'this' represents a nested join that is a NATURAL JOIN.
|
|
183 |
For one of the operands of 'this', the member 'natural_join' points
|
|
184 |
to the other operand of 'this'.
|
|
185 |
*/
|
|
186 |
bool is_natural_join; |
|
1030.1.2
by Brian Aker
More alignment for structures |
187 |
|
188 |
/* true if join_columns contains all columns of this table reference. */
|
|
189 |
bool is_join_columns_complete; |
|
190 |
||
191 |
bool straight; /* optimize with prev table */ |
|
192 |
bool updating; /* for replicate-do/ignore table */ |
|
193 |
bool force_index; /* prefer index over table scan */ |
|
194 |
bool ignore_leaves; /* preload only non-leaf nodes */ |
|
195 |
||
196 |
/*
|
|
197 |
This TableList object corresponds to the table to be created
|
|
198 |
so it is possible that it does not exist (used in CREATE TABLE
|
|
199 |
... SELECT implementation).
|
|
200 |
*/
|
|
201 |
bool create; |
|
202 |
||
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
203 |
/* Field names in a USING clause for JOIN ... USING. */
|
204 |
List<String> *join_using_fields; |
|
205 |
/*
|
|
206 |
Explicitly store the result columns of either a NATURAL/USING join or
|
|
207 |
an operand of such a join.
|
|
208 |
*/
|
|
209 |
List<Natural_join_column> *join_columns; |
|
210 |
||
211 |
/*
|
|
212 |
List of nodes in a nested join tree, that should be considered as
|
|
213 |
leaves with respect to name resolution. The leaves are: views,
|
|
214 |
top-most nodes representing NATURAL/USING joins, subqueries, and
|
|
327.2.4
by Brian Aker
Refactoring table.h |
215 |
base tables. All of these TableList instances contain a
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
216 |
materialized list of columns. The list is local to a subquery.
|
217 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
218 |
TableList *next_name_resolution_table; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
219 |
/* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
|
220 |
List<Index_hint> *index_hints; |
|
221 |
/*
|
|
222 |
select_result for derived table to pass it from table creation to table
|
|
223 |
filling procedure
|
|
224 |
*/
|
|
225 |
select_union *derived_result; |
|
226 |
/*
|
|
227 |
Reference from aux_tables to local list entry of main select of
|
|
228 |
multi-delete statement:
|
|
229 |
delete t1 from t2,t1 where t1.a<'B' and t2.b=t1.b;
|
|
230 |
here it will be reference of first occurrence of t1 to second (as you
|
|
231 |
can see this lists can't be merged)
|
|
232 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
233 |
TableList *correspondent_table; |
848
by Brian Aker
typdef class removal (just... use the name of the class). |
234 |
Select_Lex_Unit *derived; /* Select_Lex_Unit of derived table */ |
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
235 |
InfoSchemaTable *schema_table; /* Information_schema table */ |
846
by Brian Aker
Removing on typedeffed class. |
236 |
Select_Lex *schema_select_lex; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
237 |
Tmp_Table_Param *schema_table_param; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
238 |
/* link to select_lex where this table was used */
|
846
by Brian Aker
Removing on typedeffed class. |
239 |
Select_Lex *select_lex; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
240 |
/*
|
241 |
List of all base tables local to a subquery including all view
|
|
242 |
tables. Unlike 'next_local', this in this list views are *not*
|
|
243 |
leaves. Created in setup_tables() -> make_leaves_list().
|
|
244 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
245 |
TableList *next_leaf; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
246 |
thr_lock_type lock_type; |
1030.1.2
by Brian Aker
More alignment for structures |
247 |
uint32_t outer_join; /* Which join type */ |
248 |
uint32_t shared; /* Used in multi-upd */ |
|
249 |
uint32_t i_s_requested_object; |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
250 |
size_t db_length; |
251 |
size_t table_name_length; |
|
252 |
table_map dep_tables; /* tables the table depends on */ |
|
253 |
table_map on_expr_dep_tables; /* tables on expression depends on */ |
|
327.2.4
by Brian Aker
Refactoring table.h |
254 |
nested_join_st *nested_join; /* if the element is a nested join */ |
255 |
TableList *embedding; /* nested join containing the table */ |
|
256 |
List<TableList> *join_list;/* join list the table belongs to */ |
|
960.2.24
by Monty Taylor
Changed handlerton to StorageEngine. |
257 |
StorageEngine *db_type; /* table_type for handler */ |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
258 |
char timestamp_buffer[20]; /* buffer for timestamp (19+1) */ |
259 |
/* For transactional locking. */
|
|
260 |
int lock_timeout; /* NOWAIT or WAIT [X] */ |
|
261 |
bool lock_transactional; /* If transactional lock requested. */ |
|
262 |
bool internal_tmp_table; |
|
263 |
/** true if an alias for this table was specified in the SQL. */
|
|
264 |
bool is_alias; |
|
265 |
/** true if the table is referred to in the statement using a fully
|
|
266 |
qualified name (<db_name>.<table_name>).
|
|
267 |
*/
|
|
268 |
bool is_fqtn; |
|
269 |
||
270 |
bool has_db_lookup_value; |
|
271 |
bool has_table_lookup_value; |
|
482
by Brian Aker
Remove uint. |
272 |
uint32_t table_open_method; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
273 |
enum enum_schema_table_state schema_table_state; |
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
274 |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
275 |
void set_underlying_merge(); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
276 |
bool setup_underlying(Session *session); |
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
277 |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
278 |
/*
|
279 |
If you change placeholder(), please check the condition in
|
|
280 |
check_transactional_lock() too.
|
|
281 |
*/
|
|
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
282 |
bool placeholder(); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
283 |
void print(Session *session, String *str, enum_query_type query_type); |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
284 |
bool set_insert_values(MEM_ROOT *mem_root); |
327.2.4
by Brian Aker
Refactoring table.h |
285 |
TableList *find_underlying_table(Table *table); |
286 |
TableList *first_leaf_for_name_resolution(); |
|
287 |
TableList *last_leaf_for_name_resolution(); |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
288 |
bool is_leaf_for_name_resolution(); |
327.2.4
by Brian Aker
Refactoring table.h |
289 |
inline TableList *top_table() |
327.1.7
by Brian Aker
Removed belong_to_view variable |
290 |
{ return this; } |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
291 |
|
292 |
Item_subselect *containing_subselect(); |
|
293 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
294 |
/*
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
295 |
Compiles the tagged hints list and fills up st_table::keys_in_use_for_query,
|
296 |
st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by,
|
|
297 |
st_table::force_index and st_table::covering_keys.
|
|
298 |
*/
|
|
299 |
bool process_index_hints(Table *table); |
|
300 |
};
|
|
520.6.7
by Monty Taylor
Moved a bunch of crap out of common_includes. |
301 |
|
302 |
void close_thread_tables(Session *session); |
|
303 |
||
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
304 |
#endif /* DRIZZLED_TABLE_LIST_H */ |