PostgreSQL Source Code  git master
pageinspect.h File Reference
#include "storage/bufpage.h"
Include dependency graph for pageinspect.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Page get_page_from_raw (bytea *raw_page)
 

Function Documentation

◆ get_page_from_raw()

Page get_page_from_raw ( bytea raw_page)

Definition at line 182 of file rawpage.c.

References ereport, errcode(), errdetail(), errmsg(), ERROR, page_header(), palloc(), PG_FUNCTION_INFO_V1(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by gin_leafpage_items(), gin_metapage_info(), gin_page_opaque_info(), and verify_hash_page().

183 {
184  Page page;
185  int raw_page_size;
186 
187  raw_page_size = VARSIZE_ANY_EXHDR(raw_page);
188 
189  if (raw_page_size != BLCKSZ)
190  ereport(ERROR,
191  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
192  errmsg("invalid page size"),
193  errdetail("Expected %d bytes, got %d.",
194  BLCKSZ, raw_page_size)));
195 
196  page = palloc(raw_page_size);
197 
198  memcpy(page, VARDATA_ANY(raw_page), raw_page_size);
199 
200  return page;
201 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:346
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
int errdetail(const char *fmt,...)
Definition: elog.c:873
#define ereport(elevel, rest)
Definition: elog.h:122
Page page
Definition: btreefuncs.c:245
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:339
void * palloc(Size size)
Definition: mcxt.c:924
int errmsg(const char *fmt,...)
Definition: elog.c:797
Pointer Page
Definition: bufpage.h:74