#include <item.h>
Inheritance diagram for Item_ident:


Public Member Functions | |
| Item_ident (Name_resolution_context *context_arg, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg) | |
| Item_ident (THD *thd, Item_ident *item) | |
| const char * | full_name () const |
| void | cleanup () |
| bool | remove_dependence_processor (byte *arg) |
| void | print (String *str) |
| virtual bool | change_context_processor (byte *cntx) |
Public Attributes | |
| Name_resolution_context * | context |
| const char * | db_name |
| const char * | table_name |
| const char * | field_name |
| bool | alias_name_used |
| uint | cached_field_index |
| TABLE_LIST * | cached_table |
| st_select_lex * | depended_from |
Protected Attributes | |
| const char * | orig_db_name |
| const char * | orig_table_name |
| const char * | orig_field_name |
Friends | |
| bool | insert_fields (THD *thd, Name_resolution_context *context, const char *db_name, const char *table_name, List_iterator< Item > *it, bool any_privileges) |
Definition at line 1162 of file item.h.
| Item_ident::Item_ident | ( | Name_resolution_context * | context_arg, | |
| const char * | db_name_arg, | |||
| const char * | table_name_arg, | |||
| const char * | field_name_arg | |||
| ) |
Definition at line 420 of file item.cc.
References Item::name.
00423 :orig_db_name(db_name_arg), orig_table_name(table_name_arg), 00424 orig_field_name(field_name_arg), context(context_arg), 00425 db_name(db_name_arg), table_name(table_name_arg), 00426 field_name(field_name_arg), 00427 alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX), 00428 cached_table(0), depended_from(0) 00429 { 00430 name = (char*) field_name_arg; 00431 }
| Item_ident::Item_ident | ( | THD * | thd, | |
| Item_ident * | item | |||
| ) |
Definition at line 436 of file item.cc.
00437 :Item(thd, item), 00438 orig_db_name(item->orig_db_name), 00439 orig_table_name(item->orig_table_name), 00440 orig_field_name(item->orig_field_name), 00441 context(item->context), 00442 db_name(item->db_name), 00443 table_name(item->table_name), 00444 field_name(item->field_name), 00445 alias_name_used(item->alias_name_used), 00446 cached_field_index(item->cached_field_index), 00447 cached_table(item->cached_table), 00448 depended_from(item->depended_from) 00449 {}
| void Item_ident::cleanup | ( | ) | [virtual] |
Reimplemented from Item.
Reimplemented in Item_field, Item_ref, and Item_trigger_field.
Definition at line 451 of file item.cc.
References Item::cleanup(), db_name, DBUG_ENTER, DBUG_VOID_RETURN, depended_from, field_name, orig_db_name, orig_field_name, orig_table_name, and table_name.
Referenced by Item_ref::cleanup(), and Item_field::cleanup().
00452 { 00453 DBUG_ENTER("Item_ident::cleanup"); 00454 #ifdef CANT_BE_USED_AS_MEMORY_IS_FREED 00455 db_name ? db_name : "(null)", 00456 orig_db_name ? orig_db_name : "(null)", 00457 table_name ? table_name : "(null)", 00458 orig_table_name ? orig_table_name : "(null)", 00459 field_name ? field_name : "(null)", 00460 orig_field_name ? orig_field_name : "(null)")); 00461 #endif 00462 Item::cleanup(); 00463 db_name= orig_db_name; 00464 table_name= orig_table_name; 00465 field_name= orig_field_name; 00466 depended_from= 0; 00467 DBUG_VOID_RETURN; 00468 }
Here is the call graph for this function:

Here is the caller graph for this function:

| const char * Item_ident::full_name | ( | ) | const [virtual] |
Reimplemented from Item.
Definition at line 1630 of file item.cc.
References db_name, field_name, Item::name, NullS, sql_alloc(), strlen(), strxmov(), and table_name.
Referenced by find_field_in_tables(), Item_field::fix_outer_field(), and resolve_ref_in_select_and_group().
01631 { 01632 char *tmp; 01633 if (!table_name || !field_name) 01634 return field_name ? field_name : name ? name : "tmp_field"; 01635 if (db_name && db_name[0]) 01636 { 01637 tmp=(char*) sql_alloc((uint) strlen(db_name)+(uint) strlen(table_name)+ 01638 (uint) strlen(field_name)+3); 01639 strxmov(tmp,db_name,".",table_name,".",field_name,NullS); 01640 } 01641 else 01642 { 01643 if (table_name[0]) 01644 { 01645 tmp= (char*) sql_alloc((uint) strlen(table_name) + 01646 (uint) strlen(field_name) + 2); 01647 strxmov(tmp, table_name, ".", field_name, NullS); 01648 } 01649 else 01650 tmp= (char*) field_name; 01651 } 01652 return tmp; 01653 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Item_ident::print | ( | String * | str | ) | [virtual] |
Reimplemented from Item.
Reimplemented in Item_ref, Item_ref_null_helper, Item_default_value, Item_insert_value, and Item_trigger_field.
Definition at line 1655 of file item.cc.
References alias_name_used, String::append(), append_identifier(), st_table_list::belong_to_view, cached_table, st_table_list::compact_view_format, current_thd, db_name, field_name, files_charset_info, lower_case_table_names, MAX_ALIAS_NAME, my_casedn_str, Item::name, strlen(), strmov(), and table_name.
Referenced by Item_ref::print().
01656 { 01657 THD *thd= current_thd; 01658 char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME]; 01659 const char *d_name= db_name, *t_name= table_name; 01660 if (lower_case_table_names== 1 || 01661 (lower_case_table_names == 2 && !alias_name_used)) 01662 { 01663 if (table_name && table_name[0]) 01664 { 01665 strmov(t_name_buff, table_name); 01666 my_casedn_str(files_charset_info, t_name_buff); 01667 t_name= t_name_buff; 01668 } 01669 if (db_name && db_name[0]) 01670 { 01671 strmov(d_name_buff, db_name); 01672 my_casedn_str(files_charset_info, d_name_buff); 01673 d_name= d_name_buff; 01674 } 01675 } 01676 01677 if (!table_name || !field_name) 01678 { 01679 const char *nm= field_name ? field_name : name ? name : "tmp_field"; 01680 append_identifier(thd, str, nm, (uint) strlen(nm)); 01681 return; 01682 } 01683 if (db_name && db_name[0] && !alias_name_used) 01684 { 01685 if (!(cached_table && cached_table->belong_to_view && 01686 cached_table->belong_to_view->compact_view_format)) 01687 { 01688 append_identifier(thd, str, d_name, (uint)strlen(d_name)); 01689 str->append('.'); 01690 } 01691 append_identifier(thd, str, t_name, (uint)strlen(t_name)); 01692 str->append('.'); 01693 append_identifier(thd, str, field_name, (uint)strlen(field_name)); 01694 } 01695 else 01696 { 01697 if (table_name[0]) 01698 { 01699 append_identifier(thd, str, t_name, (uint) strlen(t_name)); 01700 str->append('.'); 01701 append_identifier(thd, str, field_name, (uint) strlen(field_name)); 01702 } 01703 else 01704 append_identifier(thd, str, field_name, (uint) strlen(field_name)); 01705 } 01706 }
Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from Item.
Definition at line 470 of file item.cc.
References DBUG_ENTER, DBUG_RETURN, and depended_from.
00471 { 00472 DBUG_ENTER("Item_ident::remove_dependence_processor"); 00473 if (depended_from == (st_select_lex *) arg) 00474 depended_from= 0; 00475 DBUG_RETURN(0); 00476 }
| bool insert_fields | ( | THD * | thd, | |
| Name_resolution_context * | context, | |||
| const char * | db_name, | |||
| const char * | table_name, | |||
| List_iterator< Item > * | it, | |||
| bool | any_privileges | |||
| ) | [friend] |
Definition at line 5567 of file sql_base.cc.
05570 { 05571 Field_iterator_table_ref field_iterator; 05572 bool found; 05573 char name_buff[NAME_LEN+1]; 05574 DBUG_ENTER("insert_fields"); 05575 DBUG_PRINT("arena", ("stmt arena: 0x%lx", (ulong)thd->stmt_arena)); 05576 05577 if (db_name && lower_case_table_names) 05578 { 05579 /* 05580 convert database to lower case for comparison 05581 We can't do this in Item_field as this would change the 05582 'name' of the item which may be used in the select list 05583 */ 05584 strmake(name_buff, db_name, sizeof(name_buff)-1); 05585 my_casedn_str(files_charset_info, name_buff); 05586 db_name= name_buff; 05587 } 05588 05589 found= FALSE; 05590 05591 /* 05592 If table names are qualified, then loop over all tables used in the query, 05593 else treat natural joins as leaves and do not iterate over their underlying 05594 tables. 05595 */ 05596 for (TABLE_LIST *tables= (table_name ? context->table_list : 05597 context->first_name_resolution_table); 05598 tables; 05599 tables= (table_name ? tables->next_local : 05600 tables->next_name_resolution_table) 05601 ) 05602 { 05603 Field *field; 05604 TABLE *table= tables->table; 05605 05606 DBUG_ASSERT(tables->is_leaf_for_name_resolution()); 05607 05608 if (table_name && my_strcasecmp(table_alias_charset, table_name, 05609 tables->alias) || 05610 (db_name && strcmp(tables->db,db_name))) 05611 continue; 05612 05613 #ifndef NO_EMBEDDED_ACCESS_CHECKS 05614 /* Ensure that we have access rights to all fields to be inserted. */ 05615 if (!((table && (table->grant.privilege & SELECT_ACL) || 05616 tables->view && (tables->grant.privilege & SELECT_ACL))) && 05617 !any_privileges) 05618 { 05619 field_iterator.set(tables); 05620 if (check_grant_all_columns(thd, SELECT_ACL, field_iterator.grant(), 05621 field_iterator.db_name(), 05622 field_iterator.table_name(), 05623 &field_iterator)) 05624 DBUG_RETURN(TRUE); 05625 } 05626 #endif 05627 05628 /* 05629 Update the tables used in the query based on the referenced fields. For 05630 views and natural joins this update is performed inside the loop below. 05631 */ 05632 if (table) 05633 thd->used_tables|= table->map; 05634 05635 /* 05636 Initialize a generic field iterator for the current table reference. 05637 Notice that it is guaranteed that this iterator will iterate over the 05638 fields of a single table reference, because 'tables' is a leaf (for 05639 name resolution purposes). 05640 */ 05641 field_iterator.set(tables); 05642 05643 for (; !field_iterator.end_of_fields(); field_iterator.next()) 05644 { 05645 Item *item; 05646 05647 if (!(item= field_iterator.create_item(thd))) 05648 DBUG_RETURN(TRUE); 05649 05650 if (!found) 05651 { 05652 found= TRUE; 05653 it->replace(item); /* Replace '*' with the first found item. */ 05654 } 05655 else 05656 it->after(item); /* Add 'item' to the SELECT list. */ 05657 05658 #ifndef NO_EMBEDDED_ACCESS_CHECKS 05659 /* 05660 Set privilege information for the fields of newly created views. 05661 We have that (any_priviliges == TRUE) if and only if we are creating 05662 a view. In the time of view creation we can't use the MERGE algorithm, 05663 therefore if 'tables' is itself a view, it is represented by a 05664 temporary table. Thus in this case we can be sure that 'item' is an 05665 Item_field. 05666 */ 05667 if (any_privileges) 05668 { 05669 DBUG_ASSERT(tables->field_translation == NULL && table || 05670 tables->is_natural_join); 05671 DBUG_ASSERT(item->type() == Item::FIELD_ITEM); 05672 Item_field *fld= (Item_field*) item; 05673 const char *field_table_name= field_iterator.table_name(); 05674 05675 if (!tables->schema_table && 05676 !(fld->have_privileges= 05677 (get_column_grant(thd, field_iterator.grant(), 05678 field_iterator.db_name(), 05679 field_table_name, fld->field_name) & 05680 VIEW_ANY_ACL))) 05681 { 05682 my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0), "ANY", 05683 thd->security_ctx->priv_user, 05684 thd->security_ctx->host_or_ip, 05685 fld->field_name, field_table_name); 05686 DBUG_RETURN(TRUE); 05687 } 05688 } 05689 #endif 05690 05691 if ((field= field_iterator.field())) 05692 { 05693 /* Mark fields as used to allow storage engine to optimze access */ 05694 bitmap_set_bit(field->table->read_set, field->field_index); 05695 if (table) 05696 { 05697 table->used_keys.intersect(field->part_of_key); 05698 table->merge_keys.merge(field->part_of_key); 05699 } 05700 if (tables->is_natural_join) 05701 { 05702 TABLE *field_table; 05703 /* 05704 In this case we are sure that the column ref will not be created 05705 because it was already created and stored with the natural join. 05706 */ 05707 Natural_join_column *nj_col; 05708 if (!(nj_col= field_iterator.get_natural_column_ref())) 05709 DBUG_RETURN(TRUE); 05710 DBUG_ASSERT(nj_col->table_field); 05711 field_table= nj_col->table_ref->table; 05712 if (field_table) 05713 { 05714 thd->used_tables|= field_table->map; 05715 field_table->used_keys.intersect(field->part_of_key); 05716 field_table->merge_keys.merge(field->part_of_key); 05717 field_table->used_fields++; 05718 } 05719 } 05720 } 05721 else 05722 thd->used_tables|= item->used_tables(); 05723 } 05724 /* 05725 In case of stored tables, all fields are considered as used, 05726 while in the case of views, the fields considered as used are the 05727 ones marked in setup_tables during fix_fields of view columns. 05728 For NATURAL joins, used_tables is updated in the IF above. 05729 */ 05730 if (table) 05731 table->used_fields= table->s->fields; 05732 } 05733 if (found) 05734 DBUG_RETURN(FALSE); 05735 05736 /* 05737 TODO: in the case when we skipped all columns because there was a 05738 qualified '*', and all columns were coalesced, we have to give a more 05739 meaningful message than ER_BAD_TABLE_ERROR. 05740 */ 05741 if (!table_name) 05742 my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0)); 05743 else 05744 my_error(ER_BAD_TABLE_ERROR, MYF(0), table_name); 05745 05746 DBUG_RETURN(TRUE); 05747 }
Definition at line 1180 of file item.h.
Referenced by Item_ref::print(), print(), Item_field::set_field(), and Item_ref::set_properties().
Definition at line 1192 of file item.h.
Referenced by find_field_in_tables(), Item_ref::fix_fields(), Item_field::fix_fields(), Item_field::fix_outer_field(), print(), and Item_default_value::save_in_field().
Definition at line 1176 of file item.h.
Referenced by change_context_processor(), Item_insert_value::fix_fields(), Item_default_value::fix_fields(), Item_ref::fix_fields(), Item_field::fix_fields(), Item_field::fix_outer_field(), Item_default_value::save_in_field(), and set_new_item_local_context().
| const char* Item_ident::db_name |
Definition at line 1177 of file item.h.
Referenced by cleanup(), Item_field::eq(), find_field_in_group_list(), find_field_in_tables(), full_name(), Item_field::Item_field(), Item_ref::make_field(), mark_as_dependent(), print(), and Item_field::set_field().
| st_select_lex* Item_ident::depended_from |
Definition at line 1193 of file item.h.
Referenced by cleanup(), mark_as_dependent(), remove_dependence_processor(), Item_ref_null_helper::used_tables(), Item_ref::used_tables(), and Item_field::used_tables().
| const char* Item_ident::field_name |
Definition at line 1179 of file item.h.
Referenced by cleanup(), Item_trigger_field::eq(), Item_field::eq(), find_field_in_group_list(), find_field_in_tables(), Item_trigger_field::fix_fields(), Item_field::fix_fields(), Item_field::fix_outer_field(), full_name(), Item_field::Item_field(), mark_as_dependent(), Item_trigger_field::print(), print(), Item_field::set_field(), and Item_trigger_field::setup_field().
const char* Item_ident::orig_db_name [protected] |
const char* Item_ident::orig_field_name [protected] |
const char* Item_ident::orig_table_name [protected] |
| const char* Item_ident::table_name |
Definition at line 1178 of file item.h.
Referenced by cleanup(), Item_field::eq(), find_field_in_group_list(), find_field_in_tables(), Item_field::fix_outer_field(), full_name(), Item_field::Item_field(), Item_ref::make_field(), mark_as_dependent(), print(), and Item_field::set_field().
1.4.7

