
Untitled
By: a guest on
Jul 10th, 2012 | syntax:
None | size: 0.74 KB | hits: 6 | expires: Never
Datum
get_incidences(PG_FUNCTION_ARGS)
{
text *relname = PG_GETARG_TEXT_P(0);
RangeVar *relrv;
Relation rel;
Datum result;
Buffer *buf;
HeapTupleData tuple;
ItemPointer itemp;
Datum resultDatum;
bool x;
// open relation
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = heap_openrv(relrv, AccessShareLock);
itemp = (ItemPointer) palloc(sizeof(ItemPointerData));
ItemPointerSet(itemp, 0, 2); // magic constants - it's will be filled from params
tuple.t_self = *itemp;
x = heap_fetch(rel, SnapshotNow, &tuple, &buf, true, NULL);
resultDatum = datumCopy(HeapTupleGetDatum(&tuple), false, -1);
PG_RETURN_DATUM(resultDatum);
}