Need to De-Toast #4

Closed
theory opened this Issue Oct 15, 2012 · 5 comments

2 participants

@theory
Owner

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: PG_DETOAST_DATUM
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?

@samv
Collaborator

I guess this could easily be tested by setting the column attribute to always toast

@theory
Owner

How would one do that?

@theory
Owner

bump @samv.

@theory
Owner

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.

@theory
Owner

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.

@theory theory closed this Jun 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment