1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-23 14:01:44 +03:00

Improve API of GenericXLogRegister().

Rename this function to GenericXLogRegisterBuffer() to make it clearer
what it does, and leave room for other sorts of "register" actions in
future.  Also, replace its "bool isNew" argument with an integer flags
argument, so as to allow adding more flags in future without an API
break.

Alexander Korotkov, adjusted slightly by me
This commit is contained in:
Tom Lane
2016-04-12 11:42:06 -04:00
parent bdf7db8192
commit 5713f03973
6 changed files with 41 additions and 31 deletions

View File

@ -50,7 +50,7 @@
typedef struct
{
Buffer buffer; /* registered buffer */
bool fullImage; /* are we taking a full image of this page? */
int flags; /* flags for this buffer */
int deltaLen; /* space consumed in delta field */
char image[BLCKSZ]; /* copy of page image for modification */
char delta[MAX_DELTA_SIZE]; /* delta between page images */
@ -280,9 +280,11 @@ GenericXLogStart(Relation relation)
* is what the caller should modify.
*
* If the buffer is already registered, just return its existing entry.
* (It's not very clear what to do with the flags in such a case, but
* for now we stay with the original flags.)
*/
Page
GenericXLogRegister(GenericXLogState *state, Buffer buffer, bool isNew)
GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer, int flags)
{
int block_id;
@ -295,7 +297,7 @@ GenericXLogRegister(GenericXLogState *state, Buffer buffer, bool isNew)
{
/* Empty slot, so use it (there cannot be a match later) */
page->buffer = buffer;
page->fullImage = isNew;
page->flags = flags;
memcpy(page->image,
BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST),
BLCKSZ);
@ -347,7 +349,7 @@ GenericXLogFinish(GenericXLogState *state)
BGP_NO_SNAPSHOT_TEST);
pageHeader = (PageHeader) pageData->image;
if (pageData->fullImage)
if (pageData->flags & GENERIC_XLOG_FULL_IMAGE)
{
/*
* A full-page image does not require us to supply any xlog