1
1
mirror of https://github.com/wader/fq.git synced 2024-12-02 04:05:35 +03:00

postgres: refactoring

This commit is contained in:
Pavel Safonov 2022-10-07 13:33:05 +03:00
parent 4676590624
commit e06fa6e139
19 changed files with 82 additions and 82 deletions

View File

@ -1,8 +1,8 @@
package ee14
package pgproee
import (
"github.com/wader/fq/format/postgres/common"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -15,7 +15,7 @@ import (
/* 16 | 2 */ // LocationIndex pd_special;
/* 18 | 2 */ // uint16 pd_pagesize_version;
/* 20 | 0 */ // ItemIdData pd_linp[];
func DecodePageHeaderData(page *common14.HeapPage, d *decode.D) {
func DecodePageHeaderData(page *postgres.HeapPage, d *decode.D) {
d.FieldStruct("pd_lsn", func(d *decode.D) {
/* 0 | 4 */ // uint32 xlogid;
/* 4 | 4 */ // uint32 xrecoff;
@ -41,7 +41,7 @@ func DecodePageHeaderData(page *common14.HeapPage, d *decode.D) {
/* 20 | 4 */ // uint32 pd_magic;
//
/* total size (bytes): 24 */
func DecodePageSpecial(heap *common14.Heap, d *decode.D) {
func DecodePageSpecial(heap *postgres.Heap, d *decode.D) {
page := heap.Page
special := heap.Special

View File

@ -1,4 +1,4 @@
package common14
package postgres
import (
"github.com/wader/fq/format/postgres/common"

View File

@ -1,4 +1,4 @@
package common14
package postgres
import (
"fmt"

View File

@ -2,14 +2,14 @@ package pgpro10
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package pgpro11
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -53,9 +53,9 @@ import (
/* total size (bytes): 12 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package pgpro12
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -54,9 +54,9 @@ import (
/* total size (bytes): 12 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package pgpro13
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -54,9 +54,9 @@ import (
/* total size (bytes): 12 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package pgpro14
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -54,9 +54,9 @@ import (
/* total size (bytes): 12 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,8 +2,8 @@ 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/format/postgres/common/pg_heap/pgproee"
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -55,10 +55,10 @@ import (
/* total size (bytes): 24 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres.Heap{
Args: args,
DecodePageHeaderData: ee14.DecodePageHeaderData,
DecodePageSpecial: ee14.DecodePageSpecial,
DecodePageHeaderData: pgproee.DecodePageHeaderData,
DecodePageSpecial: pgproee.DecodePageSpecial,
}
return common14.DecodeHeap(heap, d)
return postgres.DecodeHeap(heap, d)
}

View File

@ -2,8 +2,8 @@ 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/format/postgres/common/pg_heap/pgproee"
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -74,10 +74,10 @@ import (
/* total size (bytes): 24 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres.Heap{
Args: args,
DecodePageHeaderData: ee14.DecodePageHeaderData,
DecodePageSpecial: ee14.DecodePageSpecial,
DecodePageHeaderData: pgproee.DecodePageHeaderData,
DecodePageSpecial: pgproee.DecodePageSpecial,
}
return common14.DecodeHeap(heap, d)
return postgres.DecodeHeap(heap, d)
}

View File

@ -2,8 +2,8 @@ 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/format/postgres/common/pg_heap/pgproee"
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -55,10 +55,10 @@ import (
/* total size (bytes): 24 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres.Heap{
Args: args,
DecodePageHeaderData: ee14.DecodePageHeaderData,
DecodePageSpecial: ee14.DecodePageSpecial,
DecodePageHeaderData: pgproee.DecodePageHeaderData,
DecodePageSpecial: pgproee.DecodePageSpecial,
}
return common14.DecodeHeap(heap, d)
return postgres.DecodeHeap(heap, d)
}

View File

@ -2,8 +2,8 @@ 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/format/postgres/common/pg_heap/pgproee"
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -55,10 +55,10 @@ import (
/* total size (bytes): 24 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres.Heap{
Args: args,
DecodePageHeaderData: ee14.DecodePageHeaderData,
DecodePageSpecial: ee14.DecodePageSpecial,
DecodePageHeaderData: pgproee.DecodePageHeaderData,
DecodePageSpecial: pgproee.DecodePageSpecial,
}
return common14.DecodeHeap(heap, d)
return postgres.DecodeHeap(heap, d)
}

View File

@ -2,8 +2,8 @@ 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/format/postgres/common/pg_heap/pgproee"
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -82,10 +82,10 @@ import (
/* total size (bytes): 24 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres.Heap{
Args: args,
DecodePageHeaderData: ee14.DecodePageHeaderData,
DecodePageSpecial: ee14.DecodePageSpecial,
DecodePageHeaderData: pgproee.DecodePageHeaderData,
DecodePageSpecial: pgproee.DecodePageSpecial,
}
return common14.DecodeHeap(heap, d)
return postgres.DecodeHeap(heap, d)
}

View File

@ -2,14 +2,14 @@ package postgres10
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package postgres11
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -66,9 +66,9 @@ import (
/* total size (bytes): 6 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package postgres12
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -66,9 +66,9 @@ import (
/* total size (bytes): 6 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package postgres13
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -47,9 +47,9 @@ import (
/* total size (bytes): 12 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}

View File

@ -2,7 +2,7 @@ package postgres14
import (
"github.com/wader/fq/format/postgres/common"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
"github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -79,13 +79,13 @@ func DecodePgBTree(d *decode.D) any {
type BTree struct {
PageSize uint64
page *common14.HeapPage
page *postgres.HeapPage
}
func decodeBTreePages(btree *BTree, d *decode.D) {
for i := 0; ; i++ {
page := &common14.HeapPage{}
page := &postgres.HeapPage{}
if btree.page != nil {
// use prev page
page.BytesPosBegin = btree.page.BytesPosEnd
@ -118,7 +118,7 @@ func decodeBTreeMetaPage(btree *BTree, d *decode.D) {
page := btree.page
d.FieldStruct("page_header", func(d *decode.D) {
common14.DecodePageHeader(page, d)
postgres.DecodePageHeader(page, d)
})
d.FieldStruct("meta_page_data", func(d *decode.D) {
decodeBTMetaPageData(d)
@ -211,7 +211,7 @@ func decodeBTreePage(btree *BTree, d *decode.D) {
page := btree.page
d.FieldStruct("page_header", func(d *decode.D) {
common14.DecodePageHeader(page, d)
postgres.DecodePageHeader(page, d)
})
pos0 := d.Pos()
@ -227,7 +227,7 @@ func decodeBTreePage(btree *BTree, d *decode.D) {
}
d.SeekAbs(pos0)
common14.DecodeItemIds(page, d)
postgres.DecodeItemIds(page, d)
d.FieldArray("tuples", func(d *decode.D) {
decodeIndexTuples(btree, d)

View File

@ -2,7 +2,7 @@ package postgres14
import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/postgres/flavours/postgres14/common14"
postgres2 "github.com/wader/fq/format/postgres/common/pg_heap/postgres"
"github.com/wader/fq/pkg/decode"
)
@ -20,9 +20,9 @@ import (
/* total size (bytes): 24 */
func DecodeHeap(d *decode.D, args format.PostgresHeapIn) any {
heap := &common14.Heap{
heap := &postgres2.Heap{
Args: args,
DecodePageHeaderData: common14.DecodePageHeader,
DecodePageHeaderData: postgres2.DecodePageHeader,
}
return common14.DecodeHeap(heap, d)
return postgres2.DecodeHeap(heap, d)
}