MCPcopy Create free account
hub / github.com/apache/cloudberry / jsonb_to_plpython

Function jsonb_to_plpython

contrib/jsonb_plpython/jsonb_plpython.c:480–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478 */
479PG_FUNCTION_INFO_V1(jsonb_to_plpython);
480Datum
481jsonb_to_plpython(PG_FUNCTION_ARGS)
482{
483 PyObject *result;
484 Jsonb *in = PG_GETARG_JSONB_P(0);
485
486 /*
487 * Initialize pointer to Decimal constructor. First we try "cdecimal", C
488 * version of decimal library. In case of failure we use slower "decimal"
489 * module.
490 */
491 if (!decimal_constructor)
492 {
493 PyObject *decimal_module = PyImport_ImportModule("cdecimal");
494
495 if (!decimal_module)
496 {
497 PyErr_Clear();
498 decimal_module = PyImport_ImportModule("decimal");
499 }
500 Assert(decimal_module);
501 decimal_constructor = PyObject_GetAttrString(decimal_module, "Decimal");
502 }
503
504 result = PLyObject_FromJsonbContainer(&in->root);
505 if (!result)
506 PLy_elog(ERROR, "transformation from jsonb to Python failed");
507
508 return PointerGetDatum(result);
509}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected