Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit209619e

Browse files
author
Artur Zakirov
committed
Merge branch 'gitlab-fix'
A lot of fixes from Teodor Sigaev and Alexander Korotkov
2 parentsb18d5ca +376610b commit209619e

23 files changed

+1915
-127
lines changed

‎.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.deps
22
*.o
3-
*.so
3+
*.so
4+
results

‎Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ MODULE_big = rum
44
OBJS = rumsort.o rum_ts_utils.o rumtsquery.o\
55
rumbtree.o rumbulk.o rumdatapage.o\
66
rumentrypage.o rumfast.o rumget.o ruminsert.o\
7-
rumscan.o rumutil.o rumvacuum.o rumvalidate.o$(WIN32RES)
7+
rumscan.o rumutil.o rumvacuum.o rumvalidate.o\
8+
rum_timestamp.o$(WIN32RES)
89

910
EXTENSION = rum
1011
DATA = rum--1.0.sql
1112
PGFILEDESC = "RUM index access method"
1213

13-
REGRESS = rum ruminv
14+
REGRESS = rum ruminv timestamp orderby
1415

1516
ifdefUSE_PGXS
1617
PG_CONFIG = pg_config

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops);
6767
And we can execute the following queries:
6868

6969
```sql
70-
=>SELECT t, a>< to_tsquery('english','beautiful | place')AS rankFROM test_rumWHERE a @@ to_tsquery('english','beautiful | place')order by a>< to_tsquery('english','beautiful | place');
70+
=# SELECT t, a >< to_tsquery('english', 'beautiful | place') AS rank FROM test_rum WHERE a @@ to_tsquery('english', 'beautiful | place') order by a >< to_tsquery('english', 'beautiful | place');
7171
t | rank
7272
---------------------------------+-----------
7373
The situation is most beautiful |0.0303964
7474
It is a beautiful |0.0303964
7575
It lookslike a beautiful place |0.0607927
7676
(3 rows)
7777

78-
=>SELECT t, a>< to_tsquery('english','place | situation')AS rankFROM test_rumWHERE a @@ to_tsquery('english','place | situation')order by a>< to_tsquery('english','place | situation');
78+
=# SELECT t, a >< to_tsquery('english', 'place | situation') AS rank FROM test_rum WHERE a @@ to_tsquery('english', 'place | situation') order by a >< to_tsquery('english', 'place | situation');
7979
t | rank
8080
---------------------------------+-----------
8181
The situation is most beautiful |0.0303964

‎data/tsts.data

Lines changed: 508 additions & 0 deletions
Large diffs are not rendered by default.

‎expected/orderby.out

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
CREATE TABLE tsts (id int, t tsvector, d timestamp);
2+
\copy tsts from 'data/tsts.data'
3+
CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_timestamp_ops, d)
4+
WITH (orderby = 'd', addto = 't');
5+
INSERT INTO tsts VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
6+
INSERT INTO tsts VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
7+
SELECT count(*) FROM tsts WHERE t @@ 'wr|qh';
8+
count
9+
-------
10+
158
11+
(1 row)
12+
13+
SELECT count(*) FROM tsts WHERE t @@ 'wr&qh';
14+
count
15+
-------
16+
17
17+
(1 row)
18+
19+
SELECT count(*) FROM tsts WHERE t @@ 'eq&yt';
20+
count
21+
-------
22+
6
23+
(1 row)
24+
25+
SELECT count(*) FROM tsts WHERE t @@ 'eq|yt';
26+
count
27+
-------
28+
98
29+
(1 row)
30+
31+
SELECT count(*) FROM tsts WHERE t @@ '(eq&yt)|(wr&qh)';
32+
count
33+
-------
34+
23
35+
(1 row)
36+
37+
SELECT count(*) FROM tsts WHERE t @@ '(eq|yt)&(wr|qh)';
38+
count
39+
-------
40+
39
41+
(1 row)
42+
43+
SET enable_indexscan=OFF;
44+
SET enable_indexonlyscan=OFF;
45+
SET enable_bitmapscan=OFF;
46+
SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
47+
id | d | ?column?
48+
-----+---------------------------------+---------------
49+
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
50+
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
51+
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
52+
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
53+
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
54+
(5 rows)
55+
56+
SELECT id, d, d <-| '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d <-| '2016-05-16 14:21:25' LIMIT 5;
57+
id | d | ?column?
58+
-----+---------------------------------+---------------
59+
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
60+
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
61+
252 | Thu May 12 07:21:22.326724 2016 | 370802.673276
62+
232 | Wed May 11 11:21:22.326724 2016 | 442802.673276
63+
168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
64+
(5 rows)
65+
66+
SELECT id, d, d |-> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |-> '2016-05-16 14:21:25' LIMIT 5;
67+
id | d | ?column?
68+
-----+---------------------------------+---------------
69+
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
70+
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
71+
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
72+
428 | Thu May 19 15:21:22.326724 2016 | 262797.326724
73+
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
74+
(5 rows)
75+
76+
RESET enable_indexscan;
77+
RESET enable_indexonlyscan;
78+
RESET enable_bitmapscan;
79+
SET enable_seqscan = off;
80+
EXPLAIN (costs off)
81+
SELECT count(*) FROM tsts WHERE t @@ 'wr|qh';
82+
QUERY PLAN
83+
-------------------------------------------------------------
84+
Aggregate
85+
-> Bitmap Heap Scan on tsts
86+
Recheck Cond: (t @@ '''wr'' | ''qh'''::tsquery)
87+
-> Bitmap Index Scan on tsts_idx
88+
Index Cond: (t @@ '''wr'' | ''qh'''::tsquery)
89+
(5 rows)
90+
91+
SELECT count(*) FROM tsts WHERE t @@ 'wr|qh';
92+
count
93+
-------
94+
158
95+
(1 row)
96+
97+
SELECT count(*) FROM tsts WHERE t @@ 'wr&qh';
98+
count
99+
-------
100+
17
101+
(1 row)
102+
103+
SELECT count(*) FROM tsts WHERE t @@ 'eq&yt';
104+
count
105+
-------
106+
6
107+
(1 row)
108+
109+
SELECT count(*) FROM tsts WHERE t @@ 'eq|yt';
110+
count
111+
-------
112+
98
113+
(1 row)
114+
115+
SELECT count(*) FROM tsts WHERE t @@ '(eq&yt)|(wr&qh)';
116+
count
117+
-------
118+
23
119+
(1 row)
120+
121+
SELECT count(*) FROM tsts WHERE t @@ '(eq|yt)&(wr|qh)';
122+
count
123+
-------
124+
39
125+
(1 row)
126+
127+
EXPLAIN (costs off)
128+
SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
129+
QUERY PLAN
130+
-----------------------------------------------------------------------------------
131+
Limit
132+
-> Index Scan using tsts_idx on tsts
133+
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
134+
Order By: (d <-> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
135+
(4 rows)
136+
137+
SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
138+
id | d | ?column?
139+
-----+---------------------------------+---------------
140+
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
141+
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
142+
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
143+
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
144+
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
145+
(5 rows)
146+
147+
EXPLAIN (costs off)
148+
SELECT id, d, d <-| '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d <-| '2016-05-16 14:21:25' LIMIT 5;
149+
QUERY PLAN
150+
-----------------------------------------------------------------------------------
151+
Limit
152+
-> Index Scan using tsts_idx on tsts
153+
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
154+
Order By: (d <-| 'Mon May 16 14:21:25 2016'::timestamp without time zone)
155+
(4 rows)
156+
157+
SELECT id, d, d <-| '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d <-| '2016-05-16 14:21:25' LIMIT 5;
158+
id | d | ?column?
159+
-----+---------------------------------+---------------
160+
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
161+
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
162+
252 | Thu May 12 07:21:22.326724 2016 | 370802.673276
163+
232 | Wed May 11 11:21:22.326724 2016 | 442802.673276
164+
168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
165+
(5 rows)
166+
167+
EXPLAIN (costs off)
168+
SELECT id, d, d |-> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |-> '2016-05-16 14:21:25' LIMIT 5;
169+
QUERY PLAN
170+
-----------------------------------------------------------------------------------
171+
Limit
172+
-> Index Scan using tsts_idx on tsts
173+
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
174+
Order By: (d |-> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
175+
(4 rows)
176+
177+
SELECT id, d, d |-> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |-> '2016-05-16 14:21:25' LIMIT 5;
178+
id | d | ?column?
179+
-----+---------------------------------+---------------
180+
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
181+
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
182+
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
183+
428 | Thu May 19 15:21:22.326724 2016 | 262797.326724
184+
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
185+
(5 rows)
186+
187+
--to be fixed
188+
--EXPLAIN (costs off)
189+
--SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
190+
--SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;

‎expected/rum.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|
1919

2020
explain (costs off)
2121
SELECT * FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote')
22-
ORDER BY a>< to_tsquery('pg_catalog.english', 'ever|wrote');
22+
ORDER BY a<-> to_tsquery('pg_catalog.english', 'ever|wrote');
2323
QUERY PLAN
2424
------------------------------------------------------------------
2525
Sort
26-
Sort Key: ((a>< '''ever'' | ''wrote'''::tsquery))
26+
Sort Key: ((a<-> '''ever'' | ''wrote'''::tsquery))
2727
-> Bitmap Heap Scan on test_rum
2828
Recheck Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
2929
-> Bitmap Index Scan on rumidx
@@ -93,7 +93,7 @@ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
9393
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
9494
FROM test_rum
9595
WHERE a @@ to_tsquery('pg_catalog.english', 'way')
96-
ORDER BY a>< to_tsquery('pg_catalog.english', 'way');
96+
ORDER BY a<-> to_tsquery('pg_catalog.english', 'way');
9797
rum_ts_distance | t | a
9898
-----------------+--------------------------------------------------------------------------+---------------------------------------------------------------
9999
0.0607927 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
@@ -105,7 +105,7 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
105105
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')), *
106106
FROM test_rum
107107
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
108-
ORDER BY a>< to_tsquery('pg_catalog.english', 'way & (go | half)');
108+
ORDER BY a<-> to_tsquery('pg_catalog.english', 'way & (go | half)');
109109
rum_ts_distance | t | a
110110
-----------------+---------------------------------------------------------------------+---------------------------------------------------------
111111
0.103556 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14

‎expected/timestamp.out

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
CREATE TABLE test_timestamp (
2+
i timestamp
3+
);
4+
INSERT INTO test_timestamp VALUES
5+
( '2004-10-26 03:55:08' ),
6+
( '2004-10-26 04:55:08' ),
7+
( '2004-10-26 05:55:08' ),
8+
( '2004-10-26 08:55:08' ),
9+
( '2004-10-26 09:55:08' ),
10+
( '2004-10-26 10:55:08' )
11+
;
12+
SELECT i <-> '2004-10-26 06:24:08', i FROM test_timestamp ORDER BY 1, 2 ASC;
13+
?column? | i
14+
----------+--------------------------
15+
1740 | Tue Oct 26 05:55:08 2004
16+
5340 | Tue Oct 26 04:55:08 2004
17+
8940 | Tue Oct 26 03:55:08 2004
18+
9060 | Tue Oct 26 08:55:08 2004
19+
12660 | Tue Oct 26 09:55:08 2004
20+
16260 | Tue Oct 26 10:55:08 2004
21+
(6 rows)
22+
23+
SELECT i <-| '2004-10-26 06:24:08', i FROM test_timestamp ORDER BY 1, 2 ASC;
24+
?column? | i
25+
----------+--------------------------
26+
1740 | Tue Oct 26 05:55:08 2004
27+
5340 | Tue Oct 26 04:55:08 2004
28+
8940 | Tue Oct 26 03:55:08 2004
29+
Infinity | Tue Oct 26 08:55:08 2004
30+
Infinity | Tue Oct 26 09:55:08 2004
31+
Infinity | Tue Oct 26 10:55:08 2004
32+
(6 rows)
33+
34+
SELECT i |-> '2004-10-26 06:24:08', i FROM test_timestamp ORDER BY 1, 2 ASC;
35+
?column? | i
36+
----------+--------------------------
37+
9060 | Tue Oct 26 08:55:08 2004
38+
12660 | Tue Oct 26 09:55:08 2004
39+
16260 | Tue Oct 26 10:55:08 2004
40+
Infinity | Tue Oct 26 03:55:08 2004
41+
Infinity | Tue Oct 26 04:55:08 2004
42+
Infinity | Tue Oct 26 05:55:08 2004
43+
(6 rows)
44+
45+
CREATE INDEX idx_timestamp ON test_timestamp USING rum (i);
46+
set enable_seqscan=off;
47+
explain (costs off)
48+
SELECT * FROM test_timestamp WHERE i<'2004-10-26 08:55:08'::timestamp ORDER BY i;
49+
QUERY PLAN
50+
-----------------------------------------------------------------------------------
51+
Sort
52+
Sort Key: i
53+
-> Index Scan using idx_timestamp on test_timestamp
54+
Index Cond: (i < 'Tue Oct 26 08:55:08 2004'::timestamp without time zone)
55+
(4 rows)
56+
57+
SELECT * FROM test_timestamp WHERE i<'2004-10-26 08:55:08'::timestamp ORDER BY i;
58+
i
59+
--------------------------
60+
Tue Oct 26 03:55:08 2004
61+
Tue Oct 26 04:55:08 2004
62+
Tue Oct 26 05:55:08 2004
63+
(3 rows)
64+
65+
explain (costs off)
66+
SELECT * FROM test_timestamp WHERE i<='2004-10-26 08:55:08'::timestamp ORDER BY i;
67+
QUERY PLAN
68+
------------------------------------------------------------------------------------
69+
Sort
70+
Sort Key: i
71+
-> Index Scan using idx_timestamp on test_timestamp
72+
Index Cond: (i <= 'Tue Oct 26 08:55:08 2004'::timestamp without time zone)
73+
(4 rows)
74+
75+
SELECT * FROM test_timestamp WHERE i<='2004-10-26 08:55:08'::timestamp ORDER BY i;
76+
i
77+
--------------------------
78+
Tue Oct 26 03:55:08 2004
79+
Tue Oct 26 04:55:08 2004
80+
Tue Oct 26 05:55:08 2004
81+
Tue Oct 26 08:55:08 2004
82+
(4 rows)
83+
84+
explain (costs off)
85+
SELECT * FROM test_timestamp WHERE i='2004-10-26 08:55:08'::timestamp ORDER BY i;
86+
QUERY PLAN
87+
-----------------------------------------------------------------------------
88+
Index Scan using idx_timestamp on test_timestamp
89+
Index Cond: (i = 'Tue Oct 26 08:55:08 2004'::timestamp without time zone)
90+
(2 rows)
91+
92+
SELECT * FROM test_timestamp WHERE i='2004-10-26 08:55:08'::timestamp ORDER BY i;
93+
i
94+
--------------------------
95+
Tue Oct 26 08:55:08 2004
96+
(1 row)
97+
98+
explain (costs off)
99+
SELECT * FROM test_timestamp WHERE i>='2004-10-26 08:55:08'::timestamp ORDER BY i;
100+
QUERY PLAN
101+
------------------------------------------------------------------------------------
102+
Sort
103+
Sort Key: i
104+
-> Index Scan using idx_timestamp on test_timestamp
105+
Index Cond: (i >= 'Tue Oct 26 08:55:08 2004'::timestamp without time zone)
106+
(4 rows)
107+
108+
SELECT * FROM test_timestamp WHERE i>='2004-10-26 08:55:08'::timestamp ORDER BY i;
109+
i
110+
--------------------------
111+
Tue Oct 26 08:55:08 2004
112+
Tue Oct 26 09:55:08 2004
113+
Tue Oct 26 10:55:08 2004
114+
(3 rows)
115+
116+
explain (costs off)
117+
SELECT * FROM test_timestamp WHERE i>'2004-10-26 08:55:08'::timestamp ORDER BY i;
118+
QUERY PLAN
119+
-----------------------------------------------------------------------------------
120+
Sort
121+
Sort Key: i
122+
-> Index Scan using idx_timestamp on test_timestamp
123+
Index Cond: (i > 'Tue Oct 26 08:55:08 2004'::timestamp without time zone)
124+
(4 rows)
125+
126+
SELECT * FROM test_timestamp WHERE i>'2004-10-26 08:55:08'::timestamp ORDER BY i;
127+
i
128+
--------------------------
129+
Tue Oct 26 09:55:08 2004
130+
Tue Oct 26 10:55:08 2004
131+
(2 rows)
132+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp