Re: Getting a primitive numeric value from "DatumGetNumeric"?

Поиск
Список
Период
Сортировка
Искать
От
Michael Paquier
Тема
Re: Getting a primitive numeric value from "DatumGetNumeric"?
Дата
Msg-id
20180223023138.GB15131@paquier.xyz
Ответ на
Список
Дерево обсуждения
Getting a primitive numeric value from "DatumGetNumeric"? Demitri Muna <postgresql@demitri.com>
Re: Getting a primitive numeric value from "DatumGetNumeric"? Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting a primitive numeric value from "DatumGetNumeric"? Demitri Muna <postgresql@demitri.com>
Re: Getting a primitive numeric value from "DatumGetNumeric"? Michael Paquier <michael@paquier.xyz>
Re: Getting a primitive numeric value from "DatumGetNumeric"? Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting a primitive numeric value from "DatumGetNumeric"? Demitri Muna <postgresql@demitri.com>
On Thu, Feb 22, 2018 at 08:00:45PM -0500, Demitri Muna wrote:
> Ah, I wasn’t aware of implicit coercion. Yes, that solves the problem perfectly, thanks.
> 
> Out of curiosity, how does one read a numeric type from within a C
> extension (i.e. get a number value out of the Datum type)? I ask as I
> was unable to find an example and there are a few open questions on
> Stack Overflow
> (e.g. https://stackoverflow.com/questions/12588554/postgres-c-function-passing-returning-numerics). 

PG_GETARG_NUMERIC(), no? When working on implementing your own data
types or when hacking out functions which manipulate arguments of an
existing datatype, looking at the input and output functions help a
lot.  In your case, numeric_in and numeric_out in
src/backend/utils/adt/numeric.c is full of hints.
--
Michael
В списке pgsql-general по дате отправления
От: Adrian Klaver
Дата:
От: PT
Дата:
FAQ