#include <item_func.h>
Inheritance diagram for Item_func_set_user_var:


Public Member Functions | |
| Item_func_set_user_var (LEX_STRING a, Item *b) | |
| double | val_real () |
| longlong | val_int () |
| String * | val_str (String *str) |
| my_decimal * | val_decimal (my_decimal *) |
| bool | update_hash (void *ptr, uint length, enum Item_result type, CHARSET_INFO *cs, Derivation dv, bool unsigned_arg=0) |
| bool | check () |
| bool | update () |
| enum Item_result | result_type () const |
| bool | fix_fields (THD *thd, Item **ref) |
| void | fix_length_and_dec () |
| void | print (String *str) |
| void | print_as_stmt (String *str) |
| const char * | func_name () const |
Public Attributes | |
| LEX_STRING | name |
Private Attributes | |
| enum Item_result | cached_result_type |
| user_var_entry * | entry |
| char | buffer [MAX_FIELD_WIDTH] |
| String | value |
| my_decimal | decimal_buff |
| bool | null_item |
| union { | |
| longlong vint | |
| double vreal | |
| String * vstr | |
| my_decimal * vdec | |
| } | save_result |
Definition at line 1178 of file item_func.h.
| Item_func_set_user_var::Item_func_set_user_var | ( | LEX_STRING | a, | |
| Item * | b | |||
| ) | [inline] |
Definition at line 1196 of file item_func.h.
01197 :Item_func(b), cached_result_type(INT_RESULT), name(a) 01198 {}
| bool Item_func_set_user_var::check | ( | ) |
Definition at line 3744 of file item_func.cc.
References Item_func::args, cached_result_type, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, decimal_buff, DECIMAL_RESULT, FALSE, INT_RESULT, REAL_RESULT, ROW_RESULT, save_result, STRING_RESULT, Item::unsigned_flag, Item::val_decimal(), Item::val_int(), Item::val_real(), and Item::val_str().
Referenced by set_var_user::check(), Item_func_get_user_var::set_value(), val_decimal(), val_int(), val_real(), and val_str().
03745 { 03746 DBUG_ENTER("Item_func_set_user_var::check"); 03747 03748 switch (cached_result_type) { 03749 case REAL_RESULT: 03750 { 03751 save_result.vreal= args[0]->val_real(); 03752 break; 03753 } 03754 case INT_RESULT: 03755 { 03756 save_result.vint= args[0]->val_int(); 03757 unsigned_flag= args[0]->unsigned_flag; 03758 break; 03759 } 03760 case STRING_RESULT: 03761 { 03762 save_result.vstr= args[0]->val_str(&value); 03763 break; 03764 } 03765 case DECIMAL_RESULT: 03766 { 03767 save_result.vdec= args[0]->val_decimal(&decimal_buff); 03768 break; 03769 } 03770 case ROW_RESULT: 03771 default: 03772 // This case should never be chosen 03773 DBUG_ASSERT(0); 03774 break; 03775 } 03776 DBUG_RETURN(FALSE); 03777 }
Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from Item_func.
Definition at line 3466 of file item_func.cc.
References Item_func::args, cached_result_type, DTCollation::collation, Item::collation, DBUG_ASSERT, DERIVATION_IMPLICIT, FALSE, Item_func::fix_fields(), Item::fixed, get_variable(), name, Item::NULL_ITEM, null_item, Item::result_type(), DTCollation::set(), TRUE, and Item::type().
Referenced by set_var_user::check(), set_var_user::light_check(), and Item_func_get_user_var::set_value().
03467 { 03468 DBUG_ASSERT(fixed == 0); 03469 /* fix_fields will call Item_func_set_user_var::fix_length_and_dec */ 03470 if (Item_func::fix_fields(thd, ref) || 03471 !(entry= get_variable(&thd->user_vars, name, 1))) 03472 return TRUE; 03473 /* 03474 Remember the last query which updated it, this way a query can later know 03475 if this variable is a constant item in the query (it is if update_query_id 03476 is different from query_id). 03477 */ 03478 entry->update_query_id= thd->query_id; 03479 /* 03480 As it is wrong and confusing to associate any 03481 character set with NULL, @a should be latin2 03482 after this query sequence: 03483 03484 SET @a=_latin2'string'; 03485 SET @a=NULL; 03486 03487 I.e. the second query should not change the charset 03488 to the current default value, but should keep the 03489 original value assigned during the first query. 03490 In order to do it, we don't copy charset 03491 from the argument if the argument is NULL 03492 and the variable has previously been initialized. 03493 */ 03494 null_item= (args[0]->type() == NULL_ITEM); 03495 if (!entry->collation.collation || !null_item) 03496 entry->collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT); 03497 collation.set(entry->collation.collation, DERIVATION_IMPLICIT); 03498 cached_result_type= args[0]->result_type(); 03499 return FALSE; 03500 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Item_func_set_user_var::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 3504 of file item_func.cc.
References Item_func::args, DTCollation::collation, Item::collation, Item::decimals, DERIVATION_IMPLICIT, Item::max_length, Item::maybe_null, and DTCollation::set().
03505 { 03506 maybe_null=args[0]->maybe_null; 03507 max_length=args[0]->max_length; 03508 decimals=args[0]->decimals; 03509 collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT); 03510 }
Here is the call graph for this function:

| const char* Item_func_set_user_var::func_name | ( | ) | const [inline, virtual] |
| void Item_func_set_user_var::print | ( | String * | str | ) | [virtual] |
Reimplemented from Item_func.
Definition at line 3884 of file item_func.cc.
References String::append(), Item_func::args, LEX_STRING::length, name, Item::print(), LEX_STRING::str, and STRING_WITH_LEN.
03885 { 03886 str->append(STRING_WITH_LEN("(@")); 03887 str->append(name.str, name.length); 03888 str->append(STRING_WITH_LEN(":=")); 03889 args[0]->print(str); 03890 str->append(')'); 03891 }
Here is the call graph for this function:

| void Item_func_set_user_var::print_as_stmt | ( | String * | str | ) |
Definition at line 3894 of file item_func.cc.
References String::append(), Item_func::args, LEX_STRING::length, name, Item::print(), LEX_STRING::str, and STRING_WITH_LEN.
03895 { 03896 str->append(STRING_WITH_LEN("set @")); 03897 str->append(name.str, name.length); 03898 str->append(STRING_WITH_LEN(":=")); 03899 args[0]->print(str); 03900 str->append(')'); 03901 }
Here is the call graph for this function:

| enum Item_result Item_func_set_user_var::result_type | ( | ) | const [inline, virtual] |
Reimplemented from Item.
Definition at line 1207 of file item_func.h.
References cached_result_type.
01207 { return cached_result_type; }
| bool Item_func_set_user_var::update | ( | ) |
Definition at line 3797 of file item_func.cc.
References cached_result_type, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, DECIMAL_RESULT, DERIVATION_IMPLICIT, INT_RESULT, LINT_INIT, REAL_RESULT, ROW_RESULT, save_result, STRING_RESULT, Item::unsigned_flag, and update_hash().
Referenced by Item_func_get_user_var::set_value(), set_var_user::update(), val_decimal(), val_int(), val_real(), and val_str().
03798 { 03799 bool res; 03800 DBUG_ENTER("Item_func_set_user_var::update"); 03801 LINT_INIT(res); 03802 03803 switch (cached_result_type) { 03804 case REAL_RESULT: 03805 { 03806 res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal), 03807 REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT); 03808 break; 03809 } 03810 case INT_RESULT: 03811 { 03812 res= update_hash((void*) &save_result.vint, sizeof(save_result.vint), 03813 INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 03814 unsigned_flag); 03815 break; 03816 } 03817 case STRING_RESULT: 03818 { 03819 if (!save_result.vstr) // Null value 03820 res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, 03821 DERIVATION_IMPLICIT); 03822 else 03823 res= update_hash((void*) save_result.vstr->ptr(), 03824 save_result.vstr->length(), STRING_RESULT, 03825 save_result.vstr->charset(), 03826 DERIVATION_IMPLICIT); 03827 break; 03828 } 03829 case DECIMAL_RESULT: 03830 { 03831 if (!save_result.vdec) // Null value 03832 res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin, 03833 DERIVATION_IMPLICIT); 03834 else 03835 res= update_hash((void*) save_result.vdec, 03836 sizeof(my_decimal), DECIMAL_RESULT, 03837 &my_charset_bin, DERIVATION_IMPLICIT); 03838 break; 03839 } 03840 case ROW_RESULT: 03841 default: 03842 // This case should never be chosen 03843 DBUG_ASSERT(0); 03844 break; 03845 } 03846 DBUG_RETURN(res); 03847 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Item_func_set_user_var::update_hash | ( | void * | ptr, | |
| uint | length, | |||
| enum Item_result | type, | |||
| CHARSET_INFO * | cs, | |||
| Derivation | dv, | |||
| bool | unsigned_arg = 0 | |||
| ) |
Definition at line 3590 of file item_func.cc.
References Item_func::args, current_thd, and null_item.
Referenced by update().
03593 { 03594 /* 03595 If we set a variable explicitely to NULL then keep the old 03596 result type of the variable 03597 */ 03598 if ((null_value= args[0]->null_value) && null_item) 03599 type= entry->type; // Don't change type of item 03600 if (::update_hash(entry, (null_value= args[0]->null_value), 03601 ptr, length, type, cs, dv, unsigned_arg)) 03602 { 03603 current_thd->fatal_error(); // Probably end of memory 03604 null_value= 1; 03605 return 1; 03606 } 03607 return 0; 03608 }
Here is the caller graph for this function:

| my_decimal * Item_func_set_user_var::val_decimal | ( | my_decimal * | ) | [virtual] |
Reimplemented from Item_func.
Definition at line 3875 of file item_func.cc.
References check(), DBUG_ASSERT, Item::fixed, and update().
03876 { 03877 DBUG_ASSERT(fixed == 1); 03878 check(); 03879 update(); // Store expression 03880 return entry->val_decimal(&null_value, val); 03881 }
Here is the call graph for this function:

| longlong Item_func_set_user_var::val_int | ( | ) | [virtual] |
Implements Item.
Definition at line 3858 of file item_func.cc.
References check(), DBUG_ASSERT, Item::fixed, and update().
03859 { 03860 DBUG_ASSERT(fixed == 1); 03861 check(); 03862 update(); // Store expression 03863 return entry->val_int(&null_value); 03864 }
Here is the call graph for this function:

| double Item_func_set_user_var::val_real | ( | ) | [virtual] |
Implements Item.
Definition at line 3850 of file item_func.cc.
References check(), DBUG_ASSERT, Item::fixed, and update().
03851 { 03852 DBUG_ASSERT(fixed == 1); 03853 check(); 03854 update(); // Store expression 03855 return entry->val_real(&null_value); 03856 }
Here is the call graph for this function:

Implements Item.
Definition at line 3866 of file item_func.cc.
References check(), DBUG_ASSERT, Item::fixed, and update().
03867 { 03868 DBUG_ASSERT(fixed == 1); 03869 check(); 03870 update(); // Store expression 03871 return entry->val_str(&null_value, str, decimals); 03872 }
Here is the call graph for this function:

char Item_func_set_user_var::buffer[MAX_FIELD_WIDTH] [private] |
Definition at line 1182 of file item_func.h.
enum Item_result Item_func_set_user_var::cached_result_type [private] |
Definition at line 1180 of file item_func.h.
Referenced by check(), fix_fields(), result_type(), and update().
user_var_entry* Item_func_set_user_var::entry [private] |
Definition at line 1181 of file item_func.h.
Reimplemented from Item.
Definition at line 1195 of file item_func.h.
Referenced by fix_fields(), print(), and print_as_stmt().
bool Item_func_set_user_var::null_item [private] |
union { ... } Item_func_set_user_var::save_result [private] |
String Item_func_set_user_var::value [private] |
Definition at line 1183 of file item_func.h.
my_decimal* Item_func_set_user_var::vdec [private] |
Definition at line 1191 of file item_func.h.
longlong Item_func_set_user_var::vint [private] |
Definition at line 1188 of file item_func.h.
double Item_func_set_user_var::vreal [private] |
Definition at line 1189 of file item_func.h.
String* Item_func_set_user_var::vstr [private] |
Definition at line 1190 of file item_func.h.
1.4.7

