/* * gp_workfile_mgr_reset_segspace * Function to reset the used segspace on a segment * This directly manipulates the segspace counter and * should be used for testing purposes only * Returns the size before the reset */ Datum gp_workfile_mgr_reset_segspace(PG_FUNCTION_ARGS) { int64 size = WorkfileSegspace_GetSize(); WorkfileSegspace_Commit(0, size); return Int64GetDatum(size); }
/* * Returns the number of bytes used for workfiles on a segment * according to WorkfileDiskspace */ Datum gp_workfile_mgr_used_diskspace(PG_FUNCTION_ARGS) { /* * Build a tuple descriptor for our result type * The number and type of attributes have to match the definition of the * view gp_workfile_mgr_diskspace */ TupleDesc tupdesc = CreateTemplateTupleDesc(NUM_USED_DISKSPACE_ELEM, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "segid", INT4OID, -1 /* typmod */, 0 /* attdim */); TupleDescInitEntry(tupdesc, (AttrNumber) 2, "bytes", INT8OID, -1 /* typmod */, 0 /* attdim */); tupdesc = BlessTupleDesc(tupdesc); Datum values[NUM_USED_DISKSPACE_ELEM]; bool nulls[NUM_USED_DISKSPACE_ELEM]; MemSet(nulls, 0, sizeof(nulls)); values[0] = Int32GetDatum(GpIdentity.segindex); values[1] = Int64GetDatum(WorkfileSegspace_GetSize()); HeapTuple tuple = heap_form_tuple(tupdesc, values, nulls); Datum result = HeapTupleGetDatum(tuple); PG_RETURN_DATUM(result); }