PostgreSQL Source Code  git master
btreefuncs.c File Reference
#include "postgres.h"
#include "access/nbtree.h"
#include "access/relation.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "pageinspect.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/rel.h"
#include "utils/varlena.h"
Include dependency graph for btreefuncs.c:

Go to the source code of this file.

Data Structures

struct  BTPageStat
 
struct  user_args
 

Macros

#define IS_INDEX(r)   ((r)->rd_rel->relkind == RELKIND_INDEX)
 
#define IS_BTREE(r)   ((r)->rd_rel->relam == BTREE_AM_OID)
 
#define DatumGetItemPointer(X)   ((ItemPointer) DatumGetPointer(X))
 
#define ItemPointerGetDatum(X)   PointerGetDatum(X)
 
#define CHECK_RELATION_BLOCK_RANGE(rel, blkno)
 
#define BT_METAP_COLS_V1_8   9
 

Typedefs

typedef struct BTPageStat BTPageStat
 

Functions

 PG_FUNCTION_INFO_V1 (bt_metap)
 
 PG_FUNCTION_INFO_V1 (bt_page_items)
 
 PG_FUNCTION_INFO_V1 (bt_page_items_bytea)
 
 PG_FUNCTION_INFO_V1 (bt_page_stats)
 
static void GetBTPageStatistics (BlockNumber blkno, Buffer buffer, BTPageStat *stat)
 
Datum bt_page_stats (PG_FUNCTION_ARGS)
 
static Datum bt_page_print_tuples (struct user_args *uargs)
 
Datum bt_page_items (PG_FUNCTION_ARGS)
 
Datum bt_page_items_bytea (PG_FUNCTION_ARGS)
 
Datum bt_metap (PG_FUNCTION_ARGS)
 

Macro Definition Documentation

◆ BT_METAP_COLS_V1_8

#define BT_METAP_COLS_V1_8   9

Definition at line 594 of file btreefuncs.c.

Referenced by bt_metap().

◆ CHECK_RELATION_BLOCK_RANGE

#define CHECK_RELATION_BLOCK_RANGE (   rel,
  blkno 
)
Value:
{ \
if ( RelationGetNumberOfBlocks(rel) <= (BlockNumber) (blkno) ) \
elog(ERROR, "block number out of range"); }
uint32 BlockNumber
Definition: block.h:31
#define ERROR
Definition: elog.h:43
#define RelationGetNumberOfBlocks(reln)
Definition: bufmgr.h:211

Definition at line 54 of file btreefuncs.c.

Referenced by bt_page_items(), and bt_page_stats().

◆ DatumGetItemPointer

#define DatumGetItemPointer (   X)    ((ItemPointer) DatumGetPointer(X))

Definition at line 50 of file btreefuncs.c.

◆ IS_BTREE

#define IS_BTREE (   r)    ((r)->rd_rel->relam == BTREE_AM_OID)

Definition at line 49 of file btreefuncs.c.

Referenced by bt_metap(), bt_page_items(), and bt_page_stats().

◆ IS_INDEX

#define IS_INDEX (   r)    ((r)->rd_rel->relkind == RELKIND_INDEX)

Definition at line 48 of file btreefuncs.c.

Referenced by bt_metap(), bt_page_items(), and bt_page_stats().

◆ ItemPointerGetDatum

#define ItemPointerGetDatum (   X)    PointerGetDatum(X)

Definition at line 51 of file btreefuncs.c.

Referenced by bt_page_print_tuples().

Typedef Documentation

◆ BTPageStat

typedef struct BTPageStat BTPageStat

Function Documentation

◆ bt_metap()

Datum bt_metap ( PG_FUNCTION_ARGS  )

Definition at line 605 of file btreefuncs.c.

References AccessShareLock, BT_METAP_COLS_V1_8, BTMetaPageData::btm_allequalimage, BTMetaPageData::btm_fastlevel, BTMetaPageData::btm_fastroot, BTMetaPageData::btm_last_cleanup_num_heap_tuples, BTMetaPageData::btm_level, BTMetaPageData::btm_magic, BTMetaPageData::btm_oldest_btpo_xact, BTMetaPageData::btm_root, BTMetaPageData::btm_version, BTPageGetMeta, BTREE_NOVAC_VERSION, BUFFER_LOCK_SHARE, BufferGetPage, BuildTupleFromCStrings(), elog, ereport, errcode(), errhint(), errmsg(), ERROR, get_call_result_type(), HeapTupleGetDatum, INT64_FORMAT, IS_BTREE, IS_INDEX, LockBuffer(), makeRangeVarFromNameList(), TupleDescData::natts, user_args::page, PG_GETARG_TEXT_PP, PG_RETURN_DATUM, psprintf(), ReadBuffer(), relation_close(), RELATION_IS_OTHER_TEMP, relation_openrv(), RelationGetRelationName, relname, superuser(), textToQualifiedNameList(), TupleDescGetAttInMetadata(), TYPEFUNC_COMPOSITE, UnlockReleaseBuffer(), and values.

606 {
608  Datum result;
609  Relation rel;
610  RangeVar *relrv;
611  BTMetaPageData *metad;
612  TupleDesc tupleDesc;
613  int j;
614  char *values[9];
615  Buffer buffer;
616  Page page;
617  HeapTuple tuple;
618 
619  if (!superuser())
620  ereport(ERROR,
621  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
622  errmsg("must be superuser to use pageinspect functions")));
623 
625  rel = relation_openrv(relrv, AccessShareLock);
626 
627  if (!IS_INDEX(rel) || !IS_BTREE(rel))
628  elog(ERROR, "relation \"%s\" is not a btree index",
630 
631  /*
632  * Reject attempts to read non-local temporary relations; we would be
633  * likely to get wrong data since we have no visibility into the owning
634  * session's local buffers.
635  */
636  if (RELATION_IS_OTHER_TEMP(rel))
637  ereport(ERROR,
638  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
639  errmsg("cannot access temporary tables of other sessions")));
640 
641  buffer = ReadBuffer(rel, 0);
642  LockBuffer(buffer, BUFFER_LOCK_SHARE);
643 
644  page = BufferGetPage(buffer);
645  metad = BTPageGetMeta(page);
646 
647  /* Build a tuple descriptor for our result type */
648  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
649  elog(ERROR, "return type must be a row type");
650 
651  /*
652  * We need a kluge here to detect API versions prior to 1.8. Earlier
653  * versions incorrectly used int4 for certain columns. This caused
654  * various problems. For example, an int4 version of the "oldest_xact"
655  * column would not work with TransactionId values that happened to exceed
656  * PG_INT32_MAX.
657  *
658  * There is no way to reliably avoid the problems created by the old
659  * function definition at this point, so insist that the user update the
660  * extension.
661  */
662  if (tupleDesc->natts < BT_METAP_COLS_V1_8)
663  ereport(ERROR,
664  (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
665  errmsg("function has wrong number of declared columns"),
666  errhint("To resolve the problem, update the \"pageinspect\" extension to the latest version.")));
667 
668  j = 0;
669  values[j++] = psprintf("%d", metad->btm_magic);
670  values[j++] = psprintf("%d", metad->btm_version);
671  values[j++] = psprintf(INT64_FORMAT, (int64) metad->btm_root);
672  values[j++] = psprintf(INT64_FORMAT, (int64) metad->btm_level);
673  values[j++] = psprintf(INT64_FORMAT, (int64) metad->btm_fastroot);
674  values[j++] = psprintf(INT64_FORMAT, (int64) metad->btm_fastlevel);
675 
676  /*
677  * Get values of extended metadata if available, use default values
678  * otherwise. Note that we rely on the assumption that btm_allequalimage
679  * is initialized to zero with indexes that were built on versions prior
680  * to Postgres 13 (just like _bt_metaversion()).
681  */
682  if (metad->btm_version >= BTREE_NOVAC_VERSION)
683  {
684  values[j++] = psprintf("%u", metad->btm_oldest_btpo_xact);
685  values[j++] = psprintf("%f", metad->btm_last_cleanup_num_heap_tuples);
686  values[j++] = metad->btm_allequalimage ? "t" : "f";
687  }
688  else
689  {
690  values[j++] = "0";
691  values[j++] = "-1";
692  values[j++] = "f";
693  }
694 
696  values);
697 
698  result = HeapTupleGetDatum(tuple);
699 
700  UnlockReleaseBuffer(buffer);
702 
703  PG_RETURN_DATUM(result);
704 }
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:205
int errhint(const char *fmt,...)
Definition: elog.c:1068
uint32 btm_version
Definition: nbtree.h:101
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
uint32 btm_magic
Definition: nbtree.h:100
#define AccessShareLock
Definition: lockdefs.h:36
int errcode(int sqlerrcode)
Definition: elog.c:610
#define IS_BTREE(r)
Definition: btreefuncs.c:49
bool superuser(void)
Definition: superuser.c:46
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3061
NameData relname
Definition: pg_class.h:38
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
Definition: execTuples.c:2116
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:308
BlockNumber btm_fastroot
Definition: nbtree.h:104
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3534
#define ERROR
Definition: elog.h:43
#define BTPageGetMeta(p)
Definition: nbtree.h:114
bool btm_allequalimage
Definition: nbtree.h:111
#define RelationGetRelationName(relation)
Definition: rel.h:490
#define BTREE_NOVAC_VERSION
Definition: nbtree.h:145
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
List * textToQualifiedNameList(text *textval)
Definition: varlena.c:3644
uint32 btm_fastlevel
Definition: nbtree.h:105
#define BT_METAP_COLS_V1_8
Definition: btreefuncs.c:594
uintptr_t Datum
Definition: postgres.h:367
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:352
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
Definition: execTuples.c:2067
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3750
Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
Definition: relation.c:138
BlockNumber btm_root
Definition: nbtree.h:102
#define ereport(elevel,...)
Definition: elog.h:144
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:206
#define RELATION_IS_OTHER_TEMP(relation)
Definition: rel.h:593
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:607
float8 btm_last_cleanup_num_heap_tuples
Definition: nbtree.h:109
#define HeapTupleGetDatum(tuple)
Definition: funcapi.h:221
#define INT64_FORMAT
Definition: c.h:417
static Datum values[MAXATTR]
Definition: bootstrap.c:165
int errmsg(const char *fmt,...)
Definition: elog.c:821
uint32 btm_level
Definition: nbtree.h:103
#define elog(elevel,...)
Definition: elog.h:214
#define BUFFER_LOCK_SHARE
Definition: bufmgr.h:97
Definition: c.h:563
TransactionId btm_oldest_btpo_xact
Definition: nbtree.h:107
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78
#define IS_INDEX(r)
Definition: btreefuncs.c:48

◆ bt_page_items()

Datum bt_page_items ( PG_FUNCTION_ARGS  )

Definition at line 409 of file btreefuncs.c.

References AccessShareLock, BlessTupleDesc(), BTPageStat::blkno, bt_page_print_tuples(), BUFFER_LOCK_SHARE, BufferGetPage, FuncCallContext::call_cntr, CHECK_RELATION_BLOCK_RANGE, elog, ereport, errcode(), errmsg(), ERROR, FirstOffsetNumber, get_call_result_type(), IS_BTREE, IS_INDEX, user_args::leafpage, LockBuffer(), makeRangeVarFromNameList(), FuncCallContext::max_calls, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, NOTICE, user_args::offset, P_ISDELETED, P_ISLEAF, P_RIGHTMOST, user_args::page, PageGetMaxOffsetNumber, PageGetSpecialPointer, palloc(), PG_GETARG_TEXT_PP, PG_GETARG_UINT32, ReadBuffer(), relation_close(), RELATION_IS_OTHER_TEMP, relation_openrv(), RelationGetRelationName, relname, user_args::rightmost, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, superuser(), textToQualifiedNameList(), user_args::tupd, TYPEFUNC_COMPOSITE, UnlockReleaseBuffer(), and FuncCallContext::user_fctx.

410 {
412  uint32 blkno = PG_GETARG_UINT32(1);
413  Datum result;
414  FuncCallContext *fctx;
415  MemoryContext mctx;
416  struct user_args *uargs;
417 
418  if (!superuser())
419  ereport(ERROR,
420  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
421  errmsg("must be superuser to use pageinspect functions")));
422 
423  if (SRF_IS_FIRSTCALL())
424  {
425  RangeVar *relrv;
426  Relation rel;
427  Buffer buffer;
428  BTPageOpaque opaque;
429  TupleDesc tupleDesc;
430 
431  fctx = SRF_FIRSTCALL_INIT();
432 
434  rel = relation_openrv(relrv, AccessShareLock);
435 
436  if (!IS_INDEX(rel) || !IS_BTREE(rel))
437  elog(ERROR, "relation \"%s\" is not a btree index",
439 
440  /*
441  * Reject attempts to read non-local temporary relations; we would be
442  * likely to get wrong data since we have no visibility into the
443  * owning session's local buffers.
444  */
445  if (RELATION_IS_OTHER_TEMP(rel))
446  ereport(ERROR,
447  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
448  errmsg("cannot access temporary tables of other sessions")));
449 
450  if (blkno == 0)
451  elog(ERROR, "block 0 is a meta page");
452 
453  CHECK_RELATION_BLOCK_RANGE(rel, blkno);
454 
455  buffer = ReadBuffer(rel, blkno);
456  LockBuffer(buffer, BUFFER_LOCK_SHARE);
457 
458  /*
459  * We copy the page into local storage to avoid holding pin on the
460  * buffer longer than we must, and possibly failing to release it at
461  * all if the calling query doesn't fetch all rows.
462  */
464 
465  uargs = palloc(sizeof(struct user_args));
466 
467  uargs->page = palloc(BLCKSZ);
468  memcpy(uargs->page, BufferGetPage(buffer), BLCKSZ);
469 
470  UnlockReleaseBuffer(buffer);
472 
473  uargs->offset = FirstOffsetNumber;
474 
475  opaque = (BTPageOpaque) PageGetSpecialPointer(uargs->page);
476 
477  if (P_ISDELETED(opaque))
478  elog(NOTICE, "page is deleted");
479 
480  fctx->max_calls = PageGetMaxOffsetNumber(uargs->page);
481  uargs->leafpage = P_ISLEAF(opaque);
482  uargs->rightmost = P_RIGHTMOST(opaque);
483 
484  /* Build a tuple descriptor for our result type */
485  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
486  elog(ERROR, "return type must be a row type");
487  tupleDesc = BlessTupleDesc(tupleDesc);
488 
489  uargs->tupd = tupleDesc;
490 
491  fctx->user_fctx = uargs;
492 
493  MemoryContextSwitchTo(mctx);
494  }
495 
496  fctx = SRF_PERCALL_SETUP();
497  uargs = fctx->user_fctx;
498 
499  if (fctx->call_cntr < fctx->max_calls)
500  {
501  result = bt_page_print_tuples(uargs);
502  uargs->offset++;
503  SRF_RETURN_NEXT(fctx, result);
504  }
505 
506  SRF_RETURN_DONE(fctx);
507 }
uint64 call_cntr
Definition: funcapi.h:65
#define PG_GETARG_UINT32(n)
Definition: fmgr.h:270
static Datum bt_page_print_tuples(struct user_args *uargs)
Definition: btreefuncs.c:262
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:205
#define CHECK_RELATION_BLOCK_RANGE(rel, blkno)
Definition: btreefuncs.c:54
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:294
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define AccessShareLock
Definition: lockdefs.h:36
int errcode(int sqlerrcode)
Definition: elog.c:610
#define IS_BTREE(r)
Definition: btreefuncs.c:49
bool superuser(void)
Definition: superuser.c:46
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3061
NameData relname
Definition: pg_class.h:38
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:298
BTPageOpaqueData * BTPageOpaque
Definition: nbtree.h:69
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:308
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:300
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3534
#define ERROR
Definition: elog.h:43
OffsetNumber offset
Definition: btreefuncs.c:249
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2052
#define FirstOffsetNumber
Definition: off.h:27
#define RelationGetRelationName(relation)
Definition: rel.h:490
unsigned int uint32
Definition: c.h:375
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
#define P_ISDELETED(opaque)
Definition: nbtree.h:216
List * textToQualifiedNameList(text *textval)
Definition: varlena.c:3644
uintptr_t Datum
Definition: postgres.h:367
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3750
Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
Definition: relation.c:138
Page page
Definition: btreefuncs.c:248
#define ereport(elevel,...)
Definition: elog.h:144
#define NOTICE
Definition: elog.h:37
bool leafpage
Definition: btreefuncs.c:250
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:206
#define RELATION_IS_OTHER_TEMP(relation)
Definition: rel.h:593
MemoryContext multi_call_memory_ctx
Definition: funcapi.h:101
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:607
#define PageGetSpecialPointer(page)
Definition: bufpage.h:326
void * user_fctx
Definition: funcapi.h:82
void * palloc(Size size)
Definition: mcxt.c:950
int errmsg(const char *fmt,...)
Definition: elog.c:821
#define elog(elevel,...)
Definition: elog.h:214
#define BUFFER_LOCK_SHARE
Definition: bufmgr.h:97
Definition: c.h:563
TupleDesc tupd
Definition: btreefuncs.c:252
int Buffer
Definition: buf.h:23
#define P_RIGHTMOST(opaque)
Definition: nbtree.h:213
uint64 max_calls
Definition: funcapi.h:74
#define IS_INDEX(r)
Definition: btreefuncs.c:48
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:318
#define P_ISLEAF(opaque)
Definition: nbtree.h:214
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:296
bool rightmost
Definition: btreefuncs.c:251

◆ bt_page_items_bytea()

Datum bt_page_items_bytea ( PG_FUNCTION_ARGS  )

Definition at line 519 of file btreefuncs.c.

References BlessTupleDesc(), bt_page_print_tuples(), FuncCallContext::call_cntr, elog, ereport, errcode(), errmsg(), ERROR, FirstOffsetNumber, get_call_result_type(), user_args::leafpage, FuncCallContext::max_calls, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, NOTICE, user_args::offset, P_ISDELETED, P_ISLEAF, P_ISMETA, P_RIGHTMOST, user_args::page, PageGetMaxOffsetNumber, PageGetSpecialPointer, palloc(), PG_GETARG_BYTEA_P, user_args::rightmost, SizeOfPageHeaderData, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, superuser(), user_args::tupd, TYPEFUNC_COMPOSITE, FuncCallContext::user_fctx, VARDATA, VARHDRSZ, and VARSIZE.

520 {
521  bytea *raw_page = PG_GETARG_BYTEA_P(0);
522  Datum result;
523  FuncCallContext *fctx;
524  struct user_args *uargs;
525  int raw_page_size;
526 
527  if (!superuser())
528  ereport(ERROR,
529  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
530  errmsg("must be superuser to use raw page functions")));
531 
532  if (SRF_IS_FIRSTCALL())
533  {
534  BTPageOpaque opaque;
535  MemoryContext mctx;
536  TupleDesc tupleDesc;
537 
538  raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
539 
540  if (raw_page_size < SizeOfPageHeaderData)
541  ereport(ERROR,
542  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
543  errmsg("input page too small (%d bytes)", raw_page_size)));
544 
545  fctx = SRF_FIRSTCALL_INIT();
547 
548  uargs = palloc(sizeof(struct user_args));
549 
550  uargs->page = VARDATA(raw_page);
551 
552  uargs->offset = FirstOffsetNumber;
553 
554  opaque = (BTPageOpaque) PageGetSpecialPointer(uargs->page);
555 
556  if (P_ISMETA(opaque))
557  ereport(ERROR,
558  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
559  errmsg("block is a meta page")));
560 
561  if (P_ISDELETED(opaque))
562  elog(NOTICE, "page is deleted");
563 
564  fctx->max_calls = PageGetMaxOffsetNumber(uargs->page);
565  uargs->leafpage = P_ISLEAF(opaque);
566  uargs->rightmost = P_RIGHTMOST(opaque);
567 
568  /* Build a tuple descriptor for our result type */
569  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
570  elog(ERROR, "return type must be a row type");
571  tupleDesc = BlessTupleDesc(tupleDesc);
572 
573  uargs->tupd = tupleDesc;
574 
575  fctx->user_fctx = uargs;
576 
577  MemoryContextSwitchTo(mctx);
578  }
579 
580  fctx = SRF_PERCALL_SETUP();
581  uargs = fctx->user_fctx;
582 
583  if (fctx->call_cntr < fctx->max_calls)
584  {
585  result = bt_page_print_tuples(uargs);
586  uargs->offset++;
587  SRF_RETURN_NEXT(fctx, result);
588  }
589 
590  SRF_RETURN_DONE(fctx);
591 }
uint64 call_cntr
Definition: funcapi.h:65
static Datum bt_page_print_tuples(struct user_args *uargs)
Definition: btreefuncs.c:262
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:205
#define VARDATA(PTR)
Definition: postgres.h:302
#define VARSIZE(PTR)
Definition: postgres.h:303
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:294
#define VARHDRSZ
Definition: c.h:569
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
int errcode(int sqlerrcode)
Definition: elog.c:610
bool superuser(void)
Definition: superuser.c:46
#define SizeOfPageHeaderData
Definition: bufpage.h:216
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:298
BTPageOpaqueData * BTPageOpaque
Definition: nbtree.h:69
#define P_ISMETA(opaque)
Definition: nbtree.h:217
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:300
#define PG_GETARG_BYTEA_P(n)
Definition: fmgr.h:334
#define ERROR
Definition: elog.h:43
OffsetNumber offset
Definition: btreefuncs.c:249
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2052
#define FirstOffsetNumber
Definition: off.h:27
#define P_ISDELETED(opaque)
Definition: nbtree.h:216
uintptr_t Datum
Definition: postgres.h:367
Page page
Definition: btreefuncs.c:248
#define ereport(elevel,...)
Definition: elog.h:144
#define NOTICE
Definition: elog.h:37
bool leafpage
Definition: btreefuncs.c:250
MemoryContext multi_call_memory_ctx
Definition: funcapi.h:101
#define PageGetSpecialPointer(page)
Definition: bufpage.h:326
void * user_fctx
Definition: funcapi.h:82
void * palloc(Size size)
Definition: mcxt.c:950
int errmsg(const char *fmt,...)
Definition: elog.c:821
#define elog(elevel,...)
Definition: elog.h:214
Definition: c.h:563
TupleDesc tupd
Definition: btreefuncs.c:252
#define P_RIGHTMOST(opaque)
Definition: nbtree.h:213
uint64 max_calls
Definition: funcapi.h:74
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:318
#define P_ISLEAF(opaque)
Definition: nbtree.h:214
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:296
bool rightmost
Definition: btreefuncs.c:251

◆ bt_page_print_tuples()

static Datum bt_page_print_tuples ( struct user_args uargs)
static

Definition at line 262 of file btreefuncs.c.

References Assert, BoolGetDatum, BTreeTupleGetHeapTID(), BTreeTupleGetNPosting(), BTreeTupleGetPosting(), BTreeTupleGetPostingOffset(), BTreeTupleIsPivot(), BTreeTupleIsPosting(), construct_array(), CStringGetTextDatum, DatumGetInt16, elog, ERROR, heap_form_tuple(), HeapTupleGetDatum, i, INDEX_SIZE_MASK, IndexInfoFindDataOffset, IndexTupleHasNulls, IndexTupleHasVarwidths, IndexTupleSize, Int32GetDatum, ItemIdIsDead, ItemIdIsValid, ItemPointerGetDatum, user_args::leafpage, MAXALIGN, user_args::offset, P_HIKEY, user_args::page, PageGetItem, PageGetItemId, palloc(), palloc0(), pfree(), PointerGetDatum, user_args::rightmost, sprintf, IndexTupleData::t_info, IndexTupleData::t_tid, user_args::tupd, and values.

Referenced by bt_page_items(), and bt_page_items_bytea().

263 {
264  Page page = uargs->page;
265  OffsetNumber offset = uargs->offset;
266  bool leafpage = uargs->leafpage;
267  bool rightmost = uargs->rightmost;
268  bool ispivottuple;
269  Datum values[9];
270  bool nulls[9];
271  HeapTuple tuple;
272  ItemId id;
273  IndexTuple itup;
274  int j;
275  int off;
276  int dlen;
277  char *dump,
278  *datacstring;
279  char *ptr;
280  ItemPointer htid;
281 
282  id = PageGetItemId(page, offset);
283 
284  if (!ItemIdIsValid(id))
285  elog(ERROR, "invalid ItemId");
286 
287  itup = (IndexTuple) PageGetItem(page, id);
288 
289  j = 0;
290  memset(nulls, 0, sizeof(nulls));
291  values[j++] = DatumGetInt16(offset);
292  values[j++] = ItemPointerGetDatum(&itup->t_tid);
293  values[j++] = Int32GetDatum((int) IndexTupleSize(itup));
294  values[j++] = BoolGetDatum(IndexTupleHasNulls(itup));
295  values[j++] = BoolGetDatum(IndexTupleHasVarwidths(itup));
296 
297  ptr = (char *) itup + IndexInfoFindDataOffset(itup->t_info);
298  dlen = IndexTupleSize(itup) - IndexInfoFindDataOffset(itup->t_info);
299 
300  /*
301  * Make sure that "data" column does not include posting list or pivot
302  * tuple representation of heap TID(s).
303  *
304  * Note: BTreeTupleIsPivot() won't work reliably on !heapkeyspace indexes
305  * (those built before BTREE_VERSION 4), but we have no way of determining
306  * if this page came from a !heapkeyspace index. We may only have a bytea
307  * nbtree page image to go on, so in general there is no metapage that we
308  * can check.
309  *
310  * That's okay here because BTreeTupleIsPivot() can only return false for
311  * a !heapkeyspace pivot, never true for a !heapkeyspace non-pivot. Since
312  * heap TID isn't part of the keyspace in a !heapkeyspace index anyway,
313  * there cannot possibly be a pivot tuple heap TID representation that we
314  * fail to make an adjustment for. A !heapkeyspace index can have
315  * BTreeTupleIsPivot() return true (due to things like suffix truncation
316  * for INCLUDE indexes in Postgres v11), but when that happens
317  * BTreeTupleGetHeapTID() can be trusted to work reliably (i.e. return
318  * NULL).
319  *
320  * Note: BTreeTupleIsPosting() always works reliably, even with
321  * !heapkeyspace indexes.
322  */
323  if (BTreeTupleIsPosting(itup))
324  dlen -= IndexTupleSize(itup) - BTreeTupleGetPostingOffset(itup);
325  else if (BTreeTupleIsPivot(itup) && BTreeTupleGetHeapTID(itup) != NULL)
326  dlen -= MAXALIGN(sizeof(ItemPointerData));
327 
328  if (dlen < 0 || dlen > INDEX_SIZE_MASK)
329  elog(ERROR, "invalid tuple length %d for tuple at offset number %u",
330  dlen, offset);
331  dump = palloc0(dlen * 3 + 1);
332  datacstring = dump;
333  for (off = 0; off < dlen; off++)
334  {
335  if (off > 0)
336  *dump++ = ' ';
337  sprintf(dump, "%02x", *(ptr + off) & 0xff);
338  dump += 2;
339  }
340  values[j++] = CStringGetTextDatum(datacstring);
341  pfree(datacstring);
342 
343  /*
344  * We need to work around the BTreeTupleIsPivot() !heapkeyspace limitation
345  * again. Deduce whether or not tuple must be a pivot tuple based on
346  * whether or not the page is a leaf page, as well as the page offset
347  * number of the tuple.
348  */
349  ispivottuple = (!leafpage || (!rightmost && offset == P_HIKEY));
350 
351  /* LP_DEAD bit can never be set for pivot tuples, so show a NULL there */
352  if (!ispivottuple)
353  values[j++] = BoolGetDatum(ItemIdIsDead(id));
354  else
355  {
356  Assert(!ItemIdIsDead(id));
357  nulls[j++] = true;
358  }
359 
360  htid = BTreeTupleGetHeapTID(itup);
361  if (ispivottuple && !BTreeTupleIsPivot(itup))
362  {
363  /* Don't show bogus heap TID in !heapkeyspace pivot tuple */
364  htid = NULL;
365  }
366 
367  if (htid)
368  values[j++] = ItemPointerGetDatum(htid);
369  else
370  nulls[j++] = true;
371 
372  if (BTreeTupleIsPosting(itup))
373  {
374  /* Build an array of item pointers */
375  ItemPointer tids;
376  Datum *tids_datum;
377  int nposting;
378 
379  tids = BTreeTupleGetPosting(itup);
380  nposting = BTreeTupleGetNPosting(itup);
381  tids_datum = (Datum *) palloc(nposting * sizeof(Datum));
382  for (int i = 0; i < nposting; i++)
383  tids_datum[i] = ItemPointerGetDatum(&tids[i]);
384  values[j++] = PointerGetDatum(construct_array(tids_datum,
385  nposting,
386  TIDOID,
387  sizeof(ItemPointerData),
388  false, TYPALIGN_SHORT));
389  pfree(tids_datum);
390  }
391  else
392  nulls[j++] = true;
393 
394  /* Build and return the result tuple */
395  tuple = heap_form_tuple(uargs->tupd, values, nulls);
396 
397  return HeapTupleGetDatum(tuple);
398 }
#define IndexInfoFindDataOffset(t_info)
Definition: itup.h:80
static bool BTreeTupleIsPivot(IndexTuple itup)
Definition: nbtree.h:348
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
Definition: nbtree.h:506
#define PointerGetDatum(X)
Definition: postgres.h:556
static ItemPointer BTreeTupleGetPosting(IndexTuple posting)
Definition: nbtree.h:405
ItemPointerData t_tid
Definition: itup.h:37
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:3313
#define INDEX_SIZE_MASK
Definition: itup.h:65
#define IndexTupleHasNulls(itup)
Definition: itup.h:72
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
#define ItemIdIsDead(itemId)
Definition: itemid.h:113
uint16 OffsetNumber
Definition: off.h:24
#define sprintf
Definition: port.h:217
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ERROR
Definition: elog.h:43
OffsetNumber offset
Definition: btreefuncs.c:249
IndexTupleData * IndexTuple
Definition: itup.h:53
#define DatumGetInt16(X)
Definition: postgres.h:444
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:235
void * palloc0(Size size)
Definition: mcxt.c:981
uintptr_t Datum
Definition: postgres.h:367
Page page
Definition: btreefuncs.c:248
#define BoolGetDatum(X)
Definition: postgres.h:402
#define ItemIdIsValid(itemId)
Definition: itemid.h:86
static bool BTreeTupleIsPosting(IndexTuple itup)
Definition: nbtree.h:360
static uint32 BTreeTupleGetPostingOffset(IndexTuple posting)
Definition: nbtree.h:397
bool leafpage
Definition: btreefuncs.c:250
#define Assert(condition)
Definition: c.h:746
#define MAXALIGN(LEN)
Definition: c.h:699
#define HeapTupleGetDatum(tuple)
Definition: funcapi.h:221
#define IndexTupleHasVarwidths(itup)
Definition: itup.h:73
#define P_HIKEY
Definition: nbtree.h:242
static Datum values[MAXATTR]
Definition: bootstrap.c:165
#define Int32GetDatum(X)
Definition: postgres.h:479
void * palloc(Size size)
Definition: mcxt.c:950
#define elog(elevel,...)
Definition: elog.h:214
int i
#define CStringGetTextDatum(s)
Definition: builtins.h:86
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
Definition: nbtree.h:386
TupleDesc tupd
Definition: btreefuncs.c:252
#define ItemPointerGetDatum(X)
Definition: btreefuncs.c:51
unsigned short t_info
Definition: itup.h:49
#define PageGetItem(page, itemId)
Definition: bufpage.h:340
Pointer Page
Definition: bufpage.h:78
#define IndexTupleSize(itup)
Definition: itup.h:71
bool rightmost
Definition: btreefuncs.c:251

◆ bt_page_stats()

Datum bt_page_stats ( PG_FUNCTION_ARGS  )

Definition at line 164 of file btreefuncs.c.

References AccessShareLock, BTPageStat::avg_item_size, BTPageStat::blkno, BTPageStat::btpo, BTPageStat::btpo_flags, BTPageStat::btpo_next, BTPageStat::btpo_prev, BUFFER_LOCK_SHARE, BuildTupleFromCStrings(), CHECK_RELATION_BLOCK_RANGE, BTPageStat::dead_items, elog, ereport, errcode(), errmsg(), ERROR, BTPageStat::free_size, get_call_result_type(), GetBTPageStatistics(), HeapTupleGetDatum, InvalidBlockNumber, IS_BTREE, IS_INDEX, BTPageStat::level, BTPageStat::live_items, LockBuffer(), makeRangeVarFromNameList(), BTPageStat::page_size, PG_GETARG_TEXT_PP, PG_GETARG_UINT32, PG_RETURN_DATUM, psprintf(), ReadBuffer(), relation_close(), RELATION_IS_OTHER_TEMP, relation_openrv(), RelationGetRelationName, relname, stat, superuser(), textToQualifiedNameList(), TupleDescGetAttInMetadata(), BTPageStat::type, TYPEFUNC_COMPOSITE, UnlockReleaseBuffer(), values, and BTPageStat::xact.

165 {
167  uint32 blkno = PG_GETARG_UINT32(1);
168  Buffer buffer;
169  Relation rel;
170  RangeVar *relrv;
171  Datum result;
172  HeapTuple tuple;
173  TupleDesc tupleDesc;
174  int j;
175  char *values[11];
177 
178  if (!superuser())
179  ereport(ERROR,
180  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
181  errmsg("must be superuser to use pageinspect functions")));
182 
184  rel = relation_openrv(relrv, AccessShareLock);
185 
186  if (!IS_INDEX(rel) || !IS_BTREE(rel))
187  elog(ERROR, "relation \"%s\" is not a btree index",
189 
190  /*
191  * Reject attempts to read non-local temporary relations; we would be
192  * likely to get wrong data since we have no visibility into the owning
193  * session's local buffers.
194  */
195  if (RELATION_IS_OTHER_TEMP(rel))
196  ereport(ERROR,
197  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
198  errmsg("cannot access temporary tables of other sessions")));
199 
200  if (blkno == 0)
201  elog(ERROR, "block 0 is a meta page");
202 
203  CHECK_RELATION_BLOCK_RANGE(rel, blkno);
204 
205  buffer = ReadBuffer(rel, blkno);
206  LockBuffer(buffer, BUFFER_LOCK_SHARE);
207 
208  /* keep compiler quiet */
209  stat.btpo_prev = stat.btpo_next = InvalidBlockNumber;
210  stat.btpo_flags = stat.free_size = stat.avg_item_size = 0;
211 
212  GetBTPageStatistics(blkno, buffer, &stat);
213 
214  UnlockReleaseBuffer(buffer);
216 
217  /* Build a tuple descriptor for our result type */
218  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
219  elog(ERROR, "return type must be a row type");
220 
221  j = 0;
222  values[j++] = psprintf("%d", stat.blkno);
223  values[j++] = psprintf("%c", stat.type);
224  values[j++] = psprintf("%d", stat.live_items);
225  values[j++] = psprintf("%d", stat.dead_items);
226  values[j++] = psprintf("%d", stat.avg_item_size);
227  values[j++] = psprintf("%d", stat.page_size);
228  values[j++] = psprintf("%d", stat.free_size);
229  values[j++] = psprintf("%d", stat.btpo_prev);
230  values[j++] = psprintf("%d", stat.btpo_next);
231  values[j++] = psprintf("%d", (stat.type == 'd') ? stat.btpo.xact : stat.btpo.level);
232  values[j++] = psprintf("%d", stat.btpo_flags);
233 
235  values);
236 
237  result = HeapTupleGetDatum(tuple);
238 
239  PG_RETURN_DATUM(result);
240 }
uint32 avg_item_size
Definition: btreefuncs.c:70
#define PG_GETARG_UINT32(n)
Definition: fmgr.h:270
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:205
uint32 dead_items
Definition: btreefuncs.c:66
#define CHECK_RELATION_BLOCK_RANGE(rel, blkno)
Definition: btreefuncs.c:54
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
#define AccessShareLock
Definition: lockdefs.h:36
uint32 blkno
Definition: btreefuncs.c:64
int errcode(int sqlerrcode)
Definition: elog.c:610
#define IS_BTREE(r)
Definition: btreefuncs.c:49
bool superuser(void)
Definition: superuser.c:46
char type
Definition: btreefuncs.c:71
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3061
NameData relname
Definition: pg_class.h:38
union BTPageStat::@0 btpo
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
Definition: execTuples.c:2116
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:308
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3534
#define ERROR
Definition: elog.h:43
BlockNumber btpo_next
Definition: btreefuncs.c:75
#define RelationGetRelationName(relation)
Definition: rel.h:490
unsigned int uint32
Definition: c.h:375
List * textToQualifiedNameList(text *textval)
Definition: varlena.c:3644
uint32 live_items
Definition: btreefuncs.c:65
TransactionId xact
Definition: btreefuncs.c:79
BlockNumber btpo_prev
Definition: btreefuncs.c:74
uintptr_t Datum
Definition: postgres.h:367
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:352
uint32 free_size
Definition: btreefuncs.c:69
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
Definition: execTuples.c:2067
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3750
Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
Definition: relation.c:138
#define ereport(elevel,...)
Definition: elog.h:144
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:206
#define RELATION_IS_OTHER_TEMP(relation)
Definition: rel.h:593
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:607
#define InvalidBlockNumber
Definition: block.h:33
#define HeapTupleGetDatum(tuple)
Definition: funcapi.h:221
uint16 btpo_flags
Definition: btreefuncs.c:81
static void GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
Definition: btreefuncs.c:93
static Datum values[MAXATTR]
Definition: bootstrap.c:165
int errmsg(const char *fmt,...)
Definition: elog.c:821
uint32 page_size
Definition: btreefuncs.c:67
#define elog(elevel,...)
Definition: elog.h:214
#define BUFFER_LOCK_SHARE
Definition: bufmgr.h:97
Definition: c.h:563
uint32 level
Definition: btreefuncs.c:78
int Buffer
Definition: buf.h:23
#define stat
Definition: win32_port.h:275
#define IS_INDEX(r)
Definition: btreefuncs.c:48

◆ GetBTPageStatistics()

static void GetBTPageStatistics ( BlockNumber  blkno,
Buffer  buffer,
BTPageStat stat 
)
static

Definition at line 93 of file btreefuncs.c.

References BTPageStat::avg_item_size, BTPageStat::blkno, BTPageOpaqueData::btpo, BTPageStat::btpo, BTPageOpaqueData::btpo_cycleid, BTPageStat::btpo_cycleid, BTPageOpaqueData::btpo_flags, BTPageStat::btpo_flags, BTPageOpaqueData::btpo_next, BTPageStat::btpo_next, BTPageOpaqueData::btpo_prev, BTPageStat::btpo_prev, BufferGetPage, BTPageStat::dead_items, FirstOffsetNumber, BTPageStat::free_size, IndexTupleSize, ItemIdIsDead, BTPageOpaqueData::level, BTPageStat::level, BTPageStat::live_items, BTPageStat::max_avail, P_IGNORE, P_ISDELETED, P_ISLEAF, P_ISROOT, BTPageStat::page_size, PageGetFreeSpace(), PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageGetPageSize, PageGetSpecialPointer, PageHeaderData::pd_special, SizeOfPageHeaderData, BTPageStat::type, BTPageOpaqueData::xact, and BTPageStat::xact.

Referenced by bt_page_stats().

94 {
95  Page page = BufferGetPage(buffer);
96  PageHeader phdr = (PageHeader) page;
97  OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
99  int item_size = 0;
100  int off;
101 
102  stat->blkno = blkno;
103 
104  stat->max_avail = BLCKSZ - (BLCKSZ - phdr->pd_special + SizeOfPageHeaderData);
105 
106  stat->dead_items = stat->live_items = 0;
107 
108  stat->page_size = PageGetPageSize(page);
109 
110  /* page type (flags) */
111  if (P_ISDELETED(opaque))
112  {
113  stat->type = 'd';
114  stat->btpo.xact = opaque->btpo.xact;
115  return;
116  }
117  else if (P_IGNORE(opaque))
118  stat->type = 'e';
119  else if (P_ISLEAF(opaque))
120  stat->type = 'l';
121  else if (P_ISROOT(opaque))
122  stat->type = 'r';
123  else
124  stat->type = 'i';
125 
126  /* btpage opaque data */
127  stat->btpo_prev = opaque->btpo_prev;
128  stat->btpo_next = opaque->btpo_next;
129  stat->btpo.level = opaque->btpo.level;
130  stat->btpo_flags = opaque->btpo_flags;
131  stat->btpo_cycleid = opaque->btpo_cycleid;
132 
133  /* count live and dead tuples, and free space */
134  for (off = FirstOffsetNumber; off <= maxoff; off++)
135  {
136  IndexTuple itup;
137 
138  ItemId id = PageGetItemId(page, off);
139 
140  itup = (IndexTuple) PageGetItem(page, id);
141 
142  item_size += IndexTupleSize(itup);
143 
144  if (!ItemIdIsDead(id))
145  stat->live_items++;
146  else
147  stat->dead_items++;
148  }
149  stat->free_size = PageGetFreeSpace(page);
150 
151  if ((stat->live_items + stat->dead_items) > 0)
152  stat->avg_item_size = item_size / (stat->live_items + stat->dead_items);
153  else
154  stat->avg_item_size = 0;
155 }
uint32 avg_item_size
Definition: btreefuncs.c:70
BlockNumber btpo_next
Definition: nbtree.h:59
uint32 dead_items
Definition: btreefuncs.c:66
#define P_IGNORE(opaque)
Definition: nbtree.h:219
union BTPageOpaqueData::@45 btpo
uint32 blkno
Definition: btreefuncs.c:64
char type
Definition: btreefuncs.c:71
#define SizeOfPageHeaderData
Definition: bufpage.h:216
#define ItemIdIsDead(itemId)
Definition: itemid.h:113
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
TransactionId xact
Definition: nbtree.h:63
BTPageOpaqueData * BTPageOpaque
Definition: nbtree.h:69
union BTPageStat::@0 btpo
Size PageGetFreeSpace(Page page)
Definition: bufpage.c:782
uint16 OffsetNumber
Definition: off.h:24
BlockNumber btpo_next
Definition: btreefuncs.c:75
BTCycleId btpo_cycleid
Definition: nbtree.h:66
BlockNumber btpo_prev
Definition: nbtree.h:58
#define FirstOffsetNumber
Definition: off.h:27
IndexTupleData * IndexTuple
Definition: itup.h:53
#define PageGetPageSize(page)
Definition: bufpage.h:268
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
#define P_ISDELETED(opaque)
Definition: nbtree.h:216
#define P_ISROOT(opaque)
Definition: nbtree.h:215
uint32 live_items
Definition: btreefuncs.c:65
TransactionId xact
Definition: btreefuncs.c:79
LocationIndex pd_special
Definition: bufpage.h:160
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:235
uint32 level
Definition: nbtree.h:62
BlockNumber btpo_prev
Definition: btreefuncs.c:74
uint32 free_size
Definition: btreefuncs.c:69
Page page
Definition: btreefuncs.c:248
PageHeaderData * PageHeader
Definition: bufpage.h:166
uint32 max_avail
Definition: btreefuncs.c:68
#define PageGetSpecialPointer(page)
Definition: bufpage.h:326
BTCycleId btpo_cycleid
Definition: btreefuncs.c:82
uint16 btpo_flags
Definition: btreefuncs.c:81
uint32 page_size
Definition: btreefuncs.c:67
uint32 level
Definition: btreefuncs.c:78
uint16 btpo_flags
Definition: nbtree.h:65
#define PageGetItem(page, itemId)
Definition: bufpage.h:340
Pointer Page
Definition: bufpage.h:78
#define IndexTupleSize(itup)
Definition: itup.h:71
#define P_ISLEAF(opaque)
Definition: nbtree.h:214

◆ PG_FUNCTION_INFO_V1() [1/4]

PG_FUNCTION_INFO_V1 ( bt_metap  )

◆ PG_FUNCTION_INFO_V1() [2/4]

PG_FUNCTION_INFO_V1 ( bt_page_items  )

◆ PG_FUNCTION_INFO_V1() [3/4]

PG_FUNCTION_INFO_V1 ( bt_page_items_bytea  )

◆ PG_FUNCTION_INFO_V1() [4/4]

PG_FUNCTION_INFO_V1 ( bt_page_stats  )