#include <item_strfunc.h>
Inheritance diagram for Item_func_encrypt:


Public Member Functions | |
| Item_func_encrypt (Item *a) | |
| Item_func_encrypt (Item *a, Item *b) | |
| String * | val_str (String *) |
| void | fix_length_and_dec () |
| const char * | func_name () const |
Private Attributes | |
| String | tmp_value |
Definition at line 333 of file item_strfunc.h.
| Item_func_encrypt::Item_func_encrypt | ( | Item * | a | ) | [inline] |
| void Item_func_encrypt::fix_length_and_dec | ( | ) | [inline, virtual] |
Implements Item_result_field.
Definition at line 340 of file item_strfunc.h.
References Item::max_length, and Item::maybe_null.
00340 { maybe_null=1; max_length = 13; }
| const char* Item_func_encrypt::func_name | ( | ) | const [inline, virtual] |
Implements Item.
Definition at line 1573 of file item_strfunc.cc.
References Item_func::arg_count, Item_func::args, bin_to_ascii, String::c_ptr(), String::charset(), String::copy(), current_thd, DBUG_ASSERT, Item::fixed, String::length(), LOCK_crypt, my_empty_string(), Item::null_value, pthread_mutex_lock, pthread_mutex_unlock, String::set(), strlen(), tmp_value, and Item::val_str().
01574 { 01575 DBUG_ASSERT(fixed == 1); 01576 String *res =args[0]->val_str(str); 01577 01578 #ifdef HAVE_CRYPT 01579 char salt[3],*salt_ptr; 01580 if ((null_value=args[0]->null_value)) 01581 return 0; 01582 if (res->length() == 0) 01583 return &my_empty_string; 01584 01585 if (arg_count == 1) 01586 { // generate random salt 01587 time_t timestamp=current_thd->query_start(); 01588 salt[0] = bin_to_ascii( (ulong) timestamp & 0x3f); 01589 salt[1] = bin_to_ascii(( (ulong) timestamp >> 5) & 0x3f); 01590 salt[2] = 0; 01591 salt_ptr=salt; 01592 } 01593 else 01594 { // obtain salt from the first two bytes 01595 String *salt_str=args[1]->val_str(&tmp_value); 01596 if ((null_value= (args[1]->null_value || salt_str->length() < 2))) 01597 return 0; 01598 salt_ptr= salt_str->c_ptr(); 01599 } 01600 pthread_mutex_lock(&LOCK_crypt); 01601 char *tmp= crypt(res->c_ptr(),salt_ptr); 01602 if (!tmp) 01603 { 01604 pthread_mutex_unlock(&LOCK_crypt); 01605 null_value= 1; 01606 return 0; 01607 } 01608 str->set(tmp,(uint) strlen(tmp),res->charset()); 01609 str->copy(); 01610 pthread_mutex_unlock(&LOCK_crypt); 01611 return str; 01612 #else 01613 null_value=1; 01614 return 0; 01615 #endif /* HAVE_CRYPT */ 01616 }
Here is the call graph for this function:

String Item_func_encrypt::tmp_value [private] |
1.4.7

