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 188 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().

189 {
190  Page page;
191  int raw_page_size;
192 
193  raw_page_size = VARSIZE_ANY_EXHDR(raw_page);
194 
195  if (raw_page_size != BLCKSZ)
196  ereport(ERROR,
197  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
198  errmsg("invalid page size"),
199  errdetail("Expected %d bytes, got %d.",
200  BLCKSZ, raw_page_size)));
201 
202  page = palloc(raw_page_size);
203 
204  memcpy(page, VARDATA_ANY(raw_page), raw_page_size);
205 
206  return page;
207 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:348
int errcode(int sqlerrcode)
Definition: elog.c:570
#define ERROR
Definition: elog.h:43
int errdetail(const char *fmt,...)
Definition: elog.c:860
#define ereport(elevel, rest)
Definition: elog.h:141
Page page
Definition: btreefuncs.c:246
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:341
void * palloc(Size size)
Definition: mcxt.c:949
int errmsg(const char *fmt,...)
Definition: elog.c:784
Pointer Page
Definition: bufpage.h:78