From 229d8a167f9b4e6b31276ec70b46c2994a6c2f47 Mon Sep 17 00:00:00 2001
From: Nikita Glukhov <n.gluhov@postgrespro.ru>
Date: Fri, 11 Jan 2019 15:51:29 +0300
Subject: [PATCH 6/7] Remove distance operators from btree_gist

---
 contrib/btree_gist/Makefile                 |    5 +-
 contrib/btree_gist/btree_cash.c             |   15 +-
 contrib/btree_gist/btree_date.c             |    7 +-
 contrib/btree_gist/btree_float4.c           |    9 +-
 contrib/btree_gist/btree_float8.c           |    9 +-
 contrib/btree_gist/btree_gist--1.2.sql      | 1570 --------------------------
 contrib/btree_gist/btree_gist--1.5--1.6.sql |   99 ++
 contrib/btree_gist/btree_gist--1.6.sql      | 1615 +++++++++++++++++++++++++++
 contrib/btree_gist/btree_gist.control       |    2 +-
 contrib/btree_gist/btree_int2.c             |   15 +-
 contrib/btree_gist/btree_int4.c             |   15 +-
 contrib/btree_gist/btree_int8.c             |   15 +-
 contrib/btree_gist/btree_interval.c         |    6 +-
 contrib/btree_gist/btree_oid.c              |   10 +-
 contrib/btree_gist/btree_time.c             |    6 +-
 contrib/btree_gist/btree_ts.c               |   38 +-
 doc/src/sgml/btree-gist.sgml                |   13 +
 17 files changed, 1743 insertions(+), 1706 deletions(-)
 delete mode 100644 contrib/btree_gist/btree_gist--1.2.sql
 create mode 100644 contrib/btree_gist/btree_gist--1.5--1.6.sql
 create mode 100644 contrib/btree_gist/btree_gist--1.6.sql

diff --git a/contrib/btree_gist/Makefile b/contrib/btree_gist/Makefile
index af65120..46ab241 100644
--- a/contrib/btree_gist/Makefile
+++ b/contrib/btree_gist/Makefile
@@ -11,8 +11,9 @@ OBJS =  btree_gist.o btree_utils_num.o btree_utils_var.o btree_int2.o \
 
 EXTENSION = btree_gist
 DATA = btree_gist--unpackaged--1.0.sql btree_gist--1.0--1.1.sql \
-       btree_gist--1.1--1.2.sql btree_gist--1.2.sql btree_gist--1.2--1.3.sql \
-       btree_gist--1.3--1.4.sql btree_gist--1.4--1.5.sql
+       btree_gist--1.1--1.2.sql btree_gist--1.2--1.3.sql \
+       btree_gist--1.3--1.4.sql btree_gist--1.4--1.5.sql \
+       btree_gist--1.5--1.6.sql btree_gist--1.6.sql
 PGFILEDESC = "btree_gist - B-tree equivalent GiST operator classes"
 
 REGRESS = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz \
diff --git a/contrib/btree_gist/btree_cash.c b/contrib/btree_gist/btree_cash.c
index 894d0a2..1b0e317 100644
--- a/contrib/btree_gist/btree_cash.c
+++ b/contrib/btree_gist/btree_cash.c
@@ -95,20 +95,7 @@ PG_FUNCTION_INFO_V1(cash_dist);
 Datum
 cash_dist(PG_FUNCTION_ARGS)
 {
-	Cash		a = PG_GETARG_CASH(0);
-	Cash		b = PG_GETARG_CASH(1);
-	Cash		r;
-	Cash		ra;
-
-	if (pg_sub_s64_overflow(a, b, &r) ||
-		r == PG_INT64_MIN)
-		ereport(ERROR,
-				(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-				 errmsg("money out of range")));
-
-	ra = Abs(r);
-
-	PG_RETURN_CASH(ra);
+	return cash_distance(fcinfo);
 }
 
 /**************************************************
diff --git a/contrib/btree_gist/btree_date.c b/contrib/btree_gist/btree_date.c
index 992ce57..f3f0fa1 100644
--- a/contrib/btree_gist/btree_date.c
+++ b/contrib/btree_gist/btree_date.c
@@ -113,12 +113,7 @@ PG_FUNCTION_INFO_V1(date_dist);
 Datum
 date_dist(PG_FUNCTION_ARGS)
 {
-	/* we assume the difference can't overflow */
-	Datum		diff = DirectFunctionCall2(date_mi,
-										   PG_GETARG_DATUM(0),
-										   PG_GETARG_DATUM(1));
-
-	PG_RETURN_INT32(Abs(DatumGetInt32(diff)));
+	return date_distance(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_float4.c b/contrib/btree_gist/btree_float4.c
index 6b20f44..0a9148d 100644
--- a/contrib/btree_gist/btree_float4.c
+++ b/contrib/btree_gist/btree_float4.c
@@ -93,14 +93,7 @@ PG_FUNCTION_INFO_V1(float4_dist);
 Datum
 float4_dist(PG_FUNCTION_ARGS)
 {
-	float4		a = PG_GETARG_FLOAT4(0);
-	float4		b = PG_GETARG_FLOAT4(1);
-	float4		r;
-
-	r = a - b;
-	CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
-
-	PG_RETURN_FLOAT4(Abs(r));
+	return float4dist(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_float8.c b/contrib/btree_gist/btree_float8.c
index ee114cb..8b73b57 100644
--- a/contrib/btree_gist/btree_float8.c
+++ b/contrib/btree_gist/btree_float8.c
@@ -101,14 +101,7 @@ PG_FUNCTION_INFO_V1(float8_dist);
 Datum
 float8_dist(PG_FUNCTION_ARGS)
 {
-	float8		a = PG_GETARG_FLOAT8(0);
-	float8		b = PG_GETARG_FLOAT8(1);
-	float8		r;
-
-	r = a - b;
-	CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
-
-	PG_RETURN_FLOAT8(Abs(r));
+	return float8dist(fcinfo);
 }
 
 /**************************************************
diff --git a/contrib/btree_gist/btree_gist--1.2.sql b/contrib/btree_gist/btree_gist--1.2.sql
deleted file mode 100644
index 1efe753..0000000
--- a/contrib/btree_gist/btree_gist--1.2.sql
+++ /dev/null
@@ -1,1570 +0,0 @@
-/* contrib/btree_gist/btree_gist--1.2.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION btree_gist" to load this file. \quit
-
-CREATE FUNCTION gbtreekey4_in(cstring)
-RETURNS gbtreekey4
-AS 'MODULE_PATHNAME', 'gbtreekey_in'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbtreekey4_out(gbtreekey4)
-RETURNS cstring
-AS 'MODULE_PATHNAME', 'gbtreekey_out'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE TYPE gbtreekey4 (
-	INTERNALLENGTH = 4,
-	INPUT  = gbtreekey4_in,
-	OUTPUT = gbtreekey4_out
-);
-
-CREATE FUNCTION gbtreekey8_in(cstring)
-RETURNS gbtreekey8
-AS 'MODULE_PATHNAME', 'gbtreekey_in'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbtreekey8_out(gbtreekey8)
-RETURNS cstring
-AS 'MODULE_PATHNAME', 'gbtreekey_out'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE TYPE gbtreekey8 (
-	INTERNALLENGTH = 8,
-	INPUT  = gbtreekey8_in,
-	OUTPUT = gbtreekey8_out
-);
-
-CREATE FUNCTION gbtreekey16_in(cstring)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME', 'gbtreekey_in'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbtreekey16_out(gbtreekey16)
-RETURNS cstring
-AS 'MODULE_PATHNAME', 'gbtreekey_out'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE TYPE gbtreekey16 (
-	INTERNALLENGTH = 16,
-	INPUT  = gbtreekey16_in,
-	OUTPUT = gbtreekey16_out
-);
-
-CREATE FUNCTION gbtreekey32_in(cstring)
-RETURNS gbtreekey32
-AS 'MODULE_PATHNAME', 'gbtreekey_in'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbtreekey32_out(gbtreekey32)
-RETURNS cstring
-AS 'MODULE_PATHNAME', 'gbtreekey_out'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE TYPE gbtreekey32 (
-	INTERNALLENGTH = 32,
-	INPUT  = gbtreekey32_in,
-	OUTPUT = gbtreekey32_out
-);
-
-CREATE FUNCTION gbtreekey_var_in(cstring)
-RETURNS gbtreekey_var
-AS 'MODULE_PATHNAME', 'gbtreekey_in'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbtreekey_var_out(gbtreekey_var)
-RETURNS cstring
-AS 'MODULE_PATHNAME', 'gbtreekey_out'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE TYPE gbtreekey_var (
-	INTERNALLENGTH = VARIABLE,
-	INPUT  = gbtreekey_var_in,
-	OUTPUT = gbtreekey_var_out,
-	STORAGE = EXTENDED
-);
-
---distance operators
-
-CREATE FUNCTION cash_dist(money, money)
-RETURNS money
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = money,
-	RIGHTARG = money,
-	PROCEDURE = cash_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION date_dist(date, date)
-RETURNS int4
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = date,
-	RIGHTARG = date,
-	PROCEDURE = date_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION float4_dist(float4, float4)
-RETURNS float4
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = float4,
-	RIGHTARG = float4,
-	PROCEDURE = float4_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION float8_dist(float8, float8)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = float8,
-	RIGHTARG = float8,
-	PROCEDURE = float8_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION int2_dist(int2, int2)
-RETURNS int2
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = int2,
-	RIGHTARG = int2,
-	PROCEDURE = int2_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION int4_dist(int4, int4)
-RETURNS int4
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = int4,
-	RIGHTARG = int4,
-	PROCEDURE = int4_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION int8_dist(int8, int8)
-RETURNS int8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = int8,
-	RIGHTARG = int8,
-	PROCEDURE = int8_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION interval_dist(interval, interval)
-RETURNS interval
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = interval,
-	RIGHTARG = interval,
-	PROCEDURE = interval_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION oid_dist(oid, oid)
-RETURNS oid
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = oid,
-	RIGHTARG = oid,
-	PROCEDURE = oid_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION time_dist(time, time)
-RETURNS interval
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = time,
-	RIGHTARG = time,
-	PROCEDURE = time_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION ts_dist(timestamp, timestamp)
-RETURNS interval
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = timestamp,
-	RIGHTARG = timestamp,
-	PROCEDURE = ts_dist,
-	COMMUTATOR = '<->'
-);
-
-CREATE FUNCTION tstz_dist(timestamptz, timestamptz)
-RETURNS interval
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE OPERATOR <-> (
-	LEFTARG = timestamptz,
-	RIGHTARG = timestamptz,
-	PROCEDURE = tstz_dist,
-	COMMUTATOR = '<->'
-);
-
-
---
---
---
--- oid ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_oid_consistent(internal,oid,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_oid_distance(internal,oid,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_oid_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_oid_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_decompress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_var_decompress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_var_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_oid_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_oid_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_oid_union(internal, internal)
-RETURNS gbtreekey8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_oid_same(gbtreekey8, gbtreekey8, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_oid_ops
-DEFAULT FOR TYPE oid USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_oid_consistent (internal, oid, int2, oid, internal),
-	FUNCTION	2	gbt_oid_union (internal, internal),
-	FUNCTION	3	gbt_oid_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_oid_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_oid_picksplit (internal, internal),
-	FUNCTION	7	gbt_oid_same (gbtreekey8, gbtreekey8, internal),
-	STORAGE		gbtreekey8;
-
--- Add operators that are new in 9.1.  We do it like this, leaving them
--- "loose" in the operator family rather than bound into the opclass, because
--- that's the only state that can be reproduced during an upgrade from 9.0.
-ALTER OPERATOR FAMILY gist_oid_ops USING gist ADD
-	OPERATOR	6	<> (oid, oid) ,
-	OPERATOR	15	<-> (oid, oid) FOR ORDER BY pg_catalog.oid_ops ,
-	FUNCTION	8 (oid, oid) gbt_oid_distance (internal, oid, int2, oid, internal) ,
-	-- Also add support function for index-only-scans, added in 9.5.
-	FUNCTION	9 (oid, oid) gbt_oid_fetch (internal) ;
-
-
---
---
---
--- int2 ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_int2_consistent(internal,int2,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int2_distance(internal,int2,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int2_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int2_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int2_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int2_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int2_union(internal, internal)
-RETURNS gbtreekey4
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int2_same(gbtreekey4, gbtreekey4, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- 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	gbt_int2_consistent (internal, int2, int2, oid, internal),
-	FUNCTION	2	gbt_int2_union (internal, internal),
-	FUNCTION	3	gbt_int2_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_int2_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_int2_picksplit (internal, internal),
-	FUNCTION	7	gbt_int2_same (gbtreekey4, gbtreekey4, internal),
-	STORAGE		gbtreekey4;
-
-ALTER OPERATOR FAMILY gist_int2_ops USING gist ADD
-	OPERATOR	6	<> (int2, int2) ,
-	OPERATOR	15	<-> (int2, int2) FOR ORDER BY pg_catalog.integer_ops ,
-	FUNCTION	8 (int2, int2) gbt_int2_distance (internal, int2, int2, oid, internal) ,
-	FUNCTION	9 (int2, int2) gbt_int2_fetch (internal) ;
-
---
---
---
--- int4 ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_int4_consistent(internal,int4,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int4_distance(internal,int4,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int4_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int4_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int4_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int4_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int4_union(internal, internal)
-RETURNS gbtreekey8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int4_same(gbtreekey8, gbtreekey8, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_int4_ops
-DEFAULT FOR TYPE int4 USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_int4_consistent (internal, int4, int2, oid, internal),
-	FUNCTION	2	gbt_int4_union (internal, internal),
-	FUNCTION	3	gbt_int4_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_int4_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_int4_picksplit (internal, internal),
-	FUNCTION	7	gbt_int4_same (gbtreekey8, gbtreekey8, internal),
-	STORAGE		gbtreekey8;
-
-ALTER OPERATOR FAMILY gist_int4_ops USING gist ADD
-	OPERATOR	6	<> (int4, int4) ,
-	OPERATOR	15	<-> (int4, int4) FOR ORDER BY pg_catalog.integer_ops ,
-	FUNCTION	8 (int4, int4) gbt_int4_distance (internal, int4, int2, oid, internal) ,
-	FUNCTION	9 (int4, int4) gbt_int4_fetch (internal) ;
-
-
---
---
---
--- int8 ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_int8_consistent(internal,int8,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int8_distance(internal,int8,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int8_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int8_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int8_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int8_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int8_union(internal, internal)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_int8_same(gbtreekey16, gbtreekey16, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_int8_ops
-DEFAULT FOR TYPE int8 USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_int8_consistent (internal, int8, int2, oid, internal),
-	FUNCTION	2	gbt_int8_union (internal, internal),
-	FUNCTION	3	gbt_int8_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_int8_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_int8_picksplit (internal, internal),
-	FUNCTION	7	gbt_int8_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_int8_ops USING gist ADD
-	OPERATOR	6	<> (int8, int8) ,
-	OPERATOR	15	<-> (int8, int8) FOR ORDER BY pg_catalog.integer_ops ,
-	FUNCTION	8 (int8, int8) gbt_int8_distance (internal, int8, int2, oid, internal) ,
-	FUNCTION	9 (int8, int8) gbt_int8_fetch (internal) ;
-
---
---
---
--- float4 ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_float4_consistent(internal,float4,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float4_distance(internal,float4,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float4_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float4_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float4_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float4_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float4_union(internal, internal)
-RETURNS gbtreekey8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float4_same(gbtreekey8, gbtreekey8, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_float4_ops
-DEFAULT FOR TYPE float4 USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_float4_consistent (internal, float4, int2, oid, internal),
-	FUNCTION	2	gbt_float4_union (internal, internal),
-	FUNCTION	3	gbt_float4_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_float4_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_float4_picksplit (internal, internal),
-	FUNCTION	7	gbt_float4_same (gbtreekey8, gbtreekey8, internal),
-	STORAGE		gbtreekey8;
-
-ALTER OPERATOR FAMILY gist_float4_ops USING gist ADD
-	OPERATOR	6	<> (float4, float4) ,
-	OPERATOR	15	<-> (float4, float4) FOR ORDER BY pg_catalog.float_ops ,
-	FUNCTION	8 (float4, float4) gbt_float4_distance (internal, float4, int2, oid, internal) ,
-	FUNCTION	9 (float4, float4) gbt_float4_fetch (internal) ;
-
---
---
---
--- float8 ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_float8_consistent(internal,float8,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float8_distance(internal,float8,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float8_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float8_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float8_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float8_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float8_union(internal, internal)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_float8_same(gbtreekey16, gbtreekey16, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_float8_ops
-DEFAULT FOR TYPE float8 USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_float8_consistent (internal, float8, int2, oid, internal),
-	FUNCTION	2	gbt_float8_union (internal, internal),
-	FUNCTION	3	gbt_float8_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_float8_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_float8_picksplit (internal, internal),
-	FUNCTION	7	gbt_float8_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_float8_ops USING gist ADD
-	OPERATOR	6	<> (float8, float8) ,
-	OPERATOR	15	<-> (float8, float8) FOR ORDER BY pg_catalog.float_ops ,
-	FUNCTION	8 (float8, float8) gbt_float8_distance (internal, float8, int2, oid, internal) ,
-	FUNCTION	9 (float8, float8) gbt_float8_fetch (internal) ;
-
---
---
---
--- timestamp ops
---
---
---
-
-CREATE FUNCTION gbt_ts_consistent(internal,timestamp,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_ts_distance(internal,timestamp,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_tstz_consistent(internal,timestamptz,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_tstz_distance(internal,timestamptz,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_ts_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_tstz_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_ts_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_ts_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_ts_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_ts_union(internal, internal)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_ts_same(gbtreekey16, gbtreekey16, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_timestamp_ops
-DEFAULT FOR TYPE timestamp USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_ts_consistent (internal, timestamp, int2, oid, internal),
-	FUNCTION	2	gbt_ts_union (internal, internal),
-	FUNCTION	3	gbt_ts_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_ts_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_ts_picksplit (internal, internal),
-	FUNCTION	7	gbt_ts_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_timestamp_ops USING gist ADD
-	OPERATOR	6	<> (timestamp, timestamp) ,
-	OPERATOR	15	<-> (timestamp, timestamp) FOR ORDER BY pg_catalog.interval_ops ,
-	FUNCTION	8 (timestamp, timestamp) gbt_ts_distance (internal, timestamp, int2, oid, internal) ,
-	FUNCTION	9 (timestamp, timestamp) gbt_ts_fetch (internal) ;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_timestamptz_ops
-DEFAULT FOR TYPE timestamptz USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_tstz_consistent (internal, timestamptz, int2, oid, internal),
-	FUNCTION	2	gbt_ts_union (internal, internal),
-	FUNCTION	3	gbt_tstz_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_ts_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_ts_picksplit (internal, internal),
-	FUNCTION	7	gbt_ts_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_timestamptz_ops USING gist ADD
-	OPERATOR	6	<> (timestamptz, timestamptz) ,
-	OPERATOR	15	<-> (timestamptz, timestamptz) FOR ORDER BY pg_catalog.interval_ops ,
-	FUNCTION	8 (timestamptz, timestamptz) gbt_tstz_distance (internal, timestamptz, int2, oid, internal) ,
-	FUNCTION	9 (timestamptz, timestamptz) gbt_ts_fetch (internal) ;
-
---
---
---
--- time ops
---
---
---
-
-CREATE FUNCTION gbt_time_consistent(internal,time,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_time_distance(internal,time,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_timetz_consistent(internal,timetz,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_time_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_timetz_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_time_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_time_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_time_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_time_union(internal, internal)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_time_same(gbtreekey16, gbtreekey16, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_time_ops
-DEFAULT FOR TYPE time USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_time_consistent (internal, time, int2, oid, internal),
-	FUNCTION	2	gbt_time_union (internal, internal),
-	FUNCTION	3	gbt_time_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_time_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_time_picksplit (internal, internal),
-	FUNCTION	7	gbt_time_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_time_ops USING gist ADD
-	OPERATOR	6	<> (time, time) ,
-	OPERATOR	15	<-> (time, time) FOR ORDER BY pg_catalog.interval_ops ,
-	FUNCTION	8 (time, time) gbt_time_distance (internal, time, int2, oid, internal) ,
-	FUNCTION	9 (time, time) gbt_time_fetch (internal) ;
-
-
-CREATE OPERATOR CLASS gist_timetz_ops
-DEFAULT FOR TYPE timetz USING gist
-AS
-	OPERATOR	1	<   ,
-	OPERATOR	2	<=  ,
-	OPERATOR	3	=   ,
-	OPERATOR	4	>=  ,
-	OPERATOR	5	>   ,
-	FUNCTION	1	gbt_timetz_consistent (internal, timetz, int2, oid, internal),
-	FUNCTION	2	gbt_time_union (internal, internal),
-	FUNCTION	3	gbt_timetz_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_time_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_time_picksplit (internal, internal),
-	FUNCTION	7	gbt_time_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_timetz_ops USING gist ADD
-	OPERATOR	6	<> (timetz, timetz) ;
-	-- no 'fetch' function, as the compress function is lossy.
-
-
---
---
---
--- date ops
---
---
---
-
-CREATE FUNCTION gbt_date_consistent(internal,date,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_date_distance(internal,date,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_date_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_date_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_date_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_date_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_date_union(internal, internal)
-RETURNS gbtreekey8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_date_same(gbtreekey8, gbtreekey8, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_date_ops
-DEFAULT FOR TYPE date USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_date_consistent (internal, date, int2, oid, internal),
-	FUNCTION	2	gbt_date_union (internal, internal),
-	FUNCTION	3	gbt_date_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_date_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_date_picksplit (internal, internal),
-	FUNCTION	7	gbt_date_same (gbtreekey8, gbtreekey8, internal),
-	STORAGE		gbtreekey8;
-
-ALTER OPERATOR FAMILY gist_date_ops USING gist ADD
-	OPERATOR	6	<> (date, date) ,
-	OPERATOR	15	<-> (date, date) FOR ORDER BY pg_catalog.integer_ops ,
-	FUNCTION	8 (date, date) gbt_date_distance (internal, date, int2, oid, internal) ,
-	FUNCTION	9 (date, date) gbt_date_fetch (internal) ;
-
-
---
---
---
--- interval ops
---
---
---
-
-CREATE FUNCTION gbt_intv_consistent(internal,interval,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_distance(internal,interval,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_decompress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_union(internal, internal)
-RETURNS gbtreekey32
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_intv_same(gbtreekey32, gbtreekey32, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_interval_ops
-DEFAULT FOR TYPE interval USING gist
-AS
-	OPERATOR	1	< ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	= ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	> ,
-	FUNCTION	1	gbt_intv_consistent (internal, interval, int2, oid, internal),
-	FUNCTION	2	gbt_intv_union (internal, internal),
-	FUNCTION	3	gbt_intv_compress (internal),
-	FUNCTION	4	gbt_intv_decompress (internal),
-	FUNCTION	5	gbt_intv_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_intv_picksplit (internal, internal),
-	FUNCTION	7	gbt_intv_same (gbtreekey32, gbtreekey32, internal),
-	STORAGE		gbtreekey32;
-
-ALTER OPERATOR FAMILY gist_interval_ops USING gist ADD
-	OPERATOR	6	<> (interval, interval) ,
-	OPERATOR	15	<-> (interval, interval) FOR ORDER BY pg_catalog.interval_ops ,
-	FUNCTION	8 (interval, interval) gbt_intv_distance (internal, interval, int2, oid, internal) ,
-	FUNCTION	9 (interval, interval) gbt_intv_fetch (internal) ;
-
-
---
---
---
--- cash ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_cash_consistent(internal,money,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_cash_distance(internal,money,int2,oid,internal)
-RETURNS float8
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_cash_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_cash_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_cash_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_cash_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_cash_union(internal, internal)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_cash_same(gbtreekey16, gbtreekey16, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_cash_ops
-DEFAULT FOR TYPE money USING gist
-AS
-	OPERATOR	1	< ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	= ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	> ,
-	FUNCTION	1	gbt_cash_consistent (internal, money, int2, oid, internal),
-	FUNCTION	2	gbt_cash_union (internal, internal),
-	FUNCTION	3	gbt_cash_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_cash_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_cash_picksplit (internal, internal),
-	FUNCTION	7	gbt_cash_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_cash_ops USING gist ADD
-	OPERATOR	6	<> (money, money) ,
-	OPERATOR	15	<-> (money, money) FOR ORDER BY pg_catalog.money_ops ,
-	FUNCTION	8 (money, money) gbt_cash_distance (internal, money, int2, oid, internal) ,
-	FUNCTION	9 (money, money) gbt_cash_fetch (internal) ;
-
-
---
---
---
--- macaddr ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_macad_consistent(internal,macaddr,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_macad_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_macad_fetch(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_macad_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_macad_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_macad_union(internal, internal)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_macad_same(gbtreekey16, gbtreekey16, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_macaddr_ops
-DEFAULT FOR TYPE macaddr USING gist
-AS
-	OPERATOR	1	< ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	= ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	> ,
-	FUNCTION	1	gbt_macad_consistent (internal, macaddr, int2, oid, internal),
-	FUNCTION	2	gbt_macad_union (internal, internal),
-	FUNCTION	3	gbt_macad_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_macad_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_macad_picksplit (internal, internal),
-	FUNCTION	7	gbt_macad_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_macaddr_ops USING gist ADD
-	OPERATOR	6	<> (macaddr, macaddr) ,
-	FUNCTION	9 (macaddr, macaddr) gbt_macad_fetch (internal);
-
-
---
---
---
--- text/ bpchar ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_text_consistent(internal,text,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bpchar_consistent(internal,bpchar,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_text_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bpchar_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_text_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_text_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_text_union(internal, internal)
-RETURNS gbtreekey_var
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_text_same(gbtreekey_var, gbtreekey_var, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_text_ops
-DEFAULT FOR TYPE text USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_text_consistent (internal, text, int2, oid, internal),
-	FUNCTION	2	gbt_text_union (internal, internal),
-	FUNCTION	3	gbt_text_compress (internal),
-	FUNCTION	4	gbt_var_decompress (internal),
-	FUNCTION	5	gbt_text_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_text_picksplit (internal, internal),
-	FUNCTION	7	gbt_text_same (gbtreekey_var, gbtreekey_var, internal),
-	STORAGE			gbtreekey_var;
-
-ALTER OPERATOR FAMILY gist_text_ops USING gist ADD
-	OPERATOR	6	<> (text, text) ,
-	FUNCTION	9 (text, text) gbt_var_fetch (internal) ;
-
-
----- Create the operator class
-CREATE OPERATOR CLASS gist_bpchar_ops
-DEFAULT FOR TYPE bpchar USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_bpchar_consistent (internal, bpchar , int2, oid, internal),
-	FUNCTION	2	gbt_text_union (internal, internal),
-	FUNCTION	3	gbt_bpchar_compress (internal),
-	FUNCTION	4	gbt_var_decompress (internal),
-	FUNCTION	5	gbt_text_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_text_picksplit (internal, internal),
-	FUNCTION	7	gbt_text_same (gbtreekey_var, gbtreekey_var, internal),
-	STORAGE			gbtreekey_var;
-
-ALTER OPERATOR FAMILY gist_bpchar_ops USING gist ADD
-	OPERATOR	6	<> (bpchar, bpchar) ,
-	FUNCTION	9 (bpchar, bpchar) gbt_var_fetch (internal) ;
-
---
---
--- bytea ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_bytea_consistent(internal,bytea,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bytea_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bytea_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bytea_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bytea_union(internal, internal)
-RETURNS gbtreekey_var
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bytea_same(gbtreekey_var, gbtreekey_var, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_bytea_ops
-DEFAULT FOR TYPE bytea USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_bytea_consistent (internal, bytea, int2, oid, internal),
-	FUNCTION	2	gbt_bytea_union (internal, internal),
-	FUNCTION	3	gbt_bytea_compress (internal),
-	FUNCTION	4	gbt_var_decompress (internal),
-	FUNCTION	5	gbt_bytea_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_bytea_picksplit (internal, internal),
-	FUNCTION	7	gbt_bytea_same (gbtreekey_var, gbtreekey_var, internal),
-	STORAGE			gbtreekey_var;
-
-ALTER OPERATOR FAMILY gist_bytea_ops USING gist ADD
-	OPERATOR	6	<> (bytea, bytea) ,
-	FUNCTION	9 (bytea, bytea) gbt_var_fetch (internal) ;
-
-
---
---
---
--- numeric ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_numeric_consistent(internal,numeric,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_numeric_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_numeric_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_numeric_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_numeric_union(internal, internal)
-RETURNS gbtreekey_var
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_numeric_same(gbtreekey_var, gbtreekey_var, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_numeric_ops
-DEFAULT FOR TYPE numeric USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_numeric_consistent (internal, numeric, int2, oid, internal),
-	FUNCTION	2	gbt_numeric_union (internal, internal),
-	FUNCTION	3	gbt_numeric_compress (internal),
-	FUNCTION	4	gbt_var_decompress (internal),
-	FUNCTION	5	gbt_numeric_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_numeric_picksplit (internal, internal),
-	FUNCTION	7	gbt_numeric_same (gbtreekey_var, gbtreekey_var, internal),
-	STORAGE			gbtreekey_var;
-
-ALTER OPERATOR FAMILY gist_numeric_ops USING gist ADD
-	OPERATOR	6	<> (numeric, numeric) ,
-	FUNCTION	9 (numeric, numeric) gbt_var_fetch (internal) ;
-
-
---
---
--- bit ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_bit_consistent(internal,bit,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bit_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bit_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bit_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bit_union(internal, internal)
-RETURNS gbtreekey_var
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_bit_same(gbtreekey_var, gbtreekey_var, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_bit_ops
-DEFAULT FOR TYPE bit USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_bit_consistent (internal, bit, int2, oid, internal),
-	FUNCTION	2	gbt_bit_union (internal, internal),
-	FUNCTION	3	gbt_bit_compress (internal),
-	FUNCTION	4	gbt_var_decompress (internal),
-	FUNCTION	5	gbt_bit_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_bit_picksplit (internal, internal),
-	FUNCTION	7	gbt_bit_same (gbtreekey_var, gbtreekey_var, internal),
-	STORAGE			gbtreekey_var;
-
-ALTER OPERATOR FAMILY gist_bit_ops USING gist ADD
-	OPERATOR	6	<> (bit, bit) ,
-	FUNCTION	9 (bit, bit) gbt_var_fetch (internal) ;
-
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_vbit_ops
-DEFAULT FOR TYPE varbit USING gist
-AS
-	OPERATOR	1	<  ,
-	OPERATOR	2	<= ,
-	OPERATOR	3	=  ,
-	OPERATOR	4	>= ,
-	OPERATOR	5	>  ,
-	FUNCTION	1	gbt_bit_consistent (internal, bit, int2, oid, internal),
-	FUNCTION	2	gbt_bit_union (internal, internal),
-	FUNCTION	3	gbt_bit_compress (internal),
-	FUNCTION	4	gbt_var_decompress (internal),
-	FUNCTION	5	gbt_bit_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_bit_picksplit (internal, internal),
-	FUNCTION	7	gbt_bit_same (gbtreekey_var, gbtreekey_var, internal),
-	STORAGE			gbtreekey_var;
-
-ALTER OPERATOR FAMILY gist_vbit_ops USING gist ADD
-	OPERATOR	6	<> (varbit, varbit) ,
-	FUNCTION	9 (varbit, varbit) gbt_var_fetch (internal) ;
-
-
---
---
---
--- inet/cidr ops
---
---
---
--- define the GiST support methods
-CREATE FUNCTION gbt_inet_consistent(internal,inet,int2,oid,internal)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_inet_compress(internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_inet_penalty(internal,internal,internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_inet_picksplit(internal, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_inet_union(internal, internal)
-RETURNS gbtreekey16
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
-CREATE FUNCTION gbt_inet_same(gbtreekey16, gbtreekey16, internal)
-RETURNS internal
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE STRICT;
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_inet_ops
-DEFAULT FOR TYPE inet USING gist
-AS
-	OPERATOR	1	<   ,
-	OPERATOR	2	<=  ,
-	OPERATOR	3	=   ,
-	OPERATOR	4	>=  ,
-	OPERATOR	5	>   ,
-	FUNCTION	1	gbt_inet_consistent (internal, inet, int2, oid, internal),
-	FUNCTION	2	gbt_inet_union (internal, internal),
-	FUNCTION	3	gbt_inet_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_inet_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_inet_picksplit (internal, internal),
-	FUNCTION	7	gbt_inet_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_inet_ops USING gist ADD
-	OPERATOR	6	<>  (inet, inet) ;
-	-- no fetch support, the compress function is lossy
-
--- Create the operator class
-CREATE OPERATOR CLASS gist_cidr_ops
-DEFAULT FOR TYPE cidr USING gist
-AS
-	OPERATOR	1	<  (inet, inet)  ,
-	OPERATOR	2	<= (inet, inet)  ,
-	OPERATOR	3	=  (inet, inet)  ,
-	OPERATOR	4	>= (inet, inet)  ,
-	OPERATOR	5	>  (inet, inet)  ,
-	FUNCTION	1	gbt_inet_consistent (internal, inet, int2, oid, internal),
-	FUNCTION	2	gbt_inet_union (internal, internal),
-	FUNCTION	3	gbt_inet_compress (internal),
-	FUNCTION	4	gbt_decompress (internal),
-	FUNCTION	5	gbt_inet_penalty (internal, internal, internal),
-	FUNCTION	6	gbt_inet_picksplit (internal, internal),
-	FUNCTION	7	gbt_inet_same (gbtreekey16, gbtreekey16, internal),
-	STORAGE		gbtreekey16;
-
-ALTER OPERATOR FAMILY gist_cidr_ops USING gist ADD
-	OPERATOR	6	<> (inet, inet) ;
-	-- no fetch support, the compress function is lossy
diff --git a/contrib/btree_gist/btree_gist--1.5--1.6.sql b/contrib/btree_gist/btree_gist--1.5--1.6.sql
new file mode 100644
index 0000000..ef4424e
--- /dev/null
+++ b/contrib/btree_gist/btree_gist--1.5--1.6.sql
@@ -0,0 +1,99 @@
+/* contrib/btree_gist/btree_gist--1.5--1.6.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION btree_gist UPDATE TO '1.6'" to load this file. \quit
+
+-- drop btree_gist distance operators from opfamilies
+
+ALTER OPERATOR FAMILY gist_int2_ops USING gist DROP OPERATOR 15 (int2, int2);
+ALTER OPERATOR FAMILY gist_int4_ops USING gist DROP OPERATOR 15 (int4, int4);
+ALTER OPERATOR FAMILY gist_int8_ops USING gist DROP OPERATOR 15 (int8, int8);
+ALTER OPERATOR FAMILY gist_float4_ops USING gist DROP OPERATOR 15 (float4, float4);
+ALTER OPERATOR FAMILY gist_float8_ops USING gist DROP OPERATOR 15 (float8, float8);
+ALTER OPERATOR FAMILY gist_oid_ops USING gist DROP OPERATOR 15 (oid, oid);
+ALTER OPERATOR FAMILY gist_cash_ops USING gist DROP OPERATOR 15 (money, money);
+ALTER OPERATOR FAMILY gist_date_ops USING gist DROP OPERATOR 15 (date, date);
+ALTER OPERATOR FAMILY gist_time_ops USING gist DROP OPERATOR 15 (time, time);
+ALTER OPERATOR FAMILY gist_timestamp_ops USING gist DROP OPERATOR 15 (timestamp, timestamp);
+ALTER OPERATOR FAMILY gist_timestamptz_ops USING gist DROP OPERATOR 15 (timestamptz, timestamptz);
+ALTER OPERATOR FAMILY gist_interval_ops USING gist DROP OPERATOR 15 (interval, interval);
+
+-- add pg_catalog distance operators to opfamilies
+
+ALTER OPERATOR FAMILY gist_int2_ops USING gist ADD OPERATOR 15 <-> (int2, int2) FOR ORDER BY pg_catalog.integer_ops;
+ALTER OPERATOR FAMILY gist_int4_ops USING gist ADD OPERATOR 15 <-> (int4, int4) FOR ORDER BY pg_catalog.integer_ops;
+ALTER OPERATOR FAMILY gist_int8_ops USING gist ADD OPERATOR 15 <-> (int8, int8) FOR ORDER BY pg_catalog.integer_ops;
+ALTER OPERATOR FAMILY gist_float4_ops USING gist ADD OPERATOR 15 <-> (float4, float4) FOR ORDER BY pg_catalog.float_ops;
+ALTER OPERATOR FAMILY gist_float8_ops USING gist ADD OPERATOR 15 <-> (float8, float8) FOR ORDER BY pg_catalog.float_ops;
+ALTER OPERATOR FAMILY gist_oid_ops USING gist ADD OPERATOR 15 <-> (oid, oid) FOR ORDER BY pg_catalog.oid_ops;
+ALTER OPERATOR FAMILY gist_cash_ops USING gist ADD OPERATOR 15 <-> (money, money) FOR ORDER BY pg_catalog.money_ops;
+ALTER OPERATOR FAMILY gist_date_ops USING gist ADD OPERATOR 15 <-> (date, date) FOR ORDER BY pg_catalog.integer_ops;
+ALTER OPERATOR FAMILY gist_time_ops USING gist ADD OPERATOR 15 <-> (time, time) FOR ORDER BY pg_catalog.interval_ops;
+ALTER OPERATOR FAMILY gist_timestamp_ops USING gist ADD OPERATOR 15 <-> (timestamp, timestamp) FOR ORDER BY pg_catalog.interval_ops;
+ALTER OPERATOR FAMILY gist_timestamptz_ops USING gist ADD OPERATOR 15 <-> (timestamptz, timestamptz) FOR ORDER BY pg_catalog.interval_ops;
+ALTER OPERATOR FAMILY gist_interval_ops USING gist ADD OPERATOR 15 <-> (interval, interval) FOR ORDER BY pg_catalog.interval_ops;
+
+-- disable implicit pg_catalog search
+
+DO
+$$
+BEGIN
+	EXECUTE 'SET LOCAL search_path TO ' || current_schema() || ', pg_catalog';
+END
+$$;
+
+-- drop distance operators
+
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (int2, int2);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (int4, int4);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (int8, int8);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (float4, float4);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (float8, float8);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (oid, oid);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (money, money);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (date, date);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (time, time);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (timestamp, timestamp);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (timestamptz, timestamptz);
+ALTER EXTENSION btree_gist DROP OPERATOR <-> (interval, interval);
+
+DROP OPERATOR <-> (int2, int2);
+DROP OPERATOR <-> (int4, int4);
+DROP OPERATOR <-> (int8, int8);
+DROP OPERATOR <-> (float4, float4);
+DROP OPERATOR <-> (float8, float8);
+DROP OPERATOR <-> (oid, oid);
+DROP OPERATOR <-> (money, money);
+DROP OPERATOR <-> (date, date);
+DROP OPERATOR <-> (time, time);
+DROP OPERATOR <-> (timestamp, timestamp);
+DROP OPERATOR <-> (timestamptz, timestamptz);
+DROP OPERATOR <-> (interval, interval);
+
+-- drop distance functions
+
+ALTER EXTENSION btree_gist DROP FUNCTION int2_dist(int2, int2);
+ALTER EXTENSION btree_gist DROP FUNCTION int4_dist(int4, int4);
+ALTER EXTENSION btree_gist DROP FUNCTION int8_dist(int8, int8);
+ALTER EXTENSION btree_gist DROP FUNCTION float4_dist(float4, float4);
+ALTER EXTENSION btree_gist DROP FUNCTION float8_dist(float8, float8);
+ALTER EXTENSION btree_gist DROP FUNCTION oid_dist(oid, oid);
+ALTER EXTENSION btree_gist DROP FUNCTION cash_dist(money, money);
+ALTER EXTENSION btree_gist DROP FUNCTION date_dist(date, date);
+ALTER EXTENSION btree_gist DROP FUNCTION time_dist(time, time);
+ALTER EXTENSION btree_gist DROP FUNCTION ts_dist(timestamp, timestamp);
+ALTER EXTENSION btree_gist DROP FUNCTION tstz_dist(timestamptz, timestamptz);
+ALTER EXTENSION btree_gist DROP FUNCTION interval_dist(interval, interval);
+
+DROP FUNCTION int2_dist(int2, int2);
+DROP FUNCTION int4_dist(int4, int4);
+DROP FUNCTION int8_dist(int8, int8);
+DROP FUNCTION float4_dist(float4, float4);
+DROP FUNCTION float8_dist(float8, float8);
+DROP FUNCTION oid_dist(oid, oid);
+DROP FUNCTION cash_dist(money, money);
+DROP FUNCTION date_dist(date, date);
+DROP FUNCTION time_dist(time, time);
+DROP FUNCTION ts_dist(timestamp, timestamp);
+DROP FUNCTION tstz_dist(timestamptz, timestamptz);
+DROP FUNCTION interval_dist(interval, interval);
diff --git a/contrib/btree_gist/btree_gist--1.6.sql b/contrib/btree_gist/btree_gist--1.6.sql
new file mode 100644
index 0000000..8ff8eb5
--- /dev/null
+++ b/contrib/btree_gist/btree_gist--1.6.sql
@@ -0,0 +1,1615 @@
+/* contrib/btree_gist/btree_gist--1.2.sql */
+
+-- complain if script is sourced in psql, rather than via CREATE EXTENSION
+\echo Use "CREATE EXTENSION btree_gist" to load this file. \quit
+
+CREATE FUNCTION gbtreekey4_in(cstring)
+RETURNS gbtreekey4
+AS 'MODULE_PATHNAME', 'gbtreekey_in'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbtreekey4_out(gbtreekey4)
+RETURNS cstring
+AS 'MODULE_PATHNAME', 'gbtreekey_out'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE TYPE gbtreekey4 (
+	INTERNALLENGTH = 4,
+	INPUT  = gbtreekey4_in,
+	OUTPUT = gbtreekey4_out
+);
+
+CREATE FUNCTION gbtreekey8_in(cstring)
+RETURNS gbtreekey8
+AS 'MODULE_PATHNAME', 'gbtreekey_in'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbtreekey8_out(gbtreekey8)
+RETURNS cstring
+AS 'MODULE_PATHNAME', 'gbtreekey_out'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE TYPE gbtreekey8 (
+	INTERNALLENGTH = 8,
+	INPUT  = gbtreekey8_in,
+	OUTPUT = gbtreekey8_out
+);
+
+CREATE FUNCTION gbtreekey16_in(cstring)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME', 'gbtreekey_in'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbtreekey16_out(gbtreekey16)
+RETURNS cstring
+AS 'MODULE_PATHNAME', 'gbtreekey_out'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE TYPE gbtreekey16 (
+	INTERNALLENGTH = 16,
+	INPUT  = gbtreekey16_in,
+	OUTPUT = gbtreekey16_out
+);
+
+CREATE FUNCTION gbtreekey32_in(cstring)
+RETURNS gbtreekey32
+AS 'MODULE_PATHNAME', 'gbtreekey_in'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbtreekey32_out(gbtreekey32)
+RETURNS cstring
+AS 'MODULE_PATHNAME', 'gbtreekey_out'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE TYPE gbtreekey32 (
+	INTERNALLENGTH = 32,
+	INPUT  = gbtreekey32_in,
+	OUTPUT = gbtreekey32_out
+);
+
+CREATE FUNCTION gbtreekey_var_in(cstring)
+RETURNS gbtreekey_var
+AS 'MODULE_PATHNAME', 'gbtreekey_in'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbtreekey_var_out(gbtreekey_var)
+RETURNS cstring
+AS 'MODULE_PATHNAME', 'gbtreekey_out'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE TYPE gbtreekey_var (
+	INTERNALLENGTH = VARIABLE,
+	INPUT  = gbtreekey_var_in,
+	OUTPUT = gbtreekey_var_out,
+	STORAGE = EXTENDED
+);
+
+
+--
+--
+--
+-- oid ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_oid_consistent(internal,oid,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_oid_distance(internal,oid,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_oid_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_oid_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_decompress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_var_decompress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_var_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_oid_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_oid_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_oid_union(internal, internal)
+RETURNS gbtreekey8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_oid_same(gbtreekey8, gbtreekey8, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_oid_ops
+DEFAULT FOR TYPE oid USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_oid_consistent (internal, oid, int2, oid, internal),
+	FUNCTION	2	gbt_oid_union (internal, internal),
+	FUNCTION	3	gbt_oid_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_oid_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_oid_picksplit (internal, internal),
+	FUNCTION	7	gbt_oid_same (gbtreekey8, gbtreekey8, internal),
+	STORAGE		gbtreekey8;
+
+-- Add operators that are new in 9.1.  We do it like this, leaving them
+-- "loose" in the operator family rather than bound into the opclass, because
+-- that's the only state that can be reproduced during an upgrade from 9.0.
+ALTER OPERATOR FAMILY gist_oid_ops USING gist ADD
+	OPERATOR	6	<> (oid, oid) ,
+	OPERATOR	15	<-> (oid, oid) FOR ORDER BY pg_catalog.oid_ops ,
+	FUNCTION	8 (oid, oid) gbt_oid_distance (internal, oid, int2, oid, internal) ,
+	-- Also add support function for index-only-scans, added in 9.5.
+	FUNCTION	9 (oid, oid) gbt_oid_fetch (internal) ;
+
+
+--
+--
+--
+-- int2 ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_int2_consistent(internal,int2,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int2_distance(internal,int2,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int2_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int2_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int2_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int2_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int2_union(internal, internal)
+RETURNS gbtreekey4
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int2_same(gbtreekey4, gbtreekey4, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- 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	gbt_int2_consistent (internal, int2, int2, oid, internal),
+	FUNCTION	2	gbt_int2_union (internal, internal),
+	FUNCTION	3	gbt_int2_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_int2_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_int2_picksplit (internal, internal),
+	FUNCTION	7	gbt_int2_same (gbtreekey4, gbtreekey4, internal),
+	STORAGE		gbtreekey4;
+
+ALTER OPERATOR FAMILY gist_int2_ops USING gist ADD
+	OPERATOR	6	<> (int2, int2) ,
+	OPERATOR	15	<-> (int2, int2) FOR ORDER BY pg_catalog.integer_ops ,
+	FUNCTION	8 (int2, int2) gbt_int2_distance (internal, int2, int2, oid, internal) ,
+	FUNCTION	9 (int2, int2) gbt_int2_fetch (internal) ;
+
+--
+--
+--
+-- int4 ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_int4_consistent(internal,int4,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int4_distance(internal,int4,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int4_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int4_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int4_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int4_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int4_union(internal, internal)
+RETURNS gbtreekey8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int4_same(gbtreekey8, gbtreekey8, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_int4_ops
+DEFAULT FOR TYPE int4 USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_int4_consistent (internal, int4, int2, oid, internal),
+	FUNCTION	2	gbt_int4_union (internal, internal),
+	FUNCTION	3	gbt_int4_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_int4_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_int4_picksplit (internal, internal),
+	FUNCTION	7	gbt_int4_same (gbtreekey8, gbtreekey8, internal),
+	STORAGE		gbtreekey8;
+
+ALTER OPERATOR FAMILY gist_int4_ops USING gist ADD
+	OPERATOR	6	<> (int4, int4) ,
+	OPERATOR	15	<-> (int4, int4) FOR ORDER BY pg_catalog.integer_ops ,
+	FUNCTION	8 (int4, int4) gbt_int4_distance (internal, int4, int2, oid, internal) ,
+	FUNCTION	9 (int4, int4) gbt_int4_fetch (internal) ;
+
+
+--
+--
+--
+-- int8 ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_int8_consistent(internal,int8,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int8_distance(internal,int8,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int8_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int8_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int8_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int8_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int8_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_int8_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_int8_ops
+DEFAULT FOR TYPE int8 USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_int8_consistent (internal, int8, int2, oid, internal),
+	FUNCTION	2	gbt_int8_union (internal, internal),
+	FUNCTION	3	gbt_int8_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_int8_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_int8_picksplit (internal, internal),
+	FUNCTION	7	gbt_int8_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_int8_ops USING gist ADD
+	OPERATOR	6	<> (int8, int8) ,
+	OPERATOR	15	<-> (int8, int8) FOR ORDER BY pg_catalog.integer_ops ,
+	FUNCTION	8 (int8, int8) gbt_int8_distance (internal, int8, int2, oid, internal) ,
+	FUNCTION	9 (int8, int8) gbt_int8_fetch (internal) ;
+
+--
+--
+--
+-- float4 ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_float4_consistent(internal,float4,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float4_distance(internal,float4,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float4_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float4_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float4_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float4_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float4_union(internal, internal)
+RETURNS gbtreekey8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float4_same(gbtreekey8, gbtreekey8, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_float4_ops
+DEFAULT FOR TYPE float4 USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_float4_consistent (internal, float4, int2, oid, internal),
+	FUNCTION	2	gbt_float4_union (internal, internal),
+	FUNCTION	3	gbt_float4_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_float4_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_float4_picksplit (internal, internal),
+	FUNCTION	7	gbt_float4_same (gbtreekey8, gbtreekey8, internal),
+	STORAGE		gbtreekey8;
+
+ALTER OPERATOR FAMILY gist_float4_ops USING gist ADD
+	OPERATOR	6	<> (float4, float4) ,
+	OPERATOR	15	<-> (float4, float4) FOR ORDER BY pg_catalog.float_ops ,
+	FUNCTION	8 (float4, float4) gbt_float4_distance (internal, float4, int2, oid, internal) ,
+	FUNCTION	9 (float4, float4) gbt_float4_fetch (internal) ;
+
+--
+--
+--
+-- float8 ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_float8_consistent(internal,float8,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float8_distance(internal,float8,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float8_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float8_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float8_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float8_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float8_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_float8_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_float8_ops
+DEFAULT FOR TYPE float8 USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_float8_consistent (internal, float8, int2, oid, internal),
+	FUNCTION	2	gbt_float8_union (internal, internal),
+	FUNCTION	3	gbt_float8_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_float8_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_float8_picksplit (internal, internal),
+	FUNCTION	7	gbt_float8_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_float8_ops USING gist ADD
+	OPERATOR	6	<> (float8, float8) ,
+	OPERATOR	15	<-> (float8, float8) FOR ORDER BY pg_catalog.float_ops ,
+	FUNCTION	8 (float8, float8) gbt_float8_distance (internal, float8, int2, oid, internal) ,
+	FUNCTION	9 (float8, float8) gbt_float8_fetch (internal) ;
+
+--
+--
+--
+-- timestamp ops
+--
+--
+--
+
+CREATE FUNCTION gbt_ts_consistent(internal,timestamp,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_ts_distance(internal,timestamp,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_tstz_consistent(internal,timestamptz,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_tstz_distance(internal,timestamptz,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_ts_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_tstz_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_ts_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_ts_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_ts_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_ts_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_ts_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_timestamp_ops
+DEFAULT FOR TYPE timestamp USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_ts_consistent (internal, timestamp, int2, oid, internal),
+	FUNCTION	2	gbt_ts_union (internal, internal),
+	FUNCTION	3	gbt_ts_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_ts_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_ts_picksplit (internal, internal),
+	FUNCTION	7	gbt_ts_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_timestamp_ops USING gist ADD
+	OPERATOR	6	<> (timestamp, timestamp) ,
+	OPERATOR	15	<-> (timestamp, timestamp) FOR ORDER BY pg_catalog.interval_ops ,
+	FUNCTION	8 (timestamp, timestamp) gbt_ts_distance (internal, timestamp, int2, oid, internal) ,
+	FUNCTION	9 (timestamp, timestamp) gbt_ts_fetch (internal) ;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_timestamptz_ops
+DEFAULT FOR TYPE timestamptz USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_tstz_consistent (internal, timestamptz, int2, oid, internal),
+	FUNCTION	2	gbt_ts_union (internal, internal),
+	FUNCTION	3	gbt_tstz_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_ts_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_ts_picksplit (internal, internal),
+	FUNCTION	7	gbt_ts_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_timestamptz_ops USING gist ADD
+	OPERATOR	6	<> (timestamptz, timestamptz) ,
+	OPERATOR	15	<-> (timestamptz, timestamptz) FOR ORDER BY pg_catalog.interval_ops ,
+	FUNCTION	8 (timestamptz, timestamptz) gbt_tstz_distance (internal, timestamptz, int2, oid, internal) ,
+	FUNCTION	9 (timestamptz, timestamptz) gbt_ts_fetch (internal) ;
+
+--
+--
+--
+-- time ops
+--
+--
+--
+
+CREATE FUNCTION gbt_time_consistent(internal,time,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_time_distance(internal,time,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_timetz_consistent(internal,timetz,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_time_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_timetz_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_time_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_time_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_time_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_time_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_time_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_time_ops
+DEFAULT FOR TYPE time USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_time_consistent (internal, time, int2, oid, internal),
+	FUNCTION	2	gbt_time_union (internal, internal),
+	FUNCTION	3	gbt_time_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_time_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_time_picksplit (internal, internal),
+	FUNCTION	7	gbt_time_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_time_ops USING gist ADD
+	OPERATOR	6	<> (time, time) ,
+	OPERATOR	15	<-> (time, time) FOR ORDER BY pg_catalog.interval_ops ,
+	FUNCTION	8 (time, time) gbt_time_distance (internal, time, int2, oid, internal) ,
+	FUNCTION	9 (time, time) gbt_time_fetch (internal) ;
+
+
+CREATE OPERATOR CLASS gist_timetz_ops
+DEFAULT FOR TYPE timetz USING gist
+AS
+	OPERATOR	1	<   ,
+	OPERATOR	2	<=  ,
+	OPERATOR	3	=   ,
+	OPERATOR	4	>=  ,
+	OPERATOR	5	>   ,
+	FUNCTION	1	gbt_timetz_consistent (internal, timetz, int2, oid, internal),
+	FUNCTION	2	gbt_time_union (internal, internal),
+	FUNCTION	3	gbt_timetz_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_time_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_time_picksplit (internal, internal),
+	FUNCTION	7	gbt_time_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_timetz_ops USING gist ADD
+	OPERATOR	6	<> (timetz, timetz) ;
+	-- no 'fetch' function, as the compress function is lossy.
+
+
+--
+--
+--
+-- date ops
+--
+--
+--
+
+CREATE FUNCTION gbt_date_consistent(internal,date,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_date_distance(internal,date,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_date_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_date_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_date_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_date_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_date_union(internal, internal)
+RETURNS gbtreekey8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_date_same(gbtreekey8, gbtreekey8, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_date_ops
+DEFAULT FOR TYPE date USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_date_consistent (internal, date, int2, oid, internal),
+	FUNCTION	2	gbt_date_union (internal, internal),
+	FUNCTION	3	gbt_date_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_date_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_date_picksplit (internal, internal),
+	FUNCTION	7	gbt_date_same (gbtreekey8, gbtreekey8, internal),
+	STORAGE		gbtreekey8;
+
+ALTER OPERATOR FAMILY gist_date_ops USING gist ADD
+	OPERATOR	6	<> (date, date) ,
+	OPERATOR	15	<-> (date, date) FOR ORDER BY pg_catalog.integer_ops ,
+	FUNCTION	8 (date, date) gbt_date_distance (internal, date, int2, oid, internal) ,
+	FUNCTION	9 (date, date) gbt_date_fetch (internal) ;
+
+
+--
+--
+--
+-- interval ops
+--
+--
+--
+
+CREATE FUNCTION gbt_intv_consistent(internal,interval,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_distance(internal,interval,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_decompress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_union(internal, internal)
+RETURNS gbtreekey32
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_intv_same(gbtreekey32, gbtreekey32, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_interval_ops
+DEFAULT FOR TYPE interval USING gist
+AS
+	OPERATOR	1	< ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	= ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	> ,
+	FUNCTION	1	gbt_intv_consistent (internal, interval, int2, oid, internal),
+	FUNCTION	2	gbt_intv_union (internal, internal),
+	FUNCTION	3	gbt_intv_compress (internal),
+	FUNCTION	4	gbt_intv_decompress (internal),
+	FUNCTION	5	gbt_intv_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_intv_picksplit (internal, internal),
+	FUNCTION	7	gbt_intv_same (gbtreekey32, gbtreekey32, internal),
+	STORAGE		gbtreekey32;
+
+ALTER OPERATOR FAMILY gist_interval_ops USING gist ADD
+	OPERATOR	6	<> (interval, interval) ,
+	OPERATOR	15	<-> (interval, interval) FOR ORDER BY pg_catalog.interval_ops ,
+	FUNCTION	8 (interval, interval) gbt_intv_distance (internal, interval, int2, oid, internal) ,
+	FUNCTION	9 (interval, interval) gbt_intv_fetch (internal) ;
+
+
+--
+--
+--
+-- cash ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_cash_consistent(internal,money,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_cash_distance(internal,money,int2,oid,internal)
+RETURNS float8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_cash_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_cash_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_cash_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_cash_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_cash_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_cash_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_cash_ops
+DEFAULT FOR TYPE money USING gist
+AS
+	OPERATOR	1	< ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	= ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	> ,
+	FUNCTION	1	gbt_cash_consistent (internal, money, int2, oid, internal),
+	FUNCTION	2	gbt_cash_union (internal, internal),
+	FUNCTION	3	gbt_cash_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_cash_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_cash_picksplit (internal, internal),
+	FUNCTION	7	gbt_cash_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_cash_ops USING gist ADD
+	OPERATOR	6	<> (money, money) ,
+	OPERATOR	15	<-> (money, money) FOR ORDER BY pg_catalog.money_ops ,
+	FUNCTION	8 (money, money) gbt_cash_distance (internal, money, int2, oid, internal) ,
+	FUNCTION	9 (money, money) gbt_cash_fetch (internal) ;
+
+
+--
+--
+--
+-- macaddr ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_macad_consistent(internal,macaddr,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_macaddr_ops
+DEFAULT FOR TYPE macaddr USING gist
+AS
+	OPERATOR	1	< ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	= ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	> ,
+	FUNCTION	1	gbt_macad_consistent (internal, macaddr, int2, oid, internal),
+	FUNCTION	2	gbt_macad_union (internal, internal),
+	FUNCTION	3	gbt_macad_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_macad_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_macad_picksplit (internal, internal),
+	FUNCTION	7	gbt_macad_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_macaddr_ops USING gist ADD
+	OPERATOR	6	<> (macaddr, macaddr) ,
+	FUNCTION	9 (macaddr, macaddr) gbt_macad_fetch (internal);
+
+
+--
+--
+--
+-- text/ bpchar ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_text_consistent(internal,text,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bpchar_consistent(internal,bpchar,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_text_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bpchar_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_text_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_text_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_text_union(internal, internal)
+RETURNS gbtreekey_var
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_text_same(gbtreekey_var, gbtreekey_var, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_text_ops
+DEFAULT FOR TYPE text USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_text_consistent (internal, text, int2, oid, internal),
+	FUNCTION	2	gbt_text_union (internal, internal),
+	FUNCTION	3	gbt_text_compress (internal),
+	FUNCTION	4	gbt_var_decompress (internal),
+	FUNCTION	5	gbt_text_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_text_picksplit (internal, internal),
+	FUNCTION	7	gbt_text_same (gbtreekey_var, gbtreekey_var, internal),
+	STORAGE			gbtreekey_var;
+
+ALTER OPERATOR FAMILY gist_text_ops USING gist ADD
+	OPERATOR	6	<> (text, text) ,
+	FUNCTION	9 (text, text) gbt_var_fetch (internal) ;
+
+
+---- Create the operator class
+CREATE OPERATOR CLASS gist_bpchar_ops
+DEFAULT FOR TYPE bpchar USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_bpchar_consistent (internal, bpchar , int2, oid, internal),
+	FUNCTION	2	gbt_text_union (internal, internal),
+	FUNCTION	3	gbt_bpchar_compress (internal),
+	FUNCTION	4	gbt_var_decompress (internal),
+	FUNCTION	5	gbt_text_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_text_picksplit (internal, internal),
+	FUNCTION	7	gbt_text_same (gbtreekey_var, gbtreekey_var, internal),
+	STORAGE			gbtreekey_var;
+
+ALTER OPERATOR FAMILY gist_bpchar_ops USING gist ADD
+	OPERATOR	6	<> (bpchar, bpchar) ,
+	FUNCTION	9 (bpchar, bpchar) gbt_var_fetch (internal) ;
+
+--
+--
+-- bytea ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_bytea_consistent(internal,bytea,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bytea_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bytea_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bytea_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bytea_union(internal, internal)
+RETURNS gbtreekey_var
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bytea_same(gbtreekey_var, gbtreekey_var, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_bytea_ops
+DEFAULT FOR TYPE bytea USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_bytea_consistent (internal, bytea, int2, oid, internal),
+	FUNCTION	2	gbt_bytea_union (internal, internal),
+	FUNCTION	3	gbt_bytea_compress (internal),
+	FUNCTION	4	gbt_var_decompress (internal),
+	FUNCTION	5	gbt_bytea_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_bytea_picksplit (internal, internal),
+	FUNCTION	7	gbt_bytea_same (gbtreekey_var, gbtreekey_var, internal),
+	STORAGE			gbtreekey_var;
+
+ALTER OPERATOR FAMILY gist_bytea_ops USING gist ADD
+	OPERATOR	6	<> (bytea, bytea) ,
+	FUNCTION	9 (bytea, bytea) gbt_var_fetch (internal) ;
+
+
+--
+--
+--
+-- numeric ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_numeric_consistent(internal,numeric,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_numeric_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_numeric_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_numeric_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_numeric_union(internal, internal)
+RETURNS gbtreekey_var
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_numeric_same(gbtreekey_var, gbtreekey_var, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_numeric_ops
+DEFAULT FOR TYPE numeric USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_numeric_consistent (internal, numeric, int2, oid, internal),
+	FUNCTION	2	gbt_numeric_union (internal, internal),
+	FUNCTION	3	gbt_numeric_compress (internal),
+	FUNCTION	4	gbt_var_decompress (internal),
+	FUNCTION	5	gbt_numeric_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_numeric_picksplit (internal, internal),
+	FUNCTION	7	gbt_numeric_same (gbtreekey_var, gbtreekey_var, internal),
+	STORAGE			gbtreekey_var;
+
+ALTER OPERATOR FAMILY gist_numeric_ops USING gist ADD
+	OPERATOR	6	<> (numeric, numeric) ,
+	FUNCTION	9 (numeric, numeric) gbt_var_fetch (internal) ;
+
+
+--
+--
+-- bit ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_bit_consistent(internal,bit,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bit_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bit_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bit_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bit_union(internal, internal)
+RETURNS gbtreekey_var
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_bit_same(gbtreekey_var, gbtreekey_var, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_bit_ops
+DEFAULT FOR TYPE bit USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_bit_consistent (internal, bit, int2, oid, internal),
+	FUNCTION	2	gbt_bit_union (internal, internal),
+	FUNCTION	3	gbt_bit_compress (internal),
+	FUNCTION	4	gbt_var_decompress (internal),
+	FUNCTION	5	gbt_bit_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_bit_picksplit (internal, internal),
+	FUNCTION	7	gbt_bit_same (gbtreekey_var, gbtreekey_var, internal),
+	STORAGE			gbtreekey_var;
+
+ALTER OPERATOR FAMILY gist_bit_ops USING gist ADD
+	OPERATOR	6	<> (bit, bit) ,
+	FUNCTION	9 (bit, bit) gbt_var_fetch (internal) ;
+
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_vbit_ops
+DEFAULT FOR TYPE varbit USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_bit_consistent (internal, bit, int2, oid, internal),
+	FUNCTION	2	gbt_bit_union (internal, internal),
+	FUNCTION	3	gbt_bit_compress (internal),
+	FUNCTION	4	gbt_var_decompress (internal),
+	FUNCTION	5	gbt_bit_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_bit_picksplit (internal, internal),
+	FUNCTION	7	gbt_bit_same (gbtreekey_var, gbtreekey_var, internal),
+	STORAGE			gbtreekey_var;
+
+ALTER OPERATOR FAMILY gist_vbit_ops USING gist ADD
+	OPERATOR	6	<> (varbit, varbit) ,
+	FUNCTION	9 (varbit, varbit) gbt_var_fetch (internal) ;
+
+
+--
+--
+--
+-- inet/cidr ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_inet_consistent(internal,inet,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_inet_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_inet_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_inet_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_inet_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_inet_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_inet_ops
+DEFAULT FOR TYPE inet USING gist
+AS
+	OPERATOR	1	<   ,
+	OPERATOR	2	<=  ,
+	OPERATOR	3	=   ,
+	OPERATOR	4	>=  ,
+	OPERATOR	5	>   ,
+	FUNCTION	1	gbt_inet_consistent (internal, inet, int2, oid, internal),
+	FUNCTION	2	gbt_inet_union (internal, internal),
+	FUNCTION	3	gbt_inet_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_inet_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_inet_picksplit (internal, internal),
+	FUNCTION	7	gbt_inet_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_inet_ops USING gist ADD
+	OPERATOR	6	<>  (inet, inet) ;
+	-- no fetch support, the compress function is lossy
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_cidr_ops
+DEFAULT FOR TYPE cidr USING gist
+AS
+	OPERATOR	1	<  (inet, inet)  ,
+	OPERATOR	2	<= (inet, inet)  ,
+	OPERATOR	3	=  (inet, inet)  ,
+	OPERATOR	4	>= (inet, inet)  ,
+	OPERATOR	5	>  (inet, inet)  ,
+	FUNCTION	1	gbt_inet_consistent (internal, inet, int2, oid, internal),
+	FUNCTION	2	gbt_inet_union (internal, internal),
+	FUNCTION	3	gbt_inet_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_inet_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_inet_picksplit (internal, internal),
+	FUNCTION	7	gbt_inet_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_cidr_ops USING gist ADD
+	OPERATOR	6	<> (inet, inet) ;
+	-- no fetch support, the compress function is lossy
+
+--
+--
+--
+-- uuid ops
+--
+--
+---- define the GiST support methods
+CREATE FUNCTION gbt_uuid_consistent(internal,uuid,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_uuid_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_uuid_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_uuid_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_uuid_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_uuid_union(internal, internal)
+RETURNS gbtreekey32
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_uuid_same(gbtreekey32, gbtreekey32, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_uuid_ops
+DEFAULT FOR TYPE uuid USING gist
+AS
+	OPERATOR	1	<   ,
+	OPERATOR	2	<=  ,
+	OPERATOR	3	=   ,
+	OPERATOR	4	>=  ,
+	OPERATOR	5	>   ,
+	FUNCTION	1	gbt_uuid_consistent (internal, uuid, int2, oid, internal),
+	FUNCTION	2	gbt_uuid_union (internal, internal),
+	FUNCTION	3	gbt_uuid_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_uuid_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_uuid_picksplit (internal, internal),
+	FUNCTION	7	gbt_uuid_same (gbtreekey32, gbtreekey32, internal),
+	STORAGE		gbtreekey32;
+
+-- These are "loose" in the opfamily for consistency with the rest of btree_gist
+ALTER OPERATOR FAMILY gist_uuid_ops USING gist ADD
+	OPERATOR	6	<>  (uuid, uuid) ,
+	FUNCTION	9 (uuid, uuid) gbt_uuid_fetch (internal) ;
+
+
+-- Add support for indexing macaddr8 columns
+
+-- define the GiST support methods
+CREATE FUNCTION gbt_macad8_consistent(internal,macaddr8,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad8_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad8_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad8_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad8_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad8_union(internal, internal)
+RETURNS gbtreekey16
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_macad8_same(gbtreekey16, gbtreekey16, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_macaddr8_ops
+DEFAULT FOR TYPE macaddr8 USING gist
+AS
+	OPERATOR	1	< ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	= ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	> ,
+	FUNCTION	1	gbt_macad8_consistent (internal, macaddr8, int2, oid, internal),
+	FUNCTION	2	gbt_macad8_union (internal, internal),
+	FUNCTION	3	gbt_macad8_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_macad8_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_macad8_picksplit (internal, internal),
+	FUNCTION	7	gbt_macad8_same (gbtreekey16, gbtreekey16, internal),
+	STORAGE		gbtreekey16;
+
+ALTER OPERATOR FAMILY gist_macaddr8_ops USING gist ADD
+	OPERATOR	6	<> (macaddr8, macaddr8) ,
+	FUNCTION	9 (macaddr8, macaddr8) gbt_macad8_fetch (internal);
+
+--
+--
+--
+-- enum ops
+--
+--
+--
+-- define the GiST support methods
+CREATE FUNCTION gbt_enum_consistent(internal,anyenum,int2,oid,internal)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_enum_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_enum_fetch(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_enum_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_enum_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_enum_union(internal, internal)
+RETURNS gbtreekey8
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+CREATE FUNCTION gbt_enum_same(gbtreekey8, gbtreekey8, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+-- Create the operator class
+CREATE OPERATOR CLASS gist_enum_ops
+DEFAULT FOR TYPE anyenum USING gist
+AS
+	OPERATOR	1	<  ,
+	OPERATOR	2	<= ,
+	OPERATOR	3	=  ,
+	OPERATOR	4	>= ,
+	OPERATOR	5	>  ,
+	FUNCTION	1	gbt_enum_consistent (internal, anyenum, int2, oid, internal),
+	FUNCTION	2	gbt_enum_union (internal, internal),
+	FUNCTION	3	gbt_enum_compress (internal),
+	FUNCTION	4	gbt_decompress (internal),
+	FUNCTION	5	gbt_enum_penalty (internal, internal, internal),
+	FUNCTION	6	gbt_enum_picksplit (internal, internal),
+	FUNCTION	7	gbt_enum_same (gbtreekey8, gbtreekey8, internal),
+	STORAGE		gbtreekey8;
+
+ALTER OPERATOR FAMILY gist_enum_ops USING gist ADD
+	OPERATOR	6	<> (anyenum, anyenum) ,
+	FUNCTION	9 (anyenum, anyenum) gbt_enum_fetch (internal) ;
diff --git a/contrib/btree_gist/btree_gist.control b/contrib/btree_gist/btree_gist.control
index 81c8509..9ced3bc 100644
--- a/contrib/btree_gist/btree_gist.control
+++ b/contrib/btree_gist/btree_gist.control
@@ -1,5 +1,5 @@
 # btree_gist extension
 comment = 'support for indexing common datatypes in GiST'
-default_version = '1.5'
+default_version = '1.6'
 module_pathname = '$libdir/btree_gist'
 relocatable = true
diff --git a/contrib/btree_gist/btree_int2.c b/contrib/btree_gist/btree_int2.c
index 7674e2d..2afc343 100644
--- a/contrib/btree_gist/btree_int2.c
+++ b/contrib/btree_gist/btree_int2.c
@@ -94,20 +94,7 @@ PG_FUNCTION_INFO_V1(int2_dist);
 Datum
 int2_dist(PG_FUNCTION_ARGS)
 {
-	int16		a = PG_GETARG_INT16(0);
-	int16		b = PG_GETARG_INT16(1);
-	int16		r;
-	int16		ra;
-
-	if (pg_sub_s16_overflow(a, b, &r) ||
-		r == PG_INT16_MIN)
-		ereport(ERROR,
-				(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-				 errmsg("smallint out of range")));
-
-	ra = Abs(r);
-
-	PG_RETURN_INT16(ra);
+	return int2dist(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_int4.c b/contrib/btree_gist/btree_int4.c
index 80005ab..2361ce7 100644
--- a/contrib/btree_gist/btree_int4.c
+++ b/contrib/btree_gist/btree_int4.c
@@ -95,20 +95,7 @@ PG_FUNCTION_INFO_V1(int4_dist);
 Datum
 int4_dist(PG_FUNCTION_ARGS)
 {
-	int32		a = PG_GETARG_INT32(0);
-	int32		b = PG_GETARG_INT32(1);
-	int32		r;
-	int32		ra;
-
-	if (pg_sub_s32_overflow(a, b, &r) ||
-		r == PG_INT32_MIN)
-		ereport(ERROR,
-				(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-				 errmsg("integer out of range")));
-
-	ra = Abs(r);
-
-	PG_RETURN_INT32(ra);
+	return int4dist(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_int8.c b/contrib/btree_gist/btree_int8.c
index b0fd3e1..182d7c4 100644
--- a/contrib/btree_gist/btree_int8.c
+++ b/contrib/btree_gist/btree_int8.c
@@ -95,20 +95,7 @@ PG_FUNCTION_INFO_V1(int8_dist);
 Datum
 int8_dist(PG_FUNCTION_ARGS)
 {
-	int64		a = PG_GETARG_INT64(0);
-	int64		b = PG_GETARG_INT64(1);
-	int64		r;
-	int64		ra;
-
-	if (pg_sub_s64_overflow(a, b, &r) ||
-		r == PG_INT64_MIN)
-		ereport(ERROR,
-				(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-				 errmsg("bigint out of range")));
-
-	ra = Abs(r);
-
-	PG_RETURN_INT64(ra);
+	return int8dist(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_interval.c b/contrib/btree_gist/btree_interval.c
index 3a527a7..c68d48e 100644
--- a/contrib/btree_gist/btree_interval.c
+++ b/contrib/btree_gist/btree_interval.c
@@ -128,11 +128,7 @@ PG_FUNCTION_INFO_V1(interval_dist);
 Datum
 interval_dist(PG_FUNCTION_ARGS)
 {
-	Datum		diff = DirectFunctionCall2(interval_mi,
-										   PG_GETARG_DATUM(0),
-										   PG_GETARG_DATUM(1));
-
-	PG_RETURN_INTERVAL_P(abs_interval(DatumGetIntervalP(diff)));
+	return interval_distance(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_oid.c b/contrib/btree_gist/btree_oid.c
index 00e7019..c702d51 100644
--- a/contrib/btree_gist/btree_oid.c
+++ b/contrib/btree_gist/btree_oid.c
@@ -100,15 +100,7 @@ PG_FUNCTION_INFO_V1(oid_dist);
 Datum
 oid_dist(PG_FUNCTION_ARGS)
 {
-	Oid			a = PG_GETARG_OID(0);
-	Oid			b = PG_GETARG_OID(1);
-	Oid			res;
-
-	if (a < b)
-		res = b - a;
-	else
-		res = a - b;
-	PG_RETURN_OID(res);
+	return oiddist(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_time.c b/contrib/btree_gist/btree_time.c
index 90cf655..cfafd02 100644
--- a/contrib/btree_gist/btree_time.c
+++ b/contrib/btree_gist/btree_time.c
@@ -141,11 +141,7 @@ PG_FUNCTION_INFO_V1(time_dist);
 Datum
 time_dist(PG_FUNCTION_ARGS)
 {
-	Datum		diff = DirectFunctionCall2(time_mi_time,
-										   PG_GETARG_DATUM(0),
-										   PG_GETARG_DATUM(1));
-
-	PG_RETURN_INTERVAL_P(abs_interval(DatumGetIntervalP(diff)));
+	return time_distance(fcinfo);
 }
 
 
diff --git a/contrib/btree_gist/btree_ts.c b/contrib/btree_gist/btree_ts.c
index 49d1849..9e62f7d 100644
--- a/contrib/btree_gist/btree_ts.c
+++ b/contrib/btree_gist/btree_ts.c
@@ -146,48 +146,14 @@ PG_FUNCTION_INFO_V1(ts_dist);
 Datum
 ts_dist(PG_FUNCTION_ARGS)
 {
-	Timestamp	a = PG_GETARG_TIMESTAMP(0);
-	Timestamp	b = PG_GETARG_TIMESTAMP(1);
-	Interval   *r;
-
-	if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
-	{
-		Interval   *p = palloc(sizeof(Interval));
-
-		p->day = INT_MAX;
-		p->month = INT_MAX;
-		p->time = PG_INT64_MAX;
-		PG_RETURN_INTERVAL_P(p);
-	}
-	else
-		r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
-												  PG_GETARG_DATUM(0),
-												  PG_GETARG_DATUM(1)));
-	PG_RETURN_INTERVAL_P(abs_interval(r));
+	return timestamp_distance(fcinfo);
 }
 
 PG_FUNCTION_INFO_V1(tstz_dist);
 Datum
 tstz_dist(PG_FUNCTION_ARGS)
 {
-	TimestampTz a = PG_GETARG_TIMESTAMPTZ(0);
-	TimestampTz b = PG_GETARG_TIMESTAMPTZ(1);
-	Interval   *r;
-
-	if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
-	{
-		Interval   *p = palloc(sizeof(Interval));
-
-		p->day = INT_MAX;
-		p->month = INT_MAX;
-		p->time = PG_INT64_MAX;
-		PG_RETURN_INTERVAL_P(p);
-	}
-
-	r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
-											  PG_GETARG_DATUM(0),
-											  PG_GETARG_DATUM(1)));
-	PG_RETURN_INTERVAL_P(abs_interval(r));
+	return timestamptz_distance(fcinfo);
 }
 
 
diff --git a/doc/src/sgml/btree-gist.sgml b/doc/src/sgml/btree-gist.sgml
index 774442f..6eb4a18 100644
--- a/doc/src/sgml/btree-gist.sgml
+++ b/doc/src/sgml/btree-gist.sgml
@@ -96,6 +96,19 @@ INSERT 0 1
  </sect2>
 
  <sect2>
+  <title>Upgrade notes for version 1.6</title>
+
+  <para>
+   In version 1.6 <literal>btree_gist</literal> switched to using in-core
+   distance operators, and its own implementations were removed.  References to
+   these operators in <literal>btree_gist</literal> opclasses will be updated
+   automatically during the extension upgrade, but if the user has created
+   objects referencing these operators or functions, then these objects must be
+   dropped manually before updating the extension.
+  </para>
+ </sect2>
+
+ <sect2>
   <title>Authors</title>
 
   <para>
-- 
2.7.4

