Skip to content

Commit

Permalink
postgres: add postgres.md to format
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Safonov committed Sep 23, 2022
1 parent 94e5b79 commit 90386a6
Show file tree
Hide file tree
Showing 4 changed files with 951 additions and 837 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ ogg_page,
opus_packet,
pcap,
pcapng,
[pg_btree](doc/formats.md#pg_btree),
[pg_control](doc/formats.md#pg_control),
[pg_heap](doc/formats.md#pg_heap),
[pg_wal](doc/formats.md#pg_wal),
png,
prores_frame,
[protobuf](doc/formats.md#protobuf),
Expand Down
98 changes: 66 additions & 32 deletions doc/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@
|`mpeg_spu` |Sub&nbsp;Picture&nbsp;Unit&nbsp;(DVD&nbsp;subtitle) |<sub></sub>|
|`mpeg_ts` |MPEG&nbsp;Transport&nbsp;Stream |<sub></sub>|
|[`msgpack`](#msgpack) |MessagePack |<sub></sub>|
|[`postgres`](#postgres) |PostgreSQL
|`ogg` |OGG&nbsp;file |<sub>`ogg_page` `vorbis_packet` `opus_packet` `flac_metadatablock` `flac_frame`</sub>|
|`ogg_page` |OGG&nbsp;page |<sub></sub>|
|`opus_packet` |Opus&nbsp;packet |<sub>`vorbis_comment`</sub>|
|`pcap` |PCAP&nbsp;packet&nbsp;capture |<sub>`link_frame` `tcp_stream` `ipv4_packet`</sub>|
|`pcapng` |PCAPNG&nbsp;packet&nbsp;capture |<sub>`link_frame` `tcp_stream` `ipv4_packet`</sub>|
|[`pg_btree`](#pg_btree) |PostgreSQL&nbsp;btree&nbsp;index&nbsp;file |<sub></sub>|
|[`pg_control`](#pg_control) |PostgreSQL&nbsp;control&nbsp;file |<sub></sub>|
|[`pg_heap`](#pg_heap) |PostgreSQL&nbsp;heap&nbsp;file |<sub></sub>|
|[`pg_wal`](#pg_wal) |PostgreSQL&nbsp;write-ahead&nbsp;log&nbsp;file |<sub></sub>|
|`png` |Portable&nbsp;Network&nbsp;Graphics&nbsp;file |<sub>`icc_profile` `exif`</sub>|
|`prores_frame` |Apple&nbsp;ProRes&nbsp;frame |<sub></sub>|
|[`protobuf`](#protobuf) |Protobuf |<sub></sub>|
Expand Down Expand Up @@ -572,58 +575,89 @@ $ fq -d msgpack torepr file.msgpack
### References
- https://github.com/msgpack/msgpack/blob/master/spec.md

## postgres
## pg_btree

### Decode content of pg_control file
### Options

```sh
$ fq -d pg_control -o flavour=postgres14 d pg_control
```
|Name |Default|Description|
|- |- |-|
|`flavour`|default|PostgreSQL flavour: postgres, postgres13, pgpro...|
|`lsn` | |Current LSN for WAL, use "select pg_current_wal_lsn()"|

### Specific fields can be got by request
### Examples

```sh
$ fq -d pg_control -o flavour=postgres14 ".state, .check_point_copy.redo, .wal_level" pg_control
Decode file using pg_btree options
```
$ fq -d pg_btree -o flavour="default" -o lsn="" . file
```

### To see heap page's content
```sh
$ fq -d pg_heap -o flavour=postgres14 ".[0]" 16994
Decode value as pg_btree
```
... | pg_btree({flavour:"default",lsn:""})
```

### To see page's header
## pg_control

```sh
$ fq -d pg_heap -o flavour=postgres14 ".[0].page_header" 16994
```
### Options

### First and last item pointers on first page
|Name |Default|Description|
|- |- |-|
|`flavour`|default|PostgreSQL flavour: postgres, postgres13, pgpro...|
|`lsn` | |Current LSN for WAL, use "select pg_current_wal_lsn()"|

```sh
$ fq -d pg_heap -o flavour=postgres14 ".[0].pd_linp[0, -1]" 16994
```
### Examples

### First and last tuple on first page
Decode file using pg_control options
```
$ fq -d pg_control -o flavour="default" -o lsn="" . file
```

```sh
$ fq -d pg_heap -o flavour=postgres14 ".[0].tuples[0, -1]" 16994
Decode value as pg_control
```
... | pg_control({flavour:"default",lsn:""})
```

### Btree index meta page
## pg_heap

```sh
$ fq -d pg_btree -o flavour=postgres14 ".[0] | d" 16404
### Options

|Name |Default|Description|
|- |- |-|
|`flavour`|default|PostgreSQL flavour: postgres, postgres13, pgpro...|
|`lsn` | |Current LSN for WAL, use "select pg_current_wal_lsn()"|

### Examples

Decode file using pg_heap options
```
$ fq -d pg_heap -o flavour="default" -o lsn="" . file
```

Decode value as pg_heap
```
... | pg_heap({flavour:"default",lsn:""})
```

### Btree index page
## pg_wal

```sh
$ fq -d pg_btree -o flavour=postgres14 ".[1]" 16404
### Options

|Name |Default|Description|
|- |- |-|
|`flavour`|default|PostgreSQL flavour: postgres, postgres13, pgpro...|
|`lsn` | |Current LSN for WAL, use "select pg_current_wal_lsn()"|

### Examples

Decode file using pg_wal options
```
$ fq -d pg_wal -o flavour="default" -o lsn="" . file
```

### References
- https://github.com/postgres/postgres/blob/REL_14_2/src/include/catalog/pg_control.h
- https://www.postgresql.org/docs/current/storage-page-layout.html
Decode value as pg_wal
```
... | pg_wal({flavour:"default",lsn:""})
```

## protobuf

Expand Down

0 comments on commit 90386a6

Please sign in to comment.