Skip to content

Commit 5e87585

Browse files
author
Nikita Glukhov
committed
Add JsonValueInitDouble()
1 parent be68a4e commit 5e87585

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/include/utils/json_generic.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,15 @@ JsonValueInitFloat(JsonbValue *jbv, float4 f)
422422
return jbv;
423423
}
424424

425+
static inline JsonbValue *
426+
JsonValueInitDouble(JsonbValue *jbv, float8 f)
427+
{
428+
jbv->type = jbvNumeric;
429+
jbv->val.numeric = DatumGetNumeric(DirectFunctionCall1(
430+
float8_numeric, Float8GetDatum(f)));
431+
return jbv;
432+
}
433+
425434
#define pushJsonbKey(pstate, jbv, key) \
426435
pushJsonbValue(pstate, WJB_KEY, JsonValueInitString(jbv, key))
427436

0 commit comments

Comments
 (0)