PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

Page get_page_from_raw ( bytea raw_page)

Definition at line 183 of file rawpage.c.

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

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

184 {
185  Page page;
186  int raw_page_size;
187 
188  raw_page_size = VARSIZE_ANY_EXHDR(raw_page);
189 
190  if (raw_page_size != BLCKSZ)
191  ereport(ERROR,
192  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
193  errmsg("invalid page size"),
194  errdetail("Expected %d bytes, got %d.",
195  BLCKSZ, raw_page_size)));
196 
197  page = palloc(raw_page_size);
198 
199  memcpy(page, VARDATA_ANY(raw_page), raw_page_size);
200 
201  return page;
202 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:347
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:340
void * palloc(Size size)
Definition: mcxt.c:849
int errmsg(const char *fmt,...)
Definition: elog.c:797
Pointer Page
Definition: bufpage.h:74