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

Commit540ac7c

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 parent5a90ac2 commit540ac7c

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
@@ -75,10 +75,14 @@ static bytea *
7575
gbt_bit_xfrm(bytea*leaf)
7676
{
7777
bytea*out=leaf;
78-
ints=INTALIGN(VARBITBYTES(leaf)+VARHDRSZ);
79-
80-
out=palloc(s);
81-
SET_VARSIZE(out,s);
78+
intsz=VARBITBYTES(leaf)+VARHDRSZ;
79+
intpadded_sz=INTALIGN(sz);
80+
81+
out= (bytea*)palloc(padded_sz);
82+
/* initialize the padding bytes to zero */
83+
while (sz<padded_sz)
84+
((char*)out)[sz++]=0;
85+
SET_VARSIZE(out,padded_sz);
8286
memcpy((void*)VARDATA(out), (void*)VARBITS(leaf),VARBITBYTES(leaf));
8387
returnout;
8488
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp