Add cross-type comparisons to contrib/btree_gin. · postgres/postgres@e2b64fc · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit e2b64fc

Browse files
committed
Add cross-type comparisons to contrib/btree_gin.
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 a separate patch.) This improves the usability of btree_gin indexes by allowing them to support the same set of queries that a regular btree index does. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com> Discussion: https://postgr.es/m/262624.1738460652@sss.pgh.pa.us
1 parent 0059bbe commit e2b64fc

File tree

13 files changed

+931
-85
lines changed

13 files changed

+931
-85
lines changed

contrib/btree_gin/Makefile

Lines changed: 1 addition & 1 deletion
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 \
Lines changed: 63 additions & 0 deletions
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 16 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 0x11 < (int2, int4),
21+
OPERATOR 0x12 <= (int2, int4),
22+
OPERATOR 0x13 = (int2, int4),
23+
OPERATOR 0x14 >= (int2, int4),
24+
OPERATOR 0x15 > (int2, int4),
25+
-- Code 2: RHS is int8
26+
OPERATOR 0x21 < (int2, int8),
27+
OPERATOR 0x22 <= (int2, int8),
28+
OPERATOR 0x23 = (int2, int8),
29+
OPERATOR 0x24 >= (int2, int8),
30+
OPERATOR 0x25 > (int2, int8)
31+
;
32+
33+
ALTER OPERATOR FAMILY int4_ops USING gin
34+
ADD
35+
-- Code 1: RHS is int2
36+
OPERATOR 0x11 < (int4, int2),
37+
OPERATOR 0x12 <= (int4, int2),
38+
OPERATOR 0x13 = (int4, int2),
39+
OPERATOR 0x14 >= (int4, int2),
40+
OPERATOR 0x15 > (int4, int2),
41+
-- Code 2: RHS is int8
42+
OPERATOR 0x21 < (int4, int8),
43+
OPERATOR 0x22 <= (int4, int8),
44+
OPERATOR 0x23 = (int4, int8),
45+
OPERATOR 0x24 >= (int4, int8),
46+
OPERATOR 0x25 > (int4, int8)
47+
;
48+
49+
ALTER OPERATOR FAMILY int8_ops USING gin
50+
ADD
51+
-- Code 1: RHS is int2
52+
OPERATOR 0x11 < (int8, int2),
53+
OPERATOR 0x12 <= (int8, int2),
54+
OPERATOR 0x13 = (int8, int2),
55+
OPERATOR 0x14 >= (int8, int2),
56+
OPERATOR 0x15 > (int8, int2),
57+
-- Code 2: RHS is int4
58+
OPERATOR 0x21 < (int8, int4),
59+
OPERATOR 0x22 <= (int8, int4),
60+
OPERATOR 0x23 = (int8, int4),
61+
OPERATOR 0x24 >= (int8, int4),
62+
OPERATOR 0x25 > (int8, int4)
63+
;

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.