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() {
|
|
|
|
interp.RegisterFormat(decode.Format{
|
|
|
|
Name: format.PG_BTREE,
|
|
|
|
Description: "PostgreSQL btree index file",
|
|
|
|
DecodeFn: decodePgBTree,
|
2022-12-22 11:22:02 +03:00
|
|
|
DecodeInArg: format.PostgresBTreeIn{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func decodePgBTree(d *decode.D, in any) any {
|
2022-12-22 11:22:02 +03:00
|
|
|
pgIn, ok := in.(format.PostgresBTreeIn)
|
|
|
|
if !ok {
|
|
|
|
d.Fatalf("DecodeInArg must be PostgresBTreeIn!\n")
|
|
|
|
}
|
|
|
|
return postgres.DecodePgBTree(d, pgIn)
|
2022-09-19 15:45:54 +03:00
|
|
|
}
|