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


Public Member Functions | |
| Item_func_sha (Item *a) | |
| String * | val_str (String *) |
| void | fix_length_and_dec () |
| const char * | func_name () const |
| bool | check_partition_func_processor (byte *bool_arg) |
Definition at line 54 of file item_strfunc.h.
| Item_func_sha::Item_func_sha | ( | Item * | a | ) | [inline] |
| void Item_func_sha::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 204 of file item_strfunc.cc.
References Item_func::args, DTCollation::collation, Item::collation, charset_info_st::csname, DERIVATION_COERCIBLE, get_charset_by_csname(), Item::max_length, MY_CS_BINSORT, MYF, DTCollation::set(), and SHA1_HASH_SIZE.
00205 { 00206 max_length=SHA1_HASH_SIZE*2; // size of hex representation of hash 00207 /* 00208 The SHA() function treats its parameter as being a case sensitive. Thus 00209 we set binary collation on it so different instances of MD5() will be 00210 compared properly. 00211 */ 00212 args[0]->collation.set( 00213 get_charset_by_csname(args[0]->collation.collation->csname, 00214 MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE); 00215 }
Here is the call graph for this function:

| const char* Item_func_sha::func_name | ( | ) | const [inline, virtual] |
Implements Item.
Definition at line 169 of file item_strfunc.cc.
References String::alloc(), Item_func::args, DBUG_ASSERT, Item::fixed, String::length(), mysql_sha1_input(), mysql_sha1_reset(), mysql_sha1_result(), Item::null_value, String::ptr(), SHA1_HASH_SIZE, and Item::val_str().
00170 { 00171 DBUG_ASSERT(fixed == 1); 00172 String * sptr= args[0]->val_str(str); 00173 if (sptr) /* If we got value different from NULL */ 00174 { 00175 SHA1_CONTEXT context; /* Context used to generate SHA1 hash */ 00176 /* Temporary buffer to store 160bit digest */ 00177 uint8 digest[SHA1_HASH_SIZE]; 00178 mysql_sha1_reset(&context); /* We do not have to check for error here */ 00179 /* No need to check error as the only case would be too long message */ 00180 mysql_sha1_input(&context, 00181 (const uchar *) sptr->ptr(), sptr->length()); 00182 /* Ensure that memory is free and we got result */ 00183 if (!( str->alloc(SHA1_HASH_SIZE*2) || 00184 (mysql_sha1_result(&context,digest)))) 00185 { 00186 sprintf((char *) str->ptr(), 00187 "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\ 00188 %02x%02x%02x%02x%02x%02x%02x%02x", 00189 digest[0], digest[1], digest[2], digest[3], 00190 digest[4], digest[5], digest[6], digest[7], 00191 digest[8], digest[9], digest[10], digest[11], 00192 digest[12], digest[13], digest[14], digest[15], 00193 digest[16], digest[17], digest[18], digest[19]); 00194 00195 str->length((uint) SHA1_HASH_SIZE*2); 00196 null_value=0; 00197 return str; 00198 } 00199 } 00200 null_value=1; 00201 return 0; 00202 }
Here is the call graph for this function:

1.4.7

