Re: Getting a primitive numeric value from "DatumGetNumeric"?
От | Demitri Muna |
---|---|
Тема | Re: Getting a primitive numeric value from "DatumGetNumeric"? |
Дата | |
Msg-id | 66D387DA-7C49-4A32-AE92-226DB787D33C@demitri.com обсуждение исходный текст |
Ответ на | Re: Getting a primitive numeric value from "DatumGetNumeric"? (Michael Paquier <michael@paquier.xyz>) |
Список | pgsql-general |
Hi, On Feb 22, 2018, at 9:31 PM, Michael Paquier <michael@paquier.xyz> wrote: > PG_GETARG_NUMERIC(), no? That function returns an object of datatype “Numeric” which still requires some (not immediately obvious) conversation toa double (or whatever primitive C type). > 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. I spent an hour diving into the code out of curiosity. I found useful functions like this: double numeric_to_double_no_overflow(Numeric n) They’re available from the PostgreSQL main source code, but not exposed in the public headers. (Maybe I was missing something.)There was enough there where I could see a way to copy/paste or otherwise link to those methods, but as Tom pointedout, implicit coercion handles what I need so I’ll stick with that. Cheers, Demitri
В списке pgsql-general по дате отправления: