mirror of
https://github.com/wader/fq.git
synced 2024-11-26 10:33:53 +03:00
postgres: add argument to calc page's check sum correctly
This commit is contained in:
parent
46e1e337ff
commit
4676590624
@ -328,6 +328,12 @@ type PostgresIn struct {
|
||||
Flavour string `doc:"PostgreSQL flavour: postgres14, pgproee14.., postgres10"`
|
||||
}
|
||||
|
||||
type PostgresHeapIn struct {
|
||||
Flavour string `doc:"PostgreSQL flavour: postgres14, pgproee14.., postgres10"`
|
||||
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()\""`
|
||||
|
@ -7,6 +7,7 @@ const (
|
||||
fnvPrime = 16777619
|
||||
nSumsSize = 4 * nSums
|
||||
mainBlockLen = PageSize / nSumsSize
|
||||
RelSegSize = 131072
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1,12 +1,14 @@
|
||||
package pgpro10
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgpro11
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -51,8 +52,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 12 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgpro12
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -52,8 +53,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 12 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgpro13
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -52,8 +53,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 12 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgpro14
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -52,8 +53,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 12 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgproee10
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/pgproee14/ee14"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
@ -53,8 +54,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 24 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: ee14.DecodePageHeaderData,
|
||||
DecodePageSpecial: ee14.DecodePageSpecial,
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgproee11
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/pgproee14/ee14"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
@ -72,8 +73,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 24 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: ee14.DecodePageHeaderData,
|
||||
DecodePageSpecial: ee14.DecodePageSpecial,
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgproee12
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/pgproee14/ee14"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
@ -53,8 +54,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 24 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: ee14.DecodePageHeaderData,
|
||||
DecodePageSpecial: ee14.DecodePageSpecial,
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgproee13
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/pgproee14/ee14"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
@ -53,8 +54,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 24 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: ee14.DecodePageHeaderData,
|
||||
DecodePageSpecial: ee14.DecodePageSpecial,
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pgproee14
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/pgproee14/ee14"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
@ -80,8 +81,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 24 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: ee14.DecodePageHeaderData,
|
||||
DecodePageSpecial: ee14.DecodePageSpecial,
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
package postgres10
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package postgres11
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -64,8 +65,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 6 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package postgres12
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -64,8 +65,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 6 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package postgres13
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -45,8 +46,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 12 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -2,6 +2,7 @@ package common14
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/common"
|
||||
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
@ -110,6 +111,8 @@ const SizeOfHeapTupleHeaderData = 24
|
||||
/* total size (bytes): 6 */
|
||||
|
||||
type Heap struct {
|
||||
Args format.PostgresHeapIn
|
||||
|
||||
// current Page
|
||||
Page *HeapPage
|
||||
// Page special data
|
||||
@ -142,7 +145,7 @@ func DecodeHeap(heap *Heap, d *decode.D) any {
|
||||
}
|
||||
|
||||
func decodeHeapPages(heap *Heap, d *decode.D) {
|
||||
blockNumber := uint32(0)
|
||||
blockNumber := uint32(heap.Args.PageNumber + heap.Args.SegmentNumber*common.RelSegSize)
|
||||
for {
|
||||
if end, _ := d.TryEnd(); end {
|
||||
return
|
||||
|
@ -1,6 +1,7 @@
|
||||
package postgres14
|
||||
|
||||
import (
|
||||
"github.com/wader/fq/format"
|
||||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
|
||||
"github.com/wader/fq/pkg/decode"
|
||||
)
|
||||
@ -18,8 +19,9 @@ import (
|
||||
//
|
||||
/* total size (bytes): 24 */
|
||||
|
||||
func DecodeHeap(d *decode.D) any {
|
||||
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
|
||||
heap := &common14.Heap{
|
||||
Args: args,
|
||||
DecodePageHeaderData: common14.DecodePageHeader,
|
||||
}
|
||||
return common14.DecodeHeap(heap, d)
|
||||
|
@ -34,8 +34,10 @@ func init() {
|
||||
Name: format.PG_HEAP,
|
||||
Description: "PostgreSQL heap file",
|
||||
DecodeFn: decodePgheap,
|
||||
DecodeInArg: format.PostgresIn{
|
||||
Flavour: PG_FLAVOUR_POSTGRES14,
|
||||
DecodeInArg: format.PostgresHeapIn{
|
||||
Flavour: PG_FLAVOUR_POSTGRES14,
|
||||
PageNumber: 0,
|
||||
SegmentNumber: 0,
|
||||
},
|
||||
RootArray: true,
|
||||
RootName: "pages",
|
||||
@ -46,46 +48,46 @@ func init() {
|
||||
func decodePgheap(d *decode.D, in any) any {
|
||||
d.Endian = decode.LittleEndian
|
||||
|
||||
pgIn, ok := in.(format.PostgresIn)
|
||||
pgIn, ok := in.(format.PostgresHeapIn)
|
||||
if !ok {
|
||||
d.Fatalf("DecodeInArg must be PostgresIn!\n")
|
||||
}
|
||||
|
||||
switch pgIn.Flavour {
|
||||
case PG_FLAVOUR_POSTGRES10:
|
||||
return postgres10.DecodeHeap(d)
|
||||
return postgres10.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_POSTGRES11:
|
||||
return postgres11.DecodeHeap(d)
|
||||
return postgres11.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_POSTGRES12:
|
||||
return postgres12.DecodeHeap(d)
|
||||
return postgres12.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_POSTGRES13:
|
||||
return postgres13.DecodeHeap(d)
|
||||
return postgres13.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_POSTGRES14:
|
||||
return postgres14.DecodeHeap(d)
|
||||
return postgres14.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPROEE10:
|
||||
return pgproee10.DecodeHeap(d)
|
||||
return pgproee10.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPROEE11:
|
||||
return pgproee11.DecodeHeap(d)
|
||||
return pgproee11.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPROEE12:
|
||||
return pgproee12.DecodeHeap(d)
|
||||
return pgproee12.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPROEE13:
|
||||
return pgproee13.DecodeHeap(d)
|
||||
return pgproee13.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPROEE14:
|
||||
return pgproee14.DecodeHeap(d)
|
||||
return pgproee14.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPRO10:
|
||||
return pgpro10.DecodeHeap(d)
|
||||
return pgpro10.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPRO11:
|
||||
return pgpro11.DecodeHeap(d)
|
||||
return pgpro11.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPRO12:
|
||||
return pgpro12.DecodeHeap(d)
|
||||
return pgpro12.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPRO13:
|
||||
return pgpro13.DecodeHeap(d)
|
||||
return pgpro13.DecodeHeap(d, pgIn)
|
||||
case PG_FLAVOUR_PGPRO14:
|
||||
return pgpro14.DecodeHeap(d)
|
||||
return pgpro14.DecodeHeap(d, pgIn)
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
return postgres14.DecodeHeap(d)
|
||||
return postgres14.DecodeHeap(d, pgIn)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user