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