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


Public Member Functions | |
| Item_func_uuid () | |
| void | fix_length_and_dec () |
| const char * | func_name () const |
| String * | val_str (String *) |
Definition at line 841 of file item_strfunc.h.
| Item_func_uuid::Item_func_uuid | ( | ) | [inline] |
| void Item_func_uuid::fix_length_and_dec | ( | ) | [inline, virtual] |
Implements Item_result_field.
Definition at line 845 of file item_strfunc.h.
References Item::collation, Item::max_length, charset_info_st::mbmaxlen, DTCollation::set(), system_charset_info, and UUID_LENGTH.
00845 { 00846 collation.set(system_charset_info); 00847 /* 00848 NOTE! uuid() should be changed to use 'ascii' 00849 charset when hex(), format(), md5(), etc, and implicit 00850 number-to-string conversion will use 'ascii' 00851 */ 00852 max_length= UUID_LENGTH * system_charset_info->mbmaxlen; 00853 }
Here is the call graph for this function:

| const char* Item_func_uuid::func_name | ( | ) | const [inline, virtual] |
Implements Item.
Definition at line 3064 of file item_strfunc.cc.
References _dig_vec_lower, current_thd, DBUG_ASSERT, Item::fixed, int(), String::length(), LOCK_uuid_generator, my_gethwaddr(), my_getsystime(), my_rnd(), pthread_mutex_lock, pthread_mutex_unlock, String::ptr(), query_id, randominit(), String::realloc(), String::set_charset(), set_clock_seq_str(), start_time, strmov(), system_charset_info, tohex(), unlikely, UUID_LENGTH, uuid_rand, UUID_TIME_OFFSET, and UUID_VERSION.
03065 { 03066 DBUG_ASSERT(fixed == 1); 03067 char *s; 03068 THD *thd= current_thd; 03069 03070 pthread_mutex_lock(&LOCK_uuid_generator); 03071 if (! uuid_time) /* first UUID() call. initializing data */ 03072 { 03073 ulong tmp=sql_rnd_with_mutex(); 03074 uchar mac[6]; 03075 int i; 03076 if (my_gethwaddr(mac)) 03077 { 03078 /* 03079 generating random "hardware addr" 03080 and because specs explicitly specify that it should NOT correlate 03081 with a clock_seq value (initialized random below), we use a separate 03082 randominit() here 03083 */ 03084 randominit(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)query_id); 03085 for (i=0; i < (int)sizeof(mac); i++) 03086 mac[i]=(uchar)(my_rnd(&uuid_rand)*255); 03087 } 03088 s=clock_seq_and_node_str+sizeof(clock_seq_and_node_str)-1; 03089 for (i=sizeof(mac)-1 ; i>=0 ; i--) 03090 { 03091 *--s=_dig_vec_lower[mac[i] & 15]; 03092 *--s=_dig_vec_lower[mac[i] >> 4]; 03093 } 03094 randominit(&uuid_rand, tmp + (ulong)start_time, 03095 tmp + thd->status_var.bytes_sent); 03096 set_clock_seq_str(); 03097 } 03098 03099 ulonglong tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq; 03100 if (unlikely(tv < uuid_time)) 03101 set_clock_seq_str(); 03102 else if (unlikely(tv == uuid_time)) 03103 { 03104 /* special protection from low-res system clocks */ 03105 nanoseq++; 03106 tv++; 03107 } 03108 else 03109 { 03110 if (nanoseq) 03111 { 03112 tv-=nanoseq; 03113 nanoseq=0; 03114 } 03115 DBUG_ASSERT(tv > uuid_time); 03116 } 03117 uuid_time=tv; 03118 pthread_mutex_unlock(&LOCK_uuid_generator); 03119 03120 uint32 time_low= (uint32) (tv & 0xFFFFFFFF); 03121 uint16 time_mid= (uint16) ((tv >> 32) & 0xFFFF); 03122 uint16 time_hi_and_version= (uint16) ((tv >> 48) | UUID_VERSION); 03123 03124 str->realloc(UUID_LENGTH+1); 03125 str->length(UUID_LENGTH); 03126 str->set_charset(system_charset_info); 03127 s=(char *) str->ptr(); 03128 s[8]=s[13]='-'; 03129 tohex(s, time_low, 8); 03130 tohex(s+9, time_mid, 4); 03131 tohex(s+14, time_hi_and_version, 4); 03132 strmov(s+18, clock_seq_and_node_str); 03133 return str; 03134 }
Here is the call graph for this function:

1.4.7

