mirror of
https://github.com/wader/fq.git
synced 2024-12-27 15:42:07 +03:00
postgres: refactoring
This commit is contained in:
parent
7a89234b13
commit
08c535239b
@ -112,9 +112,9 @@ var (
|
||||
Opus_Packet = &decode.Group{Name: "opus_packet"}
|
||||
PCAP = &decode.Group{Name: "pcap"}
|
||||
PCAPNG = &decode.Group{Name: "pcapng"}
|
||||
PG_BTREE = &decode.Group{Name: "pg_btree"}
|
||||
PG_CONTROL = &decode.Group{Name: "pg_control"}
|
||||
PG_HEAP = &decode.Group{Name: "pg_heap"}
|
||||
Pg_BTree = &decode.Group{Name: "pg_btree"}
|
||||
Pg_Control = &decode.Group{Name: "pg_control"}
|
||||
Pg_Heap = &decode.Group{Name: "pg_heap"}
|
||||
PNG = &decode.Group{Name: "png"}
|
||||
Prores_Frame = &decode.Group{Name: "prores_frame"}
|
||||
Protobuf = &decode.Group{Name: "protobuf"}
|
||||
@ -343,16 +343,16 @@ type TLS_In struct {
|
||||
Keylog string `doc:"NSS Key Log content"`
|
||||
}
|
||||
|
||||
type PgControlIn struct {
|
||||
type Pg_Control_In struct {
|
||||
Flavour string `doc:"PostgreSQL flavour: postgres14, pgproee14.., postgres10"`
|
||||
}
|
||||
|
||||
type PostgresHeapIn struct {
|
||||
type Pg_Heap_In struct {
|
||||
Flavour string `doc:"PostgreSQL flavour: postgres14, pgproee14.., postgres10"`
|
||||
Page int `doc:"First page number in file, default is 0"`
|
||||
Segment int `doc:"Segment file number (16790.1 is 1), default is 0"`
|
||||
}
|
||||
|
||||
type PostgresBTreeIn struct {
|
||||
type Pg_BTree_In struct {
|
||||
Page int `doc:"First page number in file, default is 0"`
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ const (
|
||||
// IndexTupleData *IndexTuple;
|
||||
/* total size (bytes): 8 */
|
||||
|
||||
func DecodePgBTree(d *decode.D, args format.PostgresBTreeIn) any {
|
||||
func DecodePgBTree(d *decode.D, args format.Pg_BTree_In) any {
|
||||
btree := &BTree{
|
||||
Args: args,
|
||||
PageSize: common.PageSize,
|
||||
@ -75,7 +75,7 @@ func DecodePgBTree(d *decode.D, args format.PostgresBTreeIn) any {
|
||||
}
|
||||
|
||||
type BTree struct {
|
||||
Args format.PostgresBTreeIn
|
||||
Args format.Pg_BTree_In
|
||||
PageSize uint64
|
||||
page *postgres.HeapPage
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
func DecodeHeap(d *decode.D, args format.Pg_Heap_In) any {
|
||||
heap := &postgres.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: DecodePageHeaderData,
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
func DecodeHeap(d *decode.D, args format.Pg_Heap_In) any {
|
||||
heap := &Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: DecodePageHeader,
|
||||
|
@ -110,7 +110,7 @@ const SizeOfHeapTupleHeaderData = 24
|
||||
/* total size (bytes): 6 */
|
||||
|
||||
type Heap struct {
|
||||
Args format.PostgresHeapIn
|
||||
Args format.Pg_Heap_In
|
||||
|
||||
// current Page
|
||||
Page *HeapPage
|
||||
|
@ -14,10 +14,10 @@ import (
|
||||
var pgBTreeFS embed.FS
|
||||
|
||||
func init() {
|
||||
interp.RegisterFormat(format.PG_BTREE, &decode.Format{
|
||||
interp.RegisterFormat(format.Pg_BTree, &decode.Format{
|
||||
Description: "PostgreSQL btree index file",
|
||||
DecodeFn: decodePgBTree,
|
||||
DefaultInArg: format.PostgresBTreeIn{
|
||||
DefaultInArg: format.Pg_BTree_In{
|
||||
Page: 0,
|
||||
},
|
||||
RootArray: true,
|
||||
@ -28,9 +28,9 @@ func init() {
|
||||
|
||||
func decodePgBTree(d *decode.D) any {
|
||||
d.Endian = decode.LittleEndian
|
||||
var pgIn format.PostgresBTreeIn
|
||||
var pgIn format.Pg_BTree_In
|
||||
if !d.ArgAs(&pgIn) {
|
||||
d.Fatalf("DecodeInArg must be PostgresBTreeIn!\n")
|
||||
d.Fatalf("DecodeInArg must be Pg_BTree_In!\n")
|
||||
}
|
||||
return postgres.DecodePgBTree(d, pgIn)
|
||||
}
|
||||
|
@ -29,10 +29,10 @@ import (
|
||||
var pgControlFS embed.FS
|
||||
|
||||
func init() {
|
||||
interp.RegisterFormat(format.PG_CONTROL, &decode.Format{
|
||||
interp.RegisterFormat(format.Pg_Control, &decode.Format{
|
||||
Description: "PostgreSQL control file",
|
||||
DecodeFn: decodePgControl,
|
||||
DefaultInArg: format.PgControlIn{
|
||||
DefaultInArg: format.Pg_Control_In{
|
||||
Flavour: "",
|
||||
},
|
||||
})
|
||||
@ -72,9 +72,9 @@ const (
|
||||
func decodePgControl(d *decode.D) any {
|
||||
d.Endian = decode.LittleEndian
|
||||
|
||||
var pgIn format.PgControlIn
|
||||
var pgIn format.Pg_Control_In
|
||||
if !d.ArgAs(&pgIn) {
|
||||
d.Fatalf("DecodeInArg must be PgControlIn!\n")
|
||||
d.Fatalf("DecodeInArg must be Pg_Control_In!\n")
|
||||
}
|
||||
|
||||
switch pgIn.Flavour {
|
||||
|
@ -18,10 +18,10 @@ import (
|
||||
var pgHeapFS embed.FS
|
||||
|
||||
func init() {
|
||||
interp.RegisterFormat(format.PG_HEAP, &decode.Format{
|
||||
interp.RegisterFormat(format.Pg_Heap, &decode.Format{
|
||||
Description: "PostgreSQL heap file",
|
||||
DecodeFn: decodePgheap,
|
||||
DefaultInArg: format.PostgresHeapIn{
|
||||
DefaultInArg: format.Pg_Heap_In{
|
||||
Flavour: PG_FLAVOUR_POSTGRES14,
|
||||
Page: 0,
|
||||
Segment: 0,
|
||||
@ -35,9 +35,9 @@ func init() {
|
||||
func decodePgheap(d *decode.D) any {
|
||||
d.Endian = decode.LittleEndian
|
||||
|
||||
var pgIn format.PostgresHeapIn
|
||||
var pgIn format.Pg_Heap_In
|
||||
if !d.ArgAs(&pgIn) {
|
||||
d.Fatalf("DecodeInArg must be PostgresHeapIn!\n")
|
||||
d.Fatalf("DecodeInArg must be Pg_Heap_In!\n")
|
||||
}
|
||||
|
||||
switch pgIn.Flavour {
|
||||
|
Loading…
Reference in New Issue
Block a user