please apply attached patch to current CVS.

btree_gist now supports int2 !
Thanks Janko Richter for contribution.
This commit is contained in:
Bruce Momjian 2003-03-20 18:59:18 +00:00
parent 3be6367b9f
commit e0d043b94d
4 changed files with 91 additions and 9 deletions

View file

@ -4,15 +4,18 @@ top_builddir = ../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
MODULE_big = btree_gist MODULE_big = btree_gist
OBJS= btree_common.o btree_int4.o btree_int8.o btree_float4.o btree_float8.o btree_ts.o OBJS= btree_common.o btree_int2.o btree_int4.o btree_int8.o btree_float4.o btree_float8.o btree_ts.o
DATA_built = btree_gist.sql DATA_built = btree_gist.sql
DOCS = README.btree_gist DOCS = README.btree_gist
REGRESS = btree_gist REGRESS = btree_gist
EXTRA_CLEAN = btree_int4.c btree_int8.c btree_float4.c btree_float8.c EXTRA_CLEAN = btree_int2.c btree_int4.c btree_int8.c btree_float4.c btree_float8.c
include $(top_srcdir)/contrib/contrib-global.mk include $(top_srcdir)/contrib/contrib-global.mk
btree_int2.c: btree_num.c.in
sed 's,__DEFINE_BTREE_TYPE_HERE__,BTREE_GIST_INT2,g;s,__BTREE_GIST_TYPE__,int16,g;s,__BTREE_GIST_TYPE2__,int2,g' < $< > $@
btree_int4.c: btree_num.c.in btree_int4.c: btree_num.c.in
sed 's,__DEFINE_BTREE_TYPE_HERE__,BTREE_GIST_INT4,g;s,__BTREE_GIST_TYPE__,int32,g;s,__BTREE_GIST_TYPE2__,int4,g' < $< > $@ sed 's,__DEFINE_BTREE_TYPE_HERE__,BTREE_GIST_INT4,g;s,__BTREE_GIST_TYPE__,int32,g;s,__BTREE_GIST_TYPE2__,int4,g' < $< > $@

View file

@ -1,4 +1,4 @@
This is B-Tree implementation using GiST for int4, int8, float4, float8 This is B-Tree implementation using GiST for int2, int4, int8, float4, float8
timestamp types. timestamp types.
All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov
@ -6,7 +6,7 @@ All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov
for additional information. for additional information.
NEWS: NEWS:
Feb 5, 2003 - btree_gist now support int8, float4, float8 ! Feb 5, 2003 - btree_gist now support int2, int8, float4, float8 !
Thank Janko Richter <jankorichter@yahoo.de> for Thank Janko Richter <jankorichter@yahoo.de> for
contribution. contribution.

View file

@ -3,6 +3,23 @@ SET search_path = public;
SET autocommit TO 'on'; SET autocommit TO 'on';
-- create type of int2 key
CREATE FUNCTION int2key_in(cstring)
RETURNS int2key
AS 'MODULE_PATHNAME'
LANGUAGE 'c' WITH (isstrict);
CREATE FUNCTION int2key_out(int2key)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE 'c' WITH (isstrict);
CREATE TYPE int2key (
INTERNALLENGTH = 4,
INPUT = int2key_in,
OUTPUT = int2key_out
);
-- create type of int4 key -- create type of int4 key
CREATE FUNCTION int4key_in(cstring) CREATE FUNCTION int4key_in(cstring)
RETURNS int4key RETURNS int4key
@ -72,6 +89,67 @@ INPUT = float8key_in,
OUTPUT = float8key_out OUTPUT = float8key_out
); );
--
--
--
-- int2 ops
--
--
--
-- define the GiST support methods
CREATE FUNCTION gint2_consistent(internal,int2,int2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gint2_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION btree_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gint2_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION gint2_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gint2_union(bytea, internal)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gint2_same(internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Create the operator class
CREATE OPERATOR CLASS gist_int2_ops
DEFAULT FOR TYPE int2 USING gist
AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 gint2_consistent (internal, int2, int2),
FUNCTION 2 gint2_union (bytea, internal),
FUNCTION 3 gint2_compress (internal),
FUNCTION 4 btree_decompress (internal),
FUNCTION 5 gint2_penalty (internal, internal, internal),
FUNCTION 6 gint2_picksplit (internal, internal),
FUNCTION 7 gint2_same (internal, internal, internal),
STORAGE int2key;
-- --
-- --
-- --
@ -90,11 +168,6 @@ RETURNS internal
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
CREATE FUNCTION btree_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gint4_penalty(internal,internal,internal) CREATE FUNCTION gint4_penalty(internal,internal,internal)
RETURNS internal RETURNS internal
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'

View file

@ -51,6 +51,9 @@ g__BTREE_GIST_TYPE2___compress(PG_FUNCTION_ARGS)
if (entry->leafkey) if (entry->leafkey)
{ {
__BTREE_GIST_TYPE__KEY *r = ( __BTREE_GIST_TYPE__KEY * ) palloc(sizeof(__BTREE_GIST_TYPE__KEY)); __BTREE_GIST_TYPE__KEY *r = ( __BTREE_GIST_TYPE__KEY * ) palloc(sizeof(__BTREE_GIST_TYPE__KEY));
#ifdef BTREE_GIST_INT2
int16 leaf = DatumGetInt16(entry->key);
#endif
#ifdef BTREE_GIST_INT4 #ifdef BTREE_GIST_INT4
int32 leaf = DatumGetInt32(entry->key); int32 leaf = DatumGetInt32(entry->key);
#endif #endif
@ -80,6 +83,9 @@ Datum
g__BTREE_GIST_TYPE2___consistent(PG_FUNCTION_ARGS) g__BTREE_GIST_TYPE2___consistent(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
#ifdef BTREE_GIST_INT2
int16 query = PG_GETARG_INT16(1);
#endif
#ifdef BTREE_GIST_INT4 #ifdef BTREE_GIST_INT4
int32 query = PG_GETARG_INT32(1); int32 query = PG_GETARG_INT32(1);
#endif #endif