drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
table_list.h
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, Inc.
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
21#pragma once
22
23#include <drizzled/nested_join.h>
24#include <drizzled/table.h>
25
26namespace drizzled {
27
58class TableList
59{
60public:
61 TableList():
62 next_local(NULL),
63 next_global(NULL),
64 prev_global(NULL),
65 schema(NULL),
66 alias(NULL),
67 table_name(NULL),
68 option(NULL),
69 on_expr(NULL),
70 table(NULL),
71 prep_on_expr(NULL),
72 cond_equal(NULL),
73 natural_join(NULL),
74 is_natural_join(false),
76 straight(false),
77 force_index(false),
78 ignore_leaves(false),
80 join_columns(NULL),
82 index_hints(NULL),
83 derived_result(NULL),
84 derived(NULL),
85 schema_select_lex(NULL),
86 select_lex(NULL),
87 next_leaf(NULL),
88 outer_join(0),
89 dep_tables(0),
91 nested_join(NULL),
92 embedding(NULL),
93 join_list(NULL),
94 db_type(NULL),
95 internal_tmp_table(false),
96 is_alias(false),
97 is_fqtn(false),
98 create(false)
99 {
100 }
101
107 TableList *next_local;
108
110 TableList *next_global;
111 TableList **prev_global;
112
113private:
114 const char* schema;
115
116public:
117 const char *getSchemaName() const
118 {
119 return schema;
120 }
121
122 void setSchemaName(const char* v)
123 {
124 schema= v;
125 }
126
127 const char *alias;
128
129private:
130 const char* table_name;
131
132public:
133 const char *getTableName() const
134 {
135 return table_name;
136 }
137
138 void setTableName(const char* v)
139 {
140 table_name= v;
141 }
142
143 const char *option;
162 TableList *natural_join;
169
172
173 bool straight;
176
177 /*
178 is the table a cartesian join, assumption is yes unless "solved"
179 */
180 bool isCartesian() const;
181
189
205 Select_Lex_Unit *derived;
206 Select_Lex *schema_select_lex;
208 Select_Lex *select_lex;
214 TableList *next_leaf;
215 thr_lock_type lock_type;
216 uint32_t outer_join;
217
218 void set_underlying_merge();
219 bool setup_underlying(Session *session);
220
225 bool placeholder();
231 void print(Session *session, String *str);
242 void set_insert_values();
254 TableList *find_underlying_table(Table *table);
301 bool is_leaf_for_name_resolution() const;
302 inline TableList *top_table()
303 { return this; }
304
315
368 bool process_index_hints(Table *table);
369
370 friend std::ostream& operator<<(std::ostream& output, const TableList &list)
371 {
372 output << "TableList:(";
373 output << list.getSchemaName();
374 output << ", ";
375 output << list.getTableName();
376 output << ", ";
377 output << list.alias;
378 output << ", ";
379 output << "is_natural_join:" << list.is_natural_join;
380 output << ", ";
381 output << "is_join_columns_complete:" << list.is_join_columns_complete;
382 output << ", ";
383 output << "straight:" << list.straight;
384 output << ", ";
385 output << "force_index" << list.force_index;
386 output << ", ";
387 output << "ignore_leaves:" << list.ignore_leaves;
388 output << ", ";
389 output << "create:" << list.create;
390 output << ", ";
391 output << "outer_join:" << list.outer_join;
392 output << ", ";
393 output << "nested_join:" << list.nested_join;
394 output << ")";
395
396 return output; // for multiple << operators.
397 }
398
399 void setIsAlias(bool in_is_alias)
400 {
401 is_alias= in_is_alias;
402 }
403
404 void setIsFqtn(bool in_is_fqtn)
405 {
406 is_fqtn= in_is_fqtn;
407 }
408
409 void setCreate(bool in_create)
410 {
411 create= in_create;
412 }
413
414 void setInternalTmpTable(bool in_internal_tmp_table)
415 {
416 internal_tmp_table= in_internal_tmp_table;
417 }
418
419 void setDbType(plugin::StorageEngine *in_db_type)
420 {
421 db_type= in_db_type;
422 }
423
424 void setJoinList(List<TableList> *in_join_list)
425 {
426 join_list= in_join_list;
427 }
428
429 void setEmbedding(TableList *in_embedding)
430 {
431 embedding= in_embedding;
432 }
433
434 void setNestedJoin(NestedJoin *in_nested_join)
435 {
436 nested_join= in_nested_join;
437 }
438
439 void setDepTables(table_map in_dep_tables)
440 {
441 dep_tables= in_dep_tables;
442 }
443
444 void setOnExprDepTables(table_map in_on_expr_dep_tables)
445 {
446 on_expr_dep_tables= in_on_expr_dep_tables;
447 }
448
449 bool getIsAlias() const
450 {
451 return is_alias;
452 }
453
454 bool getIsFqtn() const
455 {
456 return is_fqtn;
457 }
458
459 bool isCreate() const
460 {
461 return create;
462 }
463
464 bool getInternalTmpTable() const
465 {
466 return internal_tmp_table;
467 }
468
469 plugin::StorageEngine *getDbType() const
470 {
471 return db_type;
472 }
473
474 TableList *getEmbedding() const
475 {
476 return embedding;
477 }
478
479 List<TableList> *getJoinList() const
480 {
481 return join_list;
482 }
483
484 NestedJoin *getNestedJoin() const
485 {
486 return nested_join;
487 }
488
489 table_map getDepTables() const
490 {
491 return dep_tables;
492 }
493
494 table_map getOnExprDepTables() const
495 {
496 return on_expr_dep_tables;
497 }
498
499 void unlock_table_name();
500 void unlock_table_names(TableList *last_table= NULL);
501
502private:
503 table_map dep_tables;
506 TableList *embedding;
509 bool internal_tmp_table;
510
513
519
525 bool create;
526
527};
528
529void close_thread_tables(Session *session);
530
531} /* namespace drizzled */
532
List< Natural_join_column > * join_columns
Definition table_list.h:188
table_map dep_tables
tables the table depends on
Definition table_list.h:503
TableList * next_global
Definition table_list.h:110
TableList * last_leaf_for_name_resolution()
Definition table_list.cc:69
bool process_index_hints(Table *table)
TableList * natural_join
Definition table_list.h:162
TableList * next_leaf
Definition table_list.h:214
bool ignore_leaves
preload only non-leaf nodes
Definition table_list.h:175
bool force_index
prefer index over table scan
Definition table_list.h:174
Item_subselect * containing_subselect()
void print(Session *session, String *str)
TableList * embedding
nested join containing the table
Definition table_list.h:506
uint32_t outer_join
Which join type.
Definition table_list.h:216
TableList * next_local
Definition table_list.h:107
TableList * first_leaf_for_name_resolution()
table_map on_expr_dep_tables
tables on expression depends on
Definition table_list.h:504
const char * option
Used by cache index.
Definition table_list.h:143
Select_Lex_Unit * derived
Select_Lex_Unit of derived table *‍/.
Definition table_list.h:205
NestedJoin * nested_join
if the element is a nested join
Definition table_list.h:505
bool straight
optimize with prev table
Definition table_list.h:173
List< TableList > * join_list
join list the table belongs to
Definition table_list.h:507
COND_EQUAL * cond_equal
Used with outer join.
Definition table_list.h:155
List< Index_hint > * index_hints
Definition table_list.h:199
TableList * next_name_resolution_table
Definition table_list.h:197
Item * on_expr
Used with outer join.
Definition table_list.h:144
List< String > * join_using_fields
Definition table_list.h:183
Table * table
opened table
Definition table_list.h:145
TableList * find_underlying_table(Table *table)
Definition table_list.cc:45
select_union * derived_result
Definition table_list.h:204
plugin::StorageEngine * db_type
table_type for handler
Definition table_list.h:508
bool is_leaf_for_name_resolution() const
Definition table_list.cc:40
Select_Lex * select_lex
Definition table_list.h:208
void unlock_table_names(TableList *last_table=NULL)
Definition global.cc:798
TODO: Rename this file - func.h is stupid.