Skip to content

Commit e0d043b

Browse files
committed
please apply attached patch to current CVS.
btree_gist now supports int2 ! Thanks Janko Richter for contribution.
1 parent 3be6367 commit e0d043b

File tree

4 files changed

+89
-7
lines changed

4 files changed

+89
-7
lines changed

contrib/btree_gist/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ top_builddir = ../..
44
include $(top_builddir)/src/Makefile.global
55

66
MODULE_big = btree_gist
7-
OBJS= btree_common.o btree_int4.o btree_int8.o btree_float4.o btree_float8.o btree_ts.o
7+
OBJS= btree_common.o btree_int2.o btree_int4.o btree_int8.o btree_float4.o btree_float8.o btree_ts.o
88
DATA_built = btree_gist.sql
99
DOCS = README.btree_gist
1010
REGRESS = btree_gist
1111

12-
EXTRA_CLEAN = btree_int4.c btree_int8.c btree_float4.c btree_float8.c
12+
EXTRA_CLEAN = btree_int2.c btree_int4.c btree_int8.c btree_float4.c btree_float8.c
1313

1414
include $(top_srcdir)/contrib/contrib-global.mk
1515

16+
btree_int2.c: btree_num.c.in
17+
sed 's,__DEFINE_BTREE_TYPE_HERE__,BTREE_GIST_INT2,g;s,__BTREE_GIST_TYPE__,int16,g;s,__BTREE_GIST_TYPE2__,int2,g' < $< > $@
18+
1619
btree_int4.c: btree_num.c.in
1720
sed 's,__DEFINE_BTREE_TYPE_HERE__,BTREE_GIST_INT4,g;s,__BTREE_GIST_TYPE__,int32,g;s,__BTREE_GIST_TYPE2__,int4,g' < $< > $@
1821

contrib/btree_gist/README.btree_gist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
This is B-Tree implementation using GiST for int4, int8, float4, float8
1+
This is B-Tree implementation using GiST for int2, int4, int8, float4, float8
22
timestamp types.
33

44
All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov
55
(oleg@sai.msu.su). See http://www.sai.msu.su/~megera/postgres/gist
66
for additional information.
77

88
NEWS:
9-
Feb 5, 2003 - btree_gist now support int8, float4, float8 !
9+
Feb 5, 2003 - btree_gist now support int2, int8, float4, float8 !
1010
Thank Janko Richter <jankorichter@yahoo.de> for
1111
contribution.
1212

contrib/btree_gist/btree_gist.sql.in

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ SET search_path = public;
33

44
SET autocommit TO 'on';
55

6+
-- create type of int2 key
7+
CREATE FUNCTION int2key_in(cstring)
8+
RETURNS int2key
9+
AS 'MODULE_PATHNAME'
10+
LANGUAGE 'c' WITH (isstrict);
11+
12+
CREATE FUNCTION int2key_out(int2key)
13+
RETURNS cstring
14+
AS 'MODULE_PATHNAME'
15+
LANGUAGE 'c' WITH (isstrict);
16+
17+
CREATE TYPE int2key (
18+
INTERNALLENGTH = 4,
19+
INPUT = int2key_in,
20+
OUTPUT = int2key_out
21+
);
22+
623
-- create type of int4 key
724
CREATE FUNCTION int4key_in(cstring)
825
RETURNS int4key
@@ -75,17 +92,17 @@ OUTPUT = float8key_out
7592
--
7693
--
7794
--
78-
-- int4 ops
95+
-- int2 ops
7996
--
8097
--
8198
--
8299
-- define the GiST support methods
83-
CREATE FUNCTION gint4_consistent(internal,int4,int2)
100+
CREATE FUNCTION gint2_consistent(internal,int2,int2)
84101
RETURNS bool
85102
AS 'MODULE_PATHNAME'
86103
LANGUAGE 'C';
87104

88-
CREATE FUNCTION gint4_compress(internal)
105+
CREATE FUNCTION gint2_compress(internal)
89106
RETURNS internal
90107
AS 'MODULE_PATHNAME'
91108
LANGUAGE 'C';
@@ -95,6 +112,62 @@ RETURNS internal
95112
AS 'MODULE_PATHNAME'
96113
LANGUAGE 'C';
97114

115+
CREATE FUNCTION gint2_penalty(internal,internal,internal)
116+
RETURNS internal
117+
AS 'MODULE_PATHNAME'
118+
LANGUAGE 'C' WITH (isstrict);
119+
120+
CREATE FUNCTION gint2_picksplit(internal, internal)
121+
RETURNS internal
122+
AS 'MODULE_PATHNAME'
123+
LANGUAGE 'C';
124+
125+
CREATE FUNCTION gint2_union(bytea, internal)
126+
RETURNS int4
127+
AS 'MODULE_PATHNAME'
128+
LANGUAGE 'C';
129+
130+
CREATE FUNCTION gint2_same(internal, internal, internal)
131+
RETURNS internal
132+
AS 'MODULE_PATHNAME'
133+
LANGUAGE 'C';
134+
135+
-- Create the operator class
136+
CREATE OPERATOR CLASS gist_int2_ops
137+
DEFAULT FOR TYPE int2 USING gist
138+
AS
139+
OPERATOR 1 < ,
140+
OPERATOR 2 <= ,
141+
OPERATOR 3 = ,
142+
OPERATOR 4 >= ,
143+
OPERATOR 5 > ,
144+
FUNCTION 1 gint2_consistent (internal, int2, int2),
145+
FUNCTION 2 gint2_union (bytea, internal),
146+
FUNCTION 3 gint2_compress (internal),
147+
FUNCTION 4 btree_decompress (internal),
148+
FUNCTION 5 gint2_penalty (internal, internal, internal),
149+
FUNCTION 6 gint2_picksplit (internal, internal),
150+
FUNCTION 7 gint2_same (internal, internal, internal),
151+
STORAGE int2key;
152+
153+
--
154+
--
155+
--
156+
-- int4 ops
157+
--
158+
--
159+
--
160+
-- define the GiST support methods
161+
CREATE FUNCTION gint4_consistent(internal,int4,int2)
162+
RETURNS bool
163+
AS 'MODULE_PATHNAME'
164+
LANGUAGE 'C';
165+
166+
CREATE FUNCTION gint4_compress(internal)
167+
RETURNS internal
168+
AS 'MODULE_PATHNAME'
169+
LANGUAGE 'C';
170+
98171
CREATE FUNCTION gint4_penalty(internal,internal,internal)
99172
RETURNS internal
100173
AS 'MODULE_PATHNAME'

contrib/btree_gist/btree_num.c.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ g__BTREE_GIST_TYPE2___compress(PG_FUNCTION_ARGS)
5151
if (entry->leafkey)
5252
{
5353
__BTREE_GIST_TYPE__KEY *r = ( __BTREE_GIST_TYPE__KEY * ) palloc(sizeof(__BTREE_GIST_TYPE__KEY));
54+
#ifdef BTREE_GIST_INT2
55+
int16 leaf = DatumGetInt16(entry->key);
56+
#endif
5457
#ifdef BTREE_GIST_INT4
5558
int32 leaf = DatumGetInt32(entry->key);
5659
#endif
@@ -80,6 +83,9 @@ Datum
8083
g__BTREE_GIST_TYPE2___consistent(PG_FUNCTION_ARGS)
8184
{
8285
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
86+
#ifdef BTREE_GIST_INT2
87+
int16 query = PG_GETARG_INT16(1);
88+
#endif
8389
#ifdef BTREE_GIST_INT4
8490
int32 query = PG_GETARG_INT32(1);
8591
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy