Skip to content

Commit 866843c

Browse files
tglsfdcCommitfest Bot
authored and
Commitfest Bot
committed
Add cross-type comparisons for integer types.
Extend the infrastructure in btree_gin.c to permit cross-type operators, and add the code to support them for the int2, int4, and int8 opclasses. (To keep this patch digestible, I left the other datatypes for later.) Discussion: https://postgr.es/m/[email protected]
1 parent 3e6b5b0 commit 866843c

File tree

12 files changed

+859
-51
lines changed

12 files changed

+859
-51
lines changed

contrib/btree_gin/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ OBJS = \
77

88
EXTENSION = btree_gin
99
DATA = btree_gin--1.0.sql btree_gin--1.0--1.1.sql btree_gin--1.1--1.2.sql \
10-
btree_gin--1.2--1.3.sql
10+
btree_gin--1.2--1.3.sql btree_gin--1.3--1.4.sql
1111
PGFILEDESC = "btree_gin - B-tree equivalent GIN operator classes"
1212

1313
REGRESS = install_btree_gin int2 int4 int8 float4 float8 money oid \
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* contrib/btree_gin/btree_gin--1.3--1.4.sql */
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "ALTER EXTENSION btree_gin UPDATE TO '1.4'" to load this file. \quit
5+
6+
--
7+
-- Cross-type operator support is new in 1.4. We only need to worry
8+
-- about this for cross-type operators that exist in core.
9+
--
10+
-- Because the opclass extractQuery and consistent methods don't directly
11+
-- get any information about the datatype of the RHS value, we have to
12+
-- encode that in the operator strategy numbers. The strategy numbers
13+
-- are the operator's normal btree strategy (1-5) plus 8 times a code
14+
-- for the RHS datatype.
15+
--
16+
17+
ALTER OPERATOR FAMILY int2_ops USING gin
18+
ADD
19+
-- Code 1: RHS is int4
20+
OPERATOR 9 < (int2, int4),
21+
OPERATOR 10 <= (int2, int4),
22+
OPERATOR 11 = (int2, int4),
23+
OPERATOR 12 >= (int2, int4),
24+
OPERATOR 13 > (int2, int4),
25+
-- Code 2: RHS is int8
26+
OPERATOR 17 < (int2, int8),
27+
OPERATOR 18 <= (int2, int8),
28+
OPERATOR 19 = (int2, int8),
29+
OPERATOR 20 >= (int2, int8),
30+
OPERATOR 21 > (int2, int8)
31+
;
32+
33+
ALTER OPERATOR FAMILY int4_ops USING gin
34+
ADD
35+
-- Code 1: RHS is int2
36+
OPERATOR 9 < (int4, int2),
37+
OPERATOR 10 <= (int4, int2),
38+
OPERATOR 11 = (int4, int2),
39+
OPERATOR 12 >= (int4, int2),
40+
OPERATOR 13 > (int4, int2),
41+
-- Code 2: RHS is int8
42+
OPERATOR 17 < (int4, int8),
43+
OPERATOR 18 <= (int4, int8),
44+
OPERATOR 19 = (int4, int8),
45+
OPERATOR 20 >= (int4, int8),
46+
OPERATOR 21 > (int4, int8)
47+
;
48+
49+
ALTER OPERATOR FAMILY int8_ops USING gin
50+
ADD
51+
-- Code 1: RHS is int2
52+
OPERATOR 9 < (int8, int2),
53+
OPERATOR 10 <= (int8, int2),
54+
OPERATOR 11 = (int8, int2),
55+
OPERATOR 12 >= (int8, int2),
56+
OPERATOR 13 > (int8, int2),
57+
-- Code 2: RHS is int4
58+
OPERATOR 17 < (int8, int4),
59+
OPERATOR 18 <= (int8, int4),
60+
OPERATOR 19 = (int8, int4),
61+
OPERATOR 20 >= (int8, int4),
62+
OPERATOR 21 > (int8, int4)
63+
;

0 commit comments

Comments
 (0)