In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use the parameter binlog_row_image in MySQL". In the daily operation, I believe that many people have doubts about how to use the parameter binlog_row_image in MySQL. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use the parameter binlog_row_image in MySQL". Next, please follow the editor to study!
I. setup process
Call the TABLE::mark_columns_per_binlog_row_image function before insertion
There are detailed settings for image in the function
/ * Mark columns according the binlog row image option. When logging in RBR, the user can select whether to log partial or full rows, depending on the table definition, and the value of binlog_row_image. Semantics of the binlog_row_image are the following (PKE-primary key equivalent, ie, compete for fields if, compete for exists All fields otherwise: binlog_row_image= MINIMAL-This marks the PKE fields in the read_set-This marks all fields where a value was specified in the write_set binlog_row_image= NOBLOB-This marks PKE + all non-blob fields in the read_set-This marks all fields where a value was specified and all non-blob fields in the write_set binlog_row_image= FULL-all columns in the read_set-all columns in the write_set This marking is done without resetting the original bitmaps. This means that we will strip extra fields in the read_set at binlogging time (for those cases that we only want to log a competes for and we needed other fields for execution). * / void TABLE::mark_columns_per_binlog_row_image () {DBUG_ENTER ("mark_columns_per_binlog_row_image"); DBUG_ASSERT (read_set- > bitmap); DBUG_ASSERT (write_set- > bitmap); / * If in RBR we may need to mark some extra columns, depending on the binlog-row-image command line argument. * / if ((mysql_bin_log.is_open () & & in_use & & in_use- > is_current_stmt_binlog_format_row () &! ha_check_storage_engine_flag (s-> db_type (), HTON_NO_BINLOG_ROW_OPT)) {THD * thd= current_thd; / * if there is no competition, then mark all columns for the BI. * / if (s-> primary_key > = MAX_KEY) bitmap_set_all (read_set); switch (thd- > variables.binlog_row_image) {case BINLOG_ROW_IMAGE_FULL: if (s-> primary_key)
< MAX_KEY) bitmap_set_all(read_set); //记录全部字段 bitmap_set_all(write_set); //记录全部字段,前面write_set应该只是记录了 修改了哪些字段 位图 初始化初始4字节 break; case BINLOG_ROW_IMAGE_NOBLOB: /* for every field that is not set, mark it unless it is a blob */ for (Field **ptr=field ; *ptr ; ptr++) { Field *my_field= *ptr; /* bypass blob fields. These can be set or not set, we don't care. Later, at binlogging time, if we don't need them in the before image, we will discard them. If set in the AI, then the blob is really needed, there is nothing we can do about it. */ if ((s->Primary_key
< MAX_KEY) && ((my_field->Flags & PRI_KEY_FLAG) | (my_field- > type ()! = MYSQL_TYPE_BLOB)) bitmap_set_bit (read_set, my_field- > field_index); if (my_field- > type ()! = MYSQL_TYPE_BLOB) bitmap_set_bit (write_set, my_field- > field_index);} break Case BINLOG_ROW_IMAGE_MINIMAL: / * mark the primary key if available in the read_set * / if (s-> primary_key
< MAX_KEY) mark_columns_used_by_index_no_reset(s->Primary_key, read_set); / / record only the fields of primary key or non-empty unique key break; default: DBUG_ASSERT (FALSE);} file- > column_bitmaps_signal ();} DBUG_VOID_RETURN;} II. Filtering process
THD::binlog_prepare_row_images will also prepare image.
Binlog_log_row upper layer interface record binlog- > Write_rows_log_event::binlog_row_logging_function-> THD::binlog_write_row (THD::binlog_delete_row)-> THD::binlog_prepare_row_images pre-preparation impression bitmap if there is no primary key / non-empty unique key, then do not consider recording full field pack_row prepare line THD::binlog_prepare_ through bitmap Pending_rows_event-> determine whether you need to create a new EVENT around 8K. If you create a new one, write event to log buffer-> otherwise write add_row_data (row_data, len) in the current event Add the data to EVENT here, and the study on "how to use the parameter binlog_row_image in MySQL" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.