1
1
mirror of https://github.com/wader/fq.git synced 2024-12-29 00:22:38 +03:00
fq/format/postgres/pg_btree.go

38 lines
735 B
Go
Raw Normal View History

2022-09-19 15:45:54 +03:00
package postgres
import (
2022-09-23 13:50:54 +03:00
"embed"
2022-10-31 14:02:08 +03:00
"github.com/wader/fq/format/postgres/common/pg_btree/postgres"
2022-10-05 19:37:42 +03:00
2022-09-19 15:45:54 +03:00
"github.com/wader/fq/format"
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/interp"
)
2022-09-23 13:50:54 +03:00
//go:embed pg_btree.md
var pgBTreeFS embed.FS
2022-09-19 15:45:54 +03:00
func init() {
2023-05-04 08:45:42 +03:00
interp.RegisterFormat(format.Pg_BTree, &decode.Format{
2022-09-19 15:45:54 +03:00
Description: "PostgreSQL btree index file",
DecodeFn: decodePgBTree,
2023-05-04 08:45:42 +03:00
DefaultInArg: format.Pg_BTree_In{
Page: 0,
},
RootArray: true,
RootName: "pages",
2022-09-19 15:45:54 +03:00
})
2022-09-23 13:50:54 +03:00
interp.RegisterFS(pgBTreeFS)
2022-09-19 15:45:54 +03:00
}
2023-05-03 09:45:25 +03:00
func decodePgBTree(d *decode.D) any {
2022-12-26 14:47:23 +03:00
d.Endian = decode.LittleEndian
2023-05-04 08:45:42 +03:00
var pgIn format.Pg_BTree_In
2023-05-03 09:45:25 +03:00
if !d.ArgAs(&pgIn) {
d.Fatalf("no page specified")
}
postgres.DecodePgBTree(d, pgIn.Page)
return nil
2022-09-19 15:45:54 +03:00
}