plpgsql_support.c
469 Bytes
#include <postgres.h>
#include <string.h>
#include <fmgr.h>
#include <executor/executor.h>
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);
}