Re: Getting a primitive numeric value from "DatumGetNumeric"?
В списке pgsql-general по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Getting a primitive numeric value from "DatumGetNumeric"? |
| Дата | |
| Msg-id | 16882.1519359939@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Getting a primitive numeric value from "DatumGetNumeric"? (Michael Paquier <michael@paquier.xyz>) |
| Список | pgsql-general |
Michael Paquier <michael@paquier.xyz> writes:
> On Thu, Feb 22, 2018 at 08:00:45PM -0500, Demitri Muna wrote:
>> 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)?
> PG_GETARG_NUMERIC(), no?
I think the core point here is that PG's "numeric" type *isn't* any
primitive C type; it's a variable-length BCD encoding. If you want
to deal with it you can, but you must spend some time reading
src/backend/utils/adt/numeric.c, as Michael suggests. If you just
want a convenient C approximation, then work with float8 and let
the implicit-coercion machinery do the conversion for you.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера