久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

怎么使用MySQL中的參數(shù)binlog

共計(jì) 3475 個(gè)字符,預(yù)計(jì)需要花費(fèi) 9 分鐘才能閱讀完成。

這篇文章主要介紹“怎么使用 MySQL 中的參數(shù) binlog_row_image”,在日常操作中,相信很多人在怎么使用 MySQL 中的參數(shù) binlog_row_image 問(wèn)題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”怎么使用 MySQL 中的參數(shù) binlog_row_image”的疑惑有所幫助!接下來(lái),請(qǐng)跟著丸趣 TV 小編一起來(lái)學(xué)習(xí)吧!

一、設(shè)置過(guò)程

插入前先調(diào)用 TABLE::mark_columns_per_binlog_row_image 函數(shù)
函數(shù)中有 image 的詳細(xì)設(shè)置

/*
 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, PK fields if PK 
 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 PK 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 PK, 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 應(yīng)該只是記錄了   修改了哪些字段   位圖   初始化初始 4 字節(jié)
 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); // 只記錄主鍵或者非空唯一鍵的   字段
 break;
 default: 
 DBUG_ASSERT(FALSE);
 }
 file- column_bitmaps_signal();
 }
 DBUG_VOID_RETURN;
}

二、過(guò)濾過(guò)程

THD::binlog_prepare_row_images 還會(huì)準(zhǔn)備 image

binlog_log_row  上層接口   記錄  binlog
-  Write_rows_log_event::binlog_row_logging_function 
 -  THD::binlog_write_row(THD::binlog_delete_row)
 - THD::binlog_prepare_row_images  準(zhǔn)備前印象位圖   如果沒(méi)有主鍵 / 非空唯一鍵   則不考慮記錄全字段
 pack_row  通過(guò)位圖準(zhǔn)備好行
 THD::binlog_prepare_pending_rows_event 
 -   判斷是否需要新建一個(gè) EVENT  大約 8K 左右,  如果新建   新建后寫(xiě) event 到  log buffer
 - 否則在當(dāng)前 event 中寫(xiě)入  
 add_row_data(row_data, len);  將數(shù)據(jù)加入到 EVENT

到此,關(guān)于“怎么使用 MySQL 中的參數(shù) binlog_row_image”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-26發(fā)表,共計(jì)3475字。
轉(zhuǎn)載說(shuō)明:除特殊說(shuō)明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒(méi)有評(píng)論)
主站蜘蛛池模板: 渭源县| 灵宝市| 华阴市| 措勤县| 武汉市| 巩留县| 南阳市| 宁安市| 肇庆市| 全椒县| 辽阳县| 邯郸市| 商城县| 崇信县| 蒙城县| 百色市| 迁安市| 从江县| 宜川县| 特克斯县| 蒙阴县| 翼城县| 罗田县| 安多县| 三原县| 孟连| 左贡县| 元谋县| 阆中市| 嘉峪关市| 华池县| 潢川县| 怀安县| 正定县| 景东| 乐平市| 宽甸| 双峰县| 沧州市| 漠河县| 永川市|