RhodiumToad tells me on IRC:
justatheory: RhodiumToad: Does semver_out() look right to you [here](https://github.com/theory/pg-semver/blob/master/src/semver.c)
RhodiumToad: justatheory: no, you're missing a detoast
justatheory: How do I detoast stuff?
RhodiumToad: and remember to use PG_FREE_OF_COPY in any btree comparison funcs
RhodiumToad: you should have something like this:
RhodiumToad: #define DatumGetSemver(x) ((semver *) PG_DETOAST_DATUM(x))
RhodiumToad: #define PG_GETARG_SEMVER(n) DatumGetSemver(PG_GETARG_DATUM(n))
RhodiumToad: strictly those should have P or _P on the ends
So we should do that. Not likely to often have long values, so maybe it doesn't need to be toasted at all?
I guess this could easily be tested by setting the column attribute to always toast
How would one do that?
Use PG_FREE_IF_COPY() to prevent leaking memory for detoasted inputs.
Added a macro in 3ab1c6a, but when I asked RhodiumToad about this again, he realized that, because the CREATE TYPE statement does not specify a storage type, the type is always "plain", and therefore never toasted. So no need to de-toast.
And in 8d0dbe8, I removed all calls to PG_FREE_IF_COPY(), as it is only needed for toastable values in btree functions or operators, and, again, semvers are not toastable. We fetch a few text values that are toastable, but not in btree operators or functions.