Categorygithub.com/csueiras/pglrmparser
repository
0.1.0
Repository: https://github.com/csueiras/pglrmparser.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

pglrmparser

Tests Coverage Status Go Report Card GitHub tag (latest SemVer pre-release) License: MIT

pglrmparser is a library for parsing Postgres Logical Replication Message format. This tool in conjunction with something like pglogrepl can allow you to easily parse our WAL data from Postgres.

Usage

package main

import (
	"encoding/hex"
	"fmt"
	"github.com/csueiras/pglrmparser/pkg/lrm"
)

func main() {
	input := "49000040054e000274000000023230740000000c48656c6c6f20576f726c6421"
	buf, _ := hex.DecodeString(input)
	msg, err := lrm.Parse(buf)
	if err != nil {
		panic(err)
	}

	insert := msg.(*lrm.Insert)
	fmt.Println("Insert:")
	fmt.Printf("Relation ID: %d\n", insert.RelationID)
	for i, datum := range insert.TupleData {
		fmt.Printf("Column #%d\n", i+1)
		fmt.Printf("Data: %v\n", datum.Value)
		fmt.Println()
	}
}

Produces:

Insert:
Relation ID: 16389
Column #1
Data: 20

Column #2
Data: Hello World!

More documentation to come soon