Urso
Urso
XXata
Created by matdehaast on 10/23/2024 in #help
pgvx: complex return types
You can always return a Datum if you find automatic conversion too limiting. If you want nullable you can return ?Datum. In that case a null will be correctly translated into a Datum. When implementing a function with pgzx we use compile time reflection for primitive types via pgzx.datum.findConv . The findConv function also checks if your type implements fromNullableDatum and toNullableDatum (although the check could be more exhaustive and allow more type patterns in the future). An example from this blog post: https://xata.io/blog/pgzx-update-0.2.0
fn pgdc_fdw_handler() pg.Datum {
return pg.PointerGetDatum(pgzx.node.create(pg.FdwRoutines{
.BeginForeignScan = ...,
.IterateForeignScan = ...,
.EndForeignScan = ...,
...
}));
}
fn pgdc_fdw_handler() pg.Datum {
return pg.PointerGetDatum(pgzx.node.create(pg.FdwRoutines{
.BeginForeignScan = ...,
.IterateForeignScan = ...,
.EndForeignScan = ...,
...
}));
}
2 replies