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

Commit38a2b95

Browse files
committed
Zero padding byte at end of GIN posting list.
This isn't strictly necessary, but helps debugging.
1 parentf235db0 commit38a2b95

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ decode_varbyte(unsigned char **ptr)
176176
* 'maxsize' bytes in size. The number items in the returned segment is
177177
* returned in *nwritten. If it's not equal to nipd, not all the items fit
178178
* in 'maxsize', and only the first *nwritten were encoded.
179+
*
180+
* The allocated size of the returned struct is short-aligned, and the padding
181+
* byte at the end, if any, is zero.
179182
*/
180183
GinPostingList*
181184
ginCompressPostingList(constItemPointeripd,intnipd,intmaxsize,
@@ -188,9 +191,12 @@ ginCompressPostingList(const ItemPointer ipd, int nipd, int maxsize,
188191
unsignedchar*ptr;
189192
unsignedchar*endptr;
190193

194+
maxsize=SHORTALIGN_DOWN(maxsize);
195+
191196
result=palloc(maxsize);
192197

193198
maxbytes=maxsize- offsetof(GinPostingList,bytes);
199+
Assert(maxbytes>0);
194200

195201
/* Store the first special item */
196202
result->first=ipd[0];
@@ -228,6 +234,13 @@ ginCompressPostingList(const ItemPointer ipd, int nipd, int maxsize,
228234
}
229235
result->nbytes=ptr-result->bytes;
230236

237+
/*
238+
* If we wrote an odd number of bytes, zero out the padding byte at the
239+
* end.
240+
*/
241+
if (result->nbytes!=SHORTALIGN(result->nbytes))
242+
result->bytes[result->nbytes]=0;
243+
231244
if (nwritten)
232245
*nwritten=totalpacked;
233246

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp