国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

mysql中ut_d宏定義用法

2024-07-24 12:59:47
字體:
供稿:網(wǎng)友

源碼摘抄

   #ifdef UNIV_DEBUG/** Debug assertion. Does nothing unless UNIV_DEBUG is defined. */#define ut_ad(EXPR)    ut_a(EXPR)/** Debug statement. Does nothing unless UNIV_DEBUG is defined. */#define ut_d(EXPR)    do {EXPR;} while (0)#else/** Debug assertion. Does nothing unless UNIV_DEBUG is defined. */#define ut_ad(EXPR)/** Debug statement. Does nothing unless UNIV_DEBUG is defined. */#define ut_d(EXPR)#endif

上述代碼涉及到define 宏定義用法 如下:

define function(x)   do{}  while()

我們常見的一種是 define N  100 定義常量 。

看上面用法:

#define ut_d(EXPR)    do {EXPR;} while (0) 

 while (0)  為false,只執(zhí)行一次 do 。如果while里值大于0,那么條件為真,將一直執(zhí)行 do ,除非在里面添加break 跳出。

參考這篇文章do{...}while(0)的意義和用法看到這篇文章真是茅塞頓開。

再回到源碼。 ifdef   univ_DEBUG   如果執(zhí)行了debug 將執(zhí)行下面的  else 執(zhí)行下面的  endif 。  ifdef ..... else ......  endif 結(jié)構(gòu)

下面摘抄一段 MySQL 源碼中調(diào)用的 lock0lock.c :: lock_clust_rec_cons_read_sees()函數(shù)

/*********************************************************************//**Checks that a record is seen in a consistent read.@return TRUE if sees, or FALSE if an earlier version of the recordshould be retrieved */UNIV_INTERNiboollock_clust_rec_cons_read_sees(/*==========================*/    const rec_t*    rec,    /*!< in: user record which should be read or                passed over by a read cursor */    dict_index_t*    index,    /*!< in: clustered index */    const ulint*    offsets,/*!< in: rec_get_offsets(rec, index) */    read_view_t*    view)    /*!< in: consistent read view */{    trx_id_t    trx_id;    ut_ad(dict_index_is_clust(index));      //  只在debug模式下才會執(zhí)行一次    ut_ad(page_rec_is_user_rec(rec));    // 只在debug模式下才會執(zhí)行一次    ut_ad(rec_offs_validate(rec, index, offsets));   //只在debug模式下才會執(zhí)行一次    /* NOTE that we call this function while holding the search    system latch. To obey the latching order we must NOT reserve the    kernel mutex here! */    trx_id = row_get_rec_trx_id(rec, index, offsets);    return(read_view_sees_trx_id(view, trx_id));}

 mysql好多ut_ad()這種斷言調(diào)用,這次終于搞明白了。    


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 泌阳县| 卫辉市| 江城| 贵南县| 自治县| 获嘉县| 滦平县| 唐海县| 吉林省| 铅山县| 张家川| 九龙坡区| 奉节县| 吴江市| 旬阳县| 曲水县| 全椒县| 高陵县| 淮南市| 东乌珠穆沁旗| 扎赉特旗| 岳阳县| 漾濞| 肇庆市| 宁国市| 永川市| 固阳县| 醴陵市| 峡江县| 什邡市| 留坝县| 长寿区| 武山县| 灵台县| 仁化县| 民勤县| 休宁县| 赤水市| 石门县| 岳阳县| 平谷区|