@@ -5,7 +5,7 @@ $$ LANGUAGE sql;
55-- empty table index should be valid
66CREATE TABLE brintest (a bigint) WITH (fillfactor = 10);
77CREATE INDEX brintest_idx ON brintest USING brin (a);
8- SELECT brin_index_check('brintest_idx', true);
8+ SELECT brin_index_check('brintest_idx', true, true );
99 brin_index_check
1010------------------
1111
@@ -19,7 +19,7 @@ CREATE INDEX brintest_idx ON brintest USING brin (a int8_minmax_ops) WITH (pages
1919INSERT INTO brintest (a) SELECT x FROM generate_series(1,100000) x;
2020-- create some empty ranges
2121DELETE FROM brintest WHERE a > 20000 AND a < 40000;
22- SELECT brin_index_check('brintest_idx', true);
22+ SELECT brin_index_check('brintest_idx', true, true );
2323 brin_index_check
2424------------------
2525
@@ -28,7 +28,7 @@ SELECT brin_index_check('brintest_idx', true);
2828-- rebuild index
2929DROP INDEX brintest_idx;
3030CREATE INDEX brintest_idx ON brintest USING brin (a int8_minmax_ops) WITH (pages_per_range = 2);
31- SELECT brin_index_check('brintest_idx', true);
31+ SELECT brin_index_check('brintest_idx', true, true );
3232 brin_index_check
3333------------------
3434
@@ -42,7 +42,7 @@ CREATE INDEX brintest_idx ON brintest USING brin (a int8_minmax_multi_ops) WITH
4242INSERT INTO brintest (a) SELECT x FROM generate_series(1,100000) x;
4343-- create some empty ranges
4444DELETE FROM brintest WHERE a > 20000 AND a < 40000;
45- SELECT brin_index_check('brintest_idx', true);
45+ SELECT brin_index_check('brintest_idx', true, true );
4646 brin_index_check
4747------------------
4848
@@ -51,7 +51,7 @@ SELECT brin_index_check('brintest_idx', true);
5151-- rebuild index
5252DROP INDEX brintest_idx;
5353CREATE INDEX brintest_idx ON brintest USING brin (a int8_minmax_multi_ops) WITH (pages_per_range = 2);
54- SELECT brin_index_check('brintest_idx', true);
54+ SELECT brin_index_check('brintest_idx', true, true );
5555 brin_index_check
5656------------------
5757
@@ -65,7 +65,7 @@ CREATE INDEX brintest_idx ON brintest USING brin (a int8_bloom_ops) WITH (pages_
6565INSERT INTO brintest (a) SELECT x FROM generate_series(1,100000) x;
6666-- create some empty ranges
6767DELETE FROM brintest WHERE a > 20000 AND a < 40000;
68- SELECT brin_index_check('brintest_idx', true);
68+ SELECT brin_index_check('brintest_idx', true, true );
6969 brin_index_check
7070------------------
7171
@@ -74,7 +74,7 @@ SELECT brin_index_check('brintest_idx', true);
7474-- rebuild index
7575DROP INDEX brintest_idx;
7676CREATE INDEX brintest_idx ON brintest USING brin (a int8_bloom_ops) WITH (pages_per_range = 2);
77- SELECT brin_index_check('brintest_idx', true);
77+ SELECT brin_index_check('brintest_idx', true, true );
7878 brin_index_check
7979------------------
8080
@@ -90,7 +90,7 @@ SELECT box(point(random() * 1000, random() * 1000), point(random() * 1000, rando
9090FROM generate_series(1, 10000);
9191-- create some empty ranges
9292DELETE FROM brintest WHERE id > 2000 AND id < 4000;
93- SELECT brin_index_check('brintest_idx', true);
93+ SELECT brin_index_check('brintest_idx', true, true, '@>' );
9494 brin_index_check
9595------------------
9696
@@ -99,7 +99,7 @@ SELECT brin_index_check('brintest_idx', true);
9999-- rebuild index
100100DROP INDEX brintest_idx;
101101CREATE INDEX brintest_idx ON brintest USING brin (a box_inclusion_ops) WITH (pages_per_range = 2);
102- SELECT brin_index_check('brintest_idx', true);
102+ SELECT brin_index_check('brintest_idx', true, true, '@>' );
103103 brin_index_check
104104------------------
105105
@@ -113,7 +113,7 @@ CREATE INDEX brintest_idx ON brintest USING brin (id int8_minmax_ops, a text_min
113113INSERT INTO brintest (a) SELECT random_string((x % 100)) FROM generate_series(1,3000) x;
114114-- create some empty ranges
115115DELETE FROM brintest WHERE id > 1500 AND id < 2500;
116- SELECT brin_index_check('brintest_idx', true);
116+ SELECT brin_index_check('brintest_idx', true, true );
117117 brin_index_check
118118------------------
119119
@@ -122,12 +122,50 @@ SELECT brin_index_check('brintest_idx', true);
122122-- rebuild index
123123DROP INDEX brintest_idx;
124124CREATE INDEX brintest_idx ON brintest USING brin (id int8_minmax_ops, a text_minmax_ops) WITH (pages_per_range = 2);
125- SELECT brin_index_check('brintest_idx', true);
125+ SELECT brin_index_check('brintest_idx', true, true );
126126 brin_index_check
127127------------------
128128
129129(1 row)
130130
131+ -- cleanup
132+ DROP TABLE brintest;
133+ -- multiple attributes test with custom operators
134+ CREATE TABLE brintest (id bigserial, a text, b box) WITH (fillfactor = 10);
135+ CREATE INDEX brintest_idx ON brintest USING brin (id int8_minmax_ops, a text_minmax_ops, b box_inclusion_ops) WITH (pages_per_range = 2);
136+ INSERT INTO brintest (a, b) SELECT
137+ random_string((x % 100)),
138+ box(point(random() * 1000, random() * 1000), point(random() * 1000, random() * 1000))
139+ FROM generate_series(1, 3000) x;
140+ -- create some empty ranges
141+ DELETE FROM brintest WHERE id > 1500 AND id < 2500;
142+ SELECT brin_index_check('brintest_idx', true, true, '=', '=', '@>');
143+ brin_index_check
144+ ------------------
145+
146+ (1 row)
147+
148+ -- rebuild index
149+ DROP INDEX brintest_idx;
150+ CREATE INDEX brintest_idx ON brintest USING brin (id int8_minmax_ops, a text_minmax_ops, b box_inclusion_ops) WITH (pages_per_range = 2);
151+ SELECT brin_index_check('brintest_idx', true, true, '=', '=', '@>');
152+ brin_index_check
153+ ------------------
154+
155+ (1 row)
156+
157+ -- error if it's impossible to use default operator for all index attributes
158+ SELECT brin_index_check('brintest_idx', true, true);
159+ ERROR: Operator = is not a member of operator family "box_inclusion_ops"
160+ -- error if number of operators in input doesn't match index attributes number
161+ SELECT brin_index_check('brintest_idx', true, true, '=');
162+ ERROR: Number of operator names in input (1) doesn't match index attributes number (3)
163+ -- error if operator name is NULL
164+ SELECT brin_index_check('brintest_idx', true, true, '=', '=', NULL);
165+ ERROR: Operator name must not be NULL
166+ -- error if there is no operator for attribute type
167+ SELECT brin_index_check('brintest_idx', true, true, '=', '=', '@@');
168+ ERROR: There is no operator @@ for type "box"
131169-- cleanup
132170DROP TABLE brintest;
133171-- cleanup
0 commit comments