C-language example of using/returning numeric

Поиск
Список
Период
Сортировка
От Mike Mascari
Тема C-language example of using/returning numeric
Дата
Msg-id 3D85C4CD.6090006@mascari.com
обсуждение исходный текст
Ответы Re: C-language example of using/returning numeric  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Does anyone happen to have a server-side C-language example of
using the Version-1 calling conventions with the NUMERIC data
type? Is it possible? For example, instead of writing:

PG_FUNCTION_INFO_V1(add_one);

Datum add_one(PG_FUNCTION_ARGS)
{
    int32 arg = PG_GETARG_INT32(0);
    PG_RETURN_INT32(arg + 1);
}

I'd like to do the equivalent with NUMERIC. I see the
appropriate macros declared in utils/numeric.h. But I'm not sure
I understand the representation of NumericData:

varlen <- self-explanatory
n_weight <- ??
n_rscale <- scale of numeric
n_sign_dscale <- ??
n_data[1] <- ?? is this BCD?

Are there any helper functions available to the C-language
server-side developer wrt numeric?

Thanks for any tips,

Mike Mascari
mascarm@mascari.com




В списке pgsql-general по дате отправления:

Предыдущее
От: Wim
Дата:
Сообщение: Urgent problem: AllocSetFree: cannot find block containing chunk ...
Следующее
От: "King King"
Дата:
Сообщение: Load Photo by using ODBC