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{
|
2022-12-22 11:22:02 +03:00
|
|
|
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) {
|
2023-05-04 09:16:55 +03:00
|
|
|
d.Fatalf("no page specified")
|
2022-12-22 11:22:02 +03:00
|
|
|
}
|
2023-05-05 11:28:38 +03:00
|
|
|
postgres.DecodePgBTree(d, pgIn.Page)
|
|
|
|
return nil
|
2022-09-19 15:45:54 +03:00
|
|
|
}
|