PostgreSQL Source Code  git master
hashfuncs.c
Go to the documentation of this file.
1 /*
2  * hashfuncs.c
3  * Functions to investigate the content of HASH indexes
4  *
5  * Copyright (c) 2017-2022, PostgreSQL Global Development Group
6  *
7  * IDENTIFICATION
8  * contrib/pageinspect/hashfuncs.c
9  */
10 
11 #include "postgres.h"
12 
13 #include "access/hash.h"
14 #include "access/htup_details.h"
15 #include "catalog/pg_am.h"
16 #include "catalog/pg_type.h"
17 #include "funcapi.h"
18 #include "miscadmin.h"
19 #include "pageinspect.h"
20 #include "utils/array.h"
21 #include "utils/builtins.h"
22 #include "utils/rel.h"
23 
29 
30 #define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
31 
32 /* ------------------------------------------------
33  * structure for single hash page statistics
34  * ------------------------------------------------
35  */
36 typedef struct HashPageStat
37 {
40  int page_size;
41  int free_size;
42 
43  /* opaque data */
50 
51 
52 /*
53  * Verify that the given bytea contains a HASH page, or die in the attempt.
54  * A pointer to a palloc'd, properly aligned copy of the page is returned.
55  */
56 static Page
57 verify_hash_page(bytea *raw_page, int flags)
58 {
59  Page page = get_page_from_raw(raw_page);
60  int pagetype = LH_UNUSED_PAGE;
61 
62  /* Treat new pages as unused. */
63  if (!PageIsNew(page))
64  {
65  HashPageOpaque pageopaque;
66 
67  if (PageGetSpecialSize(page) != MAXALIGN(sizeof(HashPageOpaqueData)))
68  ereport(ERROR,
69  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
70  errmsg("input page is not a valid %s page", "hash"),
71  errdetail("Expected special size %d, got %d.",
72  (int) MAXALIGN(sizeof(HashPageOpaqueData)),
73  (int) PageGetSpecialSize(page))));
74 
75  pageopaque = HashPageGetOpaque(page);
76  if (pageopaque->hasho_page_id != HASHO_PAGE_ID)
77  ereport(ERROR,
78  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
79  errmsg("input page is not a valid %s page", "hash"),
80  errdetail("Expected %08x, got %08x.",
81  HASHO_PAGE_ID, pageopaque->hasho_page_id)));
82 
83  pagetype = pageopaque->hasho_flag & LH_PAGE_TYPE;
84  }
85 
86  /* Check that page type is sane. */
87  if (pagetype != LH_OVERFLOW_PAGE && pagetype != LH_BUCKET_PAGE &&
88  pagetype != LH_BITMAP_PAGE && pagetype != LH_META_PAGE &&
89  pagetype != LH_UNUSED_PAGE)
90  ereport(ERROR,
91  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
92  errmsg("invalid hash page type %08x", pagetype)));
93 
94  /* If requested, verify page type. */
95  if (flags != 0 && (pagetype & flags) == 0)
96  {
97  switch (flags)
98  {
99  case LH_META_PAGE:
100  ereport(ERROR,
101  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
102  errmsg("page is not a hash meta page")));
103  break;
105  ereport(ERROR,
106  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
107  errmsg("page is not a hash bucket or overflow page")));
108  break;
109  case LH_OVERFLOW_PAGE:
110  ereport(ERROR,
111  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
112  errmsg("page is not a hash overflow page")));
113  break;
114  default:
115  elog(ERROR,
116  "hash page of type %08x not in mask %08x",
117  pagetype, flags);
118  break;
119  }
120  }
121 
122  /*
123  * If it is the metapage, also verify magic number and version.
124  */
125  if (pagetype == LH_META_PAGE)
126  {
127  HashMetaPage metap = HashPageGetMeta(page);
128 
129  if (metap->hashm_magic != HASH_MAGIC)
130  ereport(ERROR,
131  (errcode(ERRCODE_INDEX_CORRUPTED),
132  errmsg("invalid magic number for metadata"),
133  errdetail("Expected 0x%08x, got 0x%08x.",
134  HASH_MAGIC, metap->hashm_magic)));
135 
136  if (metap->hashm_version != HASH_VERSION)
137  ereport(ERROR,
138  (errcode(ERRCODE_INDEX_CORRUPTED),
139  errmsg("invalid version for metadata"),
140  errdetail("Expected %d, got %d.",
141  HASH_VERSION, metap->hashm_version)));
142  }
143 
144  return page;
145 }
146 
147 /* -------------------------------------------------
148  * GetHashPageStatistics()
149  *
150  * Collect statistics of single hash page
151  * -------------------------------------------------
152  */
153 static void
155 {
156  OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
157  HashPageOpaque opaque = HashPageGetOpaque(page);
158  int off;
159 
160  stat->dead_items = stat->live_items = 0;
161  stat->page_size = PageGetPageSize(page);
162 
163  /* hash page opaque data */
164  stat->hasho_prevblkno = opaque->hasho_prevblkno;
165  stat->hasho_nextblkno = opaque->hasho_nextblkno;
166  stat->hasho_bucket = opaque->hasho_bucket;
167  stat->hasho_flag = opaque->hasho_flag;
168  stat->hasho_page_id = opaque->hasho_page_id;
169 
170  /* count live and dead tuples, and free space */
171  for (off = FirstOffsetNumber; off <= maxoff; off++)
172  {
173  ItemId id = PageGetItemId(page, off);
174 
175  if (!ItemIdIsDead(id))
176  stat->live_items++;
177  else
178  stat->dead_items++;
179  }
180  stat->free_size = PageGetFreeSpace(page);
181 }
182 
183 /* ---------------------------------------------------
184  * hash_page_type()
185  *
186  * Usage: SELECT hash_page_type(get_raw_page('con_hash_index', 1));
187  * ---------------------------------------------------
188  */
189 Datum
191 {
192  bytea *raw_page = PG_GETARG_BYTEA_P(0);
193  Page page;
194  HashPageOpaque opaque;
195  int pagetype;
196  const char *type;
197 
198  if (!superuser())
199  ereport(ERROR,
200  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
201  errmsg("must be superuser to use raw page functions")));
202 
203  page = verify_hash_page(raw_page, 0);
204 
205  if (PageIsNew(page))
206  type = "unused";
207  else
208  {
209  opaque = HashPageGetOpaque(page);
210 
211  /* page type (flags) */
212  pagetype = opaque->hasho_flag & LH_PAGE_TYPE;
213  if (pagetype == LH_META_PAGE)
214  type = "metapage";
215  else if (pagetype == LH_OVERFLOW_PAGE)
216  type = "overflow";
217  else if (pagetype == LH_BUCKET_PAGE)
218  type = "bucket";
219  else if (pagetype == LH_BITMAP_PAGE)
220  type = "bitmap";
221  else
222  type = "unused";
223  }
224 
226 }
227 
228 /* ---------------------------------------------------
229  * hash_page_stats()
230  *
231  * Usage: SELECT * FROM hash_page_stats(get_raw_page('con_hash_index', 1));
232  * ---------------------------------------------------
233  */
234 Datum
236 {
237  bytea *raw_page = PG_GETARG_BYTEA_P(0);
238  Page page;
239  int j;
240  Datum values[9];
241  bool nulls[9] = {0};
243  HeapTuple tuple;
244  TupleDesc tupleDesc;
245 
246  if (!superuser())
247  ereport(ERROR,
248  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
249  errmsg("must be superuser to use raw page functions")));
250 
252 
253  /* keep compiler quiet */
254  stat.hasho_prevblkno = stat.hasho_nextblkno = InvalidBlockNumber;
255  stat.hasho_flag = stat.hasho_page_id = stat.free_size = 0;
256 
257  GetHashPageStatistics(page, &stat);
258 
259  /* Build a tuple descriptor for our result type */
260  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
261  elog(ERROR, "return type must be a row type");
262  tupleDesc = BlessTupleDesc(tupleDesc);
263 
264  j = 0;
265  values[j++] = Int32GetDatum(stat.live_items);
266  values[j++] = Int32GetDatum(stat.dead_items);
267  values[j++] = Int32GetDatum(stat.page_size);
268  values[j++] = Int32GetDatum(stat.free_size);
269  values[j++] = Int64GetDatum((int64) stat.hasho_prevblkno);
270  values[j++] = Int64GetDatum((int64) stat.hasho_nextblkno);
271  values[j++] = Int64GetDatum((int64) stat.hasho_bucket);
272  values[j++] = Int32GetDatum((int32) stat.hasho_flag);
273  values[j++] = Int32GetDatum((int32) stat.hasho_page_id);
274 
275  tuple = heap_form_tuple(tupleDesc, values, nulls);
276 
278 }
279 
280 /*
281  * cross-call data structure for SRF
282  */
283 struct user_args
284 {
285  Page page;
287 };
288 
289 /*-------------------------------------------------------
290  * hash_page_items()
291  *
292  * Get IndexTupleData set in a hash page
293  *
294  * Usage: SELECT * FROM hash_page_items(get_raw_page('con_hash_index', 1));
295  *-------------------------------------------------------
296  */
297 Datum
299 {
300  bytea *raw_page = PG_GETARG_BYTEA_P(0);
301  Page page;
302  Datum result;
303  Datum values[3];
304  bool nulls[3] = {0};
305  uint32 hashkey;
306  HeapTuple tuple;
307  FuncCallContext *fctx;
308  MemoryContext mctx;
309  struct user_args *uargs;
310 
311  if (!superuser())
312  ereport(ERROR,
313  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
314  errmsg("must be superuser to use raw page functions")));
315 
316  if (SRF_IS_FIRSTCALL())
317  {
318  TupleDesc tupleDesc;
319 
320  fctx = SRF_FIRSTCALL_INIT();
321 
323 
325 
326  uargs = palloc(sizeof(struct user_args));
327 
328  uargs->page = page;
329 
330  uargs->offset = FirstOffsetNumber;
331 
332  fctx->max_calls = PageGetMaxOffsetNumber(uargs->page);
333 
334  /* Build a tuple descriptor for our result type */
335  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
336  elog(ERROR, "return type must be a row type");
337  tupleDesc = BlessTupleDesc(tupleDesc);
338 
339  fctx->attinmeta = TupleDescGetAttInMetadata(tupleDesc);
340 
341  fctx->user_fctx = uargs;
342 
343  MemoryContextSwitchTo(mctx);
344  }
345 
346  fctx = SRF_PERCALL_SETUP();
347  uargs = fctx->user_fctx;
348 
349  if (fctx->call_cntr < fctx->max_calls)
350  {
351  ItemId id;
352  IndexTuple itup;
353  int j;
354 
355  id = PageGetItemId(uargs->page, uargs->offset);
356 
357  if (!ItemIdIsValid(id))
358  elog(ERROR, "invalid ItemId");
359 
360  itup = (IndexTuple) PageGetItem(uargs->page, id);
361 
362  j = 0;
363  values[j++] = Int32GetDatum((int32) uargs->offset);
364  values[j++] = PointerGetDatum(&itup->t_tid);
365 
366  hashkey = _hash_get_indextuple_hashkey(itup);
367  values[j] = Int64GetDatum((int64) hashkey);
368 
369  tuple = heap_form_tuple(fctx->attinmeta->tupdesc, values, nulls);
370  result = HeapTupleGetDatum(tuple);
371 
372  uargs->offset = uargs->offset + 1;
373 
374  SRF_RETURN_NEXT(fctx, result);
375  }
376 
377  SRF_RETURN_DONE(fctx);
378 }
379 
380 /* ------------------------------------------------
381  * hash_bitmap_info()
382  *
383  * Get bitmap information for a particular overflow page
384  *
385  * Usage: SELECT * FROM hash_bitmap_info('con_hash_index'::regclass, 5);
386  * ------------------------------------------------
387  */
388 Datum
390 {
391  Oid indexRelid = PG_GETARG_OID(0);
392  int64 ovflblkno = PG_GETARG_INT64(1);
393  HashMetaPage metap;
394  Buffer metabuf,
395  mapbuf;
396  BlockNumber bitmapblkno;
397  Page mappage;
398  bool bit = false;
399  TupleDesc tupleDesc;
400  Relation indexRel;
401  uint32 ovflbitno;
402  int32 bitmappage,
403  bitmapbit;
404  HeapTuple tuple;
405  int i,
406  j;
407  Datum values[3];
408  bool nulls[3] = {0};
409  uint32 *freep;
410 
411  if (!superuser())
412  ereport(ERROR,
413  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
414  errmsg("must be superuser to use raw page functions")));
415 
416  indexRel = index_open(indexRelid, AccessShareLock);
417 
418  if (!IS_HASH(indexRel))
419  ereport(ERROR,
420  (errcode(ERRCODE_WRONG_OBJECT_TYPE),
421  errmsg("\"%s\" is not a %s index",
422  RelationGetRelationName(indexRel), "hash")));
423 
424  if (RELATION_IS_OTHER_TEMP(indexRel))
425  ereport(ERROR,
426  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
427  errmsg("cannot access temporary tables of other sessions")));
428 
429  if (ovflblkno < 0 || ovflblkno > MaxBlockNumber)
430  ereport(ERROR,
431  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
432  errmsg("invalid block number")));
433 
434  if (ovflblkno >= RelationGetNumberOfBlocks(indexRel))
435  ereport(ERROR,
436  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
437  errmsg("block number %lld is out of range for relation \"%s\"",
438  (long long int) ovflblkno, RelationGetRelationName(indexRel))));
439 
440  /* Read the metapage so we can determine which bitmap page to use */
441  metabuf = _hash_getbuf(indexRel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
442  metap = HashPageGetMeta(BufferGetPage(metabuf));
443 
444  /*
445  * Reject attempt to read the bit for a metapage or bitmap page; this is
446  * only meaningful for overflow pages.
447  */
448  if (ovflblkno == 0)
449  ereport(ERROR,
450  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
451  errmsg("invalid overflow block number %u",
452  (BlockNumber) ovflblkno)));
453  for (i = 0; i < metap->hashm_nmaps; i++)
454  if (metap->hashm_mapp[i] == ovflblkno)
455  ereport(ERROR,
456  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
457  errmsg("invalid overflow block number %u",
458  (BlockNumber) ovflblkno)));
459 
460  /*
461  * Identify overflow bit number. This will error out for primary bucket
462  * pages, and we've already rejected the metapage and bitmap pages above.
463  */
464  ovflbitno = _hash_ovflblkno_to_bitno(metap, (BlockNumber) ovflblkno);
465 
466  bitmappage = ovflbitno >> BMPG_SHIFT(metap);
467  bitmapbit = ovflbitno & BMPG_MASK(metap);
468 
469  if (bitmappage >= metap->hashm_nmaps)
470  ereport(ERROR,
471  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
472  errmsg("invalid overflow block number %u",
473  (BlockNumber) ovflblkno)));
474 
475  bitmapblkno = metap->hashm_mapp[bitmappage];
476 
477  _hash_relbuf(indexRel, metabuf);
478 
479  /* Check the status of bitmap bit for overflow page */
480  mapbuf = _hash_getbuf(indexRel, bitmapblkno, HASH_READ, LH_BITMAP_PAGE);
481  mappage = BufferGetPage(mapbuf);
482  freep = HashPageGetBitmap(mappage);
483 
484  bit = ISSET(freep, bitmapbit) != 0;
485 
486  _hash_relbuf(indexRel, mapbuf);
487  index_close(indexRel, AccessShareLock);
488 
489  /* Build a tuple descriptor for our result type */
490  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
491  elog(ERROR, "return type must be a row type");
492  tupleDesc = BlessTupleDesc(tupleDesc);
493 
494  j = 0;
495  values[j++] = Int64GetDatum((int64) bitmapblkno);
496  values[j++] = Int32GetDatum(bitmapbit);
497  values[j++] = BoolGetDatum(bit);
498 
499  tuple = heap_form_tuple(tupleDesc, values, nulls);
500 
502 }
503 
504 /* ------------------------------------------------
505  * hash_metapage_info()
506  *
507  * Get the meta-page information for a hash index
508  *
509  * Usage: SELECT * FROM hash_metapage_info(get_raw_page('con_hash_index', 0))
510  * ------------------------------------------------
511  */
512 Datum
514 {
515  bytea *raw_page = PG_GETARG_BYTEA_P(0);
516  Page page;
517  HashMetaPageData *metad;
518  TupleDesc tupleDesc;
519  HeapTuple tuple;
520  int i,
521  j;
522  Datum values[16];
523  bool nulls[16] = {0};
524  Datum spares[HASH_MAX_SPLITPOINTS];
525  Datum mapp[HASH_MAX_BITMAPS];
526 
527  if (!superuser())
528  ereport(ERROR,
529  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
530  errmsg("must be superuser to use raw page functions")));
531 
532  page = verify_hash_page(raw_page, LH_META_PAGE);
533 
534  /* Build a tuple descriptor for our result type */
535  if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
536  elog(ERROR, "return type must be a row type");
537  tupleDesc = BlessTupleDesc(tupleDesc);
538 
539  metad = HashPageGetMeta(page);
540 
541  j = 0;
542  values[j++] = Int64GetDatum((int64) metad->hashm_magic);
543  values[j++] = Int64GetDatum((int64) metad->hashm_version);
544  values[j++] = Float8GetDatum(metad->hashm_ntuples);
545  values[j++] = Int32GetDatum((int32) metad->hashm_ffactor);
546  values[j++] = Int32GetDatum((int32) metad->hashm_bsize);
547  values[j++] = Int32GetDatum((int32) metad->hashm_bmsize);
548  values[j++] = Int32GetDatum((int32) metad->hashm_bmshift);
549  values[j++] = Int64GetDatum((int64) metad->hashm_maxbucket);
550  values[j++] = Int64GetDatum((int64) metad->hashm_highmask);
551  values[j++] = Int64GetDatum((int64) metad->hashm_lowmask);
552  values[j++] = Int64GetDatum((int64) metad->hashm_ovflpoint);
553  values[j++] = Int64GetDatum((int64) metad->hashm_firstfree);
554  values[j++] = Int64GetDatum((int64) metad->hashm_nmaps);
555  values[j++] = ObjectIdGetDatum((Oid) metad->hashm_procid);
556 
557  for (i = 0; i < HASH_MAX_SPLITPOINTS; i++)
558  spares[i] = Int64GetDatum((int64) metad->hashm_spares[i]);
560 
561  for (i = 0; i < HASH_MAX_BITMAPS; i++)
562  mapp[i] = Int64GetDatum((int64) metad->hashm_mapp[i]);
564 
565  tuple = heap_form_tuple(tupleDesc, values, nulls);
566 
568 }
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
Definition: arrayfuncs.c:3363
uint32 BlockNumber
Definition: block.h:31
#define InvalidBlockNumber
Definition: block.h:33
#define MaxBlockNumber
Definition: block.h:35
static Datum values[MAXATTR]
Definition: bootstrap.c:156
int Buffer
Definition: buf.h:23
#define RelationGetNumberOfBlocks(reln)
Definition: bufmgr.h:156
static Page BufferGetPage(Buffer buffer)
Definition: bufmgr.h:280
Size PageGetFreeSpace(Page page)
Definition: bufpage.c:907
Pointer Page
Definition: bufpage.h:78
static Item PageGetItem(Page page, ItemId itemId)
Definition: bufpage.h:351
static Size PageGetPageSize(Page page)
Definition: bufpage.h:273
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition: bufpage.h:240
static bool PageIsNew(Page page)
Definition: bufpage.h:230
static OffsetNumber PageGetMaxOffsetNumber(Page page)
Definition: bufpage.h:369
static uint16 PageGetSpecialSize(Page page)
Definition: bufpage.h:313
unsigned short uint16
Definition: c.h:441
unsigned int uint32
Definition: c.h:442
#define MAXALIGN(LEN)
Definition: c.h:747
signed int int32
Definition: c.h:430
int errdetail(const char *fmt,...)
Definition: elog.c:1202
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2071
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
Definition: execTuples.c:2086
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1749
Datum Float8GetDatum(float8 X)
Definition: fmgr.c:1758
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define PG_GETARG_INT64(n)
Definition: fmgr.h:283
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:353
#define PG_GETARG_BYTEA_P(n)
Definition: fmgr.h:335
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:276
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:303
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:307
@ TYPEFUNC_COMPOSITE
Definition: funcapi.h:149
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:309
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:305
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition: funcapi.h:230
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:327
#define HashPageGetOpaque(page)
Definition: hash.h:88
#define LH_BUCKET_PAGE
Definition: hash.h:55
#define HASH_MAX_BITMAPS
Definition: hash.h:230
#define BMPG_MASK(metap)
Definition: hash.h:314
#define HASH_VERSION
Definition: hash.h:201
#define HASH_MAX_SPLITPOINTS
Definition: hash.h:239
#define LH_UNUSED_PAGE
Definition: hash.h:53
#define HashPageGetBitmap(page)
Definition: hash.h:316
#define LH_META_PAGE
Definition: hash.h:57
#define HASHO_PAGE_ID
Definition: hash.h:101
#define ISSET(A, N)
Definition: hash.h:334
#define HashPageGetMeta(page)
Definition: hash.h:323
#define HASH_READ
Definition: hash.h:339
#define HASH_METAPAGE
Definition: hash.h:198
#define LH_PAGE_TYPE
Definition: hash.h:63
uint32 Bucket
Definition: hash.h:35
#define LH_BITMAP_PAGE
Definition: hash.h:56
#define BMPG_SHIFT(metap)
Definition: hash.h:313
#define HASH_MAGIC
Definition: hash.h:200
#define LH_OVERFLOW_PAGE
Definition: hash.h:54
#define IS_HASH(r)
Definition: hashfuncs.c:30
Datum hash_bitmap_info(PG_FUNCTION_ARGS)
Definition: hashfuncs.c:389
Datum hash_page_stats(PG_FUNCTION_ARGS)
Definition: hashfuncs.c:235
PG_FUNCTION_INFO_V1(hash_page_type)
Datum hash_page_type(PG_FUNCTION_ARGS)
Definition: hashfuncs.c:190
Datum hash_metapage_info(PG_FUNCTION_ARGS)
Definition: hashfuncs.c:513
struct HashPageStat HashPageStat
static Page verify_hash_page(bytea *raw_page, int flags)
Definition: hashfuncs.c:57
static void GetHashPageStatistics(Page page, HashPageStat *stat)
Definition: hashfuncs.c:154
Datum hash_page_items(PG_FUNCTION_ARGS)
Definition: hashfuncs.c:298
uint32 _hash_ovflblkno_to_bitno(HashMetaPage metap, BlockNumber ovflblkno)
Definition: hashovfl.c:62
void _hash_relbuf(Relation rel, Buffer buf)
Definition: hashpage.c:266
Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access, int flags)
Definition: hashpage.c:70
uint32 _hash_get_indextuple_hashkey(IndexTuple itup)
Definition: hashutil.c:292
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:158
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:132
int j
Definition: isn.c:74
int i
Definition: isn.c:73
#define ItemIdIsDead(itemId)
Definition: itemid.h:113
#define ItemIdIsValid(itemId)
Definition: itemid.h:86
IndexTupleData * IndexTuple
Definition: itup.h:53
#define AccessShareLock
Definition: lockdefs.h:36
void * palloc(Size size)
Definition: mcxt.c:1199
uint16 OffsetNumber
Definition: off.h:24
#define FirstOffsetNumber
Definition: off.h:27
Page get_page_from_raw(bytea *raw_page)
Definition: rawpage.c:215
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:135
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:670
uintptr_t Datum
Definition: postgres.h:412
static Datum BoolGetDatum(bool X)
Definition: postgres.h:450
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:600
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:560
unsigned int Oid
Definition: postgres_ext.h:31
#define RelationGetRelationName(relation)
Definition: rel.h:535
#define RELATION_IS_OTHER_TEMP(relation)
Definition: rel.h:656
TupleDesc tupdesc
Definition: funcapi.h:38
void * user_fctx
Definition: funcapi.h:82
uint64 max_calls
Definition: funcapi.h:74
uint64 call_cntr
Definition: funcapi.h:65
AttInMetadata * attinmeta
Definition: funcapi.h:91
MemoryContext multi_call_memory_ctx
Definition: funcapi.h:101
uint32 hashm_version
Definition: hash.h:247
BlockNumber hashm_mapp[HASH_MAX_BITMAPS]
Definition: hash.h:264
uint32 hashm_lowmask
Definition: hash.h:256
uint32 hashm_maxbucket
Definition: hash.h:254
RegProcedure hashm_procid
Definition: hash.h:261
uint32 hashm_spares[HASH_MAX_SPLITPOINTS]
Definition: hash.h:262
double hashm_ntuples
Definition: hash.h:248
uint32 hashm_firstfree
Definition: hash.h:259
uint16 hashm_bmsize
Definition: hash.h:251
uint16 hashm_bsize
Definition: hash.h:250
uint32 hashm_ovflpoint
Definition: hash.h:257
uint32 hashm_highmask
Definition: hash.h:255
uint32 hashm_magic
Definition: hash.h:246
uint16 hashm_bmshift
Definition: hash.h:253
uint32 hashm_nmaps
Definition: hash.h:260
uint16 hashm_ffactor
Definition: hash.h:249
BlockNumber hasho_nextblkno
Definition: hash.h:80
uint16 hasho_flag
Definition: hash.h:82
BlockNumber hasho_prevblkno
Definition: hash.h:79
uint16 hasho_page_id
Definition: hash.h:83
Bucket hasho_bucket
Definition: hash.h:81
BlockNumber hasho_prevblkno
Definition: hashfuncs.c:44
int page_size
Definition: hashfuncs.c:40
int dead_items
Definition: hashfuncs.c:39
uint16 hasho_page_id
Definition: hashfuncs.c:48
int live_items
Definition: hashfuncs.c:38
Bucket hasho_bucket
Definition: hashfuncs.c:46
int free_size
Definition: hashfuncs.c:41
uint16 hasho_flag
Definition: hashfuncs.c:47
BlockNumber hasho_nextblkno
Definition: hashfuncs.c:45
ItemPointerData t_tid
Definition: itup.h:37
OffsetNumber offset
Definition: btreefuncs.c:293
Page page
Definition: btreefuncs.c:292
Definition: c.h:623
bool superuser(void)
Definition: superuser.c:46
Datum bit(PG_FUNCTION_ARGS)
Definition: varbit.c:391
text * cstring_to_text(const char *s)
Definition: varlena.c:189
#define stat
Definition: win32_port.h:286