真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

PostgreSQLDBA(17)-XLOGRecorddata內(nèi)部結(jié)構(gòu)

PostgreSQL DBA(17) - XLOG Record data內(nèi)部結(jié)構(gòu)
XLOG Record data for DML

下面逐一介紹上述幾個(gè)部分,通過(guò)使用hexdump工具查看相關(guān)數(shù)據(jù)。

十余年的城口網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營(yíng)銷型網(wǎng)站的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整城口建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“城口網(wǎng)站設(shè)計(jì)”,“城口網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

1、XLogRecordBlockHeader

uint8 id

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 80 -n 1
00000050  00                                                |.|
00000051

塊引用ID為0x00,即0號(hào)Block.

uint8 fork_flags

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 81 -n 1
00000051  20                                                | |
00000052

值為0x20,高4位用于標(biāo)記,即BKPBLOCK_HAS_DATA

uint16 data_length

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 82 -n 2
00000052  1e 00                                             |..|
00000054

payload bytes = 0x001E,十進(jìn)制數(shù)值為30.
接下來(lái)是RelFileNode

RelFileNode
tablespace/database/relation,均為Oid類型(unsigned int)
1.tablespace

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 84 -n 4
00000054  7f 06 00 00                                       |....|
00000058

值為0x0000067F,十進(jìn)制值為1663
表空間為default

testdb=# select * from pg_tablespace where oid=1663;
  spcname   | spcowner | spcacl | spcoptions 
------------+----------+--------+------------
 pg_default |       10 |        | 
(1 row)

2.database

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 88 -n 4
00000058  12 40 00 00                                       |.@..|
0000005c

值為0x00004012,十進(jìn)制值為16402,數(shù)據(jù)庫(kù)為testdb

testdb=# select * from pg_database where oid=16402;
 datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfroze
nxid | datminmxid | dattablespace | datacl 
---------+--------+----------+------------+----------+---------------+--------------+--------------+---------------+---------
-----+------------+---------------+--------
 testdb  |     10 |        6 | C          | C        | f             | t            |           -1 |         13284 |         
 561 |          1 |          1663 | 
(1 row)

3.relation

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 92 -n 4
0000005c  56 42 00 00                                       |VB..|
00000060

值為0x00004256,十進(jìn)制值為16982

testdb=# select oid,relfilenode,relname from pg_class where relfilenode = 16982;
  oid  | relfilenode | relname 
-------+-------------+---------
 16982 |       16982 | t_jfxx
(1 row)

相應(yīng)的關(guān)系為t_jfxx

BlockNumber

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 96 -n 4
00000060  85 00 00 00                                       |....|
00000064

值為0x00000085,十進(jìn)制值為133,這是對(duì)應(yīng)的數(shù)據(jù)塊號(hào).

2、XLogRecordDataHeaderShort

接下來(lái)是XLogRecordDataHeaderShort/Long,由于數(shù)據(jù)小于256B,使用XLogRecordDataHeaderShort結(jié)構(gòu)
unit8 id

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 100 -n 1
00000064  ff                                                |.|
00000065

值為0xFF --> XLR_BLOCK_ID_DATA_SHORT 255
uint8 data_length

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 101 -n 1
00000065  03                                                |.|
00000066

值為0x03,3個(gè)字節(jié),指的是main data的大小,3個(gè)字節(jié)是xl_heap_insert結(jié)構(gòu)體的大小.

3、block data

XLogRecordDataHeaderShort之后是block data,由兩部分組成:
1.xl_heap_header
2.Tuple data

xl_heap_header
1.uint16 t_infomask2

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 102 -n 2
00000066  03 00                                             |..|
00000068

t_infomask2值為0x03,二進(jìn)制值為00000000 00000011

2.uint16 t_infomask

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 104 -n 2
00000068  02 08                                             |..|
0000006a

t_infomask值為0x0802,二進(jìn)制值為00001000 00000010

3.uint8 t_hoff

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 106 -n 1
0000006a  18                                                |.|
0000006b

t_hoff值(偏移)為0x18,十進(jìn)制值為24

Tuple data
XLOG Record的大小是0x4F,即79B,減去頭部數(shù)據(jù)XLogRecord(24B) + XLogRecordBlockHeader(20B) + XLogRecordDataHeaderShort(2B) + xl_heap_header(5B) + main data(3B),剩余25B

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 107 -n 25
0000006b  00 0d 32 30 39 31 39 0f  32 30 31 33 30 37 00 00  |..20919.201307..|
0000007b  00 00 00 00 00 00 03 b3  40                       |........@|
00000084
4、main data

這是xl_heap_insert結(jié)構(gòu)體
uint16 OffsetNumber

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 132 -n 2
00000084  26 00                                             |&.|
00000086

插入的tuple的偏移為0x0026,十進(jìn)制為38

uint8 flags

[xdb@localhost pg_wal]$ hexdump -C 000000010000000100000042 -s 134 -n 1
00000086  00                                                |.|
00000087

標(biāo)志位為0x00

二、參考資料

WAL Internals Of PostgreSQL
PostgreSQL 源碼解讀(109)- WAL#5(相關(guān)數(shù)據(jù)結(jié)構(gòu))
PostgreSQL DBA(16) - WAL segment file內(nèi)部結(jié)構(gòu)
關(guān)于結(jié)構(gòu)體占用空間大小總結(jié)


網(wǎng)站名稱:PostgreSQLDBA(17)-XLOGRecorddata內(nèi)部結(jié)構(gòu)
分享鏈接:http://weahome.cn/article/pcccsh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部