Re: Issue on C function that reads int2[] (using "int2vector")
От | Tom Lane |
---|---|
Тема | Re: Issue on C function that reads int2[] (using "int2vector") |
Дата | |
Msg-id | 15566.1448851148@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Issue on C function that reads int2[] (using "int2vector") (Rodrigo Hjort <rodrigo.hjort@gmail.com>) |
Ответы |
Re: Issue on C function that reads int2[] (using "int2vector")
|
Список | pgsql-hackers |
Rodrigo Hjort <rodrigo.hjort@gmail.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
В списке pgsql-hackers по дате отправления: