Drizzled Public API Documentation

table_list.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <drizzled/nested_join.h>
00024 #include <drizzled/table.h>
00025 
00026 namespace drizzled {
00027 
00058 class TableList
00059 {
00060 public:
00061   TableList():
00062     next_local(NULL),
00063     next_global(NULL),
00064     prev_global(NULL),
00065     schema(NULL),
00066     alias(NULL),
00067     table_name(NULL),
00068     option(NULL),
00069     on_expr(NULL),
00070     table(NULL),
00071     prep_on_expr(NULL),
00072     cond_equal(NULL),
00073     natural_join(NULL),
00074     is_natural_join(false),
00075     is_join_columns_complete(false),
00076     straight(false),
00077     force_index(false),
00078     ignore_leaves(false),
00079     join_using_fields(NULL),
00080     join_columns(NULL),
00081     next_name_resolution_table(NULL),
00082     index_hints(NULL),
00083     derived_result(NULL),
00084     derived(NULL),
00085     schema_select_lex(NULL),
00086     select_lex(NULL),
00087     next_leaf(NULL),
00088     outer_join(0),
00089     dep_tables(0),
00090     on_expr_dep_tables(0),
00091     nested_join(NULL),
00092     embedding(NULL),
00093     join_list(NULL),
00094     db_type(NULL),
00095     internal_tmp_table(false),
00096     is_alias(false),
00097     is_fqtn(false),
00098     create(false)
00099   {
00100   }
00101 
00107   TableList *next_local;
00108 
00110   TableList *next_global; 
00111   TableList **prev_global;
00112 
00113 private:
00114   const char* schema;
00115 
00116 public:
00117   const char *getSchemaName() const
00118   {
00119     return schema;
00120   }
00121 
00122   void setSchemaName(const char* v)
00123   {
00124     schema= v;
00125   }
00126 
00127   const char *alias;
00128 
00129 private:
00130   const char* table_name;
00131 
00132 public:
00133   const char *getTableName() const
00134   {
00135     return table_name;
00136   }
00137 
00138   void setTableName(const char* v)
00139   {
00140     table_name= v;
00141   }
00142 
00143   const char *option; 
00144   Item *on_expr; 
00145   Table *table; 
00146 
00154   Item *prep_on_expr;
00155   COND_EQUAL *cond_equal; 
00156 
00162   TableList *natural_join;
00168   bool is_natural_join;
00169 
00171   bool is_join_columns_complete;
00172 
00173   bool straight; 
00174   bool force_index; 
00175   bool ignore_leaves; 
00176 
00177   /*
00178     is the table a cartesian join, assumption is yes unless "solved"
00179   */
00180   bool isCartesian() const;
00181 
00183   List<String> *join_using_fields;
00188   List<Natural_join_column> *join_columns;
00189 
00197   TableList *next_name_resolution_table;
00199   List<Index_hint> *index_hints;
00204   select_union *derived_result;
00205   Select_Lex_Unit *derived; 
00206   Select_Lex *schema_select_lex;
00208   Select_Lex *select_lex;
00214   TableList *next_leaf;
00215   thr_lock_type lock_type;
00216   uint32_t outer_join; 
00217 
00218   void set_underlying_merge();
00219   bool setup_underlying(Session *session);
00220 
00225   bool placeholder();
00231   void print(Session *session, String *str);
00242   void set_insert_values();
00254   TableList *find_underlying_table(Table *table);
00270   TableList *first_leaf_for_name_resolution();
00286   TableList *last_leaf_for_name_resolution();
00301   bool is_leaf_for_name_resolution() const;
00302   inline TableList *top_table()
00303   { return this; }
00304 
00314   Item_subselect *containing_subselect();
00315 
00368   bool process_index_hints(Table *table);
00369 
00370   friend std::ostream& operator<<(std::ostream& output, const TableList &list)
00371   {
00372     output << "TableList:(";
00373     output << list.getSchemaName();
00374     output << ", ";
00375     output << list.getTableName();
00376     output << ", ";
00377     output << list.alias;
00378     output << ", ";
00379     output << "is_natural_join:" << list.is_natural_join;
00380     output << ", ";
00381     output << "is_join_columns_complete:" << list.is_join_columns_complete;
00382     output << ", ";
00383     output << "straight:" << list.straight;
00384     output << ", ";
00385     output << "force_index" << list.force_index;
00386     output << ", ";
00387     output << "ignore_leaves:" << list.ignore_leaves;
00388     output << ", ";
00389     output << "create:" << list.create;
00390     output << ", ";
00391     output << "outer_join:" << list.outer_join;
00392     output << ", ";
00393     output << "nested_join:" << list.nested_join;
00394     output << ")";
00395 
00396     return output;  // for multiple << operators.
00397   }
00398 
00399   void setIsAlias(bool in_is_alias)
00400   {
00401     is_alias= in_is_alias;
00402   }
00403 
00404   void setIsFqtn(bool in_is_fqtn)
00405   {
00406     is_fqtn= in_is_fqtn;
00407   }
00408 
00409   void setCreate(bool in_create)
00410   {
00411     create= in_create;
00412   }
00413 
00414   void setInternalTmpTable(bool in_internal_tmp_table)
00415   {
00416     internal_tmp_table= in_internal_tmp_table;
00417   }
00418 
00419   void setDbType(plugin::StorageEngine *in_db_type)
00420   {
00421     db_type= in_db_type;
00422   }
00423 
00424   void setJoinList(List<TableList> *in_join_list)
00425   {
00426     join_list= in_join_list;
00427   }
00428 
00429   void setEmbedding(TableList *in_embedding)
00430   {
00431     embedding= in_embedding;
00432   }
00433 
00434   void setNestedJoin(NestedJoin *in_nested_join)
00435   {
00436     nested_join= in_nested_join;
00437   }
00438 
00439   void setDepTables(table_map in_dep_tables)
00440   {
00441     dep_tables= in_dep_tables;
00442   }
00443 
00444   void setOnExprDepTables(table_map in_on_expr_dep_tables)
00445   {
00446     on_expr_dep_tables= in_on_expr_dep_tables;
00447   }
00448 
00449   bool getIsAlias() const
00450   {
00451     return is_alias;
00452   }
00453 
00454   bool getIsFqtn() const
00455   {
00456     return is_fqtn;
00457   }
00458 
00459   bool isCreate() const
00460   {
00461     return create;
00462   }
00463 
00464   bool getInternalTmpTable() const
00465   {
00466     return internal_tmp_table;
00467   }
00468 
00469   plugin::StorageEngine *getDbType() const
00470   {
00471     return db_type;
00472   }
00473 
00474   TableList *getEmbedding() const
00475   {
00476     return embedding;
00477   }
00478 
00479   List<TableList> *getJoinList() const
00480   {
00481     return join_list;
00482   }
00483 
00484   NestedJoin *getNestedJoin() const
00485   {
00486     return nested_join;
00487   }
00488 
00489   table_map getDepTables() const
00490   {
00491     return dep_tables;
00492   }
00493 
00494   table_map getOnExprDepTables() const
00495   {
00496     return on_expr_dep_tables;
00497   }
00498 
00499   void unlock_table_name();
00500   void unlock_table_names(TableList *last_table= NULL);
00501 
00502 private:
00503   table_map dep_tables; 
00504   table_map on_expr_dep_tables; 
00505   NestedJoin *nested_join; 
00506   TableList *embedding; 
00507   List<TableList> *join_list; 
00508   plugin::StorageEngine *db_type; 
00509   bool internal_tmp_table;
00510 
00512   bool is_alias;
00513 
00518   bool is_fqtn;
00519 
00525   bool create;
00526 
00527 };
00528 
00529 void close_thread_tables(Session *session);
00530 
00531 } /* namespace drizzled */
00532