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

Commitd5b912c

Browse files
committed
Initialize padding bytes in btree_gist varbit support.
The code expands a varbit gist leaf key to a node key by copying the bitdata twice in a varlen datum, as both the lower and upper key. The lower keywas expanded to INTALIGN size, but the padding bytes were not initialized.That's a problem because when the lower/upper keys are compared, the paddingbytes are used compared too, when the values are otherwise equal. That couldlead to incorrect query results.REINDEX is advised for any btree_gist indexes on bit or bit varying datatype, to fix any garbage padding bytes on disk.Per Valgrind, reported by Andres Freund. Backpatch to all supportedversions.
1 parentb65a258 commitd5b912c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎contrib/btree_gist/btree_bit.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ static bytea *
8383
gbt_bit_xfrm(bytea*leaf)
8484
{
8585
bytea*out=leaf;
86-
ints=INTALIGN(VARBITBYTES(leaf)+VARHDRSZ);
87-
88-
out=palloc(s);
89-
SET_VARSIZE(out,s);
86+
intsz=VARBITBYTES(leaf)+VARHDRSZ;
87+
intpadded_sz=INTALIGN(sz);
88+
89+
out= (bytea*)palloc(padded_sz);
90+
/* initialize the padding bytes to zero */
91+
while (sz<padded_sz)
92+
((char*)out)[sz++]=0;
93+
SET_VARSIZE(out,padded_sz);
9094
memcpy((void*)VARDATA(out), (void*)VARBITS(leaf),VARBITBYTES(leaf));
9195
returnout;
9296
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp