3 * Functions to investigate the content of GIN indexes
5 * Copyright (c) 2014-2025, PostgreSQL Global Development Group
8 * contrib/pageinspect/ginfuncs.c
41 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
42 errmsg(
"must be superuser to use raw page functions")));
51 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
52 errmsg(
"input page is not a valid GIN metapage"),
53 errdetail(
"Expected special size %d, got %d.",
61 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
62 errmsg(
"input page is not a GIN metapage"),
66 /* Build a tuple descriptor for our result type */
68 elog(
ERROR,
"return type must be a row type");
72 memset(nulls, 0,
sizeof(nulls));
80 /* statistics, updated by VACUUM */
88 /* Build and return the result tuple. */
111 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
112 errmsg(
"must be superuser to use raw page functions")));
121 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
122 errmsg(
"input page is not a valid GIN data leaf page"),
123 errdetail(
"Expected special size %d, got %d.",
129 /* Build a tuple descriptor for our result type */
131 elog(
ERROR,
"return type must be a row type");
133 /* Convert the flags bitmask to an array of human-readable names */
134 flagbits = opaq->
flags;
155 /* any flags we don't recognize are printed in hex */
159 memset(nulls, 0,
sizeof(nulls));
165 /* Build and return the result tuple. */
187 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
188 errmsg(
"must be superuser to use raw page functions")));
210 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
211 errmsg(
"input page is not a valid GIN data leaf page"),
212 errdetail(
"Expected special size %d, got %d.",
219 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
220 errmsg(
"input page is not a compressed GIN data leaf page"),
227 /* Build a tuple descriptor for our result type */
229 elog(
ERROR,
"return type must be a row type");
231 inter_call_data->
tupd = tupdesc;
235 (((
char *) inter_call_data->
seg) +
246 if (inter_call_data->
seg != inter_call_data->
lastseg)
258 memset(nulls, 0,
sizeof(nulls));
263 /* build an array of decoded item pointers */
266 for (
i = 0;
i < ndecoded;
i++)
272 /* Build and return the result tuple. */
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static Datum values[MAXATTR]
static uint16 PageGetSpecialSize(const PageData *page)
static bool PageIsNew(const PageData *page)
#define CStringGetTextDatum(s)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define DirectFunctionCall1(func, arg1)
#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)
#define GinPageGetOpaque(page)
#define GinDataLeafPageGetPostingListSize(page)
#define GinNextPostingListSegment(cur)
#define GIN_INCOMPLETE_SPLIT
#define GinPageGetMeta(p)
#define GinDataLeafPageGetPostingList(page)
PG_FUNCTION_INFO_V1(gin_metapage_info)
struct gin_leafpage_items_state gin_leafpage_items_state
Datum gin_leafpage_items(PG_FUNCTION_ARGS)
Datum gin_page_opaque_info(PG_FUNCTION_ARGS)
Datum gin_metapage_info(PG_FUNCTION_ARGS)
ItemPointer ginPostingListDecode(GinPostingList *plist, int *ndecoded_out)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
static Datum ItemPointerGetDatum(const ItemPointerData *X)
void pfree(void *pointer)
Page get_page_from_raw(bytea *raw_page)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static Datum Int64GetDatum(int64 X)
static Datum PointerGetDatum(const void *X)
static Datum UInt16GetDatum(uint16 X)
static Datum Int32GetDatum(int32 X)
MemoryContext multi_call_memory_ctx
BlockNumber nPendingPages
Datum to_hex32(PG_FUNCTION_ARGS)