Database error: no binary output function available for type pksuid
Howdy folks! I'm writing a plugin to create a prefixed KSUID and I'm running into an issue:
Error: error returned from database: no binary output function available for type pksuid
Caused by:
no binary output function available for type pksuid
This is when performing a query with sqlx. I have no issues when running queries via cargo pgrx run.
My type: https://github.com/sycertech/pksuid/blob/main/pksuid/src/sqlx.rs
Is there something I need to implement pgrx-side? Or is this something with sqlx?
Relevant Files https://github.com/sycertech/prefixed-ksuid/blob/1e2097299e1066f9deb73c4471e1659f3aedaf92/pksuid-example/src/main.rs https://github.com/sycertech/prefixed-ksuid/blob/1e2097299e1066f9deb73c4471e1659f3aedaf92/pksuid/src/lib.rs https://github.com/sycertech/prefixed-ksuid/blob/1e2097299e1066f9deb73c4471e1659f3aedaf92/pksuid-extension/src/lib.rs
We've been chatting about this on Discord a bit. pgrx doesn't yet support a safe interface for also implementing a type's SEND and RECEIVE functions, so you gotta do that yourself. Which then means you can't use #[derive(PostgresType)] and have to do a lot of additional manual effort.
Sounds like you were doing that once via:
yeah this is how i was doing it before https://github.com/sycertech/pksuid/tree/67081388e686f84f80c978d06d6641202d8c2b5e/src wrt implementing pgtype, into/fromdatum, etc.
So you'll want to head back in that direction and then add the send/receive functions, which will be akin to:
#[pg_extern]
fn send(input: MyType) -> Vec<u8> {
... convert input to bytes ...
}
/// this one is funky
#[pg_extern]
fn recv(internal: Internal) -> MyType {
let string_info = unsafe { StringInfo::from_pg(internal.get().unwrap() as *mut pg_sys::StringInfoData) };
... take data from `string_info` and convert to MyType ...
}
If you get past your problem with this approach, let us know and we'll update our hexint example to also do this... which was clearly an oversight.
Did someone actually manage to fix this?
Did someone actually manage to fix this?
I did, in PR https://github.com/pgcentralfoundation/pgrx/pull/2068
This issue should now be closed as PR #2068 has been merged.