diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2016-05-17 00:01:35 +0300 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2016-05-17 00:01:35 +0300 |
commit | 7c8345f67f3008a394adccae262f2a2162b6f5c7 (patch) | |
tree | c5f93e1e08b0ba501290f5ddeafd6e9406e71d01 /src/backend/access/transam/generic_xlog.c | |
parent | 02a568a02769ca626591039f460109369bf05dc2 (diff) | |
download | postgresql-7c8345f67f3008a394adccae262f2a2162b6f5c7.tar.gz postgresql-7c8345f67f3008a394adccae262f2a2162b6f5c7.zip |
Correctly align page's images in generic wal API
Page image should be MAXALIGN'ed because existing code could directly align
pointers in page instead of align offset from beginning of page.
Found during play with indexes as extenstion, Alexander Korotkov and me
Diffstat (limited to 'src/backend/access/transam/generic_xlog.c')
-rw-r--r-- | src/backend/access/transam/generic_xlog.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/access/transam/generic_xlog.c b/src/backend/access/transam/generic_xlog.c index 6e213e2f60c..8ad69f83b1f 100644 --- a/src/backend/access/transam/generic_xlog.c +++ b/src/backend/access/transam/generic_xlog.c @@ -52,7 +52,9 @@ typedef struct Buffer buffer; /* registered buffer */ int flags; /* flags for this buffer */ int deltaLen; /* space consumed in delta field */ - char image[BLCKSZ]; /* copy of page image for modification */ + char *image; /* copy of page image for modification, + * do not do it in-place to have aligned + * memory chunk */ char delta[MAX_DELTA_SIZE]; /* delta between page images */ } PageData; @@ -268,7 +270,15 @@ GenericXLogStart(Relation relation) state->isLogged = RelationNeedsWAL(relation); for (i = 0; i < MAX_GENERIC_XLOG_PAGES; i++) + { + /* + * pre-alloc page's images to prevent allocation in + * GenericXLogRegisterBuffer() which could be called in different + * memory context(s) + */ + state->pages[i].image = palloc(BLCKSZ); state->pages[i].buffer = InvalidBuffer; + } return state; } @@ -422,6 +432,8 @@ GenericXLogFinish(GenericXLogState *state) lsn = InvalidXLogRecPtr; } + for (i = 0; i < MAX_GENERIC_XLOG_PAGES; i++) + pfree(state->pages[i].image); pfree(state); return lsn; |