123
// timestamp_buffer[20];
115
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 */
122
* List of tables local to a subquery (used by SQL_LIST). Considers
123
* views as leaves (unlike 'next_leaf' below). Created at parse time
124
* in Select_Lex::add_table_to_list() -> table_list.link_in_list().
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().
126
138
TableList *next_local;
128
/** link in a global list of all queries tables */
140
/* link in a global list of all queries tables */
129
141
TableList *next_global;
130
142
TableList **prev_global;
136
const char *getSchemaName()
141
char **getSchemaNamePtr()
146
void setSchemaName(char *arg)
157
const char *getTableName()
162
char **getTableNamePtr()
167
void setTableName(char *arg)
172
char *option; ///< Used by cache index
173
Item *on_expr; ///< Used with outer join
174
Table *table; ///< opened table
176
* The structure of ON expression presented in the member above
177
* can be changed during certain optimizations. This member
178
* contains a snapshot of AND-OR structure of the ON expression
179
* made after permanent transformations of the parse tree, and is
180
* used to restore ON clause before every reexecution of a prepared
181
* statement or stored procedure.
184
COND_EQUAL *cond_equal; ///< Used with outer join
186
* During parsing - left operand of NATURAL/USING join where 'this' is
187
* the right operand. After parsing (this->natural_join == this) iff
188
* 'this' represents a NATURAL or USING join operation. Thus after
189
* parsing 'this' is a NATURAL/USING join iff (natural_join != NULL).
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).
191
178
TableList *natural_join;
193
* True if 'this' represents a nested join that is a NATURAL JOIN.
194
* For one of the operands of 'this', the member 'natural_join' points
195
* to the other operand of 'this'.
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'.
197
184
bool is_natural_join;
199
/** true if join_columns contains all columns of this table reference. */
186
/* true if join_columns contains all columns of this table reference. */
200
187
bool is_join_columns_complete;
202
bool straight; ///< optimize with prev table
203
bool force_index; ///< prefer index over table scan
204
bool ignore_leaves; ///< preload only non-leaf nodes
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 */
207
is the table a cartesian join, assumption is yes unless "solved"
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).
209
bool isCartesian() const;
211
/** Field names in a USING clause for JOIN ... USING. */
201
/* Field names in a USING clause for JOIN ... USING. */
212
202
List<String> *join_using_fields;
214
* Explicitly store the result columns of either a NATURAL/USING join or
215
* an operand of such a join.
204
Explicitly store the result columns of either a NATURAL/USING join or
205
an operand of such a join.
217
207
List<Natural_join_column> *join_columns;
220
* List of nodes in a nested join tree, that should be considered as
221
* leaves with respect to name resolution. The leaves are: views,
222
* top-most nodes representing NATURAL/USING joins, subqueries, and
223
* base tables. All of these TableList instances contain a
224
* materialized list of columns. The list is local to a subquery.
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.
226
216
TableList *next_name_resolution_table;
227
/** Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
217
/* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
228
218
List<Index_hint> *index_hints;
230
* select_result for derived table to pass it from table creation to table
233
select_union *derived_result;
234
Select_Lex_Unit *derived; ///< Select_Lex_Unit of derived table */
235
Select_Lex *schema_select_lex;
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;
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
244
thr_lock_type lock_type;
245
uint32_t outer_join; ///< Which join type
247
size_t table_name_length;
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;
249
270
void set_underlying_merge();
250
271
bool setup_underlying(Session *session);
253
* If you change placeholder(), please check the condition in
254
* check_transactional_lock() too.
274
If you change placeholder(), please check the condition in
275
check_transactional_lock() too.
256
277
bool placeholder();
258
* Print table as it should be in join list.
260
* @param str string where table should be printed
262
278
void print(Session *session, String *str, enum_query_type query_type);
264
* Sets insert_values buffer
266
* @param[in] memory pool for allocating
271
* true - out of memory
273
bool set_insert_values(memory::Root *mem_root);
275
* Find underlying base tables (TableList) which represent given
276
* table_to_find (Table)
278
* @param[in] table to find
281
* NULL if table is not found
283
* Pointer to found table reference
279
bool set_insert_values(MEM_ROOT *mem_root);
285
280
TableList *find_underlying_table(Table *table);
287
* Retrieve the first (left-most) leaf in a nested join tree with
288
* respect to name resolution.
292
* Given that 'this' is a nested table reference, recursively walk
293
* down the left-most children of 'this' until we reach a leaf
294
* table reference with respect to name resolution.
297
* If 'this' is a nested table reference - the left-most child of
298
* the tree rooted in 'this',
301
281
TableList *first_leaf_for_name_resolution();
303
* Retrieve the last (right-most) leaf in a nested join tree with
304
* respect to name resolution.
308
* Given that 'this' is a nested table reference, recursively walk
309
* down the right-most children of 'this' until we reach a leaf
310
* table reference with respect to name resolution.
313
* If 'this' is a nested table reference - the right-most child of
314
* the tree rooted in 'this',
317
282
TableList *last_leaf_for_name_resolution();
319
* Test if this is a leaf with respect to name resolution.
323
* A table reference is a leaf with respect to name resolution if
324
* it is either a leaf node in a nested join tree (table, view,
325
* schema table, subquery), or an inner node that represents a
326
* NATURAL/USING join, or a nested join with materialized join
330
* true if a leaf, false otherwise.
332
283
bool is_leaf_for_name_resolution();
333
284
inline TableList *top_table()
337
* Return subselect that contains the FROM list this table is taken from
340
* Subselect item for the subquery that contains the FROM list
341
* this table is taken from if there is any
345
287
Item_subselect *containing_subselect();
348
* Compiles the tagged hints list and fills up st_table::keys_in_use_for_query,
349
* st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by,
350
* st_table::force_index and st_table::covering_keys.
352
* @param the Table to operate on.
356
* The parser collects the index hints for each table in a "tagged list"
357
* (TableList::index_hints). Using the information in this tagged list
358
* this function sets the members Table::keys_in_use_for_query,
359
* Table::keys_in_use_for_group_by, Table::keys_in_use_for_order_by,
360
* Table::force_index and Table::covering_keys.
362
* Current implementation of the runtime does not allow mixing FORCE INDEX
363
* and USE INDEX, so this is checked here. Then the FORCE INDEX list
364
* (if non-empty) is appended to the USE INDEX list and a flag is set.
366
* Multiple hints of the same kind are processed so that each clause
367
* is applied to what is computed in the previous clause.
370
* USE INDEX (i1) USE INDEX (i2)
373
* and means "consider only i1 and i2".
376
* USE INDEX () USE INDEX (i1)
379
* and means "consider only the index i1"
381
* It is OK to have the same index several times, e.g. "USE INDEX (i1,i1)" is
384
* Different kind of hints (USE/FORCE/IGNORE) are processed in the following
386
* 1. All indexes in USE (or FORCE) INDEX are added to the mask.
387
* 2. All IGNORE INDEX
388
* e.g. "USE INDEX i1, IGNORE INDEX i1, USE INDEX i1" will not use i1 at all
389
* as if we had "USE INDEX i1, USE INDEX i1, IGNORE INDEX i1".
390
* As an optimization if there is a covering index, and we have
391
* IGNORE INDEX FOR GROUP/order_st, and this index is used for the JOIN part,
392
* then we have to ignore the IGNORE INDEX FROM GROUP/order_st.
395
* false no errors found
397
* true found and reported an error.
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.
399
294
bool process_index_hints(Table *table);
401
friend std::ostream& operator<<(std::ostream& output, const TableList &list)
403
output << "TableList:(";
406
output << list.table_name;
408
output << list.alias;
410
output << "is_natural_join:" << list.is_natural_join;
412
output << "is_join_columns_complete:" << list.is_join_columns_complete;
414
output << "straight:" << list.straight;
416
output << "force_index" << list.force_index;
418
output << "ignore_leaves:" << list.ignore_leaves;
420
output << "create:" << list.create;
422
output << "outer_join:" << list.outer_join;
424
output << "nested_join:" << list.nested_join;
427
return output; // for multiple << operators.
430
void setIsAlias(bool in_is_alias)
432
is_alias= in_is_alias;
435
void setIsFqtn(bool in_is_fqtn)
440
void setCreate(bool in_create)
445
void setInternalTmpTable(bool in_internal_tmp_table)
447
internal_tmp_table= in_internal_tmp_table;
450
void setDbType(plugin::StorageEngine *in_db_type)
455
void setJoinList(List<TableList> *in_join_list)
457
join_list= in_join_list;
460
void setEmbedding(TableList *in_embedding)
462
embedding= in_embedding;
465
void setNestedJoin(nested_join_st *in_nested_join)
467
nested_join= in_nested_join;
470
void setDepTables(table_map in_dep_tables)
472
dep_tables= in_dep_tables;
475
void setOnExprDepTables(table_map in_on_expr_dep_tables)
477
on_expr_dep_tables= in_on_expr_dep_tables;
480
bool getIsAlias() const
485
bool getIsFqtn() const
490
bool isCreate() const
495
bool getInternalTmpTable() const
497
return internal_tmp_table;
500
plugin::StorageEngine *getDbType() const
505
TableList *getEmbedding() const
510
List<TableList> *getJoinList() const
515
nested_join_st *getNestedJoin() const
520
table_map getDepTables() const
525
table_map getOnExprDepTables() const
527
return on_expr_dep_tables;
530
void unlock_table_name();
531
void unlock_table_names(TableList *last_table= NULL);
535
table_map dep_tables; ///< tables the table depends on
536
table_map on_expr_dep_tables; ///< tables on expression depends on
537
nested_join_st *nested_join; ///< if the element is a nested join
538
TableList *embedding; ///< nested join containing the table
539
List<TableList> *join_list; ///< join list the table belongs to
540
plugin::StorageEngine *db_type; ///< table_type for handler
541
char timestamp_buffer[20]; ///< buffer for timestamp (19+1)
542
bool internal_tmp_table;
543
/** true if an alias for this table was specified in the SQL. */
547
* true if the table is referred to in the statement using a fully
548
* qualified name (<db_name>.<table_name>).
552
* This TableList object corresponds to the table to be created
553
* so it is possible that it does not exist (used in CREATE TABLE
554
* ... SELECT implementation).
295
uint32_t create_table_def_key(char *key);
560
298
void close_thread_tables(Session *session);
562
} /* namespace drizzled */
564
300
#endif /* DRIZZLED_TABLE_LIST_H */