#include #include #include #include PG_FUNCTION_INFO_V1(get_int4_record_val); Datum get_int4_record_val(PG_FUNCTION_ARGS) { TupleTableSlot* t=(TupleTableSlot*)PG_GETARG_POINTER(0); text* valName=(text*)PG_GETARG_POINTER(1); int32 val; bool isnull; val=DatumGetInt32(GetAttributeByName(t, VARDATA(valName), &isnull)); if(isnull) PG_RETURN_NULL(); PG_RETURN_INT32(val); }