https://github.com/misachi/pg_wal_ext
Read WAL files and possibly generate the SQL
https://github.com/misachi/pg_wal_ext
postgres postgresql-extension wal write-ahead-log
Last synced: 2 months ago
JSON representation
Read WAL files and possibly generate the SQL
- Host: GitHub
- URL: https://github.com/misachi/pg_wal_ext
- Owner: misachi
- License: mit
- Created: 2024-07-15T08:10:02.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-09T14:01:37.000Z (over 1 year ago)
- Last Synced: 2025-06-26T07:05:20.159Z (about 1 year ago)
- Topics: postgres, postgresql-extension, wal, write-ahead-log
- Language: C
- Homepage:
- Size: 4.04 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pg_wal_ext
Read WAL files and generate SQL from WAL
The extension has been ran on Postgres v16(both compiled from source and other from Ubuntu/APT upstream packages). ~~PG17 still has an issue with the hash table implementation.~~
Runs on Postgres v17 as well.
A Postgres extension to read logged WAL records and attempt to decode the records and generate SQL for DML operations. One possible use case would be for database restoration(has limitations) or audit purposes.
# Installation
By default, it uses PGXS for installation. Set `OLD_INSTALL` to any value if this is not desired.
### Postgres [Only applies if you don't have Postgres installed already]
Update APT repository
```
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
```
install Postgres with its headers
```
sudo apt update
sudo apt install postgresql postgresql-server-dev-XXX
```
Replace the XXX in `postgresql-server-dev-XXX` with your Postgres version
### Install Extension
Run these inside the directory you cloned the repository in:
```
make PG_CONFIG=/usr/bin/pg_config
make PG_CONFIG=/usr/bin/pg_config install
```
Note you might need to run above two commands using `sudo`
Next log in to your database and create the extension:
```
CREATE EXTENSION pg_wal_ext;
```
# Usage
Pass in the WAL file(to replace "path/to/wal/file" as shown) to be decoded: `select * from pg_xlog_records("path/to/wal/file");`
# Demo
