PostgreSQL GiST compress skeleton when no compression required I'm trying to implement my GiST index, where storage type is the same as column type (bytea). They are even going to have same length because these are bitarrays and unions are just disjunctions of all arrays in set (in other words, bitwise OR of all arrays).

Because of that, I don't need to convert or compress data. In that case, is this a correct implementation of compress function?

Datum
sub_fp_compress(PG_FUNCTION_ARGS)
{
    GISTENTRY  *entry = (GISTENTRY *)PG_GETARG_POINTER(0);
    // Column and Storage data types are the same (bytea)
    // so no compression is required.
    GISTENTRY  *retval = entry;

    PG_RETURN_POINTER(retval);
}


The reason why I'm asking is that when creating index I get some unexpected values and first occurrence of this is in compress function. To be more precise, all my bitarrays stored in DB are 256 bytes long (checked) and the GiST nodes I create have same length. But all of sudden I get in penalty function as second newentry param a bitarray that is 9 bytes long. I have traced this to compress function where it first appears so it's first place I need to check.
I think this would actually work, but I would follow the same format used in the docs for consistency on the decompress version that doesn't require compression,

PG_FUNCTION_INFO_V1(my_decompress);

Datum
my_decompress(PG_FUNCTION_ARGS)
{
    PG_RETURN_POINTER(PG_GETARG_POINTER(0));
}


My assumption here is that because you don't actually need to initialize a new GIST entry to return for Pg to write it disk, and because you're just using binary stuff, you can use one function for both

PG_FUNCTION_INFO_V1(id);

Datum
id(PG_FUNCTION_ARGS)
{
    PG_RETURN_POINTER(PG_GETARG_POINTER(0));
}


But you may have to DETOAST too which the docs eerily don't mention.