INNODBSYSTEMRECORDinfimum和supremum的舉例分析

這篇文章主要介紹“INNODB SYSTEM RECORD infimum和supremum的舉例分析”,在日常操作中,相信很多人在INNODB SYSTEM RECORD infimum和supremum的舉例分析問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”INNODB SYSTEM RECORD infimum和supremum的舉例分析”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

成都創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:做網(wǎng)站、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的友誼網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

我們知道在一個C語言中最后一個鏈表的NEXT指針指向的NULL空指針,那么這里SUPREMUM實際就是NULL空指針及0
他們位置固定在塊的94-120字節(jié),其中94-107為infimum 相關(guān)信息,而107到120為supremum相關(guān)信息

info flags              4bits
number of records owned 4bits
order                  13bits
record type             3bits
next record offset      2bytes
"infimum\0"             8bytes (C語言數(shù)組以\0表示結(jié)尾)
以上是infimum固定信息
info flags              4bits
number of records owned 4bits
order                   13bits
record type             3bits
next record offset      2bytes
"supremum"              8bytes
以上是supremum固定信息

我們同樣適用bcview來查看infimum信息,當(dāng)然查看的還是塊3(0開頭實際是第4個塊)
bcview km1.ibd 16 94 16|more

current block:00000003--Offset:00094--cnt bytes:13--data is:0100020041696e66696d756d00
1、info flags
這4位(4bits)標(biāo)示是一個行標(biāo)識,其中binary 0001表示最小的行,其中binary 0010表示是刪除的行,而infimum和supremum行在我測試數(shù)據(jù)庫中為binary 0000
2、number of records owned 
這4位(4bits)表示在本page directory(槽)中的記錄數(shù),關(guān)于槽的概念后面詳細(xì)探討
3、order
這13位(13bits)表示記錄插入到塊中順序,INFIMUM恒等于0而SPREMUM恒等于1,而數(shù)據(jù)行的ORDER從2開始
4、record type
這3位(3bits)表示記錄的類型,supermum恒等于3及binary 011,infimum恒等于2及binary010,節(jié)點指針為1及001,數(shù)據(jù)行為000
5、next record offset 
這2個字節(jié) 在INFIMUM中表示的是第一個行的偏移量這個偏移量是當(dāng)前記錄的位置+offset,這個offset直接指向了數(shù)據(jù)而相關(guān)的行頭在offset-n開始n為行頭的開銷。
當(dāng)然supermum為的偏移量就是NULL空指針了。
6、"infimum\0" OR "supremum" 
這沒什么好解釋的就是實際的ASCII值
我們還是適用我寫工具M(jìn)ySQLblock和bcview進(jìn)行驗證

[root@hadoop1 test]# mysqlblock km1.ibd -d
***************************************************
USEAGE: mysqlblock datafile -t/-d                  
This small tool used in study and test database,not
uesd on online database!                           
This tool is used to find how many blocks and types
in specified datafile,Exp:how many undo block in d 
ata file!                                          
QQ:2238980                                         
***************************************************
-t Only Total blocks types in ibdata!              
-d Blocks types detail  in ibdata!                 
***************************************************
FILE SIZE IS : 98304
current read blocks is : 0 --This Block is file space header blocks!
current read blocks is : 1 --This Block is insert buffer bitmap  blocks!
current read blocks is : 2 --This Block is inode blocks!
current read blocks is : 3 --This Block is data blocks( index pages)!
current read blocks is : 4 --This Block is new allocate blocks!
current read blocks is : 5 --This Block is new allocate blocks!
Total Block Status    :
Total  block                   :     6,Total size is: 0.093750 MB
Total undo block               :     0,Total size is: 0.000000 MB
Total inode block              :     1,Total size is: 0.015625 MB
Total insert buffer free blocks:     0,Total size is: 0.000000 MB
Total data(index pages) block  :     1,Total size is: 0.015625 MB
Total new allocate blocks      :     2,Total size is: 0.031250 MB
Total insert buf bitmap blocks :     1,Total size is: 0.015625 MB
Total system blocks            :     0,Total size is: 0.000000 MB
Total transaction system blocks:     0,Total size is: 0.000000 MB
Total file space header blocks :     1,Total size is: 0.015625 MB
Total extrenl disc blocks      :     0,Total size is: 0.000000 MB
Total LOB blocks               :     0,Total size is: 0.000000 MB
Total Unkown blocks            :     0,Total size is: 0.000000 MB

可以看到
current read blocks is : 3 --This Block is data blocks( index pages)!
就是實際的數(shù)據(jù),因為我這里只有
mysql> select * from km1;
+------+---------+
| id   | name    |
+------+---------+
|    2 | gaopeng |
|    4 | gaopeng |
|    5 | gaopeng |
|    6 | gaopeng |
|    7 | gaopeng |
|    8 | gaopeng |
+------+---------+
6 rows in set (0.04 sec)

6行數(shù)據(jù),并且是上次測試留下了,這些數(shù)據(jù)部分是從用的DELETE的空間,當(dāng)然這也就是說,你的INSERT并不一定在文件中是順序存儲的,
因為delete的空間會被重用。

[root@hadoop1 test]# bcview km1.ibd 16 94 26|more
******************************************************************
This Tool Is Uesed For Find The Data In Binary format(Hexadecimal)
Usage:./bcview file blocksize offset cnt-bytes!                   
file: Is Your File Will To Find Data!                             
blocksize: Is N kb Block.Eg: 8 Is 8 Kb Blocksize(Oracle)!         
                         Eg: 16 Is 16 Kb Blocksize(Innodb)!       
offset:Is Every Block Offset Your Want Start!                                     
cnt-bytes:Is After Offset,How Bytes Your Want Gets!                               
Edtor QQ:22389860!                                                
Used gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)                
******************************************************************
----Current file size is :0.093750 Mb
----Current use set blockszie is 16 Kb
current block:00000000--Offset:00094--cnt bytes:26--data is:00000000ffffffff0000ffffffff000000000000000000030000
current block:00000001--Offset:00094--cnt bytes:26--data is:0000000000000000000000000000000000000000000000000000
current block:00000002--Offset:00094--cnt bytes:26--data is:00000000ffffffff0000ffffffff000005d669d200000003ffff
current block:00000003--Offset:00094--cnt bytes:26--data is:0100020041696e66696d756d0007000b000073757072656d756d
current block:00000004--Offset:00094--cnt bytes:26--data is:0000000000000000000000000000000000000000000000000000
current block:00000005--Offset:00094--cnt bytes:26--data is:0000000000000000000000000000000000000000000000000000

我們只研究數(shù)據(jù)塊current block:00000003的實際數(shù)據(jù)
current block:00000003--Offset:00094--cnt bytes:26--data is:0100020041696e66696d756d0007000b000073757072656d756d
分解一下:

0100020041696e66696d756d00 為infimum的相關(guān)信息
07000b000073757072656d756d 為SPREMUM的相關(guān)信息

1、info flags
4位
0X0 infimum
0X0 supremum
infimum和supremum行在我測試數(shù)據(jù)庫中為binary 0000
2、number of records owned 
4位
0X1 infimum   binary 0001  1行
0X7 supremum  binary 0111  7行
3、order
由于13位不能轉(zhuǎn)化為16進(jìn)制直接給出二進(jìn)制binary
infimum 0X0002 兩字節(jié)0000 0000 0000 0010
supermum 0X000b兩字節(jié)0000 0000 0000 1011 
binary 0000 0000 0000 0 infimum  可以看到確實infimum在這13位上為0
binary 0000 0000 0000 1 supermum 可以看到確實supermum在這13位上為1

4、record type
infimum  3位為binary 010 及10進(jìn)制的2    可以看到確實infimum恒等于2及binary  010
supermum 3位為binary 011 及10進(jìn)制的3    可以看到確實supermum恒等于3及binary 011

5、next record offset
infimum  2個字節(jié)為 0X0041  這里infimum指向了下一個行的指針
supermum 2個字節(jié)為 0X0000  這里supermum為空指針0X0000

那么我們就要看看infimum的指針0X0041是不是指向的數(shù)據(jù)了,
0X0041 十進(jìn)制為65,這個位置是infimum header 結(jié)束位置相對偏移量及99
我們知道int類型為4BYTES而我的數(shù)據(jù)'gaopeng'為7字節(jié)
那么就是11字節(jié)
同時在我們的頁數(shù)據(jù)塊,當(dāng)然我這里就一個塊當(dāng)然也就是頁塊了
他的數(shù)據(jù)結(jié)構(gòu)實際如下:
CLUSTER KEY FIELDS 主鍵字節(jié)數(shù),我這里沒有就是ROWID,6字節(jié)
transaction id     固定6字節(jié)
roll pointer       固定7字節(jié)
Non-key fields     就是數(shù)據(jù)的字節(jié)數(shù),我這里就是11字節(jié)了
那么我們可以算出起始位置為99+65=164 查看的字節(jié)數(shù)為 11+6+6+7=30
注意這里的偏移量為65很顯然,這里不是物理的第一行,order 排序的第一行。order就是插入的順序,原來的第一行被我DELETE掉了,空間重用過了。

bcview km1.ibd 16 164 30|more
current block:00000003--Offset:00164--cnt bytes:30--data is:000001cc64260000002d0272d300000d1201108000000267616f70656e67
分解一下數(shù)據(jù)
000001cc6426   ROWID
0000002d0272   transaction id
d300000d120110 roll pointer
80000002       數(shù)據(jù)2,這里8出現(xiàn)在第15位,可能為符號位
67616f70656e67 數(shù)據(jù)'gaopeng'的ascII值

可以看到?jīng)]有問題,我們找到了他的數(shù)據(jù),由于ROW HEADER是可變的,所以這個指針指向是數(shù)據(jù)的開頭,而不包含行頭
行頭信息需要計算offset后像前面偏移N個字節(jié)開始,當(dāng)然這內(nèi)容以后再討論
關(guān)于行的格式會在以后的文章中給出,這里重要解釋infimum和supermum,

6、"infimum\0"和"supermum"

這個沒什么好說的就是ASCII值
696e66696d756d00="infimum\0"
73757072656d756d="supermum"

最后
這里在做一個測試試一下 bigint UNSIGNED  類型 
首先測試bigint是否為8個字節(jié),同時測試符號位
mysql> create table km15(id   bigint UNSIGNED ,name varchar(20));
Query OK, 0 rows affected (0.15 sec)
mysql> insert into km15 values(10,'gaopeng');
Query OK, 1 row affected (0.02 sec)
同樣不需要主鍵
bcview km15.ibd 16 94 26|more
current block:00000003--Offset:00094--cnt bytes:26--data is:010002001c696e66696d756d0002000b000073757072656d756d
分解數(shù)據(jù)
010002001c696e66696d756d00  infimum
02000b000073757072656d756d  supermum
infimum行的偏移量001c=28
99+28=127   
CLUSTER KEY FIELDS 主鍵字節(jié)數(shù),我這里沒有就是ROWID,6字節(jié)
transaction id     固定6字節(jié)
roll pointer       固定7字節(jié)
Non-key fields     就是數(shù)據(jù)的字節(jié)數(shù),我這里就是8(bigint)+7字節(jié)了=15字節(jié)
bcview km15.ibd 16 127 34|more
current block:00000003--Offset:00127--cnt bytes:34--data is:000001cc680a0000002d0e74e0000080240110000000000000000a67616f70656e67
分解數(shù)據(jù)
000001cc680a
0000002d0e74
e0000080240110
000000000000000a 實際數(shù)據(jù)10
67616f70656e67   數(shù)據(jù)'goapeng'
沒有問題bigint UNSIGNED為8字節(jié)同時沒有了符號位當(dāng)然沒有符號位存儲的數(shù)據(jù)最大也就是2^64 如果有符號當(dāng)然少一位
就是-2^32到2^32 如果有C語言的基礎(chǔ)也就不難理解了。

到此,關(guān)于“INNODB SYSTEM RECORD infimum和supremum的舉例分析”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

分享標(biāo)題:INNODBSYSTEMRECORDinfimum和supremum的舉例分析
文章網(wǎng)址:http://bm7419.com/article26/gegccg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版云服務(wù)器、企業(yè)網(wǎng)站制作、品牌網(wǎng)站制作、全網(wǎng)營銷推廣、App設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)