mirror of
https://github.com/wader/fq.git
synced 2024-11-27 14:14:58 +03:00
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
package postgres
|
|
|
|
import (
|
|
"embed"
|
|
|
|
"github.com/wader/fq/format/postgres/common/pg_heap/pgproee"
|
|
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
|
|
|
|
"github.com/wader/fq/format"
|
|
"github.com/wader/fq/pkg/decode"
|
|
"github.com/wader/fq/pkg/interp"
|
|
)
|
|
|
|
// TO DO
|
|
// oom kill on 1 GB file
|
|
|
|
//go:embed pg_heap.md
|
|
var pgHeapFS embed.FS
|
|
|
|
func init() {
|
|
interp.RegisterFormat(decode.Format{
|
|
Name: format.PG_HEAP,
|
|
Description: "PostgreSQL heap file",
|
|
DecodeFn: decodePgheap,
|
|
DecodeInArg: format.PostgresHeapIn{
|
|
Flavour: PG_FLAVOUR_POSTGRES14,
|
|
Page: 0,
|
|
Segment: 0,
|
|
},
|
|
RootArray: true,
|
|
RootName: "pages",
|
|
})
|
|
interp.RegisterFS(pgHeapFS)
|
|
}
|
|
|
|
func decodePgheap(d *decode.D, in any) any {
|
|
d.Endian = decode.LittleEndian
|
|
|
|
pgIn, ok := in.(format.PostgresHeapIn)
|
|
if !ok {
|
|
d.Fatalf("DecodeInArg must be PostgresIn!\n")
|
|
}
|
|
|
|
switch pgIn.Flavour {
|
|
case PG_FLAVOUR_POSTGRES10,
|
|
PG_FLAVOUR_POSTGRES11,
|
|
PG_FLAVOUR_POSTGRES12,
|
|
PG_FLAVOUR_POSTGRES13,
|
|
PG_FLAVOUR_POSTGRES14,
|
|
PG_FLAVOUR_POSTGRES15,
|
|
PG_FLAVOUR_PGPRO10,
|
|
PG_FLAVOUR_PGPRO11,
|
|
PG_FLAVOUR_PGPRO12,
|
|
PG_FLAVOUR_PGPRO13,
|
|
PG_FLAVOUR_PGPRO14,
|
|
PG_FLAVOUR_PGPRO15:
|
|
return postgres.DecodeHeap(d, pgIn)
|
|
|
|
case PG_FLAVOUR_PGPROEE10,
|
|
PG_FLAVOUR_PGPROEE11,
|
|
PG_FLAVOUR_PGPROEE12,
|
|
PG_FLAVOUR_PGPROEE13,
|
|
PG_FLAVOUR_PGPROEE14,
|
|
PG_FLAVOUR_PGPROEE15:
|
|
return pgproee.DecodeHeap(d, pgIn)
|
|
|
|
default:
|
|
break
|
|
}
|
|
|
|
return postgres.DecodeHeap(d, pgIn)
|
|
}
|