51 #define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
52 #define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
121 stat->dead_items =
stat->live_items = 0;
145 elog(
DEBUG2,
"deleted page from block %u has safexid %u:%u",
150 elog(
DEBUG2,
"deleted page from block %u has safexid %u",
190 if ((
stat->live_items +
stat->dead_items) > 0)
191 stat->avg_item_size = item_size / (
stat->live_items +
stat->dead_items);
193 stat->avg_item_size = 0;
208 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
209 errmsg(
"invalid block number %lld",
210 (
long long) blkno)));
214 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
215 errmsg(
"block number %lld is out of range",
216 (
long long) blkno)));
231 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
232 errmsg(
"\"%s\" is not a %s index",
242 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
243 errmsg(
"cannot access temporary tables of other sessions")));
247 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
248 errmsg(
"block 0 is a meta page")));
277 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
278 errmsg(
"must be superuser to use pageinspect functions")));
290 stat.btpo_flags =
stat.free_size =
stat.avg_item_size = 0;
299 elog(
ERROR,
"return type must be a row type");
354 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
355 errmsg(
"must be superuser to use pageinspect functions")));
386 uargs->
blkno = blkno;
430 stat.btpo_flags =
stat.free_size =
stat.avg_item_size = 0;
439 elog(
ERROR,
"return type must be a row type");
510 memset(nulls, 0,
sizeof(nulls));
549 elog(
ERROR,
"invalid tuple length %d for tuple at offset number %u",
553 for (off = 0; off < dlen; off++)
557 sprintf(dump,
"%02x", *(ptr + off) & 0xff);
569 ispivottuple = (!leafpage || (!rightmost && offset ==
P_HIKEY));
602 for (
int i = 0;
i < nposting;
i++)
636 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
637 errmsg(
"must be superuser to use pageinspect functions")));
689 elog(
ERROR,
"return type must be a row type");
692 uargs->
tupd = tupleDesc;
744 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
745 errmsg(
"must be superuser to use raw page functions")));
771 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
772 errmsg(
"input page is not a valid %s page",
"btree"),
773 errdetail(
"Expected special size %d, got %d.",
781 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
782 errmsg(
"block is a meta page")));
786 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
787 errmsg(
"block is not a valid btree leaf page")));
805 elog(
ERROR,
"return type must be a row type");
808 uargs->
tupd = tupleDesc;
829 #define BT_METAP_COLS_V1_8 9
856 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
857 errmsg(
"must be superuser to use pageinspect functions")));
864 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
865 errmsg(
"\"%s\" is not a %s index",
875 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
876 errmsg(
"cannot access temporary tables of other sessions")));
886 elog(
ERROR,
"return type must be a row type");
898 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
899 errmsg(
"function has wrong number of declared columns"),
900 errhint(
"To resolve the problem, update the \"pageinspect\" extension to the latest version.")));
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
#define InvalidBlockNumber
static Datum values[MAXATTR]
struct BTPageStat BTPageStat
Datum bt_page_stats(PG_FUNCTION_ARGS)
Datum bt_page_items(PG_FUNCTION_ARGS)
Datum bt_page_stats_1_9(PG_FUNCTION_ARGS)
Datum bt_page_items_1_9(PG_FUNCTION_ARGS)
Datum bt_page_items_bytea(PG_FUNCTION_ARGS)
#define BT_METAP_COLS_V1_8
static Datum bt_page_stats_internal(PG_FUNCTION_ARGS, enum pageinspect_version ext_version)
static void bt_index_block_validate(Relation rel, int64 blkno)
Datum bt_metap(PG_FUNCTION_ARGS)
static void check_relation_block_range(Relation rel, int64 blkno)
struct ua_page_items ua_page_items
PG_FUNCTION_INFO_V1(bt_metap)
struct ua_page_stats ua_page_stats
static Datum bt_page_print_tuples(ua_page_items *uargs)
static void GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
static Datum bt_page_items_internal(PG_FUNCTION_ARGS, enum pageinspect_version ext_version)
Datum bt_multi_page_stats(PG_FUNCTION_ARGS)
void UnlockReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define BUFFER_LOCK_SHARE
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
Size PageGetFreeSpace(Page page)
PageHeaderData * PageHeader
static Item PageGetItem(Page page, ItemId itemId)
static Size PageGetPageSize(Page page)
#define SizeOfPageHeaderData
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
static uint16 PageGetSpecialSize(Page page)
#define CStringGetTextDatum(s)
#define Assert(condition)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
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)
#define PG_GETARG_TEXT_PP(n)
#define PG_GETARG_UINT32(n)
#define PG_GETARG_INT64(n)
#define PG_RETURN_DATUM(x)
#define PG_GETARG_BYTEA_P(n)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define SRF_RETURN_DONE(_funcctx)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
#define ItemIdIsDead(itemId)
#define ItemIdIsValid(itemId)
static Datum ItemPointerGetDatum(const ItemPointerData *X)
#define IndexTupleHasVarwidths(itup)
#define IndexTupleHasNulls(itup)
IndexTupleData * IndexTuple
#define IndexTupleSize(itup)
static Size IndexInfoFindDataOffset(unsigned short t_info)
void pfree(void *pointer)
void * palloc0(Size size)
RangeVar * makeRangeVarFromNameList(const List *names)
#define P_HAS_FULLXID(opaque)
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
static bool BTreeTupleIsPivot(IndexTuple itup)
static FullTransactionId BTPageGetDeleteXid(Page page)
#define BTPageGetOpaque(page)
#define P_ISDELETED(opaque)
static ItemPointer BTreeTupleGetPosting(IndexTuple posting)
static uint32 BTreeTupleGetPostingOffset(IndexTuple posting)
#define P_RIGHTMOST(opaque)
static bool BTreeTupleIsPosting(IndexTuple itup)
#define BTREE_NOVAC_VERSION
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
#define InvalidOffsetNumber
#define FirstOffsetNumber
Page get_page_from_raw(bytea *raw_page)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum Int32GetDatum(int32 X)
static int16 DatumGetInt16(Datum X)
char * psprintf(const char *fmt,...)
MemoryContextSwitchTo(old_ctx)
#define RelationGetRelid(relation)
#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)
uint32 btm_last_cleanup_num_delpages
float8 btm_last_cleanup_num_heap_tuples
MemoryContext multi_call_memory_ctx
#define EpochFromFullTransactionId(x)
#define XidFromFullTransactionId(x)
List * textToQualifiedNameList(text *textval)