Skip to content

Commit 6487a70

Browse files
committed
Added upgrade script, tests
1 parent 6563725 commit 6487a70

20 files changed

+697
-7
lines changed

Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ OBJS = src/rumsort.o src/rum_ts_utils.o src/rumtsquery.o \
88
src/btree_rum.o $(WIN32RES)
99

1010
EXTENSION = rum
11-
DATA = rum--1.0.sql rum--1.0--1.1.sql rum--1.1.sql
11+
EXTVERSION = 1.2
12+
DATA = rum--1.0.sql
13+
DATA_updates = rum--1.0--1.1.sql rum--1.1--1.2.sql
14+
DATA_built = rum--$(EXTVERSION).sql $(DATA_updates)
1215
PGFILEDESC = "RUM index access method"
1316
INCLUDES = src/rum.h src/rumsort.h
1417

@@ -35,14 +38,14 @@ endif
3538
wal-check: temp-install
3639
$(prove_check)
3740

38-
all: rum--1.1.sql
41+
all: rum--$(EXTVERSION).sql
3942

40-
#9.6 requires 1.1 file but 10.0 could live with 1.0 + 1.0-1.1 files
41-
rum--1.1.sql: rum--1.0.sql rum--1.0--1.1.sql
42-
cat rum--1.0.sql rum--1.0--1.1.sql > rum--1.1.sql
43+
#9.6 requires 1.2 file but 10.0 could live with update files
44+
rum--$(EXTVERSION).sql: $(DATA) $(DATA_updates)
45+
cat $(DATA) $(DATA_updates) > rum--$(EXTVERSION).sql
4346

44-
rum--1.0--1.1.sql: Makefile gen_rum_sql--1.0--1.1.pl
45-
perl gen_rum_sql--1.0--1.1.pl > rum--1.0--1.1.sql
47+
rum--%.sql: gen_rum_sql--%.pl
48+
perl $< > $@
4649

4750
install: installincludes
4851

expected/float4.out

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,39 @@ SELECT * FROM test_float4 WHERE i>1::float4 ORDER BY i;
4242
3
4343
(2 rows)
4444

45+
EXPLAIN (costs off)
46+
SELECT *, i <=> 0::float4 FROM test_float4 ORDER BY i <=> 0::float4;
47+
QUERY PLAN
48+
--------------------------------------------
49+
Index Scan using idx_float4 on test_float4
50+
Order By: (i <=> '0'::real)
51+
(2 rows)
52+
53+
SELECT *, i <=> 0::float4 FROM test_float4 ORDER BY i <=> 0::float4;
54+
i | ?column?
55+
----+----------
56+
0 | 0
57+
-1 | 1
58+
1 | 1
59+
-2 | 2
60+
2 | 2
61+
3 | 3
62+
(6 rows)
63+
64+
EXPLAIN (costs off)
65+
SELECT *, i <=> 1::float4 FROM test_float4 WHERE i<1::float4 ORDER BY i <=> 1::float4;
66+
QUERY PLAN
67+
--------------------------------------------
68+
Index Scan using idx_float4 on test_float4
69+
Index Cond: (i < '1'::real)
70+
Order By: (i <=> '1'::real)
71+
(3 rows)
72+
73+
SELECT *, i <=> 1::float4 FROM test_float4 WHERE i<1::float4 ORDER BY i <=> 1::float4;
74+
i | ?column?
75+
----+----------
76+
0 | 1
77+
-1 | 2
78+
-2 | 3
79+
(3 rows)
80+

expected/float8.out

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,39 @@ SELECT * FROM test_float8 WHERE i>1::float8 ORDER BY i;
4242
3
4343
(2 rows)
4444

45+
EXPLAIN (costs off)
46+
SELECT *, i <=> 0::float8 FROM test_float8 ORDER BY i <=> 0::float8;
47+
QUERY PLAN
48+
--------------------------------------------
49+
Index Scan using idx_float8 on test_float8
50+
Order By: (i <=> '0'::double precision)
51+
(2 rows)
52+
53+
SELECT *, i <=> 0::float8 FROM test_float8 ORDER BY i <=> 0::float8;
54+
i | ?column?
55+
----+----------
56+
0 | 0
57+
-1 | 1
58+
1 | 1
59+
-2 | 2
60+
2 | 2
61+
3 | 3
62+
(6 rows)
63+
64+
EXPLAIN (costs off)
65+
SELECT *, i <=> 1::float8 FROM test_float8 WHERE i<1::float8 ORDER BY i <=> 1::float8;
66+
QUERY PLAN
67+
--------------------------------------------
68+
Index Scan using idx_float8 on test_float8
69+
Index Cond: (i < '1'::double precision)
70+
Order By: (i <=> '1'::double precision)
71+
(3 rows)
72+
73+
SELECT *, i <=> 1::float8 FROM test_float8 WHERE i<1::float8 ORDER BY i <=> 1::float8;
74+
i | ?column?
75+
----+----------
76+
0 | 1
77+
-1 | 2
78+
-2 | 3
79+
(3 rows)
80+

expected/int2.out

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,39 @@ SELECT * FROM test_int2 WHERE i>1::int2 ORDER BY i;
4242
3
4343
(2 rows)
4444

45+
EXPLAIN (costs off)
46+
SELECT *, i <=> 0::int2 FROM test_int2 ORDER BY i <=> 0::int2;
47+
QUERY PLAN
48+
----------------------------------------
49+
Index Scan using idx_int2 on test_int2
50+
Order By: (i <=> '0'::smallint)
51+
(2 rows)
52+
53+
SELECT *, i <=> 0::int2 FROM test_int2 ORDER BY i <=> 0::int2;
54+
i | ?column?
55+
----+----------
56+
0 | 0
57+
-1 | 1
58+
1 | 1
59+
-2 | 2
60+
2 | 2
61+
3 | 3
62+
(6 rows)
63+
64+
EXPLAIN (costs off)
65+
SELECT *, i <=> 1::int2 FROM test_int2 WHERE i<1::int2 ORDER BY i <=> 1::int2;
66+
QUERY PLAN
67+
----------------------------------------
68+
Index Scan using idx_int2 on test_int2
69+
Index Cond: (i < '1'::smallint)
70+
Order By: (i <=> '1'::smallint)
71+
(3 rows)
72+
73+
SELECT *, i <=> 1::int2 FROM test_int2 WHERE i<1::int2 ORDER BY i <=> 1::int2;
74+
i | ?column?
75+
----+----------
76+
0 | 1
77+
-1 | 2
78+
-2 | 3
79+
(3 rows)
80+

expected/int4.out

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,42 @@ SELECT * FROM test_int4 WHERE i>1::int4 ORDER BY i;
4242
3
4343
(2 rows)
4444

45+
EXPLAIN (costs off)
46+
SELECT *, i <=> 0::int4 FROM test_int4 ORDER BY i <=> 0::int4;
47+
QUERY PLAN
48+
----------------------------------------
49+
Index Scan using idx_int4 on test_int4
50+
Order By: (i <=> 0)
51+
(2 rows)
52+
53+
SELECT *, i <=> 0::int4 FROM test_int4 ORDER BY i <=> 0::int4;
54+
i | ?column?
55+
----+----------
56+
0 | 0
57+
-1 | 1
58+
1 | 1
59+
-2 | 2
60+
2 | 2
61+
3 | 3
62+
(6 rows)
63+
64+
EXPLAIN (costs off)
65+
SELECT *, i <=> 1::int4 FROM test_int4 WHERE i<1::int4 ORDER BY i <=> 1::int4;
66+
QUERY PLAN
67+
----------------------------------------
68+
Index Scan using idx_int4 on test_int4
69+
Index Cond: (i < 1)
70+
Order By: (i <=> 1)
71+
(3 rows)
72+
73+
SELECT *, i <=> 1::int4 FROM test_int4 WHERE i<1::int4 ORDER BY i <=> 1::int4;
74+
i | ?column?
75+
----+----------
76+
0 | 1
77+
-1 | 2
78+
-2 | 3
79+
(3 rows)
80+
4581
CREATE TABLE test_int4_o AS SELECT id::int4, t FROM tsts;
4682
CREATE INDEX test_int4_o_idx ON test_int4_o USING rum
4783
(t rum_tsvector_addon_ops, id)
@@ -648,3 +684,30 @@ SELECT id FROM test_int4_h_a WHERE t @@ 'wr&qh' AND id >= 400 ORDER BY id;
648684
496
649685
(7 rows)
650686

687+
CREATE TABLE test_int4_id_t AS SELECT id::int4, t FROM tsts;
688+
CREATE INDEX test_int4_id_t_idx ON test_int4_o USING rum
689+
(t rum_tsvector_ops, id);
690+
EXPLAIN (costs off)
691+
SELECT id FROM test_int4_h_a WHERE t @@ 'wr&qh' AND id <= 400::int4 ORDER BY id <=> 400::int4;
692+
QUERY PLAN
693+
-------------------------------------------------------------------
694+
Index Scan using test_int4_h_a_idx on test_int4_h_a
695+
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= 400))
696+
Order By: (id <=> 400)
697+
(3 rows)
698+
699+
SELECT id FROM test_int4_h_a WHERE t @@ 'wr&qh' AND id <= 400::int4 ORDER BY id <=> 400::int4;
700+
id
701+
-----
702+
371
703+
355
704+
354
705+
252
706+
232
707+
168
708+
135
709+
71
710+
39
711+
16
712+
(10 rows)
713+

expected/int8.out

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,42 @@ SELECT * FROM test_int8 WHERE i>1::int8 ORDER BY i;
4242
3
4343
(2 rows)
4444

45+
EXPLAIN (costs off)
46+
SELECT *, i <=> 0::int8 FROM test_int8 ORDER BY i <=> 0::int8;
47+
QUERY PLAN
48+
----------------------------------------
49+
Index Scan using idx_int8 on test_int8
50+
Order By: (i <=> '0'::bigint)
51+
(2 rows)
52+
53+
SELECT *, i <=> 0::int8 FROM test_int8 ORDER BY i <=> 0::int8;
54+
i | ?column?
55+
----+----------
56+
0 | 0
57+
-1 | 1
58+
1 | 1
59+
-2 | 2
60+
2 | 2
61+
3 | 3
62+
(6 rows)
63+
64+
EXPLAIN (costs off)
65+
SELECT *, i <=> 1::int8 FROM test_int8 WHERE i<1::int8 ORDER BY i <=> 1::int8;
66+
QUERY PLAN
67+
----------------------------------------
68+
Index Scan using idx_int8 on test_int8
69+
Index Cond: (i < '1'::bigint)
70+
Order By: (i <=> '1'::bigint)
71+
(3 rows)
72+
73+
SELECT *, i <=> 1::int8 FROM test_int8 WHERE i<1::int8 ORDER BY i <=> 1::int8;
74+
i | ?column?
75+
----+----------
76+
0 | 1
77+
-1 | 2
78+
-2 | 3
79+
(3 rows)
80+
4581
CREATE TABLE test_int8_o AS SELECT id::int8, t FROM tsts;
4682
CREATE INDEX test_int8_o_idx ON test_int8_o USING rum
4783
(t rum_tsvector_addon_ops, id)
@@ -648,3 +684,30 @@ SELECT id FROM test_int8_h_a WHERE t @@ 'wr&qh' AND id >= 400::int8 ORDER BY id
648684
496
649685
(7 rows)
650686

687+
CREATE TABLE test_int8_id_t AS SELECT id::int8, t FROM tsts;
688+
CREATE INDEX test_int8_id_t_idx ON test_int8_o USING rum
689+
(t rum_tsvector_ops, id);
690+
EXPLAIN (costs off)
691+
SELECT id FROM test_int8_h_a WHERE t @@ 'wr&qh' AND id <= 400::int8 ORDER BY id <=> 400::int8;
692+
QUERY PLAN
693+
-----------------------------------------------------------------------------
694+
Index Scan using test_int8_h_a_idx on test_int8_h_a
695+
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::bigint))
696+
Order By: (id <=> '400'::bigint)
697+
(3 rows)
698+
699+
SELECT id FROM test_int8_h_a WHERE t @@ 'wr&qh' AND id <= 400::int8 ORDER BY id <=> 400::int8;
700+
id
701+
-----
702+
371
703+
355
704+
354
705+
252
706+
232
707+
168
708+
135
709+
71
710+
39
711+
16
712+
(10 rows)
713+

expected/money.out

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,39 @@ SELECT * FROM test_money WHERE i>'1'::money ORDER BY i;
4242
$3.00
4343
(2 rows)
4444

45+
EXPLAIN (costs off)
46+
SELECT *, i <=> 0::money FROM test_money ORDER BY i <=> 0::money;
47+
QUERY PLAN
48+
------------------------------------------
49+
Index Scan using idx_money on test_money
50+
Order By: (i <=> (0)::money)
51+
(2 rows)
52+
53+
SELECT *, i <=> 0::money FROM test_money ORDER BY i <=> 0::money;
54+
i | ?column?
55+
--------+----------
56+
$0.00 | 0
57+
-$1.00 | 100
58+
$1.00 | 100
59+
-$2.00 | 200
60+
$2.00 | 200
61+
$3.00 | 300
62+
(6 rows)
63+
64+
EXPLAIN (costs off)
65+
SELECT *, i <=> 1::money FROM test_money WHERE i<1::money ORDER BY i <=> 1::money;
66+
QUERY PLAN
67+
------------------------------------------
68+
Index Scan using idx_money on test_money
69+
Index Cond: (i < (1)::money)
70+
Order By: (i <=> (1)::money)
71+
(3 rows)
72+
73+
SELECT *, i <=> 1::money FROM test_money WHERE i<1::money ORDER BY i <=> 1::money;
74+
i | ?column?
75+
--------+----------
76+
$0.00 | 100
77+
-$1.00 | 200
78+
-$2.00 | 300
79+
(3 rows)
80+

expected/oid.out

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,37 @@ SELECT * FROM test_oid WHERE i>3::oid ORDER BY i;
4242
5
4343
(2 rows)
4444

45+
EXPLAIN (costs off)
46+
SELECT *, i <=> 0::oid FROM test_oid ORDER BY i <=> 0::oid;
47+
QUERY PLAN
48+
--------------------------------------
49+
Index Scan using idx_oid on test_oid
50+
Order By: (i <=> '0'::oid)
51+
(2 rows)
52+
53+
SELECT *, i <=> 0::oid FROM test_oid ORDER BY i <=> 0::oid;
54+
i | ?column?
55+
---+----------
56+
0 | 0
57+
1 | 1
58+
2 | 2
59+
3 | 3
60+
4 | 4
61+
5 | 5
62+
(6 rows)
63+
64+
EXPLAIN (costs off)
65+
SELECT *, i <=> 1::oid FROM test_oid WHERE i<1::oid ORDER BY i <=> 1::oid;
66+
QUERY PLAN
67+
--------------------------------------
68+
Index Scan using idx_oid on test_oid
69+
Index Cond: (i < '1'::oid)
70+
Order By: (i <=> '1'::oid)
71+
(3 rows)
72+
73+
SELECT *, i <=> 1::oid FROM test_oid WHERE i<1::oid ORDER BY i <=> 1::oid;
74+
i | ?column?
75+
---+----------
76+
0 | 1
77+
(1 row)
78+

gen_rum_sql--1.0--1.1.pl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@
262262
##############Generate!!!
263263

264264
print <<EOT;
265+
/*
266+
* RUM version 1.1
267+
*/
268+
265269
CREATE FUNCTION rum_btree_consistent(internal,smallint,internal,int,internal,internal,internal,internal)
266270
RETURNS bool
267271
AS 'MODULE_PATHNAME'

0 commit comments

Comments
 (0)