Skip to content

Commit f97b644

Browse files
committed
add tests for int4/int8
1 parent dfafaeb commit f97b644

File tree

9 files changed

+1617
-140
lines changed

9 files changed

+1617
-140
lines changed

expected/int4.out

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

expected/int8.out

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

expected/rum.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,5 +350,3 @@ SELECT a <=> to_tsquery('pg_catalog.english', 'b:*'), *
350350
16.4493 | the few that escaped destruction in 1693. It is a beautiful, highly | '1693':7 'beauti':11 'destruct':5 'escap':4 'high':12
351351
(20 rows)
352352

353-
DROP TABLE test_rum CASCADE;
354-
DROP TABLE tst CASCADE;

expected/rum_hash.out

Lines changed: 63 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,122 @@
1-
CREATE TABLE test_rum( t text, a tsvector );
1+
CREATE TABLE test_rum_hash( t text, a tsvector );
22
CREATE TRIGGER tsvectorupdate
3-
BEFORE UPDATE OR INSERT ON test_rum
3+
BEFORE UPDATE OR INSERT ON test_rum_hash
44
FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a', 'pg_catalog.english', 't');
5-
CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_hash_ops);
6-
\copy test_rum(t) from 'data/rum.data';
7-
CREATE INDEX failed_rumidx ON test_rum USING rum (a rum_tsvector_addon_ops);
5+
CREATE INDEX rumhashidx ON test_rum_hash USING rum (a rum_tsvector_hash_ops);
6+
\copy test_rum_hash(t) from 'data/rum.data';
7+
CREATE INDEX failed_rumidx ON test_rum_hash USING rum (a rum_tsvector_addon_ops);
88
ERROR: additional information attribute "a" is not found in index
99
SET enable_seqscan=off;
1010
explain (costs off)
11-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
11+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
1212
QUERY PLAN
1313
------------------------------------------------------------------
1414
Aggregate
15-
-> Bitmap Heap Scan on test_rum
15+
-> Bitmap Heap Scan on test_rum_hash
1616
Recheck Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
17-
-> Bitmap Index Scan on rumidx
17+
-> Bitmap Index Scan on rumhashidx
1818
Index Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
1919
(5 rows)
2020

2121
explain (costs off)
22-
SELECT * FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote')
22+
SELECT * FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote')
2323
ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
2424
QUERY PLAN
2525
------------------------------------------------------------------
2626
Sort
2727
Sort Key: ((a <=> '''ever'' | ''wrote'''::tsquery))
28-
-> Bitmap Heap Scan on test_rum
28+
-> Bitmap Heap Scan on test_rum_hash
2929
Recheck Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
30-
-> Bitmap Index Scan on rumidx
30+
-> Bitmap Index Scan on rumhashidx
3131
Index Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
3232
(6 rows)
3333

3434
explain (costs off)
35-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
35+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
3636
'def <-> fgr');
3737
QUERY PLAN
3838
-----------------------------------------------------------
3939
Aggregate
40-
-> Index Scan using rumidx on test_rum
40+
-> Index Scan using rumhashidx on test_rum_hash
4141
Index Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
4242
(3 rows)
4343

44-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
44+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
4545
count
4646
-------
4747
2
4848
(1 row)
4949

50-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'have&wish');
50+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'have&wish');
5151
count
5252
-------
5353
1
5454
(1 row)
5555

56-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'knew&brain');
56+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'knew&brain');
5757
count
5858
-------
5959
0
6060
(1 row)
6161

62-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'among');
62+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'among');
6363
count
6464
-------
6565
1
6666
(1 row)
6767

68-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'structure&ancient');
68+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'structure&ancient');
6969
count
7070
-------
7171
1
7272
(1 row)
7373

74-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(complimentary|sight)&(sending|heart)');
74+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '(complimentary|sight)&(sending|heart)');
7575
count
7676
-------
7777
2
7878
(1 row)
7979

80-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(gave | half) <-> way');
80+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '(gave | half) <-> way');
8181
count
8282
-------
8383
2
8484
(1 row)
8585

86-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(gave | !half) <-> way');
86+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '(gave | !half) <-> way');
8787
count
8888
-------
8989
3
9090
(1 row)
9191

92-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '!gave & way');
92+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '!gave & way');
9393
count
9494
-------
9595
3
9696
(1 row)
9797

98-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '!gave & wooded & !look');
98+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '!gave & wooded & !look');
9999
count
100100
-------
101101
1
102102
(1 row)
103103

104-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
104+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
105105
'def <-> fgr');
106106
count
107107
-------
108108
1
109109
(1 row)
110110

111-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
111+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
112112
'def <2> fgr');
113113
count
114114
-------
115115
1
116116
(1 row)
117117

118118
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
119-
FROM test_rum
119+
FROM test_rum_hash
120120
WHERE a @@ to_tsquery('pg_catalog.english', 'way')
121121
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
122122
rum_ts_distance | t | a
@@ -128,7 +128,7 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
128128
(4 rows)
129129

130130
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')), *
131-
FROM test_rum
131+
FROM test_rum_hash
132132
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
133133
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
134134
rum_ts_distance | t | a
@@ -141,7 +141,7 @@ SELECT
141141
a <=> to_tsquery('pg_catalog.english', 'way & (go | half)'),
142142
rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
143143
*
144-
FROM test_rum
144+
FROM test_rum_hash
145145
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
146146
?column? | rum_ts_distance | t | a
147147
----------+-----------------+---------------------------------------------------------------------+---------------------------------------------------------
@@ -151,7 +151,7 @@ SELECT
151151

152152
-- Check ranking normalization
153153
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0), *
154-
FROM test_rum
154+
FROM test_rum_hash
155155
WHERE a @@ to_tsquery('pg_catalog.english', 'way')
156156
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
157157
rum_ts_distance | t | a
@@ -163,7 +163,7 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0), *
163163
(4 rows)
164164

165165
SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query), *
166-
FROM test_rum
166+
FROM test_rum_hash
167167
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
168168
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
169169
rum_ts_distance | t | a
@@ -172,42 +172,42 @@ SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half
172172
57.5727 | 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
173173
(2 rows)
174174

175-
INSERT INTO test_rum (t) VALUES ('foo bar foo the over foo qq bar');
176-
INSERT INTO test_rum (t) VALUES ('345 qwerty copyright');
177-
INSERT INTO test_rum (t) VALUES ('345 qwerty');
178-
INSERT INTO test_rum (t) VALUES ('A fat cat has just eaten a rat.');
179-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar');
175+
INSERT INTO test_rum_hash (t) VALUES ('foo bar foo the over foo qq bar');
176+
INSERT INTO test_rum_hash (t) VALUES ('345 qwerty copyright');
177+
INSERT INTO test_rum_hash (t) VALUES ('345 qwerty');
178+
INSERT INTO test_rum_hash (t) VALUES ('A fat cat has just eaten a rat.');
179+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'bar');
180180
count
181181
-------
182182
1
183183
(1 row)
184184

185-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'qwerty&345');
185+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'qwerty&345');
186186
count
187187
-------
188188
2
189189
(1 row)
190190

191-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '345');
191+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '345');
192192
count
193193
-------
194194
2
195195
(1 row)
196196

197-
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'rat');
197+
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'rat');
198198
count
199199
-------
200200
1
201201
(1 row)
202202

203-
SELECT a FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER BY a;
203+
SELECT a FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER BY a;
204204
a
205205
------------------------------
206206
'bar':2,8 'foo':1,3,6 'qq':7
207207
(1 row)
208208

209209
-- Check full-index scan with order by
210-
SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
210+
SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum_hash ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
211211
?column?
212212
----------
213213
16.4493
@@ -268,41 +268,39 @@ SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum ORDER
268268
Infinity
269269
(56 rows)
270270

271-
CREATE TABLE tst (i int4, t tsvector);
272-
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(1,100000) i;
273-
CREATE INDEX tstidx ON tst USING rum (t rum_tsvector_hash_ops);
274-
DELETE FROM tst WHERE i = 1;
275-
VACUUM tst;
276-
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(10001,11000) i;
277-
DELETE FROM tst WHERE i = 2;
278-
VACUUM tst;
279-
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(11001,12000) i;
280-
DELETE FROM tst WHERE i = 3;
281-
VACUUM tst;
282-
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(12001,13000) i;
283-
DELETE FROM tst WHERE i = 4;
284-
VACUUM tst;
285-
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(13001,14000) i;
286-
DELETE FROM tst WHERE i = 5;
287-
VACUUM tst;
288-
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
271+
CREATE TABLE tst_hash (i int4, t tsvector);
272+
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(1,100000) i;
273+
CREATE INDEX tst_hashidx ON tst_hash USING rum (t rum_tsvector_hash_ops);
274+
DELETE FROM tst_hash WHERE i = 1;
275+
VACUUM tst_hash;
276+
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(10001,11000) i;
277+
DELETE FROM tst_hash WHERE i = 2;
278+
VACUUM tst_hash;
279+
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(11001,12000) i;
280+
DELETE FROM tst_hash WHERE i = 3;
281+
VACUUM tst_hash;
282+
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(12001,13000) i;
283+
DELETE FROM tst_hash WHERE i = 4;
284+
VACUUM tst_hash;
285+
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(13001,14000) i;
286+
DELETE FROM tst_hash WHERE i = 5;
287+
VACUUM tst_hash;
288+
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
289289
set enable_bitmapscan=off;
290290
explain (costs off)
291291
SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
292-
FROM test_rum
292+
FROM test_rum_hash
293293
WHERE a @@ to_tsquery('pg_catalog.english', 'w:*')
294294
ORDER BY a <=> to_tsquery('pg_catalog.english', 'w:*');
295-
QUERY PLAN
296-
-----------------------------------------
297-
Index Scan using rumidx on test_rum
295+
QUERY PLAN
296+
----------------------------------------------
297+
Index Scan using rumhashidx on test_rum_hash
298298
Index Cond: (a @@ '''w'':*'::tsquery)
299299
Order By: (a <=> '''w'':*'::tsquery)
300300
(3 rows)
301301

302302
SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
303-
FROM test_rum
303+
FROM test_rum_hash
304304
WHERE a @@ to_tsquery('pg_catalog.english', 'w:*')
305305
ORDER BY a <=> to_tsquery('pg_catalog.english', 'w:*');
306306
ERROR: Compare with prefix expressions isn't supported
307-
DROP TABLE test_rum CASCADE;
308-
DROP TABLE tst CASCADE;

gen_rum_sql--1.0--1.1.pl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@
7070
CREATE OPERATOR CLASS rum_TYPEIDENT_ops
7171
DEFAULT FOR TYPE TYPENAME USING rum
7272
AS
73-
OPERATOR 1 < (TYPECMPTYPE, TYPECMPTYPE),
74-
OPERATOR 2 <=(TYPECMPTYPE, TYPECMPTYPE),
75-
OPERATOR 3 = (TYPECMPTYPE, TYPECMPTYPE),
76-
OPERATOR 4 >=(TYPECMPTYPE, TYPECMPTYPE),
77-
OPERATOR 5 > (TYPECMPTYPE, TYPECMPTYPE),
73+
OPERATOR 1 < TYPESOPARG,
74+
OPERATOR 2 <= TYPESOPARG,
75+
OPERATOR 3 = TYPESOPARG,
76+
OPERATOR 4 >= TYPESOPARG,
77+
OPERATOR 5 > TYPESOPARG,
7878
FUNCTION 1 TYPECMPFUNC(TYPECMPTYPE,TYPECMPTYPE),
7979
FUNCTION 2 rum_TYPESUBIDENT_extract_value(TYPESUBNAME, internal),
8080
FUNCTION 3 rum_TYPESUBIDENT_extract_query(TYPESUBNAME, internal, int2, internal, internal),
@@ -89,11 +89,11 @@
8989
CREATE OPERATOR CLASS rum_TYPEIDENT_ops
9090
DEFAULT FOR TYPE TYPENAME USING rum
9191
AS
92-
OPERATOR 1 < (TYPECMPTYPE, TYPECMPTYPE),
93-
OPERATOR 2 <= (TYPECMPTYPE, TYPECMPTYPE),
94-
OPERATOR 3 = (TYPECMPTYPE, TYPECMPTYPE),
95-
OPERATOR 4 >= (TYPECMPTYPE, TYPECMPTYPE),
96-
OPERATOR 5 > (TYPECMPTYPE, TYPECMPTYPE),
92+
OPERATOR 1 < TYPESOPARG,
93+
OPERATOR 2 <= TYPESOPARG,
94+
OPERATOR 3 = TYPESOPARG,
95+
OPERATOR 4 >= TYPESOPARG,
96+
OPERATOR 5 > TYPESOPARG,
9797
OPERATOR 20 <=> (TYPENAME,TYPENAME) FOR ORDER BY pg_catalog.float_ops,
9898
OPERATOR 21 <=| (TYPENAME,TYPENAME) FOR ORDER BY pg_catalog.float_ops,
9999
OPERATOR 22 |=> (TYPENAME,TYPENAME) FOR ORDER BY pg_catalog.float_ops,
@@ -113,6 +113,7 @@
113113
$_->{TYPECMPTYPE} = $_->{TYPENAME} if !exists $_->{TYPECMPTYPE};
114114
$_->{TYPESUBNAME} = $_->{TYPENAME} if !exists $_->{TYPESUBNAME};
115115
$_->{TYPESUBIDENT}= $_->{TYPEIDENT} if ! exists $_->{TYPESUBIDENT};
116+
$_->{TYPESOPARG}= '' if ! exists $_->{TYPESOPARG};
116117
$_
117118
} (
118119
# timestamp/tz aren't here: they are in rum--1.0.sql
@@ -198,7 +199,8 @@
198199
{
199200
TYPENAME => 'cidr',
200201
TYPECMPFUNC => 'network_cmp',
201-
TYPECMPTYPE => 'inet',
202+
TYPECMPTYPE => 'inet',
203+
TYPESOPARG => '(inet, inet)',
202204
func_tmpl => \$func_base_template,
203205
opclass_tmpl=> \$opclass_base_template,
204206
},
@@ -211,9 +213,10 @@
211213
{
212214
TYPENAME => 'varchar',
213215
TYPECMPFUNC => 'bttextcmp',
214-
TYPECMPTYPE => 'text',
215-
TYPESUBIDENT=> 'text',
216-
TYPESUBNAME => 'text',
216+
TYPECMPTYPE => 'text',
217+
TYPESUBIDENT=> 'text',
218+
TYPESUBNAME => 'text',
219+
TYPESOPARG => '(text, text)',
217220
opclass_tmpl=> \$opclass_base_template,
218221
},
219222
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy