|
| 1 | +The functions in this module allow you to inspect the contents of data pages |
| 2 | +at a low level, for debugging purposes. |
| 3 | + |
| 4 | +1. Installation |
| 5 | + |
| 6 | + $ make |
| 7 | + $ make install |
| 8 | + $ psql -e -f /usr/local/pgsql/share/contrib/pageinspect.sql test |
| 9 | + |
| 10 | +2. Functions included: |
| 11 | + |
| 12 | + get_raw_page |
| 13 | + ------------ |
| 14 | + get_raw_page reads one block of the named table and returns a copy as a |
| 15 | + bytea field. This allows a single time-consistent copy of the block to be |
| 16 | + made. Use of this functions is restricted to superusers. |
| 17 | + |
| 18 | + page_header |
| 19 | + ----------- |
| 20 | + page_header shows fields which are common to all PostgreSQL heap and index |
| 21 | + pages. Use of this function is restricted to superusers. |
| 22 | + |
| 23 | + A page image obtained with get_raw_page should be passed as argument: |
| 24 | + |
| 25 | + test=# SELECT * FROM page_header(get_raw_page('pg_class',0)); |
| 26 | + lsn | tli | flags | lower | upper | special | pagesize | version |
| 27 | + ----------+-----+-------+-------+-------+---------+----------+--------- |
| 28 | + 0/3C5614 | 1 | 1 | 216 | 256 | 8192 | 8192 | 4 |
| 29 | + (1 row) |
| 30 | + |
| 31 | + The returned columns correspond to the fields in the PageHeaderData-struct, |
| 32 | + see src/include/storage/bufpage.h for more details. |
| 33 | + |
| 34 | + heap_page_items |
| 35 | + --------------- |
| 36 | + heap_page_items shows all line pointers on a heap page. For those line |
| 37 | + pointers that are in use, tuple headers are also shown. All tuples are |
| 38 | + shown, whether or not the tuples were visible to an MVCC snapshot at the |
| 39 | + time the raw page was copied. Use of this function is restricted to |
| 40 | + superusers. |
| 41 | + |
| 42 | + A heap page image obtained with get_raw_page should be passed as argument: |
| 43 | + |
| 44 | + test=# SELECT * FROM heap_page_items(get_raw_page('pg_class',0)); |
| 45 | + |
| 46 | + See src/include/storage/itemid.h and src/include/access/htup.h for |
| 47 | + explanations of the fields returned. |
| 48 | + |
| 49 | + bt_metap |
| 50 | + -------- |
| 51 | + bt_metap() returns information about the btree index metapage: |
| 52 | + |
| 53 | + test=> SELECT * FROM bt_metap('pg_cast_oid_index'); |
| 54 | + -[ RECORD 1 ]----- |
| 55 | + magic | 340322 |
| 56 | + version | 2 |
| 57 | + root | 1 |
| 58 | + level | 0 |
| 59 | + fastroot | 1 |
| 60 | + fastlevel | 0 |
| 61 | + |
| 62 | + bt_page_stats |
| 63 | + ------------- |
| 64 | + bt_page_stats() shows information about single btree pages: |
| 65 | + |
| 66 | + test=> SELECT * FROM bt_page_stats('pg_cast_oid_index', 1); |
| 67 | + -[ RECORD 1 ]-+----- |
| 68 | + blkno | 1 |
| 69 | + type | l |
| 70 | + live_items | 256 |
| 71 | + dead_items | 0 |
| 72 | + avg_item_size | 12 |
| 73 | + page_size | 8192 |
| 74 | + free_size | 4056 |
| 75 | + btpo_prev | 0 |
| 76 | + btpo_next | 0 |
| 77 | + btpo | 0 |
| 78 | + btpo_flags | 3 |
| 79 | + |
| 80 | + bt_page_items |
| 81 | + ------------- |
| 82 | + bt_page_items() returns information about specific items on btree pages: |
| 83 | + |
| 84 | + test=> SELECT * FROM bt_page_items('pg_cast_oid_index', 1); |
| 85 | + itemoffset | ctid | itemlen | nulls | vars | data |
| 86 | + ------------+---------+---------+-------+------+------------- |
| 87 | + 1 | (0,1) | 12 | f | f | 23 27 00 00 |
| 88 | + 2 | (0,2) | 12 | f | f | 24 27 00 00 |
| 89 | + 3 | (0,3) | 12 | f | f | 25 27 00 00 |
| 90 | + 4 | (0,4) | 12 | f | f | 26 27 00 00 |
| 91 | + 5 | (0,5) | 12 | f | f | 27 27 00 00 |
| 92 | + 6 | (0,6) | 12 | f | f | 28 27 00 00 |
| 93 | + 7 | (0,7) | 12 | f | f | 29 27 00 00 |
| 94 | + 8 | (0,8) | 12 | f | f | 2a 27 00 00 |
0 commit comments