From e06fa6e13993fa6454e0dab2ecac8a41e6d35858 Mon Sep 17 00:00:00 2001 From: Pavel Safonov Date: Fri, 7 Oct 2022 13:33:05 +0300 Subject: [PATCH] postgres: refactoring --- .../pgheap.go => common/pg_heap/pgproee/pg_heap.go} | 8 ++++---- .../pg_heap/postgres}/heap_page.go | 2 +- .../common14 => common/pg_heap/postgres}/pg_heap.go | 2 +- format/postgres/flavours/pgpro10/pg_heap.go | 8 ++++---- format/postgres/flavours/pgpro11/pg_heap.go | 8 ++++---- format/postgres/flavours/pgpro12/pg_heap.go | 8 ++++---- format/postgres/flavours/pgpro13/pg_heap.go | 8 ++++---- format/postgres/flavours/pgpro14/pg_heap.go | 8 ++++---- format/postgres/flavours/pgproee10/pg_heap.go | 12 ++++++------ format/postgres/flavours/pgproee11/pg_heap.go | 12 ++++++------ format/postgres/flavours/pgproee12/pg_heap.go | 12 ++++++------ format/postgres/flavours/pgproee13/pg_heap.go | 12 ++++++------ format/postgres/flavours/pgproee14/pg_heap.go | 12 ++++++------ format/postgres/flavours/postgres10/pg_heap.go | 8 ++++---- format/postgres/flavours/postgres11/pg_heap.go | 8 ++++---- format/postgres/flavours/postgres12/pg_heap.go | 8 ++++---- format/postgres/flavours/postgres13/pg_heap.go | 8 ++++---- format/postgres/flavours/postgres14/pg_btree.go | 12 ++++++------ format/postgres/flavours/postgres14/pg_heap.go | 8 ++++---- 19 files changed, 82 insertions(+), 82 deletions(-) rename format/postgres/{flavours/pgproee14/ee14/pgheap.go => common/pg_heap/pgproee/pg_heap.go} (90%) rename format/postgres/{flavours/postgres14/common14 => common/pg_heap/postgres}/heap_page.go (99%) rename format/postgres/{flavours/postgres14/common14 => common/pg_heap/postgres}/pg_heap.go (99%) diff --git a/format/postgres/flavours/pgproee14/ee14/pgheap.go b/format/postgres/common/pg_heap/pgproee/pg_heap.go similarity index 90% rename from format/postgres/flavours/pgproee14/ee14/pgheap.go rename to format/postgres/common/pg_heap/pgproee/pg_heap.go index cc3a3f6a..0b4d54be 100644 --- a/format/postgres/flavours/pgproee14/ee14/pgheap.go +++ b/format/postgres/common/pg_heap/pgproee/pg_heap.go @@ -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 diff --git a/format/postgres/flavours/postgres14/common14/heap_page.go b/format/postgres/common/pg_heap/postgres/heap_page.go similarity index 99% rename from format/postgres/flavours/postgres14/common14/heap_page.go rename to format/postgres/common/pg_heap/postgres/heap_page.go index 6d31b9dd..07bc5a17 100644 --- a/format/postgres/flavours/postgres14/common14/heap_page.go +++ b/format/postgres/common/pg_heap/postgres/heap_page.go @@ -1,4 +1,4 @@ -package common14 +package postgres import ( "github.com/wader/fq/format/postgres/common" diff --git a/format/postgres/flavours/postgres14/common14/pg_heap.go b/format/postgres/common/pg_heap/postgres/pg_heap.go similarity index 99% rename from format/postgres/flavours/postgres14/common14/pg_heap.go rename to format/postgres/common/pg_heap/postgres/pg_heap.go index cad9c4df..424cea14 100644 --- a/format/postgres/flavours/postgres14/common14/pg_heap.go +++ b/format/postgres/common/pg_heap/postgres/pg_heap.go @@ -1,4 +1,4 @@ -package common14 +package postgres import ( "fmt" diff --git a/format/postgres/flavours/pgpro10/pg_heap.go b/format/postgres/flavours/pgpro10/pg_heap.go index 644b7038..8a5d99cb 100644 --- a/format/postgres/flavours/pgpro10/pg_heap.go +++ b/format/postgres/flavours/pgpro10/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgpro11/pg_heap.go b/format/postgres/flavours/pgpro11/pg_heap.go index b5cc9003..629854fc 100644 --- a/format/postgres/flavours/pgpro11/pg_heap.go +++ b/format/postgres/flavours/pgpro11/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgpro12/pg_heap.go b/format/postgres/flavours/pgpro12/pg_heap.go index ac053076..32ba3fbd 100644 --- a/format/postgres/flavours/pgpro12/pg_heap.go +++ b/format/postgres/flavours/pgpro12/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgpro13/pg_heap.go b/format/postgres/flavours/pgpro13/pg_heap.go index 5e353342..edcefd02 100644 --- a/format/postgres/flavours/pgpro13/pg_heap.go +++ b/format/postgres/flavours/pgpro13/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgpro14/pg_heap.go b/format/postgres/flavours/pgpro14/pg_heap.go index af6e299d..72862ef2 100644 --- a/format/postgres/flavours/pgpro14/pg_heap.go +++ b/format/postgres/flavours/pgpro14/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgproee10/pg_heap.go b/format/postgres/flavours/pgproee10/pg_heap.go index 0c20e6b5..8ed4d8d3 100644 --- a/format/postgres/flavours/pgproee10/pg_heap.go +++ b/format/postgres/flavours/pgproee10/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgproee11/pg_heap.go b/format/postgres/flavours/pgproee11/pg_heap.go index c0b62ba4..4131ccb1 100644 --- a/format/postgres/flavours/pgproee11/pg_heap.go +++ b/format/postgres/flavours/pgproee11/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgproee12/pg_heap.go b/format/postgres/flavours/pgproee12/pg_heap.go index 74b63d92..aa284c60 100644 --- a/format/postgres/flavours/pgproee12/pg_heap.go +++ b/format/postgres/flavours/pgproee12/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgproee13/pg_heap.go b/format/postgres/flavours/pgproee13/pg_heap.go index 6b1ded54..b9822033 100644 --- a/format/postgres/flavours/pgproee13/pg_heap.go +++ b/format/postgres/flavours/pgproee13/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/pgproee14/pg_heap.go b/format/postgres/flavours/pgproee14/pg_heap.go index ffc5c91b..c096efab 100644 --- a/format/postgres/flavours/pgproee14/pg_heap.go +++ b/format/postgres/flavours/pgproee14/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/postgres10/pg_heap.go b/format/postgres/flavours/postgres10/pg_heap.go index 262d89ea..6a3d808a 100644 --- a/format/postgres/flavours/postgres10/pg_heap.go +++ b/format/postgres/flavours/postgres10/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/postgres11/pg_heap.go b/format/postgres/flavours/postgres11/pg_heap.go index 2944c2be..7ce1eb0a 100644 --- a/format/postgres/flavours/postgres11/pg_heap.go +++ b/format/postgres/flavours/postgres11/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/postgres12/pg_heap.go b/format/postgres/flavours/postgres12/pg_heap.go index 4012907c..c62f8a8c 100644 --- a/format/postgres/flavours/postgres12/pg_heap.go +++ b/format/postgres/flavours/postgres12/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/postgres13/pg_heap.go b/format/postgres/flavours/postgres13/pg_heap.go index 2a153618..b34ee67f 100644 --- a/format/postgres/flavours/postgres13/pg_heap.go +++ b/format/postgres/flavours/postgres13/pg_heap.go @@ -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) } diff --git a/format/postgres/flavours/postgres14/pg_btree.go b/format/postgres/flavours/postgres14/pg_btree.go index f795f389..c4b529cd 100644 --- a/format/postgres/flavours/postgres14/pg_btree.go +++ b/format/postgres/flavours/postgres14/pg_btree.go @@ -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) diff --git a/format/postgres/flavours/postgres14/pg_heap.go b/format/postgres/flavours/postgres14/pg_heap.go index d3d6a64f..47f329fc 100644 --- a/format/postgres/flavours/postgres14/pg_heap.go +++ b/format/postgres/flavours/postgres14/pg_heap.go @@ -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) }