mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
Add Generic WAL interface
This interface is designed to give an access to WAL for extensions which could implement new access method, for example. Previously it was impossible because restoring from custom WAL would need to access system catalog to find a redo custom function. This patch suggests generic way to describe changes on page with standart layout. Bump XLOG_PAGE_MAGIC because of new record type. Author: Alexander Korotkov with a help of Petr Jelinek, Markus Nullmeier and minor editorization by my Reviewers: Petr Jelinek, Alvaro Herrera, Teodor Sigaev, Jim Nasby, Michael Paquier
This commit is contained in:
58
src/backend/access/rmgrdesc/genericdesc.c
Normal file
58
src/backend/access/rmgrdesc/genericdesc.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* genericdesc.c
|
||||
* rmgr descriptor routines for access/transam/generic_xlog.c
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/backend/access/rmgrdesc/genericdesc.c
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/generic_xlog.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "storage/relfilenode.h"
|
||||
|
||||
/*
|
||||
* Description of generic xlog record: write page regions that this record
|
||||
* overrides.
|
||||
*/
|
||||
void
|
||||
generic_desc(StringInfo buf, XLogReaderState *record)
|
||||
{
|
||||
Pointer ptr = XLogRecGetData(record),
|
||||
end = ptr + XLogRecGetDataLen(record);
|
||||
|
||||
while (ptr < end)
|
||||
{
|
||||
OffsetNumber offset,
|
||||
length;
|
||||
|
||||
memcpy(&offset, ptr, sizeof(offset));
|
||||
ptr += sizeof(offset);
|
||||
memcpy(&length, ptr, sizeof(length));
|
||||
ptr += sizeof(length);
|
||||
ptr += length;
|
||||
|
||||
if (ptr < end)
|
||||
appendStringInfo(buf, "offset %u, length %u; ", offset, length);
|
||||
else
|
||||
appendStringInfo(buf, "offset %u, length %u", offset, length);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Identification of generic xlog record: we don't distinguish any subtypes
|
||||
* inside generic xlog records.
|
||||
*/
|
||||
const char *
|
||||
generic_identify(uint8 info)
|
||||
{
|
||||
return "Generic";
|
||||
}
|
||||
Reference in New Issue
Block a user