Skip to content

Commit 6580056

Browse files
committed
Merge branch 'PGPROEE9_6_rum' into PGPROEE9_6
2 parents 2efccfa + 15f7f5a commit 6580056

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+8279
-924
lines changed

contrib/rum/Makefile

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ OBJS = src/rumsort.o src/rum_ts_utils.o src/rumtsquery.o \
55
src/rumbtree.o src/rumbulk.o src/rumdatapage.o \
66
src/rumentrypage.o src/rumget.o src/ruminsert.o \
77
src/rumscan.o src/rumutil.o src/rumvacuum.o src/rumvalidate.o \
8-
src/rum_timestamp.o $(WIN32RES)
8+
src/btree_rum.o $(WIN32RES)
99

1010
EXTENSION = rum
11-
DATA = rum--1.0.sql
11+
DATA = rum--1.0.sql rum--1.0--1.1.sql rum--1.1.sql
1212
PGFILEDESC = "RUM index access method"
13+
INCLUDES = src/rum.h src/rumsort.h
1314

1415
REGRESS = rum rum_hash ruminv timestamp orderby orderby_hash altorder \
15-
altorder_hash
16+
altorder_hash limits \
17+
int2 int4 int8 float4 float8 money oid \
18+
time timetz date interval \
19+
macaddr inet cidr text varchar char bytea bit varbit \
20+
numeric
21+
22+
EXTRA_CLEAN += rum--1.1.sql rum--1.0--1.1.sql
1623

1724
LDFLAGS_SL += $(filter -lm, $(LIBS))
1825

@@ -29,3 +36,17 @@ endif
2936

3037
wal-check: temp-install
3138
$(prove_check)
39+
40+
all: rum--1.1.sql
41+
42+
#9.6 requires 1.1 file but 10.0 could live with 1.0 + 1.0-1.1 files
43+
rum--1.1.sql: rum--1.0.sql rum--1.0--1.1.sql
44+
cat rum--1.0.sql rum--1.0--1.1.sql > rum--1.1.sql
45+
46+
rum--1.0--1.1.sql: Makefile gen_rum_sql--1.0--1.1.pl
47+
perl gen_rum_sql--1.0--1.1.pl > rum--1.0--1.1.sql
48+
49+
install: installincludes
50+
51+
installincludes:
52+
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(INCLUDES)) '$(DESTDIR)$(includedir_server)/'

contrib/rum/README.md

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Typical installation procedure may look like this:
5959
| timestamp <=| timestamp | float8 | Returns distance only for left timestamps.
6060
| timestamp |=> timestamp | float8 | Returns distance only for right timestamps.
6161

62+
Last three operations also works for types int2, int4, int8, float4, float8,
63+
money and oid.
64+
6265
## Operator classes
6366

6467
**rum** provides next operator classes.
@@ -128,35 +131,33 @@ For type: `tsvector`
128131
This operator class stores hash of `tsvector` lexemes with positional information.
129132
Supports ordering by `<=>` operator. But **doesn't** support prefix search.
130133

131-
### rum_timestamp_ops
132-
133-
For type: `timestamp`
134-
135-
Operator class provides fast search and ordering by timestamp fields. Supports
136-
ordering by `<=>`, `<=|` and `|=>` operators. Can be used with
137-
`rum_tsvector_timestamp_ops` operator class.
134+
### rum_TYPE_ops
138135

139-
### rum_timestamptz_ops
136+
For types: int2, int4, int8, float4, float8, money, oid, time, timetz, date,
137+
interval, macaddr, inet, cidr, text, varchar, char, bytea, bit, varbit,
138+
numeric, timestamp, timestamptz
140139

141-
For type: `timestamptz`
140+
Supported operations: `<`, `<=`, `=`, `>=`, `>` for all types and
141+
`<=>`, `<=|` and `|=>` for int2, int4, int8, float4, float8, money, oid,
142+
timestamp and timestamptz types.
142143

143-
Operator class provides fast search and ordering by timestamptz fields. Supports
144-
ordering by `<=>`, `<=|` and `|=>` operators. Can be used with
145-
`rum_tsvector_timestamptz_ops` operator class.
144+
Supports ordering by `<=>`, `<=|` and `|=>` operators. Can be used with
145+
`rum_tsvector_addon_ops` operator class.
146146

147-
### rum_tsvector_timestamp_ops
147+
### rum_tsvector_addon_ops
148148

149149
For type: `tsvector`
150150

151-
This operator class stores `tsvector` lexems with timestamp field. There is the example.
151+
This operator class stores `tsvector` lexems with any supported by module
152+
field. There is the example.
152153

153154
Let us assume we have the table:
154155
```sql
155156
CREATE TABLE tsts (id int, t tsvector, d timestamp);
156157

157158
\copy tsts from 'rum/data/tsts.data'
158159

159-
CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_timestamp_ops, d)
160+
CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d)
160161
WITH (attach = 'd', to = 't');
161162
```
162163

@@ -183,24 +184,13 @@ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY
183184
(5 rows)
184185
```
185186

186-
### rum_tsvector_timestamptz_ops
187+
### rum_tsvector_hash_addon_ops
187188

188189
For type: `tsvector`
189190

190-
See comments for `rum_tsvector_timestamp_ops` operator class.
191-
192-
### rum_tsvector_hash_timestamp_ops
193-
194-
For type: `tsvector`
195-
196-
This operator class stores hash of `tsvector` lexems with timestamp field.
197-
**Doesn't** support prefix search.
198-
199-
### rum_tsvector_hash_timestamptz_ops
200-
201-
For type: `tsvector`
191+
This operator class stores hash of `tsvector` lexems with any supported by module
192+
field.
202193

203-
This operator class stores hash of `tsvector` lexems with timestamptz field.
204194
**Doesn't** support prefix search.
205195

206196
### rum_tsquery_ops

contrib/rum/TODO

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
1. with naturalOrder=true make scan the rest to be consistent with seqscan
2-
2. add leftlink to data page to privide backward scan on index (<=| op)
1+
1. with naturalOrder=true make scan the rest to be consistent with seqscan [done]
2+
2. add leftlink to data page to privide backward scan on index (<=| op) [done]
33
3. Compression of ItemPointer for use_alternative_order
44
4. Compression addInfo
5-
5. Remove FROM_STRATEGY ugly magick
5+
5. Remove FROM_STRATEGY ugly magick [done]
66

7+
8+
BTREE:
9+
1 fix changes in rum--1.0.sql [done]
10+
2 adding using as addinfo

contrib/rum/expected/altorder.out

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE TABLE atsts (id int, t tsvector, d timestamp);
22
\copy atsts from 'data/tsts.data'
3-
CREATE INDEX atsts_idx ON atsts USING rum (t rum_tsvector_timestamp_ops, d)
3+
CREATE INDEX atsts_idx ON atsts USING rum (t rum_tsvector_addon_ops, d)
44
WITH (attach = 'd', to = 't', order_by_attach='t');
55
INSERT INTO atsts VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
66
INSERT INTO atsts VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
@@ -323,4 +323,3 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
323323
496 | Sun May 22 11:21:22.326724 2016
324324
(8 rows)
325325

326-
DROP TABLE atsts CASCADE;

contrib/rum/expected/altorder_1.out

Lines changed: 57 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
CREATE TABLE atsts (id int, t tsvector, d timestamp);
22
\copy atsts from 'data/tsts.data'
3-
CREATE INDEX atsts_idx ON atsts USING rum (t rum_tsvector_timestamp_ops, d)
3+
CREATE INDEX atsts_idx ON atsts USING rum (t rum_tsvector_addon_ops, d)
44
WITH (attach = 'd', to = 't', order_by_attach='t');
5-
ERROR: currently, RUM doesn't support order by over pass-by-reference column
65
INSERT INTO atsts VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
76
INSERT INTO atsts VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
87
SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
@@ -119,12 +118,14 @@ RESET enable_bitmapscan;
119118
SET enable_seqscan = off;
120119
EXPLAIN (costs off)
121120
SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
122-
QUERY PLAN
123-
---------------------------------------------------
121+
QUERY PLAN
122+
-------------------------------------------------------------
124123
Aggregate
125-
-> Seq Scan on atsts
126-
Filter: (t @@ '''wr'' | ''qh'''::tsquery)
127-
(3 rows)
124+
-> Bitmap Heap Scan on atsts
125+
Recheck Cond: (t @@ '''wr'' | ''qh'''::tsquery)
126+
-> Bitmap Index Scan on atsts_idx
127+
Index Cond: (t @@ '''wr'' | ''qh'''::tsquery)
128+
(5 rows)
128129

129130
SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
130131
count
@@ -164,12 +165,14 @@ SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
164165

165166
EXPLAIN (costs off)
166167
SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
167-
QUERY PLAN
168-
-------------------------------------------------------------------------------
168+
QUERY PLAN
169+
-----------------------------------------------------------------------------------------
169170
Aggregate
170-
-> Seq Scan on atsts
171-
Filter: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
172-
(3 rows)
171+
-> Bitmap Heap Scan on atsts
172+
Recheck Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
173+
-> Bitmap Index Scan on atsts_idx
174+
Index Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
175+
(5 rows)
173176

174177
SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
175178
count
@@ -179,12 +182,14 @@ SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
179182

180183
EXPLAIN (costs off)
181184
SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
182-
QUERY PLAN
183-
-------------------------------------------------------------------------------
185+
QUERY PLAN
186+
-----------------------------------------------------------------------------------------
184187
Aggregate
185-
-> Seq Scan on atsts
186-
Filter: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
187-
(3 rows)
188+
-> Bitmap Heap Scan on atsts
189+
Recheck Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
190+
-> Bitmap Index Scan on atsts_idx
191+
Index Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
192+
(5 rows)
188193

189194
SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
190195
count
@@ -194,95 +199,59 @@ SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
194199

195200
EXPLAIN (costs off)
196201
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
197-
QUERY PLAN
198-
-------------------------------------------------------------------------------------
202+
QUERY PLAN
203+
-----------------------------------------------------------------------------------
199204
Limit
200-
-> Sort
201-
Sort Key: ((d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
202-
-> Seq Scan on atsts
203-
Filter: (t @@ '''wr'' & ''qh'''::tsquery)
204-
(5 rows)
205+
-> Index Scan using atsts_idx on atsts
206+
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
207+
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
208+
(4 rows)
205209

206210
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
207-
id | d | ?column?
208-
-----+---------------------------------+---------------
209-
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
210-
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
211-
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
212-
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
213-
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
214-
(5 rows)
215-
211+
ERROR: doesn't support order by over pass-by-reference column
216212
EXPLAIN (costs off)
217213
SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
218-
QUERY PLAN
219-
-------------------------------------------------------------------------------------
214+
QUERY PLAN
215+
-----------------------------------------------------------------------------------
220216
Limit
221-
-> Sort
222-
Sort Key: ((d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone))
223-
-> Seq Scan on atsts
224-
Filter: (t @@ '''wr'' & ''qh'''::tsquery)
225-
(5 rows)
217+
-> Index Scan using atsts_idx on atsts
218+
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
219+
Order By: (d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone)
220+
(4 rows)
226221

227222
SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
228-
id | d | ?column?
229-
-----+---------------------------------+---------------
230-
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
231-
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
232-
252 | Thu May 12 07:21:22.326724 2016 | 370802.673276
233-
232 | Wed May 11 11:21:22.326724 2016 | 442802.673276
234-
168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
235-
(5 rows)
236-
223+
ERROR: doesn't support order by over pass-by-reference column
237224
EXPLAIN (costs off)
238225
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
239-
QUERY PLAN
240-
-------------------------------------------------------------------------------------
226+
QUERY PLAN
227+
-----------------------------------------------------------------------------------
241228
Limit
242-
-> Sort
243-
Sort Key: ((d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
244-
-> Seq Scan on atsts
245-
Filter: (t @@ '''wr'' & ''qh'''::tsquery)
246-
(5 rows)
229+
-> Index Scan using atsts_idx on atsts
230+
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
231+
Order By: (d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
232+
(4 rows)
247233

248234
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
249-
id | d | ?column?
250-
-----+---------------------------------+---------------
251-
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
252-
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
253-
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
254-
428 | Thu May 19 15:21:22.326724 2016 | 262797.326724
255-
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
256-
(5 rows)
257-
235+
ERROR: doesn't support order by over pass-by-reference column
258236
EXPLAIN (costs off)
259237
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
260-
QUERY PLAN
261-
-------------------------------------------------------------------------------------
238+
QUERY PLAN
239+
-----------------------------------------------------------------------------------
262240
Limit
263-
-> Sort
264-
Sort Key: ((d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
265-
-> Seq Scan on atsts
266-
(4 rows)
241+
-> Index Scan using atsts_idx on atsts
242+
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
243+
(3 rows)
267244

268245
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
269-
id | d | ?column?
270-
-----+---------------------------------+-------------
271-
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
272-
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
273-
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
274-
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
275-
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
276-
(5 rows)
277-
246+
ERROR: doesn't support order by over pass-by-reference column
278247
EXPLAIN (costs off)
279248
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
280-
QUERY PLAN
281-
------------------------------------------------------------------------------------------------------------------------
249+
QUERY PLAN
250+
----------------------------------------------------------------------------------------------------------------------------
282251
Sort
283252
Sort Key: d
284-
-> Seq Scan on atsts
285-
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
253+
-> Index Scan using atsts_idx on atsts
254+
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
286255
(4 rows)
287256

288257
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
@@ -301,12 +270,12 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER
301270

302271
EXPLAIN (costs off)
303272
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
304-
QUERY PLAN
305-
------------------------------------------------------------------------------------------------------------------------
273+
QUERY PLAN
274+
----------------------------------------------------------------------------------------------------------------------------
306275
Sort
307276
Sort Key: d
308-
-> Seq Scan on atsts
309-
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
277+
-> Index Scan using atsts_idx on atsts
278+
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
310279
(4 rows)
311280

312281
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
@@ -322,4 +291,3 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
322291
496 | Sun May 22 11:21:22.326724 2016
323292
(8 rows)
324293

325-
DROP TABLE atsts CASCADE;

0 commit comments

Comments
 (0)