Conference Schedule - PGConf NYC 2022
How to create an hacking toolkit thanks to the pageinspect extension and some linux commands like dd, od…?
Room: The Hub
Feedback: Leave feedback
This session will provide some tools to hack PostgreSQL internals using the well known pageinspect extension and basic linux tools like dd and od.
With shell scripts (no C coding is needed) from the files on “disk” we’ll see how to:
- Read the checksum from a page
- Extract how many tuples (dead or not) are stored in a page
- Read a tuple xmin, xmax, infomask2, infomask
- Get the tuple user data
- Get the whole tuple data (including HeapTupleHeaderData and user data)
This understanding will help us to write shell scripts to:
- be the counterparts of the pageinspect’s page_header, heap_page_items, bt_metap, bt_page_items, bt_page_stats functions to get the same information directly from “disk”
- get the xact status directly from the filesystem files with a shell script.
- get the multixid members directly from the filesystem files with a shell script.
With pageinspect “only” we’ll also see how:
- to link the user table tuples to the toast pages by using user table tuples and toast index data (not querying the toast at all)
- to search for tuples (dead or not) based on attributes values
We’ll see that all of this is possible thanks to PostgreSQL being open source.
That’s nice but why? how is it useful?
That could be useful when working on edge cases when for examples:
- you want to compare pages content from “disk” and memory
- the engine does not start and you want to have a look at some contents on disk