00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <drizzled/nested_join.h>
00024 #include <drizzled/table.h>
00025
00026 namespace drizzled
00027 {
00028
00029 class Index_hint;
00030 class COND_EQUAL;
00031 class Natural_join_column;
00032 class select_union;
00033 class Select_Lex_Unit;
00034 class Select_Lex;
00035 class Tmp_Table_Param;
00036 class Item_subselect;
00037 class Table;
00038
00039 namespace plugin
00040 {
00041 class StorageEngine;
00042 }
00043
00074 class TableList
00075 {
00076 public:
00077 TableList():
00078 next_local(NULL),
00079 next_global(NULL),
00080 prev_global(NULL),
00081 db(NULL),
00082 alias(NULL),
00083 table_name(NULL),
00084 option(NULL),
00085 on_expr(NULL),
00086 table(NULL),
00087 prep_on_expr(NULL),
00088 cond_equal(NULL),
00089 natural_join(NULL),
00090 is_natural_join(false),
00091 is_join_columns_complete(false),
00092 straight(false),
00093 force_index(false),
00094 ignore_leaves(false),
00095 join_using_fields(NULL),
00096 join_columns(NULL),
00097 next_name_resolution_table(NULL),
00098 index_hints(NULL),
00099 derived_result(NULL),
00100 derived(NULL),
00101 schema_select_lex(NULL),
00102 select_lex(NULL),
00103 next_leaf(NULL),
00104 outer_join(0),
00105 db_length(0),
00106 table_name_length(0),
00107 dep_tables(0),
00108 on_expr_dep_tables(0),
00109 nested_join(NULL),
00110 embedding(NULL),
00111 join_list(NULL),
00112 db_type(NULL),
00113 internal_tmp_table(false),
00114 is_alias(false),
00115 is_fqtn(false),
00116 create(false)
00117 {}
00118
00124 TableList *next_local;
00125
00127 TableList *next_global;
00128 TableList **prev_global;
00129
00130 private:
00131 char *db;
00132
00133 public:
00134 const char *getSchemaName()
00135 {
00136 return db;
00137 }
00138
00139 char **getSchemaNamePtr()
00140 {
00141 return &db;
00142 }
00143
00144 void setSchemaName(char *arg)
00145 {
00146 db= arg;
00147 }
00148
00149 const char *alias;
00150
00151 private:
00152 const char *table_name;
00153
00154 public:
00155 const char *getTableName()
00156 {
00157 return table_name;
00158 }
00159
00160 void setTableName(const char *arg)
00161 {
00162 table_name= arg;
00163 }
00164
00165 char *option;
00166 Item *on_expr;
00167 Table *table;
00168
00176 Item *prep_on_expr;
00177 COND_EQUAL *cond_equal;
00178
00184 TableList *natural_join;
00190 bool is_natural_join;
00191
00193 bool is_join_columns_complete;
00194
00195 bool straight;
00196 bool force_index;
00197 bool ignore_leaves;
00198
00199
00200
00201
00202 bool isCartesian() const;
00203
00205 List<String> *join_using_fields;
00210 List<Natural_join_column> *join_columns;
00211
00219 TableList *next_name_resolution_table;
00221 List<Index_hint> *index_hints;
00226 select_union *derived_result;
00227 Select_Lex_Unit *derived;
00228 Select_Lex *schema_select_lex;
00230 Select_Lex *select_lex;
00236 TableList *next_leaf;
00237 thr_lock_type lock_type;
00238 uint32_t outer_join;
00239 size_t db_length;
00240 size_t table_name_length;
00241
00242 void set_underlying_merge();
00243 bool setup_underlying(Session *session);
00244
00249 bool placeholder();
00255 void print(Session *session, String *str);
00266 bool set_insert_values(memory::Root *mem_root);
00278 TableList *find_underlying_table(Table *table);
00294 TableList *first_leaf_for_name_resolution();
00310 TableList *last_leaf_for_name_resolution();
00325 bool is_leaf_for_name_resolution();
00326 inline TableList *top_table()
00327 { return this; }
00328
00338 Item_subselect *containing_subselect();
00339
00392 bool process_index_hints(Table *table);
00393
00394 friend std::ostream& operator<<(std::ostream& output, const TableList &list)
00395 {
00396 output << "TableList:(";
00397 output << list.db;
00398 output << ", ";
00399 output << list.table_name;
00400 output << ", ";
00401 output << list.alias;
00402 output << ", ";
00403 output << "is_natural_join:" << list.is_natural_join;
00404 output << ", ";
00405 output << "is_join_columns_complete:" << list.is_join_columns_complete;
00406 output << ", ";
00407 output << "straight:" << list.straight;
00408 output << ", ";
00409 output << "force_index" << list.force_index;
00410 output << ", ";
00411 output << "ignore_leaves:" << list.ignore_leaves;
00412 output << ", ";
00413 output << "create:" << list.create;
00414 output << ", ";
00415 output << "outer_join:" << list.outer_join;
00416 output << ", ";
00417 output << "nested_join:" << list.nested_join;
00418 output << ")";
00419
00420 return output;
00421 }
00422
00423 void setIsAlias(bool in_is_alias)
00424 {
00425 is_alias= in_is_alias;
00426 }
00427
00428 void setIsFqtn(bool in_is_fqtn)
00429 {
00430 is_fqtn= in_is_fqtn;
00431 }
00432
00433 void setCreate(bool in_create)
00434 {
00435 create= in_create;
00436 }
00437
00438 void setInternalTmpTable(bool in_internal_tmp_table)
00439 {
00440 internal_tmp_table= in_internal_tmp_table;
00441 }
00442
00443 void setDbType(plugin::StorageEngine *in_db_type)
00444 {
00445 db_type= in_db_type;
00446 }
00447
00448 void setJoinList(List<TableList> *in_join_list)
00449 {
00450 join_list= in_join_list;
00451 }
00452
00453 void setEmbedding(TableList *in_embedding)
00454 {
00455 embedding= in_embedding;
00456 }
00457
00458 void setNestedJoin(NestedJoin *in_nested_join)
00459 {
00460 nested_join= in_nested_join;
00461 }
00462
00463 void setDepTables(table_map in_dep_tables)
00464 {
00465 dep_tables= in_dep_tables;
00466 }
00467
00468 void setOnExprDepTables(table_map in_on_expr_dep_tables)
00469 {
00470 on_expr_dep_tables= in_on_expr_dep_tables;
00471 }
00472
00473 bool getIsAlias() const
00474 {
00475 return is_alias;
00476 }
00477
00478 bool getIsFqtn() const
00479 {
00480 return is_fqtn;
00481 }
00482
00483 bool isCreate() const
00484 {
00485 return create;
00486 }
00487
00488 bool getInternalTmpTable() const
00489 {
00490 return internal_tmp_table;
00491 }
00492
00493 plugin::StorageEngine *getDbType() const
00494 {
00495 return db_type;
00496 }
00497
00498 TableList *getEmbedding() const
00499 {
00500 return embedding;
00501 }
00502
00503 List<TableList> *getJoinList() const
00504 {
00505 return join_list;
00506 }
00507
00508 NestedJoin *getNestedJoin() const
00509 {
00510 return nested_join;
00511 }
00512
00513 table_map getDepTables() const
00514 {
00515 return dep_tables;
00516 }
00517
00518 table_map getOnExprDepTables() const
00519 {
00520 return on_expr_dep_tables;
00521 }
00522
00523 void unlock_table_name();
00524 void unlock_table_names(TableList *last_table= NULL);
00525
00526 private:
00527 table_map dep_tables;
00528 table_map on_expr_dep_tables;
00529 NestedJoin *nested_join;
00530 TableList *embedding;
00531 List<TableList> *join_list;
00532 plugin::StorageEngine *db_type;
00533 bool internal_tmp_table;
00534
00536 bool is_alias;
00537
00542 bool is_fqtn;
00543
00549 bool create;
00550
00551 };
00552
00553 void close_thread_tables(Session *session);
00554
00555 }
00556