Now that I have taken a closer look, the code looks significantly better than it seemed at first glance, though there are still peculiarities, and some drawbacks.
An unfortunate aspect is that the code has become a bit more bloated in some regards due to usage of Result, instead of an implicit elog() macro and similar. Passing Result around, in some ways as an alternative to an unwinding exception, is cleaner in some ways, but it also bloats the code somewhat.
The rewrite also could have simpler code in some cases, like
https://github.com/malisper/pgrust/blob/3646a73515a5e4ac7d0b...
could perhaps just be
match syscache_seams::search_pg_class_full_form::call(ctx.mcx(), relationId)? {
Some(form) => Ok(form.relhassubclass),
None => {
Err(ereport(ERROR)
.errmsg(format!("cache lookup failed for relation {relationId}"))
.into_error())
}
}
but that is a smaller thing.I see a lot of MemoryContext. I am not sure how much that bloats the code (though the C code is bloated due to C's issues and problems, like re-using collections and such). Does it incur an overhead?