708
Table reference in the FROM clause.
710
These table references can be of several types that correspond to
711
different SQL elements. Below we list all types of TableLists with
712
the necessary conditions to determine when a TableList instance
713
belongs to a certain type.
715
1) table (TableList::view == NULL)
717
(TableList::derived == NULL)
718
- subquery - TableList::table is a temp table
719
(TableList::derived != NULL)
720
- information schema table
721
(TableList::schema_table != NULL)
722
NOTICE: for schema tables TableList::field_translation may be != NULL
723
2) view (TableList::view != NULL)
724
- merge (TableList::effective_algorithm == VIEW_ALGORITHM_MERGE)
725
also (TableList::field_translation != NULL)
726
- tmptable (TableList::effective_algorithm == VIEW_ALGORITHM_TMPTABLE)
727
also (TableList::field_translation == NULL)
728
3) nested table reference (TableList::nested_join != NULL)
729
- table sequence - e.g. (t1, t2, t3)
730
TODO: how to distinguish from a JOIN?
732
TODO: how to distinguish from a table sequence?
734
(TableList::natural_join != NULL)
736
(TableList::join_using_fields != NULL)
744
Iterator over the fields of a generic table reference.
747
class Field_iterator: public Sql_alloc
750
Field_iterator() {} /* Remove gcc warning */
751
virtual ~Field_iterator() {}
752
virtual void set(TableList *)= 0;
753
virtual void next()= 0;
754
virtual bool end_of_fields()= 0; /* Return 1 at end of list */
755
virtual const char *name()= 0;
756
virtual Item *create_item(THD *)= 0;
757
virtual Field *field()= 0;
762
Iterator over the fields of a base table, view with temporary
767
class Field_iterator_table: public Field_iterator
771
Field_iterator_table() :ptr(0) {}
772
void set(TableList *table);
773
void set_table(Table *table) { ptr= table->field; }
774
void next() { ptr++; }
775
bool end_of_fields() { return *ptr == 0; }
777
Item *create_item(THD *thd);
778
Field *field() { return *ptr; }
782
/* Iterator over the fields of a merge view. */
785
Field_iterator interface to the list of materialized fields of a
789
class Field_iterator_natural_join: public Field_iterator
791
List_iterator_fast<Natural_join_column> column_ref_it;
792
Natural_join_column *cur_column_ref;
794
Field_iterator_natural_join() :cur_column_ref(NULL) {}
795
~Field_iterator_natural_join() {}
796
void set(TableList *table);
798
bool end_of_fields() { return !cur_column_ref; }
799
const char *name() { return cur_column_ref->name(); }
800
Item *create_item(THD *thd) { return cur_column_ref->create_item(thd); }
801
Field *field() { return cur_column_ref->field(); }
802
Natural_join_column *column_ref() { return cur_column_ref; }
807
Generic iterator over the fields of an arbitrary table reference.
810
This class unifies the various ways of iterating over the columns
811
of a table reference depending on the type of SQL entity it
812
represents. If such an entity represents a nested table reference,
813
this iterator encapsulates the iteration over the columns of the
814
members of the table reference.
817
The implementation assumes that all underlying NATURAL/USING table
818
references already contain their result columns and are linked into
819
the list TableList::next_name_resolution_table.
822
class Field_iterator_table_ref: public Field_iterator
824
TableList *table_ref, *first_leaf, *last_leaf;
825
Field_iterator_table table_field_it;
826
Field_iterator_natural_join natural_join_it;
827
Field_iterator *field_it;
828
void set_field_iterator();
830
Field_iterator_table_ref() :field_it(NULL) {}
831
void set(TableList *table);
834
{ return (table_ref == last_leaf && field_it->end_of_fields()); }
835
const char *name() { return field_it->name(); }
836
const char *table_name();
837
const char *db_name();
838
Item *create_item(THD *thd) { return field_it->create_item(thd); }
839
Field *field() { return field_it->field(); }
840
Natural_join_column *get_or_create_column_ref(TableList *parent_table_ref);
841
Natural_join_column *get_natural_column_ref();
845
708
typedef struct st_changed_table_list
847
710
struct st_changed_table_list *next;