119
// timestamp_buffer[20];
114
120
internal_tmp_table(false),
123
has_db_lookup_value(false),
124
has_table_lookup_value(false),
126
// schema_table_state(0)
127
{} /* Remove gcc warning */
121
* List of tables local to a subquery (used by SQL_LIST). Considers
122
* views as leaves (unlike 'next_leaf' below). Created at parse time
123
* in Select_Lex::add_table_to_list() -> table_list.link_in_list().
130
List of tables local to a subquery (used by SQL_LIST). Considers
131
views as leaves (unlike 'next_leaf' below). Created at parse time
132
in Select_Lex::add_table_to_list() -> table_list.link_in_list().
125
134
TableList *next_local;
127
/** link in a global list of all queries tables */
136
/* link in a global list of all queries tables */
128
137
TableList *next_global;
129
138
TableList **prev_global;
135
const char *getSchemaName()
140
char **getSchemaNamePtr()
145
void setSchemaName(char *arg)
156
const char *getTableName()
161
char **getTableNamePtr()
166
void setTableName(char *arg)
171
char *option; ///< Used by cache index
172
Item *on_expr; ///< Used with outer join
173
Table *table; ///< opened table
175
* The structure of ON expression presented in the member above
176
* can be changed during certain optimizations. This member
177
* contains a snapshot of AND-OR structure of the ON expression
178
* made after permanent transformations of the parse tree, and is
179
* used to restore ON clause before every reexecution of a prepared
180
* statement or stored procedure.
183
COND_EQUAL *cond_equal; ///< Used with outer join
185
* During parsing - left operand of NATURAL/USING join where 'this' is
186
* the right operand. After parsing (this->natural_join == this) iff
187
* 'this' represents a NATURAL or USING join operation. Thus after
188
* parsing 'this' is a NATURAL/USING join iff (natural_join != NULL).
143
char *schema_table_name;
144
char *option; /* Used by cache index */
145
Item *on_expr; /* Used with outer join */
146
uint32_t table_id; /* table id (from binlog) for opened table */
147
Table *table; /* opened table */
149
The structure of ON expression presented in the member above
150
can be changed during certain optimizations. This member
151
contains a snapshot of AND-OR structure of the ON expression
152
made after permanent transformations of the parse tree, and is
153
used to restore ON clause before every reexecution of a prepared
154
statement or stored procedure.
157
COND_EQUAL *cond_equal; /* Used with outer join */
159
During parsing - left operand of NATURAL/USING join where 'this' is
160
the right operand. After parsing (this->natural_join == this) iff
161
'this' represents a NATURAL or USING join operation. Thus after
162
parsing 'this' is a NATURAL/USING join iff (natural_join != NULL).
190
164
TableList *natural_join;
192
* True if 'this' represents a nested join that is a NATURAL JOIN.
193
* For one of the operands of 'this', the member 'natural_join' points
194
* to the other operand of 'this'.
166
True if 'this' represents a nested join that is a NATURAL JOIN.
167
For one of the operands of 'this', the member 'natural_join' points
168
to the other operand of 'this'.
196
170
bool is_natural_join;
198
/** true if join_columns contains all columns of this table reference. */
172
/* true if join_columns contains all columns of this table reference. */
199
173
bool is_join_columns_complete;
201
bool straight; ///< optimize with prev table
202
bool force_index; ///< prefer index over table scan
203
bool ignore_leaves; ///< preload only non-leaf nodes
175
bool straight; /* optimize with prev table */
176
bool updating; /* for replicate-do/ignore table */
177
bool force_index; /* prefer index over table scan */
178
bool ignore_leaves; /* preload only non-leaf nodes */
206
is the table a cartesian join, assumption is yes unless "solved"
181
This TableList object corresponds to the table to be created
182
so it is possible that it does not exist (used in CREATE TABLE
183
... SELECT implementation).
208
bool isCartesian() const;
210
/** Field names in a USING clause for JOIN ... USING. */
187
/* Field names in a USING clause for JOIN ... USING. */
211
188
List<String> *join_using_fields;
213
* Explicitly store the result columns of either a NATURAL/USING join or
214
* an operand of such a join.
190
Explicitly store the result columns of either a NATURAL/USING join or
191
an operand of such a join.
216
193
List<Natural_join_column> *join_columns;
219
* List of nodes in a nested join tree, that should be considered as
220
* leaves with respect to name resolution. The leaves are: views,
221
* top-most nodes representing NATURAL/USING joins, subqueries, and
222
* base tables. All of these TableList instances contain a
223
* materialized list of columns. The list is local to a subquery.
196
List of nodes in a nested join tree, that should be considered as
197
leaves with respect to name resolution. The leaves are: views,
198
top-most nodes representing NATURAL/USING joins, subqueries, and
199
base tables. All of these TableList instances contain a
200
materialized list of columns. The list is local to a subquery.
225
202
TableList *next_name_resolution_table;
226
/** Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
203
/* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
227
204
List<Index_hint> *index_hints;
229
* select_result for derived table to pass it from table creation to table
232
select_union *derived_result;
233
Select_Lex_Unit *derived; ///< Select_Lex_Unit of derived table */
234
Select_Lex *schema_select_lex;
235
/** link to select_lex where this table was used */
236
Select_Lex *select_lex;
238
* List of all base tables local to a subquery including all view
239
* tables. Unlike 'next_local', this in this list views are *not*
240
* leaves. Created in setup_tables() -> make_leaves_list().
242
TableList *next_leaf;
206
select_result for derived table to pass it from table creation to table
209
select_union *derived_result;
210
Select_Lex_Unit *derived; /* Select_Lex_Unit of derived table */
211
InfoSchemaTable *schema_table; /* Information_schema table */
212
Select_Lex *schema_select_lex;
213
Tmp_Table_Param *schema_table_param;
214
/* link to select_lex where this table was used */
215
Select_Lex *select_lex;
217
List of all base tables local to a subquery including all view
218
tables. Unlike 'next_local', this in this list views are *not*
219
leaves. Created in setup_tables() -> make_leaves_list().
221
TableList *next_leaf;
243
222
thr_lock_type lock_type;
244
uint32_t outer_join; ///< Which join type
246
size_t table_name_length;
223
uint32_t outer_join; /* Which join type */
224
uint32_t shared; /* Used in multi-upd */
225
uint32_t i_s_requested_object;
227
size_t table_name_length;
228
table_map dep_tables; /* tables the table depends on */
229
table_map on_expr_dep_tables; /* tables on expression depends on */
230
nested_join_st *nested_join; /* if the element is a nested join */
231
TableList *embedding; /* nested join containing the table */
232
List<TableList> *join_list;/* join list the table belongs to */
233
StorageEngine *db_type; /* table_type for handler */
234
char timestamp_buffer[20]; /* buffer for timestamp (19+1) */
235
bool internal_tmp_table;
236
/** true if an alias for this table was specified in the SQL. */
238
/** true if the table is referred to in the statement using a fully
239
qualified name (<db_name>.<table_name>).
243
bool has_db_lookup_value;
244
bool has_table_lookup_value;
245
uint32_t table_open_method;
246
enum enum_schema_table_state schema_table_state;
248
248
void set_underlying_merge();
249
249
bool setup_underlying(Session *session);
252
* If you change placeholder(), please check the condition in
253
* check_transactional_lock() too.
252
If you change placeholder(), please check the condition in
253
check_transactional_lock() too.
255
255
bool placeholder();
257
* Print table as it should be in join list.
259
* @param str string where table should be printed
261
256
void print(Session *session, String *str, enum_query_type query_type);
263
* Sets insert_values buffer
265
* @param[in] memory pool for allocating
270
* true - out of memory
272
bool set_insert_values(memory::Root *mem_root);
274
* Find underlying base tables (TableList) which represent given
275
* table_to_find (Table)
277
* @param[in] table to find
280
* NULL if table is not found
282
* Pointer to found table reference
257
bool set_insert_values(MEM_ROOT *mem_root);
284
258
TableList *find_underlying_table(Table *table);
286
* Retrieve the first (left-most) leaf in a nested join tree with
287
* respect to name resolution.
291
* Given that 'this' is a nested table reference, recursively walk
292
* down the left-most children of 'this' until we reach a leaf
293
* table reference with respect to name resolution.
296
* If 'this' is a nested table reference - the left-most child of
297
* the tree rooted in 'this',
300
259
TableList *first_leaf_for_name_resolution();
302
* Retrieve the last (right-most) leaf in a nested join tree with
303
* respect to name resolution.
307
* Given that 'this' is a nested table reference, recursively walk
308
* down the right-most children of 'this' until we reach a leaf
309
* table reference with respect to name resolution.
312
* If 'this' is a nested table reference - the right-most child of
313
* the tree rooted in 'this',
316
260
TableList *last_leaf_for_name_resolution();
318
* Test if this is a leaf with respect to name resolution.
322
* A table reference is a leaf with respect to name resolution if
323
* it is either a leaf node in a nested join tree (table, view,
324
* schema table, subquery), or an inner node that represents a
325
* NATURAL/USING join, or a nested join with materialized join
329
* true if a leaf, false otherwise.
331
261
bool is_leaf_for_name_resolution();
332
262
inline TableList *top_table()
336
* Return subselect that contains the FROM list this table is taken from
339
* Subselect item for the subquery that contains the FROM list
340
* this table is taken from if there is any
344
265
Item_subselect *containing_subselect();
347
* Compiles the tagged hints list and fills up st_table::keys_in_use_for_query,
348
* st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by,
349
* st_table::force_index and st_table::covering_keys.
351
* @param the Table to operate on.
355
* The parser collects the index hints for each table in a "tagged list"
356
* (TableList::index_hints). Using the information in this tagged list
357
* this function sets the members Table::keys_in_use_for_query,
358
* Table::keys_in_use_for_group_by, Table::keys_in_use_for_order_by,
359
* Table::force_index and Table::covering_keys.
361
* Current implementation of the runtime does not allow mixing FORCE INDEX
362
* and USE INDEX, so this is checked here. Then the FORCE INDEX list
363
* (if non-empty) is appended to the USE INDEX list and a flag is set.
365
* Multiple hints of the same kind are processed so that each clause
366
* is applied to what is computed in the previous clause.
369
* USE INDEX (i1) USE INDEX (i2)
372
* and means "consider only i1 and i2".
375
* USE INDEX () USE INDEX (i1)
378
* and means "consider only the index i1"
380
* It is OK to have the same index several times, e.g. "USE INDEX (i1,i1)" is
383
* Different kind of hints (USE/FORCE/IGNORE) are processed in the following
385
* 1. All indexes in USE (or FORCE) INDEX are added to the mask.
386
* 2. All IGNORE INDEX
387
* e.g. "USE INDEX i1, IGNORE INDEX i1, USE INDEX i1" will not use i1 at all
388
* as if we had "USE INDEX i1, USE INDEX i1, IGNORE INDEX i1".
389
* As an optimization if there is a covering index, and we have
390
* IGNORE INDEX FOR GROUP/order_st, and this index is used for the JOIN part,
391
* then we have to ignore the IGNORE INDEX FROM GROUP/order_st.
394
* false no errors found
396
* true found and reported an error.
268
Compiles the tagged hints list and fills up st_table::keys_in_use_for_query,
269
st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by,
270
st_table::force_index and st_table::covering_keys.
398
272
bool process_index_hints(Table *table);
400
friend std::ostream& operator<<(std::ostream& output, const TableList &list)
402
output << "TableList:(";
405
output << list.table_name;
407
output << list.alias;
409
output << "is_natural_join:" << list.is_natural_join;
411
output << "is_join_columns_complete:" << list.is_join_columns_complete;
413
output << "straight:" << list.straight;
415
output << "force_index" << list.force_index;
417
output << "ignore_leaves:" << list.ignore_leaves;
419
output << "create:" << list.create;
421
output << "outer_join:" << list.outer_join;
423
output << "nested_join:" << list.nested_join;
426
return output; // for multiple << operators.
429
void setIsAlias(bool in_is_alias)
431
is_alias= in_is_alias;
434
void setIsFqtn(bool in_is_fqtn)
439
void setCreate(bool in_create)
444
void setInternalTmpTable(bool in_internal_tmp_table)
446
internal_tmp_table= in_internal_tmp_table;
449
void setDbType(plugin::StorageEngine *in_db_type)
454
void setJoinList(List<TableList> *in_join_list)
456
join_list= in_join_list;
459
void setEmbedding(TableList *in_embedding)
461
embedding= in_embedding;
464
void setNestedJoin(NestedJoin *in_nested_join)
466
nested_join= in_nested_join;
469
void setDepTables(table_map in_dep_tables)
471
dep_tables= in_dep_tables;
474
void setOnExprDepTables(table_map in_on_expr_dep_tables)
476
on_expr_dep_tables= in_on_expr_dep_tables;
479
bool getIsAlias() const
484
bool getIsFqtn() const
489
bool isCreate() const
494
bool getInternalTmpTable() const
496
return internal_tmp_table;
499
plugin::StorageEngine *getDbType() const
504
TableList *getEmbedding() const
509
List<TableList> *getJoinList() const
514
NestedJoin *getNestedJoin() const
519
table_map getDepTables() const
524
table_map getOnExprDepTables() const
526
return on_expr_dep_tables;
529
void unlock_table_name();
530
void unlock_table_names(TableList *last_table= NULL);
533
table_map dep_tables; ///< tables the table depends on
534
table_map on_expr_dep_tables; ///< tables on expression depends on
535
NestedJoin *nested_join; ///< if the element is a nested join
536
TableList *embedding; ///< nested join containing the table
537
List<TableList> *join_list; ///< join list the table belongs to
538
plugin::StorageEngine *db_type; ///< table_type for handler
539
bool internal_tmp_table;
541
/** true if an alias for this table was specified in the SQL. */
545
* true if the table is referred to in the statement using a fully
546
* qualified name (<db_name>.<table_name>).
551
* This TableList object corresponds to the table to be created
552
* so it is possible that it does not exist (used in CREATE TABLE
553
* ... SELECT implementation).
273
uint32_t create_table_def_key(char *key);
559
276
void close_thread_tables(Session *session);
561
} /* namespace drizzled */
563
278
#endif /* DRIZZLED_TABLE_LIST_H */