#include "postgres.h"
#include "funcapi.h"
#include "storage/freespace.h"
Go to the source code of this file.
Functions | |
Datum | pg_freespace (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (pg_freespace) | |
Variables | |
PG_MODULE_MAGIC |
Datum pg_freespace | ( | PG_FUNCTION_ARGS | ) |
Definition at line 26 of file pg_freespacemap.c.
References AccessShareLock, ereport, errcode(), errmsg(), ERROR, GetRecordedFreeSpace(), MaxBlockNumber, PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_INT16, relation_close(), and relation_open().
{ Oid relid = PG_GETARG_OID(0); int64 blkno = PG_GETARG_INT64(1); int16 freespace; Relation rel; rel = relation_open(relid, AccessShareLock); if (blkno < 0 || blkno > MaxBlockNumber) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid block number"))); freespace = GetRecordedFreeSpace(rel, blkno); relation_close(rel, AccessShareLock); PG_RETURN_INT16(freespace); }
PG_FUNCTION_INFO_V1 | ( | pg_freespace | ) |
Definition at line 15 of file pg_freespacemap.c.