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 177 of file rawpage.c.

References ereport, errcode(), errdetail(), errmsg(), ERROR, palloc(), VARDATA, VARHDRSZ, and VARSIZE.

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

178 {
179  Page page;
180  int raw_page_size;
181 
182  raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
183 
184  if (raw_page_size != BLCKSZ)
185  ereport(ERROR,
186  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
187  errmsg("invalid page size"),
188  errdetail("Expected %d bytes, got %d.",
189  BLCKSZ, raw_page_size)));
190 
191  page = palloc(raw_page_size);
192 
193  memcpy(page, VARDATA(raw_page), raw_page_size);
194 
195  return page;
196 }
#define VARDATA(PTR)
Definition: postgres.h:305
#define VARSIZE(PTR)
Definition: postgres.h:306
#define VARHDRSZ
Definition: c.h:441
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:252
void * palloc(Size size)
Definition: mcxt.c:891
int errmsg(const char *fmt,...)
Definition: elog.c:797
Pointer Page
Definition: bufpage.h:74