diff --git a/format/format.go b/format/format.go index 79b9502e..b43caedf 100644 --- a/format/format.go +++ b/format/format.go @@ -333,8 +333,3 @@ type PostgresHeapIn struct { PageNumber int `doc:"First page number in file, default is 0"` SegmentNumber int `doc:"Segment file number (16790.1 is 1), default is 0"` } - -type PostgresWalIn struct { - Flavour string `doc:"PostgreSQL flavour: postgres14, pgproee14.., postgres10"` - Lsn string `doc:"Current LSN for WAL, use \"select pg_current_wal_lsn()\""` -} diff --git a/format/postgres/common/pg_wal/pgproee/decode.go b/format/postgres/common/pg_wal/pgproee/decode.go index 98a46cb4..fe48c062 100644 --- a/format/postgres/common/pg_wal/pgproee/decode.go +++ b/format/postgres/common/pg_wal/pgproee/decode.go @@ -5,9 +5,8 @@ import ( "github.com/wader/fq/pkg/decode" ) -func DecodePGWAL(d *decode.D, maxOffset uint32) any { +func DecodePGWAL(d *decode.D) any { wal := &postgres.Wal{ - MaxOffset: int64(maxOffset), DecodeXLogRecord: decodeXLogRecord, } return postgres.Decode(d, wal) diff --git a/format/postgres/common/pg_wal/postgres/decode.go b/format/postgres/common/pg_wal/postgres/decode.go index 2fe9b96f..0f899d6c 100644 --- a/format/postgres/common/pg_wal/postgres/decode.go +++ b/format/postgres/common/pg_wal/postgres/decode.go @@ -2,9 +2,8 @@ package postgres import "github.com/wader/fq/pkg/decode" -func DecodePGWAL(d *decode.D, maxOffset uint32) any { +func DecodePGWAL(d *decode.D) any { wal := &Wal{ - MaxOffset: int64(maxOffset), DecodeXLogRecord: decodeXLogRecord, } return Decode(d, wal) diff --git a/format/postgres/common/pg_wal/postgres/pg_wal.go b/format/postgres/common/pg_wal/postgres/pg_wal.go index 662f0b1c..22a57b97 100644 --- a/format/postgres/common/pg_wal/postgres/pg_wal.go +++ b/format/postgres/common/pg_wal/postgres/pg_wal.go @@ -49,8 +49,7 @@ const ( /* total size (bytes): 12 */ type Wal struct { - MaxOffset int64 - page *walPage + page *walPage pageRecords *decode.D @@ -79,11 +78,6 @@ func Decode(d *decode.D, wal *Wal) any { } posBytes := pages.Pos() / 8 - if posBytes >= wal.MaxOffset { - d.FieldRawLen("unused", d.BitsLeft()) - break - } - remBytes := posBytes % XLOG_BLCKSZ if remBytes != 0 { d.Fatalf("invalid page remBytes = %d\n", remBytes) @@ -193,12 +187,6 @@ func decodeXLogRecords(wal *Wal, d *decode.D) { /* 20 | 4 */ // pg_crc32c xl_crc posBytes1 := d.Pos() / 8 posBytes1Aligned := int64(common.TypeAlign8(uint64(posBytes1))) - // check aligned - this is correct - // record header is 8 byte aligned - if posBytes1Aligned >= wal.MaxOffset { - d.FieldRawLen("unused", d.BitsLeft()) - break - } // check what we cat read xl_tot_len on this page if posMaxOfPageBytes < posBytes1Aligned+4 { diff --git a/format/postgres/pg_wal.go b/format/postgres/pg_wal.go index 6e793223..7d72f3ed 100644 --- a/format/postgres/pg_wal.go +++ b/format/postgres/pg_wal.go @@ -21,9 +21,8 @@ func init() { Name: format.PG_WAL, Description: "PostgreSQL write-ahead log file", DecodeFn: decodePGWAL, - DecodeInArg: format.PostgresWalIn{ + DecodeInArg: format.PostgresIn{ Flavour: PG_FLAVOUR_POSTGRES14, - Lsn: "", }, RootArray: true, RootName: "pages", @@ -48,28 +47,14 @@ func ParseLsn(lsn string) (uint32, error) { return uint32(r1), err } -func XLogSegmentOffset(xLogPtr uint32) uint32 { - const walSegSizeBytes = 16 * 1024 * 1024 - return xLogPtr & (walSegSizeBytes - 1) -} - func decodePGWAL(d *decode.D, in any) any { d.Endian = decode.LittleEndian - pgIn, ok := in.(format.PostgresWalIn) + pgIn, ok := in.(format.PostgresIn) if !ok { d.Fatalf("DecodeInArg must be PostgresIn!\n") } - maxOffset := uint32(0xFFFFFFFF) - if pgIn.Lsn != "" { - lsn, err := ParseLsn(pgIn.Lsn) - if err != nil { - d.Fatalf("Failed to ParseLsn, err = %v\n", err) - } - maxOffset = XLogSegmentOffset(lsn) - } - switch pgIn.Flavour { case PG_FLAVOUR_POSTGRES10, PG_FLAVOUR_POSTGRES11, @@ -81,18 +66,18 @@ func decodePGWAL(d *decode.D, in any) any { PG_FLAVOUR_PGPRO12, PG_FLAVOUR_PGPRO13, PG_FLAVOUR_PGPRO14: - return postgres.DecodePGWAL(d, maxOffset) + return postgres.DecodePGWAL(d) case PG_FLAVOUR_PGPROEE10, PG_FLAVOUR_PGPROEE11, PG_FLAVOUR_PGPROEE12, PG_FLAVOUR_PGPROEE13, PG_FLAVOUR_PGPROEE14: - return pgproee.DecodePGWAL(d, maxOffset) + return pgproee.DecodePGWAL(d) default: break } - return postgres.DecodePGWAL(d, maxOffset) + return postgres.DecodePGWAL(d) }