Thread: pgsql: Initialize padding bytes in btree_gist varbit support.

pgsql: Initialize padding bytes in btree_gist varbit support.

From
Heikki Linnakangas
Date:
Initialize padding bytes in btree_gist varbit support.

The code expands a varbit gist leaf key to a node key by copying the bit
data twice in a varlen datum, as both the lower and upper key. The lower key
was expanded to INTALIGN size, but the padding bytes were not initialized.
That's a problem because when the lower/upper keys are compared, the padding
bytes are used compared too, when the values are otherwise equal. That could
lead to incorrect query results.

REINDEX is advised for any btree_gist indexes on bit or bit varying data
type, to fix any garbage padding bytes on disk.

Per Valgrind, reported by Andres Freund. Backpatch to all supported
versions.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/1913d0f28d6ad1ccebba1035e7c319b1ff4a8b02

Modified Files
--------------
contrib/btree_gist/btree_bit.c |   12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)