Rodrigo Hjort <rodrigo(dot)hjort(at)gmail(dot)com> writes:
> I created a custom C function with this signature:
> CREATE FUNCTION calculate_hash(numbers int2[])
> RETURNS int8
> AS 'MODULE_PATHNAME', 'pg_calculate_hash'
> LANGUAGE C
> IMMUTABLE STRICT;
> And here is the function source code (inspired in codes I found in
> src/backend/utils/adt/int.c):
> PG_FUNCTION_INFO_V1(pg_calculate_hash);
> Datum
> pg_calculate_hash(PG_FUNCTION_ARGS)
> {
> int2vector *int2Array = (int2vector *) PG_GETARG_POINTER(0);
Nope. int2vector is not the same as int2[]. It might occasionally seem
to work, but in general it's not the same type. And this particular
coding won't work at all on on-disk int2[] data, because it doesn't
account for toasting.
regards, tom lane