Skip to content

Commit e2fbb88

Browse files
committed
Fix gist_bool_ops to use gbtreekey2
Commit 57e3c51 added a new GiST bool opclass, but it used gbtreekey4 to store the data, which left two bytes undefined, as reported by skink, our valgrind animal. There was a bit more confusion, because the opclass also used gbtreekey8 in the definition. Fix by defining a new gbtreekey2 struct, and using it in all the places. Discussion: https://postgr.es/m/CAE2gYzyDKJBZngssR84VGZEN=Ux=V9FV23QfPgo+7-yYnKKg4g@mail.gmail.com
1 parent ccf2897 commit e2fbb88

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

contrib/btree_gist/btree_bool.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static const gbtree_ninfo tinfo =
7272
{
7373
gbt_t_bool,
7474
sizeof(bool),
75-
4, /* sizeof(gbtreekey4) */
75+
2, /* sizeof(gbtreekey2) */
7676
gbt_boolgt,
7777
gbt_boolge,
7878
gbt_booleq,

contrib/btree_gist/btree_gist--1.6--1.7.sql

+19-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
\echo Use "ALTER EXTENSION btree_gist UPDATE TO '1.7'" to load this file. \quit
55

66
-- This upgrade scripts add support for bool.
7+
CREATE FUNCTION gbtreekey2_in(cstring)
8+
RETURNS gbtreekey2
9+
AS 'MODULE_PATHNAME', 'gbtreekey_in'
10+
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
11+
12+
CREATE FUNCTION gbtreekey2_out(gbtreekey2)
13+
RETURNS cstring
14+
AS 'MODULE_PATHNAME', 'gbtreekey_out'
15+
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
16+
17+
CREATE TYPE gbtreekey2 (
18+
INTERNALLENGTH = 2,
19+
INPUT = gbtreekey2_in,
20+
OUTPUT = gbtreekey2_out
21+
);
722

823
-- Define the GiST support methods
924
CREATE FUNCTION gbt_bool_consistent(internal,bool,int2,oid,internal)
@@ -32,11 +47,11 @@ AS 'MODULE_PATHNAME'
3247
LANGUAGE C IMMUTABLE STRICT;
3348

3449
CREATE FUNCTION gbt_bool_union(internal, internal)
35-
RETURNS gbtreekey8
50+
RETURNS gbtreekey2
3651
AS 'MODULE_PATHNAME'
3752
LANGUAGE C IMMUTABLE STRICT;
3853

39-
CREATE FUNCTION gbt_bool_same(gbtreekey8, gbtreekey8, internal)
54+
CREATE FUNCTION gbt_bool_same(gbtreekey2, gbtreekey2, internal)
4055
RETURNS internal
4156
AS 'MODULE_PATHNAME'
4257
LANGUAGE C IMMUTABLE STRICT;
@@ -57,6 +72,6 @@ AS
5772
FUNCTION 4 gbt_decompress (internal),
5873
FUNCTION 5 gbt_bool_penalty (internal, internal, internal),
5974
FUNCTION 6 gbt_bool_picksplit (internal, internal),
60-
FUNCTION 7 gbt_bool_same (gbtreekey8, gbtreekey8, internal),
75+
FUNCTION 7 gbt_bool_same (gbtreekey2, gbtreekey2, internal),
6176
FUNCTION 9 gbt_bool_fetch (internal),
62-
STORAGE gbtreekey8;
77+
STORAGE gbtreekey2;

0 commit comments

Comments
 (0)