67#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
68#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
69#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
70#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
150 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
151 errmsg(
"must be superuser to use pgstattuple functions")));
192 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
193 errmsg(
"must be superuser to use pgstattuple functions")));
223 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
224 errmsg(
"relation \"%s\" is not a btree index",
234 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
235 errmsg(
"cannot access temporary tables of other sessions")));
245 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
246 errmsg(
"index \"%s\" is not valid",
280 for (blkno = 1; blkno < nblocks; blkno++)
344 elog(
ERROR,
"return type must be a row type");
400 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
401 errmsg(
"must be superuser to use pgstattuple functions")));
432 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
433 errmsg(
"must be superuser to use pgstattuple functions")));
457 if (!RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
459 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
460 errmsg(
"cannot get page count of relation \"%s\"",
488 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
489 errmsg(
"must be superuser to use pgstattuple functions")));
514 bool nulls[3] = {
false,
false,
false};
521 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
522 errmsg(
"relation \"%s\" is not a GIN index",
532 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
533 errmsg(
"cannot access temporary indexes of other sessions")));
538 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
539 errmsg(
"index \"%s\" is not valid",
561 elog(
ERROR,
"return type must be a row type");
604 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
605 errmsg(
"relation \"%s\" is not a hash index",
615 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
616 errmsg(
"cannot access temporary indexes of other sessions")));
621 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
622 errmsg(
"index \"%s\" is not valid",
626 memset(&stats, 0,
sizeof(stats));
640 for (blkno = 1; blkno < nblocks; blkno++)
657 (
errcode(ERRCODE_INDEX_CORRUPTED),
658 errmsg(
"index \"%s\" contains corrupted page at block %u",
685 (
errcode(ERRCODE_INDEX_CORRUPTED),
686 errmsg(
"unexpected page type 0x%04X in HASH index \"%s\" block %u",
706 if (total_space == 0)
709 free_percent = 100.0 * stats.
free_space / total_space;
715 elog(
ERROR,
"return type must be a row type");
static Datum values[MAXATTR]
BlockNumber BufferGetBlockNumber(Buffer buffer)
void ReleaseBuffer(Buffer buffer)
void UnlockReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define BUFFER_LOCK_UNLOCK
#define BUFFER_LOCK_SHARE
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
Size PageGetExactFreeSpace(Page page)
PageHeaderData * PageHeader
#define SizeOfPageHeaderData
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
static uint16 PageGetSpecialSize(Page page)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
Datum Int64GetDatum(int64 X)
Datum Float8GetDatum(float8 X)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_INT64(x)
#define PG_RETURN_DATUM(x)
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define GIN_METAPAGE_BLKNO
#define GinPageGetMeta(p)
#define HashPageGetOpaque(page)
#define HashPageGetMeta(page)
void _hash_relbuf(Relation rel, Buffer buf)
Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access, int flags)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void index_close(Relation relation, LOCKMODE lockmode)
if(TABLE==NULL||TABLE_index==NULL)
#define ItemIdIsDead(itemId)
char * pstrdup(const char *in)
#define CHECK_FOR_INTERRUPTS()
RangeVar * makeRangeVarFromNameList(const List *names)
#define BTPageGetOpaque(page)
#define P_ISDELETED(opaque)
#define FirstOffsetNumber
int errdetail_relkind_not_supported(char relkind)
Datum pgstatindexbyid(PG_FUNCTION_ARGS)
Datum pgstatindexbyid_v1_5(PG_FUNCTION_ARGS)
Datum pgstatindex_v1_5(PG_FUNCTION_ARGS)
static void GetHashPageStats(Page page, HashIndexStat *stats)
static int64 pg_relpages_impl(Relation rel)
Datum pgstatginindex_v1_5(PG_FUNCTION_ARGS)
Datum pg_relpagesbyid(PG_FUNCTION_ARGS)
Datum pg_relpages(PG_FUNCTION_ARGS)
Datum pgstatginindex_internal(Oid relid, FunctionCallInfo fcinfo)
Datum pg_relpages_v1_5(PG_FUNCTION_ARGS)
struct HashIndexStat HashIndexStat
static Datum pgstatindex_impl(Relation rel, FunctionCallInfo fcinfo)
Datum pg_relpagesbyid_v1_5(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(pgstatindex)
Datum pgstatginindex(PG_FUNCTION_ARGS)
struct GinIndexStat GinIndexStat
Datum pgstathashindex(PG_FUNCTION_ARGS)
struct BTIndexStat BTIndexStat
Datum pgstatindex(PG_FUNCTION_ARGS)
static Datum Int32GetDatum(int32 X)
static Datum UInt32GetDatum(uint32 X)
char * psprintf(const char *fmt,...)
#define RelationGetRelationName(relation)
#define RELATION_IS_OTHER_TEMP(relation)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
BlockNumber pending_pages
BlockNumber nPendingPages
BlockNumber overflow_pages
List * textToQualifiedNameList(text *textval)