Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit398cf25

Browse files
committed
In GIN recompression code, use mmemove rather than memcpy, for vacuum.
When vacuuming a data leaf page, any compressed posting lists that are notmodified, are copied back to the buffer from a later location in the samebuffer rather than from a palloc'd copy. IOW, they are just moveddownwards in the same buffer. Because the source and destination addressescan overlap, we must use memmove rather than memcpy.Report and fix by Alexander Korotkov.
1 parentfbe19ee commit398cf25

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/backend/access/gin/gindatapage.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,13 @@ ginVacuumPostingTreeLeaf(Relation indexrel, Buffer buffer, GinVacuumState *gvs)
753753
* *prdata is filled with WAL information about this operation. The caller
754754
* is responsible for inserting to the WAL, along with any other information
755755
* about the operation that triggered this recompression.
756+
*
757+
* NOTE: The segment pointers can point directly to the same buffer, with
758+
* the limitation that any earlier segment must not overlap with an original,
759+
* later segment. In other words, some segments may point the original buffer
760+
* as long as you don't make any segments larger. Currently, leafRepackItems
761+
* satisies this rule because it rewrites all segments after the first
762+
* modified one, and vacuum can only make segments shorter.
756763
*/
757764
staticvoid
758765
dataPlaceToPageLeafRecompress(Bufferbuf,disassembledLeaf*leaf,
@@ -798,7 +805,13 @@ dataPlaceToPageLeafRecompress(Buffer buf, disassembledLeaf *leaf,
798805
if (!modified)
799806
unmodifiedsize+=segsize;
800807
else
801-
memcpy(ptr,seginfo->seg,segsize);
808+
{
809+
/*
810+
* Use memmove rather than memcpy, in case the segment points
811+
* to the same buffer
812+
*/
813+
memmove(ptr,seginfo->seg,segsize);
814+
}
802815
ptr+=segsize;
803816
newsize+=segsize;
804817
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp