The world's most popular open source database
00001 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 00018 /* Structs that defines the TABLE */ 00019 00020 class Item; /* Needed by ORDER */ 00021 class GRANT_TABLE; 00022 class st_select_lex_unit; 00023 class st_select_lex; 00024 class partition_info; 00025 class COND_EQUAL; 00026 class Security_context; 00027 00028 /* Order clause list element */ 00029 00030 typedef struct st_order { 00031 struct st_order *next; 00032 Item **item; /* Point at item in select fields */ 00033 Item *item_ptr; /* Storage for initial item */ 00034 Item **item_copy; /* For SPs; the original item ptr */ 00035 int counter; /* position in SELECT list, correct 00036 only if counter_used is true*/ 00037 bool asc; /* true if ascending */ 00038 bool free_me; /* true if item isn't shared */ 00039 bool in_field_list; /* true if in select field list */ 00040 bool counter_used; /* parameter was counter of columns */ 00041 Field *field; /* If tmp-table group */ 00042 char *buff; /* If tmp-table group */ 00043 table_map used, depend_map; 00044 } ORDER; 00045 00046 typedef struct st_grant_info 00047 { 00048 GRANT_TABLE *grant_table; 00049 uint version; 00050 ulong privilege; 00051 ulong want_privilege; 00052 /* 00053 Stores the requested access acl of top level tables list. Is used to 00054 check access rights to the underlying tables of a view. 00055 */ 00056 ulong orig_want_privilege; 00057 } GRANT_INFO; 00058 00059 enum tmp_table_type 00060 { 00061 NO_TMP_TABLE, TMP_TABLE, TRANSACTIONAL_TMP_TABLE, 00062 INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE 00063 }; 00064 00065 enum frm_type_enum 00066 { 00067 FRMTYPE_ERROR= 0, 00068 FRMTYPE_TABLE, 00069 FRMTYPE_VIEW 00070 }; 00071 00072 enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP }; 00073 00074 typedef struct st_filesort_info 00075 { 00076 IO_CACHE *io_cache; /* If sorted through filebyte */ 00077 byte *addon_buf; /* Pointer to a buffer if sorted with fields */ 00078 uint addon_length; /* Length of the buffer */ 00079 struct st_sort_addon_field *addon_field; /* Pointer to the fields info */ 00080 void (*unpack)(struct st_sort_addon_field *, byte *); /* To unpack back */ 00081 byte *record_pointers; /* If sorted in memory */ 00082 ha_rows found_records; /* How many records in sort */ 00083 } FILESORT_INFO; 00084 00085 00086 /* 00087 Values in this enum are used to indicate how a tables TIMESTAMP field 00088 should be treated. It can be set to the current timestamp on insert or 00089 update or both. 00090 WARNING: The values are used for bit operations. If you change the 00091 enum, you must keep the bitwise relation of the values. For example: 00092 (int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to 00093 (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE. 00094 We use an enum here so that the debugger can display the value names. 00095 */ 00096 enum timestamp_auto_set_type 00097 { 00098 TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1, 00099 TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3 00100 }; 00101 #define clear_timestamp_auto_bits(_target_, _bits_) \ 00102 (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_)) 00103 00104 class Field_timestamp; 00105 class Field_blob; 00106 class Table_triggers_list; 00107 00108 /* 00109 This structure is shared between different table objects. There is one 00110 instance of table share per one table in the database. 00111 */ 00112 00113 typedef struct st_table_share 00114 { 00115 /* hash of field names (contains pointers to elements of field array) */ 00116 HASH name_hash; /* hash of field names */ 00117 MEM_ROOT mem_root; 00118 TYPELIB keynames; /* Pointers to keynames */ 00119 TYPELIB fieldnames; /* Pointer to fieldnames */ 00120 TYPELIB *intervals; /* pointer to interval info */ 00121 pthread_mutex_t mutex; /* For locking the share */ 00122 pthread_cond_t cond; /* To signal that share is ready */ 00123 struct st_table_share *next, /* Link to unused shares */ 00124 **prev; 00125 #ifdef NOT_YET 00126 struct st_table *open_tables; /* link to open tables */ 00127 #endif 00128 00129 /* The following is copied to each TABLE on OPEN */ 00130 Field **field; 00131 Field **found_next_number_field; 00132 Field *timestamp_field; /* Used only during open */ 00133 KEY *key_info; /* data of keys in database */ 00134 uint *blob_field; /* Index to blobs in Field arrray*/ 00135 00136 byte *default_values; /* row with default values */ 00137 LEX_STRING comment; /* Comment about table */ 00138 CHARSET_INFO *table_charset; /* Default charset of string fields */ 00139 00140 MY_BITMAP all_set; 00141 /* 00142 Key which is used for looking-up table in table cache and in the list 00143 of thread's temporary tables. Has the form of: 00144 "database_name\0table_name\0" + optional part for temporary tables. 00145 00146 Note that all three 'table_cache_key', 'db' and 'table_name' members 00147 must be set (and be non-zero) for tables in table cache. They also 00148 should correspond to each other. 00149 To ensure this one can use set_table_cache() methods. 00150 */ 00151 LEX_STRING table_cache_key; 00152 LEX_STRING db; /* Pointer to db */ 00153 LEX_STRING table_name; /* Table name (for open) */ 00154 LEX_STRING path; /* Path to .frm file (from datadir) */ 00155 LEX_STRING normalized_path; /* unpack_filename(path) */ 00156 LEX_STRING connect_string; 00157 key_map keys_in_use; /* Keys in use for table */ 00158 key_map keys_for_keyread; 00159 ha_rows min_rows, max_rows; /* create information */ 00160 ulong avg_row_length; /* create information */ 00161 ulong raid_chunksize; 00162 ulong version, flush_version, mysql_version; 00163 ulong timestamp_offset; /* Set to offset+1 of record */ 00164 ulong reclength; /* Recordlength */ 00165 00166 handlerton *db_type; /* table_type for handler */ 00167 enum row_type row_type; /* How rows are stored */ 00168 enum tmp_table_type tmp_table; 00169 00170 uint ref_count; /* How many TABLE objects uses this */ 00171 uint open_count; /* Number of tables in open list */ 00172 uint blob_ptr_size; /* 4 or 8 */ 00173 uint key_block_size; /* create key_block_size, if used */ 00174 uint null_bytes, last_null_bit_pos; 00175 uint fields; /* Number of fields */ 00176 uint rec_buff_length; /* Size of table->record[] buffer */ 00177 uint keys, key_parts; 00178 uint max_key_length, max_unique_length, total_key_length; 00179 uint uniques; /* Number of UNIQUE index */ 00180 uint null_fields; /* number of null fields */ 00181 uint blob_fields; /* number of blob fields */ 00182 uint timestamp_field_offset; /* Field number for timestamp field */ 00183 uint varchar_fields; /* number of varchar fields */ 00184 uint db_create_options; /* Create options from database */ 00185 uint db_options_in_use; /* Options in use */ 00186 uint db_record_offset; /* if HA_REC_IN_SEQ */ 00187 uint raid_type, raid_chunks; 00188 uint rowid_field_offset; /* Field_nr +1 to rowid field */ 00189 /* Index of auto-updated TIMESTAMP field in field array */ 00190 uint primary_key; 00191 uint next_number_index; 00192 uint next_number_key_offset; 00193 uint error, open_errno, errarg; /* error from open_table_def() */ 00194 uint column_bitmap_size; 00195 uchar frm_version; 00196 bool null_field_first; 00197 bool system; /* Set if system table (one record) */ 00198 bool crypted; /* If .frm file is crypted */ 00199 bool db_low_byte_first; /* Portable row format */ 00200 bool crashed; 00201 bool is_view; 00202 bool name_lock, replace_with_name_lock; 00203 bool waiting_on_cond; /* Protection against free */ 00204 ulong table_map_id; /* for row-based replication */ 00205 ulonglong table_map_version; 00206 00207 /* 00208 Cache for row-based replication table share checks that does not 00209 need to be repeated. Possible values are: -1 when cache value is 00210 not calculated yet, 0 when table *shall not* be replicated, 1 when 00211 table *may* be replicated. 00212 */ 00213 int cached_row_logging_check; 00214 00215 /* 00216 TRUE if this is a system table like 'mysql.proc', which we want to be 00217 able to open and lock even when we already have some tables open and 00218 locked. To avoid deadlocks we have to put certain restrictions on 00219 locking of this table for writing. FALSE - otherwise. 00220 */ 00221 bool system_table; 00222 /* 00223 This flag is set for the log tables. Used during FLUSH instances to skip 00224 log tables, while closing tables (since logs must be always available) 00225 */ 00226 bool log_table; 00227 #ifdef WITH_PARTITION_STORAGE_ENGINE 00228 bool auto_partitioned; 00229 const uchar *partition_info; 00230 uint partition_info_len; 00231 const uchar *part_state; 00232 uint part_state_len; 00233 handlerton *default_part_db_type; 00234 #endif 00235 00236 00237 /* 00238 Set share's table cache key and update its db and table name appropriately. 00239 00240 SYNOPSIS 00241 set_table_cache_key() 00242 key_buff Buffer with already built table cache key to be 00243 referenced from share. 00244 key_length Key length. 00245 00246 NOTES 00247 Since 'key_buff' buffer will be referenced from share it should has same 00248 life-time as share itself. 00249 This method automatically ensures that TABLE_SHARE::table_name/db have 00250 appropriate values by using table cache key as their source. 00251 */ 00252 00253 void set_table_cache_key(char *key_buff, uint key_length) 00254 { 00255 table_cache_key.str= key_buff; 00256 table_cache_key.length= key_length; 00257 /* 00258 Let us use the fact that the key is "db/0/table_name/0" + optional 00259 part for temporary tables. 00260 */ 00261 db.str= table_cache_key.str; 00262 db.length= strlen(db.str); 00263 table_name.str= db.str + db.length + 1; 00264 table_name.length= strlen(table_name.str); 00265 } 00266 00267 00268 /* 00269 Set share's table cache key and update its db and table name appropriately. 00270 00271 SYNOPSIS 00272 set_table_cache_key() 00273 key_buff Buffer to be used as storage for table cache key 00274 (should be at least key_length bytes). 00275 key Value for table cache key. 00276 key_length Key length. 00277 00278 NOTE 00279 Since 'key_buff' buffer will be used as storage for table cache key 00280 it should has same life-time as share itself. 00281 */ 00282 00283 void set_table_cache_key(char *key_buff, const char *key, uint key_length) 00284 { 00285 memcpy(key_buff, key, key_length); 00286 set_table_cache_key(key_buff, key_length); 00287 } 00288 00289 } TABLE_SHARE; 00290 00291 00292 /* Information for one open table */ 00293 00294 struct st_table { 00295 st_table() {} /* Remove gcc warning */ 00296 00297 TABLE_SHARE *s; 00298 handler *file; 00299 #ifdef NOT_YET 00300 struct st_table *used_next, **used_prev; /* Link to used tables */ 00301 #endif 00302 struct st_table *open_next, **open_prev; /* Link to open tables */ 00303 struct st_table *next, *prev; 00304 00305 THD *in_use; /* Which thread uses this */ 00306 Field **field; /* Pointer to fields */ 00307 00308 byte *record[2]; /* Pointer to records */ 00309 byte *write_row_record; /* Used as optimisation in 00310 THD::write_row */ 00311 byte *insert_values; /* used by INSERT ... UPDATE */ 00312 key_map quick_keys, used_keys, keys_in_use_for_query, merge_keys; 00313 KEY *key_info; /* data of keys in database */ 00314 00315 Field *next_number_field; /* Set if next_number is activated */ 00316 Field *found_next_number_field; /* Set on open */ 00317 Field_timestamp *timestamp_field; 00318 00319 /* Table's triggers, 0 if there are no of them */ 00320 Table_triggers_list *triggers; 00321 struct st_table_list *pos_in_table_list;/* Element referring to this table */ 00322 ORDER *group; 00323 const char *alias; /* alias or table name */ 00324 uchar *null_flags; 00325 my_bitmap_map *bitmap_init_value; 00326 MY_BITMAP def_read_set, def_write_set, tmp_set; /* containers */ 00327 MY_BITMAP *read_set, *write_set; /* Active column sets */ 00328 query_id_t query_id; 00329 00330 /* 00331 For each key that has quick_keys.is_set(key) == TRUE: estimate of #records 00332 and max #key parts that range access would use. 00333 */ 00334 ha_rows quick_rows[MAX_KEY]; 00335 00336 /* Bitmaps of key parts that =const for the entire join. */ 00337 key_part_map const_key_parts[MAX_KEY]; 00338 00339 uint quick_key_parts[MAX_KEY]; 00340 uint quick_n_ranges[MAX_KEY]; 00341 00342 /* 00343 Estimate of number of records that satisfy SARGable part of the table 00344 condition, or table->file->records if no SARGable condition could be 00345 constructed. 00346 This value is used by join optimizer as an estimate of number of records 00347 that will pass the table condition (condition that depends on fields of 00348 this table and constants) 00349 */ 00350 ha_rows quick_condition_rows; 00351 00352 /* 00353 If this table has TIMESTAMP field with auto-set property (pointed by 00354 timestamp_field member) then this variable indicates during which 00355 operations (insert only/on update/in both cases) we should set this 00356 field to current timestamp. If there are no such field in this table 00357 or we should not automatically set its value during execution of current 00358 statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0). 00359 00360 Value of this variable is set for each statement in open_table() and 00361 if needed cleared later in statement processing code (see mysql_update() 00362 as example). 00363 */ 00364 timestamp_auto_set_type timestamp_field_type; 00365 table_map map; /* ID bit of table (1,2,4,8,16...) */ 00366 00367 uint lock_position; /* Position in MYSQL_LOCK.table */ 00368 uint lock_data_start; /* Start pos. in MYSQL_LOCK.locks */ 00369 uint lock_count; /* Number of locks */ 00370 uint tablenr,used_fields; 00371 uint temp_pool_slot; /* Used by intern temp tables */ 00372 uint status; /* What's in record[0] */ 00373 uint db_stat; /* mode of file as in handler.h */ 00374 /* number of select if it is derived table */ 00375 uint derived_select_number; 00376 int current_lock; /* Type of lock on table */ 00377 my_bool copy_blobs; /* copy_blobs when storing */ 00378 00379 /* 00380 0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0. 00381 If maybe_null !=0, this table is inner w.r.t. some outer join operation, 00382 and null_row may be true. 00383 */ 00384 uint maybe_null; 00385 /* 00386 If true, the current table row is considered to have all columns set to 00387 NULL, including columns declared as "not null" (see maybe_null). 00388 */ 00389 my_bool null_row; 00390 my_bool force_index; 00391 my_bool distinct,const_table,no_rows; 00392 my_bool key_read, no_keyread; 00393 my_bool locked_by_flush; 00394 my_bool locked_by_logger; 00395 my_bool locked_by_name; 00396 my_bool fulltext_searched; 00397 my_bool no_cache; 00398 /* To signal that we should reset query_id for tables and cols */ 00399 my_bool clear_query_id; 00400 my_bool auto_increment_field_not_null; 00401 my_bool insert_or_update; /* Can be used by the handler */ 00402 my_bool alias_name_used; /* true if table_name is alias */ 00403 my_bool get_fields_in_item_tree; /* Signal to fix_field */ 00404 00405 REGINFO reginfo; /* field connections */ 00406 MEM_ROOT mem_root; 00407 GRANT_INFO grant; 00408 FILESORT_INFO sort; 00409 #ifdef WITH_PARTITION_STORAGE_ENGINE 00410 partition_info *part_info; /* Partition related information */ 00411 bool no_partitions_used; /* If true, all partitions have been pruned away */ 00412 #endif 00413 00414 bool fill_item_list(List<Item> *item_list) const; 00415 void reset_item_list(List<Item> *item_list) const; 00416 void clear_column_bitmaps(void); 00417 void prepare_for_position(void); 00418 void mark_columns_used_by_index_no_reset(uint index, MY_BITMAP *map); 00419 void mark_columns_used_by_index(uint index); 00420 void restore_column_maps_after_mark_index(); 00421 void mark_auto_increment_column(void); 00422 void mark_columns_needed_for_update(void); 00423 void mark_columns_needed_for_delete(void); 00424 void mark_columns_needed_for_insert(void); 00425 inline void column_bitmaps_set(MY_BITMAP *read_set_arg, 00426 MY_BITMAP *write_set_arg) 00427 { 00428 read_set= read_set_arg; 00429 write_set= write_set_arg; 00430 if (file) 00431 file->column_bitmaps_signal(); 00432 } 00433 inline void column_bitmaps_set_no_signal(MY_BITMAP *read_set_arg, 00434 MY_BITMAP *write_set_arg) 00435 { 00436 read_set= read_set_arg; 00437 write_set= write_set_arg; 00438 } 00439 inline void use_all_columns() 00440 { 00441 column_bitmaps_set(&s->all_set, &s->all_set); 00442 } 00443 inline void default_column_bitmaps() 00444 { 00445 read_set= &def_read_set; 00446 write_set= &def_write_set; 00447 } 00448 00449 }; 00450 00451 00452 typedef struct st_foreign_key_info 00453 { 00454 LEX_STRING *forein_id; 00455 LEX_STRING *referenced_db; 00456 LEX_STRING *referenced_table; 00457 LEX_STRING *update_method; 00458 LEX_STRING *delete_method; 00459 List<LEX_STRING> foreign_fields; 00460 List<LEX_STRING> referenced_fields; 00461 } FOREIGN_KEY_INFO; 00462 00463 /* 00464 Make sure that the order of schema_tables and enum_schema_tables are the same. 00465 */ 00466 00467 enum enum_schema_tables 00468 { 00469 SCH_CHARSETS= 0, 00470 SCH_COLLATIONS, 00471 SCH_COLLATION_CHARACTER_SET_APPLICABILITY, 00472 SCH_COLUMNS, 00473 SCH_COLUMN_PRIVILEGES, 00474 SCH_ENGINES, 00475 SCH_EVENTS, 00476 SCH_FILES, 00477 SCH_KEY_COLUMN_USAGE, 00478 SCH_OPEN_TABLES, 00479 SCH_PARTITIONS, 00480 SCH_PLUGINS, 00481 SCH_PROCESSLIST, 00482 SCH_REFERENTIAL_CONSTRAINTS, 00483 SCH_PROCEDURES, 00484 SCH_SCHEMATA, 00485 SCH_SCHEMA_PRIVILEGES, 00486 SCH_STATISTICS, 00487 SCH_STATUS, 00488 SCH_TABLES, 00489 SCH_TABLE_CONSTRAINTS, 00490 SCH_TABLE_NAMES, 00491 SCH_TABLE_PRIVILEGES, 00492 SCH_TRIGGERS, 00493 SCH_USER_PRIVILEGES, 00494 SCH_VARIABLES, 00495 SCH_VIEWS 00496 }; 00497 00498 00499 typedef struct st_field_info 00500 { 00501 const char* field_name; 00502 uint field_length; 00503 enum enum_field_types field_type; 00504 int value; 00505 bool maybe_null; 00506 const char* old_name; 00507 } ST_FIELD_INFO; 00508 00509 00510 struct st_table_list; 00511 typedef class Item COND; 00512 00513 typedef struct st_schema_table 00514 { 00515 const char* table_name; 00516 ST_FIELD_INFO *fields_info; 00517 /* Create information_schema table */ 00518 TABLE *(*create_table) (THD *thd, struct st_table_list *table_list); 00519 /* Fill table with data */ 00520 int (*fill_table) (THD *thd, struct st_table_list *tables, COND *cond); 00521 /* Handle fileds for old SHOW */ 00522 int (*old_format) (THD *thd, struct st_schema_table *schema_table); 00523 int (*process_table) (THD *thd, struct st_table_list *tables, 00524 TABLE *table, bool res, const char *base_name, 00525 const char *file_name); 00526 int idx_field1, idx_field2; 00527 bool hidden; 00528 } ST_SCHEMA_TABLE; 00529 00530 00531 #define JOIN_TYPE_LEFT 1 00532 #define JOIN_TYPE_RIGHT 2 00533 00534 #define VIEW_ALGORITHM_UNDEFINED 0 00535 #define VIEW_ALGORITHM_TMPTABLE 1 00536 #define VIEW_ALGORITHM_MERGE 2 00537 00538 #define VIEW_SUID_INVOKER 0 00539 #define VIEW_SUID_DEFINER 1 00540 #define VIEW_SUID_DEFAULT 2 00541 00542 /* view WITH CHECK OPTION parameter options */ 00543 #define VIEW_CHECK_NONE 0 00544 #define VIEW_CHECK_LOCAL 1 00545 #define VIEW_CHECK_CASCADED 2 00546 00547 /* result of view WITH CHECK OPTION parameter check */ 00548 #define VIEW_CHECK_OK 0 00549 #define VIEW_CHECK_ERROR 1 00550 #define VIEW_CHECK_SKIP 2 00551 00552 struct st_lex; 00553 class select_union; 00554 class TMP_TABLE_PARAM; 00555 00556 Item *create_view_field(THD *thd, st_table_list *view, Item **field_ref, 00557 const char *name); 00558 00559 struct Field_translator 00560 { 00561 Item *item; 00562 const char *name; 00563 }; 00564 00565 00566 /* 00567 Column reference of a NATURAL/USING join. Since column references in 00568 joins can be both from views and stored tables, may point to either a 00569 Field (for tables), or a Field_translator (for views). 00570 */ 00571 00572 class Natural_join_column: public Sql_alloc 00573 { 00574 public: 00575 Field_translator *view_field; /* Column reference of merge view. */ 00576 Field *table_field; /* Column reference of table or temp view. */ 00577 st_table_list *table_ref; /* Original base table/view reference. */ 00578 /* 00579 True if a common join column of two NATURAL/USING join operands. Notice 00580 that when we have a hierarchy of nested NATURAL/USING joins, a column can 00581 be common at some level of nesting but it may not be common at higher 00582 levels of nesting. Thus this flag may change depending on at which level 00583 we are looking at some column. 00584 */ 00585 bool is_common; 00586 public: 00587 Natural_join_column(Field_translator *field_param, st_table_list *tab); 00588 Natural_join_column(Field *field_param, st_table_list *tab); 00589 const char *name(); 00590 Item *create_item(THD *thd); 00591 Field *field(); 00592 const char *table_name(); 00593 const char *db_name(); 00594 GRANT_INFO *grant(); 00595 }; 00596 00597 00598 /* 00599 Table reference in the FROM clause. 00600 00601 These table references can be of several types that correspond to 00602 different SQL elements. Below we list all types of TABLE_LISTs with 00603 the necessary conditions to determine when a TABLE_LIST instance 00604 belongs to a certain type. 00605 00606 1) table (TABLE_LIST::view == NULL) 00607 - base table 00608 (TABLE_LIST::derived == NULL) 00609 - subquery - TABLE_LIST::table is a temp table 00610 (TABLE_LIST::derived != NULL) 00611 - information schema table 00612 (TABLE_LIST::schema_table != NULL) 00613 NOTICE: for schema tables TABLE_LIST::field_translation may be != NULL 00614 2) view (TABLE_LIST::view != NULL) 00615 - merge (TABLE_LIST::effective_algorithm == VIEW_ALGORITHM_MERGE) 00616 also (TABLE_LIST::field_translation != NULL) 00617 - tmptable (TABLE_LIST::effective_algorithm == VIEW_ALGORITHM_TMPTABLE) 00618 also (TABLE_LIST::field_translation == NULL) 00619 3) nested table reference (TABLE_LIST::nested_join != NULL) 00620 - table sequence - e.g. (t1, t2, t3) 00621 TODO: how to distinguish from a JOIN? 00622 - general JOIN 00623 TODO: how to distinguish from a table sequence? 00624 - NATURAL JOIN 00625 (TABLE_LIST::natural_join != NULL) 00626 - JOIN ... USING 00627 (TABLE_LIST::join_using_fields != NULL) 00628 */ 00629 00630 typedef struct st_table_list 00631 { 00632 st_table_list() {} /* Remove gcc warning */ 00633 /* 00634 List of tables local to a subquery (used by SQL_LIST). Considers 00635 views as leaves (unlike 'next_leaf' below). Created at parse time 00636 in st_select_lex::add_table_to_list() -> table_list.link_in_list(). 00637 */ 00638 struct st_table_list *next_local; 00639 /* link in a global list of all queries tables */ 00640 struct st_table_list *next_global, **prev_global; 00641 char *db, *alias, *table_name, *schema_table_name; 00642 char *option; /* Used by cache index */ 00643 Item *on_expr; /* Used with outer join */ 00644 /* 00645 The structure of ON expression presented in the member above 00646 can be changed during certain optimizations. This member 00647 contains a snapshot of AND-OR structure of the ON expression 00648 made after permanent transformations of the parse tree, and is 00649 used to restore ON clause before every reexecution of a prepared 00650 statement or stored procedure. 00651 */ 00652 Item *prep_on_expr; 00653 COND_EQUAL *cond_equal; /* Used with outer join */ 00654 /* 00655 During parsing - left operand of NATURAL/USING join where 'this' is 00656 the right operand. After parsing (this->natural_join == this) iff 00657 'this' represents a NATURAL or USING join operation. Thus after 00658 parsing 'this' is a NATURAL/USING join iff (natural_join != NULL). 00659 */ 00660 struct st_table_list *natural_join; 00661 /* 00662 True if 'this' represents a nested join that is a NATURAL JOIN. 00663 For one of the operands of 'this', the member 'natural_join' points 00664 to the other operand of 'this'. 00665 */ 00666 bool is_natural_join; 00667 /* Field names in a USING clause for JOIN ... USING. */ 00668 List<String> *join_using_fields; 00669 /* 00670 Explicitly store the result columns of either a NATURAL/USING join or 00671 an operand of such a join. 00672 */ 00673 List<Natural_join_column> *join_columns; 00674 /* TRUE if join_columns contains all columns of this table reference. */ 00675 bool is_join_columns_complete; 00676 00677 /* 00678 List of nodes in a nested join tree, that should be considered as 00679 leaves with respect to name resolution. The leaves are: views, 00680 top-most nodes representing NATURAL/USING joins, subqueries, and 00681 base tables. All of these TABLE_LIST instances contain a 00682 materialized list of columns. The list is local to a subquery. 00683 */ 00684 struct st_table_list *next_name_resolution_table; 00685 /* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */ 00686 List<St

