Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL:MGR Learning (2): the writing process of Write set (write set)

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

< iterator; i++) { uchar buff[BUFFER_READ_PKE]; int8store(buff, set->

Write_ set [I]); / / copy byte by byte to buffer uint64 const tmp_str_sz= base64_needed_encoded_length ((uint64) BUFFER_READ_PKE); char * write_set_value= (char *) my_malloc (PSI_NOT_INSTRUMENTED, static_cast (tmp_str_sz), MYF (MY_WME)) / / 13bytes (gdb) p tmp_str_sz $2 = 13 if (! write_set_value) / / memory allocation error {/ * purecov: begin inspected * / log_message (MY_ERROR_LEVEL, "No memory to generate write identification hash"); DBUG_RETURN (1) / * purecov: end * /} if (base64_encode (buff, (size_t) BUFFER_READ_PKE, write_set_value) / / do base64 algorithm {/ * purecov: begin inspected * / log_message (MY_ERROR_LEVEL, "Base64 encoding of the write identification hash failed"); DBUG_RETURN (1) / * purecov: end * /} tcle- > add_write_set (write_set_value); / / finally write write set in base64 format to event} DBUG_RETURN (0);} 3. Get_transaction_write_set function Transaction_write_set* get_transaction_write_set (unsigned long m_thread_id) {DBUG_ENTER ("get_transaction_write_set"); THD * thd= NULL; Transaction_write_set* result_set= NULL Find_thd_with_id find_thd_with_id (m_thread_id, false); thd= Global_THD_manager::get_instance ()-> find_thd (& find_thd_with_id); if (thd) {std::set * write_set= thd- > get_transaction ()-> get_transaction_write_set_ctx ()-> get_write_set (); / / Rpl_transaction_write_set_ctx std::set * get_write_set () Unsigned long write_set_size= write_set- > size (); / / returns the collection size if (write_set_size= = 0) {mysql_mutex_unlock (& thd- > LOCK_thd_data); DBUG_RETURN (NULL) } result_set= (Transaction_write_set*) my_malloc (key_memory_write_set_extraction, sizeof (Transaction_write_set), MYF (0)); / / memory space result_set- > write_set_size= write_set_size is allocated for its Transaction_write_set here / / get size result_set- > write_set= (unsigned long long*) my_malloc (key_memory_write_set_extraction, write_set_size * sizeof (unsigned long long), MYF (0)); / / allocate memory int result_set_index= 0 For (std::set::iterator it= write_set- > begin (); / / copy from set to simple memory it! = write_set- > end (); + + it) {uint64 temp= * it; result_set- > write_ set [result _ set_index++] = temp;} mysql_mutex_unlock (& thd- > LOCK_thd_data);} DBUG_RETURN (result_set);}

Author Wechat:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report