In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
XLOG Record data for DML
The above sections are described one by one, and the relevant data is viewed by using the hexdump tool.
1 、 XLogRecordBlockHeader
Uint8 id
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 80-n 10000005000 |. | 00000051
The block reference ID is 0x00, that is, Block 0.
Uint8 fork_flags
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 81-n 100000051 20 | 00000052
The value is 0x20, and the highest 4 bits are used for tagging, namely BKPBLOCK_HAS_DATA
Uint16 data_length
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 82-n 200000052 1e00 |.. | 00000054
Payload bytes = 0x001E, the decimal value is 30.
And then there's RelFileNode.
RelFileNode
Tablespace/database/relation, all of which are Oid type (unsigned int)
1.tablespace
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 84-n 400000054 7f 06 0000 | | 00000058
Value is 0x0000067F, decimal value is 1663
Tablespace is 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 400000058 12 400000 |. @.. | 0000005c
Value is 0x00004012, decimal value is 16402, and database is testdb
Testdb=# select * from pg_database where oid=16402 Datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | datminmxid | dattablespace | datacl-+- -+-testdb | 10 | 6 | C | C | f | t |-1 | 13284 | 13284 | 1 | 1663 | (1 row)
3.relation
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 92-n 40000005c 56 42 0000 | VB.. | 00000060
Value is 0x00004256, decimal value is 16982
Testdb=# select oid,relfilenode,relname from pg_class where relfilenode = 16982; oid | relfilenode | relname-+-16982 | 16982 | t_jfxx (1 row)
The corresponding relationship is t_jfxx
BlockNumber
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 96-n 400000060 85 000000 |. | 00000064
The value is 0x00000085, and the decimal value is 133, which is the corresponding block number.
2 、 XLogRecordDataHeaderShort
Next is XLogRecordDataHeaderShort/Long, because the data is less than 256B, using the XLogRecordDataHeaderShort structure
Unit8 id
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 100-n 100000064 ff |. | 00000065
The value is 0xFF-- > XLR_BLOCK_ID_DATA_SHORT 255
Uint8 data_length
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 101-n 10000006503 |. | 00000066
The value of 0x03 is 3 bytes, which refers to the size of main data, and 3 bytes is the size of xl_heap_insert structure.
3 、 block data
XLogRecordDataHeaderShort is followed by block data, which consists of two parts:
1.xl_heap_header
2.Tuple data
Xl_heap_header
1.uint16 t_infomask2
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 102-n 200000066 03 00 |.. | 00000068
The t _ infomask2 value is 0x03 and the binary value is 00000000 00000011
2.uint16 t_infomask
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 104-n 200000068 02 08 |.. | 0000006a
The t _ infomask value is 0x0802 and the binary value is 00001000 00000010
3.uint8 t_hoff
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 106-n 10000006a 18 |. | 0000006b
T _ hoff value (offset) is 0x18, decimal value is 24
Tuple data
The size of XLOG Record is 0x4F, or 79B, minus header data XLogRecord (24B) + XLogRecordBlockHeader (20B) + XLogRecordDataHeaderShort (2B) + xl_heap_header (5B) + main data (3B), leaving 25B
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 107-n 250000006b 0000d 32 30 39 31 39 0f 32 30 31 33 30 37 0000 | 20919.201307..0000007b 000000000000 03 b3 40 | .@ | 000000844, main data
This is the xl_heap_insert structure.
Uint16 OffsetNumber
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 132-n 200000084 26 00 | &. | 00000086
The offset of the inserted tuple is 0x0026, and the decimal is 38
Uint8 flags
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 134-n 10000008600 |. | 00000087
The flag bit is 0x00
II. Reference materials
WAL Internals Of PostgreSQL
PostgreSQL Source Code interpretation (109)-WAL#5 (related data structures)
PostgreSQL DBA (16)-WAL segment file internal structure
Summary on the space occupied by the structure
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.