1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
22
#ifndef DRIZZLED_TABLE_LIST_H
23
#define DRIZZLED_TABLE_LIST_H
26
Table reference in the FROM clause.
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.
33
1) table (TableList::view == NULL)
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
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?
46
TODO: how to distinguish from a table sequence?
48
(TableList::natural_join != NULL)
50
(TableList::join_using_fields != NULL)
56
#include <drizzled/table.h>
60
class Natural_join_column;
62
class Select_Lex_Unit;
63
class InfoSchemaTable;
65
class Tmp_Table_Param;
69
struct nested_join_st;
81
schema_table_name(NULL),
92
is_natural_join(false),
93
is_join_columns_complete(false),
99
join_using_fields(NULL),
101
next_name_resolution_table(NULL),
103
derived_result(NULL),
104
correspondent_table(NULL),
107
schema_select_lex(NULL),
108
schema_table_param(NULL),
114
i_s_requested_object(0),
116
table_name_length(0),
118
on_expr_dep_tables(0),
123
// timestamp_buffer[20];
124
internal_tmp_table(false),
127
has_db_lookup_value(false),
128
has_table_lookup_value(false),
130
// schema_table_state(0)
131
{} /* Remove gcc warning */
134
List of tables local to a subquery (used by SQL_LIST). Considers
135
views as leaves (unlike 'next_leaf' below). Created at parse time
136
in Select_Lex::add_table_to_list() -> table_list.link_in_list().
138
TableList *next_local;
140
/* link in a global list of all queries tables */
141
TableList *next_global;
142
TableList **prev_global;
147
char *schema_table_name;
148
char *option; /* Used by cache index */
149
Item *on_expr; /* Used with outer join */
152
(Valid only for semi-join nests) Bitmap of tables that are within the
153
semi-join (this is different from bitmap of all nest's children because
154
tables that were pulled out of the semi-join nest remain listed as
157
table_map sj_inner_tables;
158
/* Number of IN-compared expressions */
159
uint32_t sj_in_exprs;
160
uint32_t table_id; /* table id (from binlog) for opened table */
161
Table *table; /* opened table */
163
The structure of ON expression presented in the member above
164
can be changed during certain optimizations. This member
165
contains a snapshot of AND-OR structure of the ON expression
166
made after permanent transformations of the parse tree, and is
167
used to restore ON clause before every reexecution of a prepared
168
statement or stored procedure.
171
COND_EQUAL *cond_equal; /* Used with outer join */
173
During parsing - left operand of NATURAL/USING join where 'this' is
174
the right operand. After parsing (this->natural_join == this) iff
175
'this' represents a NATURAL or USING join operation. Thus after
176
parsing 'this' is a NATURAL/USING join iff (natural_join != NULL).
178
TableList *natural_join;
180
True if 'this' represents a nested join that is a NATURAL JOIN.
181
For one of the operands of 'this', the member 'natural_join' points
182
to the other operand of 'this'.
184
bool is_natural_join;
186
/* true if join_columns contains all columns of this table reference. */
187
bool is_join_columns_complete;
189
bool straight; /* optimize with prev table */
190
bool updating; /* for replicate-do/ignore table */
191
bool force_index; /* prefer index over table scan */
192
bool ignore_leaves; /* preload only non-leaf nodes */
195
This TableList object corresponds to the table to be created
196
so it is possible that it does not exist (used in CREATE TABLE
197
... SELECT implementation).
201
/* Field names in a USING clause for JOIN ... USING. */
202
List<String> *join_using_fields;
204
Explicitly store the result columns of either a NATURAL/USING join or
205
an operand of such a join.
207
List<Natural_join_column> *join_columns;
210
List of nodes in a nested join tree, that should be considered as
211
leaves with respect to name resolution. The leaves are: views,
212
top-most nodes representing NATURAL/USING joins, subqueries, and
213
base tables. All of these TableList instances contain a
214
materialized list of columns. The list is local to a subquery.
216
TableList *next_name_resolution_table;
217
/* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
218
List<Index_hint> *index_hints;
220
select_result for derived table to pass it from table creation to table
223
select_union *derived_result;
225
Reference from aux_tables to local list entry of main select of
226
multi-delete statement:
227
delete t1 from t2,t1 where t1.a<'B' and t2.b=t1.b;
228
here it will be reference of first occurrence of t1 to second (as you
229
can see this lists can't be merged)
231
TableList *correspondent_table;
232
Select_Lex_Unit *derived; /* Select_Lex_Unit of derived table */
233
InfoSchemaTable *schema_table; /* Information_schema table */
234
Select_Lex *schema_select_lex;
235
Tmp_Table_Param *schema_table_param;
236
/* link to select_lex where this table was used */
237
Select_Lex *select_lex;
239
List of all base tables local to a subquery including all view
240
tables. Unlike 'next_local', this in this list views are *not*
241
leaves. Created in setup_tables() -> make_leaves_list().
243
TableList *next_leaf;
244
thr_lock_type lock_type;
245
uint32_t outer_join; /* Which join type */
246
uint32_t shared; /* Used in multi-upd */
247
uint32_t i_s_requested_object;
249
size_t table_name_length;
250
table_map dep_tables; /* tables the table depends on */
251
table_map on_expr_dep_tables; /* tables on expression depends on */
252
nested_join_st *nested_join; /* if the element is a nested join */
253
TableList *embedding; /* nested join containing the table */
254
List<TableList> *join_list;/* join list the table belongs to */
255
StorageEngine *db_type; /* table_type for handler */
256
char timestamp_buffer[20]; /* buffer for timestamp (19+1) */
257
bool internal_tmp_table;
258
/** true if an alias for this table was specified in the SQL. */
260
/** true if the table is referred to in the statement using a fully
261
qualified name (<db_name>.<table_name>).
265
bool has_db_lookup_value;
266
bool has_table_lookup_value;
267
uint32_t table_open_method;
268
enum enum_schema_table_state schema_table_state;
270
void set_underlying_merge();
271
bool setup_underlying(Session *session);
274
If you change placeholder(), please check the condition in
275
check_transactional_lock() too.
278
void print(Session *session, String *str, enum_query_type query_type);
279
bool set_insert_values(MEM_ROOT *mem_root);
280
TableList *find_underlying_table(Table *table);
281
TableList *first_leaf_for_name_resolution();
282
TableList *last_leaf_for_name_resolution();
283
bool is_leaf_for_name_resolution();
284
inline TableList *top_table()
287
Item_subselect *containing_subselect();
290
Compiles the tagged hints list and fills up st_table::keys_in_use_for_query,
291
st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by,
292
st_table::force_index and st_table::covering_keys.
294
bool process_index_hints(Table *table);
295
uint32_t create_table_def_key(char *key);
298
void close_thread_tables(Session *session);
300
#endif /* DRIZZLED_TABLE_LIST_H */