mirror of
https://github.com/wader/fq.git
synced 2024-11-23 00:57:15 +03:00
postgres: add page arg in pg_btree, change args names in pg_heap
This commit is contained in:
parent
0ea20e6827
commit
97bbc22a1d
@ -332,7 +332,11 @@ type PostgresIn struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PostgresHeapIn struct {
|
type PostgresHeapIn struct {
|
||||||
Flavour string `doc:"PostgreSQL flavour: postgres14, pgproee14.., postgres10"`
|
Flavour string `doc:"PostgreSQL flavour: postgres14, pgproee14.., postgres10"`
|
||||||
PageNumber int `doc:"First page number in file, default is 0"`
|
Page int `doc:"First page number in file, default is 0"`
|
||||||
SegmentNumber int `doc:"Segment file number (16790.1 is 1), default is 0"`
|
Segment int `doc:"Segment file number (16790.1 is 1), default is 0"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostgresBTreeIn struct {
|
||||||
|
Page int `doc:"First page number in file, default is 0"`
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package postgres
|
package postgres
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/postgres/common"
|
"github.com/wader/fq/format/postgres/common"
|
||||||
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
|
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
@ -66,8 +67,9 @@ const (
|
|||||||
// IndexTupleData *IndexTuple;
|
// IndexTupleData *IndexTuple;
|
||||||
/* total size (bytes): 8 */
|
/* total size (bytes): 8 */
|
||||||
|
|
||||||
func DecodePgBTree(d *decode.D) any {
|
func DecodePgBTree(d *decode.D, args format.PostgresBTreeIn) any {
|
||||||
btree := &BTree{
|
btree := &BTree{
|
||||||
|
Args: args,
|
||||||
PageSize: common.PageSize,
|
PageSize: common.PageSize,
|
||||||
}
|
}
|
||||||
decodeBTreePages(btree, d)
|
decodeBTreePages(btree, d)
|
||||||
@ -75,13 +77,13 @@ func DecodePgBTree(d *decode.D) any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BTree struct {
|
type BTree struct {
|
||||||
|
Args format.PostgresBTreeIn
|
||||||
PageSize uint64
|
PageSize uint64
|
||||||
page *postgres.HeapPage
|
page *postgres.HeapPage
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeBTreePages(btree *BTree, d *decode.D) {
|
func decodeBTreePages(btree *BTree, d *decode.D) {
|
||||||
for i := 0; ; i++ {
|
for i := btree.Args.Page; ; i++ {
|
||||||
|
|
||||||
page := &postgres.HeapPage{}
|
page := &postgres.HeapPage{}
|
||||||
if btree.page != nil {
|
if btree.page != nil {
|
||||||
// use prev page
|
// use prev page
|
||||||
|
@ -144,7 +144,7 @@ func Decode(heap *Heap, d *decode.D) any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func decodeHeapPages(heap *Heap, d *decode.D) {
|
func decodeHeapPages(heap *Heap, d *decode.D) {
|
||||||
blockNumber := uint32(heap.Args.PageNumber + heap.Args.SegmentNumber*common.RelSegSize)
|
blockNumber := uint32(heap.Args.Page + heap.Args.Segment*common.RelSegSize)
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
for {
|
for {
|
||||||
if end, _ := d.TryEnd(); end {
|
if end, _ := d.TryEnd(); end {
|
||||||
|
@ -18,13 +18,19 @@ func init() {
|
|||||||
Name: format.PG_BTREE,
|
Name: format.PG_BTREE,
|
||||||
Description: "PostgreSQL btree index file",
|
Description: "PostgreSQL btree index file",
|
||||||
DecodeFn: decodePgBTree,
|
DecodeFn: decodePgBTree,
|
||||||
RootArray: true,
|
DecodeInArg: format.PostgresBTreeIn{
|
||||||
RootName: "pages",
|
Page: 0,
|
||||||
|
},
|
||||||
|
RootArray: true,
|
||||||
|
RootName: "pages",
|
||||||
})
|
})
|
||||||
interp.RegisterFS(pgBTreeFS)
|
interp.RegisterFS(pgBTreeFS)
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodePgBTree(d *decode.D, in any) any {
|
func decodePgBTree(d *decode.D, in any) any {
|
||||||
d.Endian = decode.LittleEndian
|
pgIn, ok := in.(format.PostgresBTreeIn)
|
||||||
return postgres.DecodePgBTree(d)
|
if !ok {
|
||||||
|
d.Fatalf("DecodeInArg must be PostgresBTreeIn!\n")
|
||||||
|
}
|
||||||
|
return postgres.DecodePgBTree(d, pgIn)
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ func init() {
|
|||||||
Description: "PostgreSQL heap file",
|
Description: "PostgreSQL heap file",
|
||||||
DecodeFn: decodePgheap,
|
DecodeFn: decodePgheap,
|
||||||
DecodeInArg: format.PostgresHeapIn{
|
DecodeInArg: format.PostgresHeapIn{
|
||||||
Flavour: PG_FLAVOUR_POSTGRES14,
|
Flavour: PG_FLAVOUR_POSTGRES14,
|
||||||
PageNumber: 0,
|
Page: 0,
|
||||||
SegmentNumber: 0,
|
Segment: 0,
|
||||||
},
|
},
|
||||||
RootArray: true,
|
RootArray: true,
|
||||||
RootName: "pages",
|
RootName: "pages",
|
||||||
|
Loading…
Reference in New Issue
Block a user