mirror of
https://github.com/postgres/postgres.git
synced 2025-08-09 17:03:00 +03:00
Expose internal function for converting int64 to numeric
Existing callers had to take complicated detours via DirectFunctionCall1(). This simplifies a lot of code. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu
This commit is contained in:
@@ -195,7 +195,7 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
Numeric nul = DatumGetNumeric(DirectFunctionCall1(int4_numeric, Int32GetDatum(0)));
|
||||
Numeric nul = int64_to_numeric(0);
|
||||
|
||||
*result = 0.0;
|
||||
|
||||
|
@@ -216,9 +216,7 @@ SV_to_JsonbValue(SV *in, JsonbParseState **jsonb_state, bool is_elem)
|
||||
IV ival = SvIV(in);
|
||||
|
||||
out.type = jbvNumeric;
|
||||
out.val.numeric =
|
||||
DatumGetNumeric(DirectFunctionCall1(int8_numeric,
|
||||
Int64GetDatum((int64) ival)));
|
||||
out.val.numeric = int64_to_numeric(ival);
|
||||
}
|
||||
else if (SvNOK(in))
|
||||
{
|
||||
|
Reference in New Issue
Block a user