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

Function PLy_trigger_build_args

src/pl/plpython/plpy_exec.c:708–920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706}
707
708static PyObject *
709PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *rv)
710{
711 TriggerData *tdata = (TriggerData *) fcinfo->context;
712 TupleDesc rel_descr = RelationGetDescr(tdata->tg_relation);
713 PyObject *pltname,
714 *pltevent,
715 *pltwhen,
716 *pltlevel,
717 *pltrelid,
718 *plttablename,
719 *plttableschema,
720 *pltargs,
721 *pytnew,
722 *pytold,
723 *pltdata;
724 char *stroid;
725
726 /*
727 * Make any Py*_New() calls before the PG_TRY block so that we can quickly
728 * return NULL on failure. We can't return within the PG_TRY block, else
729 * we'd miss unwinding the exception stack.
730 */
731 pltdata = PyDict_New();
732 if (!pltdata)
733 return NULL;
734
735 if (tdata->tg_trigger->tgnargs)
736 {
737 pltargs = PyList_New(tdata->tg_trigger->tgnargs);
738 if (!pltargs)
739 {
740 Py_DECREF(pltdata);
741 return NULL;
742 }
743 }
744 else
745 {
746 Py_INCREF(Py_None);
747 pltargs = Py_None;
748 }
749
750 PG_TRY();
751 {
752 pltname = PyString_FromString(tdata->tg_trigger->tgname);
753 PyDict_SetItemString(pltdata, "name", pltname);
754 Py_DECREF(pltname);
755
756 stroid = DatumGetCString(DirectFunctionCall1(oidout,
757 ObjectIdGetDatum(tdata->tg_relation->rd_id)));
758 pltrelid = PyString_FromString(stroid);
759 PyDict_SetItemString(pltdata, "relid", pltrelid);
760 Py_DECREF(pltrelid);
761 pfree(stroid);
762
763 stroid = SPI_getrelname(tdata->tg_relation);
764 plttablename = PyString_FromString(stroid);
765 PyDict_SetItemString(pltdata, "table_name", plttablename);

Callers 1

PLy_exec_triggerFunction · 0.85

Calls 6

DatumGetCStringFunction · 0.85
ObjectIdGetDatumFunction · 0.85
SPI_getrelnameFunction · 0.85
SPI_getnspnameFunction · 0.85
PLy_input_from_tupleFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected