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