diff --git a/.travis.yml b/.travis.yml index 7c635e8074..0c21a422c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ os: linux -dist: bionic +dist: jammy language: c @@ -23,6 +23,8 @@ notifications: on_failure: always env: + - PG_VERSION=17 + - PG_VERSION=17 LEVEL=hardcore - PG_VERSION=16 - PG_VERSION=16 LEVEL=hardcore - PG_VERSION=15 diff --git a/LICENSE b/LICENSE index 5b55f87617..a51596793f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ RUM is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses. -Portions Copyright (c) 2015-2019, Postgres Professional +Portions Copyright (c) 2015-2024, Postgres Professional Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group Portions Copyright (c) 1994, The Regents of the University of California diff --git a/Makefile b/Makefile index cbf846293e..61674c812e 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ TAP_TESTS = 1 ISOLATION = predicate-rum predicate-rum-2 ISOLATION_OPTS = --load-extension=rum +EXTRA_CLEAN = pglist_tmp ifdef USE_PGXS PG_CONFIG = pg_config diff --git a/README.md b/README.md index 5f3e6887cf..b6fb08420c 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,26 @@ Typical installation procedure may look like this: > **Important:** Don't forget to set the `PG_CONFIG` variable in case you want to test `RUM` on a custom build of PostgreSQL. Read more [here](https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules). +## Tests + +$ make check + +This command runs: +- regression tests; +- isolation tests; +- tap tests. + + One of the tap tests downloads a 1GB archive and then unpacks it + into a file weighing almost 3GB. It is disabled by default. + + To run this test, you need to set an environment variable: + + $ export PG_TEST_EXTRA=big_values + + The way to turn it off again: + + $ export -n PG_TEST_EXTRA + ## Common operators and functions The **rum** module provides next operators. diff --git a/expected/altorder.out b/expected/altorder.out index dcf5a51954..6c0bcae2ad 100644 --- a/expected/altorder.out +++ b/expected/altorder.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * altorder.out - test output for 64-bit systems and + * altorder_1.out - test output for 32-bit systems. + * + */ CREATE TABLE atsts (id int, t tsvector, d timestamp); \copy atsts from 'data/tsts.data' -- PGPRO-2537: We need more data to test rumsort.c with logtape.c diff --git a/expected/altorder_1.out b/expected/altorder_1.out index 2fb7f52326..980515f58e 100644 --- a/expected/altorder_1.out +++ b/expected/altorder_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * altorder.out - test output for 64-bit systems and + * altorder_1.out - test output for 32-bit systems. + * + */ CREATE TABLE atsts (id int, t tsvector, d timestamp); \copy atsts from 'data/tsts.data' -- PGPRO-2537: We need more data to test rumsort.c with logtape.c diff --git a/expected/altorder_hash.out b/expected/altorder_hash.out index 125c195be9..1011b90d0c 100644 --- a/expected/altorder_hash.out +++ b/expected/altorder_hash.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * altorder_hash.out - test output for 64-bit systems and + * altorder_hash_1.out - test output for 32-bit systems. + * + */ CREATE TABLE atstsh (id int, t tsvector, d timestamp); \copy atstsh from 'data/tsts.data' CREATE INDEX atstsh_idx ON atstsh USING rum (t rum_tsvector_hash_addon_ops, d) diff --git a/expected/altorder_hash_1.out b/expected/altorder_hash_1.out index 2d93f3f5eb..e310fbdb89 100644 --- a/expected/altorder_hash_1.out +++ b/expected/altorder_hash_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * altorder_hash.out - test output for 64-bit systems and + * altorder_hash_1.out - test output for 32-bit systems. + * + */ CREATE TABLE atstsh (id int, t tsvector, d timestamp); \copy atstsh from 'data/tsts.data' CREATE INDEX atstsh_idx ON atstsh USING rum (t rum_tsvector_hash_addon_ops, d) diff --git a/expected/array.out b/expected/array.out index 4094d98492..a2fb3bb8df 100644 --- a/expected/array.out +++ b/expected/array.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * array.out - test output for 64-bit systems and + * array_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; set enable_sort=off; /* @@ -843,41 +852,71 @@ EXPLAIN (COSTS OFF) SELECT * FROM test_array WHERE i % '{}'; DROP INDEX idx_array; /* * Check ordering using distance operator + * + * We want to check that index scan provides us correct ordering by distance + * operator. File 'data/rum_array.data' contains two arrays that statisfy + * i @> '{23,20}' and have finite distance i <=> '{51}', and a bunch of arrays + * that statisfy i @> '{23,20}' and have infinite distance i <=> '{51}'. + * + * When ordering by distance the order of this bunch of arrays with infinite + * distance is not determined and may depend of PostgreSQL version and system. + * We don't add another sort expression to ORDER BY because that might cause + * the planner to avoid using the index. Instead, we replace arrays that have + * infinite distance with {-1} to unambiguously determine the test output. + * + * 'Infinity' is printed differently in the output in different PostgreSQL + * versions, so we replace it with -1. */ CREATE TABLE test_array_order ( i int2[] ); \copy test_array_order(i) from 'data/rum_array.data'; CREATE INDEX idx_array_order ON test_array_order USING rum (i rum_anyarray_ops); +/* + * Check that plan of the query uses ordering provided by index scan + */ EXPLAIN (COSTS OFF) -SELECT *, i <=> '{51}' from test_array_order WHERE i @> '{23,20}' order by i <=> '{51}'; - QUERY PLAN ------------------------------------------------------- - Index Scan using idx_array_order on test_array_order - Index Cond: (i @> '{23,20}'::smallint[]) - Order By: (i <=> '{51}'::smallint[]) -(3 rows) +SELECT + CASE WHEN distance = 'Infinity' THEN '{-1}' + ELSE i + END i, + CASE WHEN distance = 'Infinity' THEN -1 + ELSE distance::numeric(18,14) + END distance + FROM + (SELECT *, (i <=> '{51}') AS distance + FROM test_array_order WHERE i @> '{23,20}' ORDER BY distance) t; + QUERY PLAN +------------------------------------------------------------ + Subquery Scan on t + -> Index Scan using idx_array_order on test_array_order + Index Cond: (i @> '{23,20}'::smallint[]) + Order By: (i <=> '{51}'::smallint[]) +(4 rows) -SELECT i, +SELECT + CASE WHEN distance = 'Infinity' THEN '{-1}' + ELSE i + END i, CASE WHEN distance = 'Infinity' THEN -1 ELSE distance::numeric(18,14) END distance FROM (SELECT *, (i <=> '{51}') AS distance - FROM test_array_order WHERE i @> '{23,20}' ORDER BY i <=> '{51}') t; + FROM test_array_order WHERE i @> '{23,20}' ORDER BY distance) t; i | distance ---------------------+------------------ {20,23,51} | 1.73205080756888 {33,51,20,77,23,65} | 2.44948974278318 - {23,76,34,23,2,20} | -1 - {20,60,45,23,29} | -1 - {23,89,38,20,40,95} | -1 - {23,20,72} | -1 - {73,23,20} | -1 - {6,97,20,89,23} | -1 - {20,98,30,23,1,66} | -1 - {57,23,39,46,50,20} | -1 - {81,20,26,22,23} | -1 - {18,23,10,90,15,20} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 (12 rows) diff --git a/expected/array_1.out b/expected/array_1.out index ec3abfb693..cc5f93307c 100644 --- a/expected/array_1.out +++ b/expected/array_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * array.out - test output for 64-bit systems and + * array_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; set enable_sort=off; /* @@ -836,41 +845,71 @@ EXPLAIN (COSTS OFF) SELECT * FROM test_array WHERE i % '{}'; DROP INDEX idx_array; /* * Check ordering using distance operator + * + * We want to check that index scan provides us correct ordering by distance + * operator. File 'data/rum_array.data' contains two arrays that statisfy + * i @> '{23,20}' and have finite distance i <=> '{51}', and a bunch of arrays + * that statisfy i @> '{23,20}' and have infinite distance i <=> '{51}'. + * + * When ordering by distance the order of this bunch of arrays with infinite + * distance is not determined and may depend of PostgreSQL version and system. + * We don't add another sort expression to ORDER BY because that might cause + * the planner to avoid using the index. Instead, we replace arrays that have + * infinite distance with {-1} to unambiguously determine the test output. + * + * 'Infinity' is printed differently in the output in different PostgreSQL + * versions, so we replace it with -1. */ CREATE TABLE test_array_order ( i int2[] ); \copy test_array_order(i) from 'data/rum_array.data'; CREATE INDEX idx_array_order ON test_array_order USING rum (i rum_anyarray_ops); +/* + * Check that plan of the query uses ordering provided by index scan + */ EXPLAIN (COSTS OFF) -SELECT *, i <=> '{51}' from test_array_order WHERE i @> '{23,20}' order by i <=> '{51}'; - QUERY PLAN ------------------------------------------------------- - Index Scan using idx_array_order on test_array_order - Index Cond: (i @> '{23,20}'::smallint[]) - Order By: (i <=> '{51}'::smallint[]) -(3 rows) +SELECT + CASE WHEN distance = 'Infinity' THEN '{-1}' + ELSE i + END i, + CASE WHEN distance = 'Infinity' THEN -1 + ELSE distance::numeric(18,14) + END distance + FROM + (SELECT *, (i <=> '{51}') AS distance + FROM test_array_order WHERE i @> '{23,20}' ORDER BY distance) t; + QUERY PLAN +------------------------------------------------------------ + Subquery Scan on t + -> Index Scan using idx_array_order on test_array_order + Index Cond: (i @> '{23,20}'::smallint[]) + Order By: (i <=> '{51}'::smallint[]) +(4 rows) -SELECT i, +SELECT + CASE WHEN distance = 'Infinity' THEN '{-1}' + ELSE i + END i, CASE WHEN distance = 'Infinity' THEN -1 ELSE distance::numeric(18,14) END distance FROM (SELECT *, (i <=> '{51}') AS distance - FROM test_array_order WHERE i @> '{23,20}' ORDER BY i <=> '{51}') t; + FROM test_array_order WHERE i @> '{23,20}' ORDER BY distance) t; i | distance ---------------------+------------------ {20,23,51} | 1.73205080756888 {33,51,20,77,23,65} | 2.44948974278318 - {23,76,34,23,2,20} | -1 - {20,60,45,23,29} | -1 - {23,89,38,20,40,95} | -1 - {23,20,72} | -1 - {73,23,20} | -1 - {6,97,20,89,23} | -1 - {20,98,30,23,1,66} | -1 - {57,23,39,46,50,20} | -1 - {81,20,26,22,23} | -1 - {18,23,10,90,15,20} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 + {-1} | -1 (12 rows) diff --git a/expected/float8.out b/expected/float8.out index e96cb0ea54..fdca51343a 100644 --- a/expected/float8.out +++ b/expected/float8.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * float8.out - test output for 64-bit systems and + * float8_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; CREATE TABLE test_float8 ( i float8 diff --git a/expected/float8_1.out b/expected/float8_1.out index dabdd51964..b421dcf311 100644 --- a/expected/float8_1.out +++ b/expected/float8_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * float8.out - test output for 64-bit systems and + * float8_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; CREATE TABLE test_float8 ( i float8 diff --git a/expected/int8.out b/expected/int8.out index 62e4f80a37..663162a18e 100644 --- a/expected/int8.out +++ b/expected/int8.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * int8.out - test output for 64-bit systems and + * int8_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; CREATE TABLE test_int8 ( i int8 diff --git a/expected/int8_1.out b/expected/int8_1.out index cbf68dff13..ffced0aaf8 100644 --- a/expected/int8_1.out +++ b/expected/int8_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * int8.out - test output for 64-bit systems and + * int8_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; CREATE TABLE test_int8 ( i int8 diff --git a/expected/money.out b/expected/money.out index 7b9b20580e..b2e9bac41d 100644 --- a/expected/money.out +++ b/expected/money.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * money.out - test output for 64-bit systems and + * money_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; CREATE TABLE test_money ( i money diff --git a/expected/money_1.out b/expected/money_1.out index b8ec0ec5c7..6a3fa8c211 100644 --- a/expected/money_1.out +++ b/expected/money_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * money.out - test output for 64-bit systems and + * money_1.out - test output for 32-bit systems. + * + */ set enable_seqscan=off; CREATE TABLE test_money ( i money diff --git a/expected/orderby.out b/expected/orderby.out index 9bc421970c..07ae7322ed 100644 --- a/expected/orderby.out +++ b/expected/orderby.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * orderby.out - test output for 64-bit systems and + * orderby_1.out - test output for 32-bit systems. + * + */ CREATE TABLE tsts (id int, t tsvector, d timestamp); \copy tsts from 'data/tsts.data' CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d) @@ -460,6 +469,11 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER 458 | Fri May 20 21:21:22.326724 2016 (3 rows) +-- Test "ORDER BY" error message +DROP INDEX tsts_idx; +CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d); +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; +ERROR: cannot order without attribute 2 in ORDER BY clause -- Test multicolumn index RESET enable_indexscan; RESET enable_indexonlyscan; diff --git a/expected/orderby_1.out b/expected/orderby_1.out index a6fb68c1e3..cdd536ac9d 100644 --- a/expected/orderby_1.out +++ b/expected/orderby_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * orderby.out - test output for 64-bit systems and + * orderby_1.out - test output for 32-bit systems. + * + */ CREATE TABLE tsts (id int, t tsvector, d timestamp); \copy tsts from 'data/tsts.data' CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d) @@ -420,6 +429,11 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER 458 | Fri May 20 21:21:22.326724 2016 (3 rows) +-- Test "ORDER BY" error message +DROP INDEX tsts_idx; +CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d); +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; +ERROR: doesn't support order by over pass-by-reference column -- Test multicolumn index RESET enable_indexscan; RESET enable_indexonlyscan; diff --git a/expected/orderby_hash.out b/expected/orderby_hash.out index 7ff1794c5f..782ad5700e 100644 --- a/expected/orderby_hash.out +++ b/expected/orderby_hash.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * orderby_hash.out - test output for 64-bit systems and + * orderby_hash_1.out - test output for 32-bit systems. + * + */ CREATE TABLE tstsh (id int, t tsvector, d timestamp); \copy tstsh from 'data/tsts.data' CREATE INDEX tstsh_idx ON tstsh USING rum (t rum_tsvector_hash_addon_ops, d) diff --git a/expected/orderby_hash_1.out b/expected/orderby_hash_1.out index f32267631c..f19e4507c7 100644 --- a/expected/orderby_hash_1.out +++ b/expected/orderby_hash_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * orderby_hash.out - test output for 64-bit systems and + * orderby_hash_1.out - test output for 32-bit systems. + * + */ CREATE TABLE tstsh (id int, t tsvector, d timestamp); \copy tstsh from 'data/tsts.data' CREATE INDEX tstsh_idx ON tstsh USING rum (t rum_tsvector_hash_addon_ops, d) diff --git a/expected/timestamp.out b/expected/timestamp.out index 37f26f073f..00969a7534 100644 --- a/expected/timestamp.out +++ b/expected/timestamp.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * timestamp.out - test output for 64-bit systems and + * timestamp_1.out - test output for 32-bit systems. + * + */ CREATE TABLE test_timestamp ( i timestamp ); diff --git a/expected/timestamp_1.out b/expected/timestamp_1.out index e15bcc7584..a8641a3232 100644 --- a/expected/timestamp_1.out +++ b/expected/timestamp_1.out @@ -1,3 +1,12 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * timestamp.out - test output for 64-bit systems and + * timestamp_1.out - test output for 32-bit systems. + * + */ CREATE TABLE test_timestamp ( i timestamp ); diff --git a/sql/altorder.sql b/sql/altorder.sql index bc89f8fc06..850e252325 100644 --- a/sql/altorder.sql +++ b/sql/altorder.sql @@ -1,3 +1,14 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * altorder.out - test output for 64-bit systems and + * altorder_1.out - test output for 32-bit systems. + * + */ + + CREATE TABLE atsts (id int, t tsvector, d timestamp); \copy atsts from 'data/tsts.data' diff --git a/sql/altorder_hash.sql b/sql/altorder_hash.sql index 3b723876f9..148407c661 100644 --- a/sql/altorder_hash.sql +++ b/sql/altorder_hash.sql @@ -1,3 +1,14 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * altorder_hash.out - test output for 64-bit systems and + * altorder_hash_1.out - test output for 32-bit systems. + * + */ + + CREATE TABLE atstsh (id int, t tsvector, d timestamp); \copy atstsh from 'data/tsts.data' diff --git a/sql/array.sql b/sql/array.sql index 11defc9e07..9eba800bcf 100644 --- a/sql/array.sql +++ b/sql/array.sql @@ -1,7 +1,17 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * array.out - test output for 64-bit systems and + * array_1.out - test output for 32-bit systems. + * + */ + + set enable_seqscan=off; set enable_sort=off; - /* * Complete checks for int2[]. */ @@ -199,6 +209,20 @@ DROP INDEX idx_array; /* * Check ordering using distance operator + * + * We want to check that index scan provides us correct ordering by distance + * operator. File 'data/rum_array.data' contains two arrays that statisfy + * i @> '{23,20}' and have finite distance i <=> '{51}', and a bunch of arrays + * that statisfy i @> '{23,20}' and have infinite distance i <=> '{51}'. + * + * When ordering by distance the order of this bunch of arrays with infinite + * distance is not determined and may depend of PostgreSQL version and system. + * We don't add another sort expression to ORDER BY because that might cause + * the planner to avoid using the index. Instead, we replace arrays that have + * infinite distance with {-1} to unambiguously determine the test output. + * + * 'Infinity' is printed differently in the output in different PostgreSQL + * versions, so we replace it with -1. */ CREATE TABLE test_array_order ( @@ -208,12 +232,29 @@ CREATE TABLE test_array_order ( CREATE INDEX idx_array_order ON test_array_order USING rum (i rum_anyarray_ops); +/* + * Check that plan of the query uses ordering provided by index scan + */ + EXPLAIN (COSTS OFF) -SELECT *, i <=> '{51}' from test_array_order WHERE i @> '{23,20}' order by i <=> '{51}'; -SELECT i, +SELECT + CASE WHEN distance = 'Infinity' THEN '{-1}' + ELSE i + END i, + CASE WHEN distance = 'Infinity' THEN -1 + ELSE distance::numeric(18,14) + END distance + FROM + (SELECT *, (i <=> '{51}') AS distance + FROM test_array_order WHERE i @> '{23,20}' ORDER BY distance) t; + +SELECT + CASE WHEN distance = 'Infinity' THEN '{-1}' + ELSE i + END i, CASE WHEN distance = 'Infinity' THEN -1 ELSE distance::numeric(18,14) END distance FROM (SELECT *, (i <=> '{51}') AS distance - FROM test_array_order WHERE i @> '{23,20}' ORDER BY i <=> '{51}') t; + FROM test_array_order WHERE i @> '{23,20}' ORDER BY distance) t; diff --git a/sql/float8.sql b/sql/float8.sql index 2de5b9ea19..b61cbfb0da 100644 --- a/sql/float8.sql +++ b/sql/float8.sql @@ -1,3 +1,14 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * float8.out - test output for 64-bit systems and + * float8_1.out - test output for 32-bit systems. + * + */ + + set enable_seqscan=off; CREATE TABLE test_float8 ( diff --git a/sql/int8.sql b/sql/int8.sql index 4ec9bf0abf..c51705e62b 100644 --- a/sql/int8.sql +++ b/sql/int8.sql @@ -1,3 +1,14 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * int8.out - test output for 64-bit systems and + * int8_1.out - test output for 32-bit systems. + * + */ + + set enable_seqscan=off; CREATE TABLE test_int8 ( diff --git a/sql/money.sql b/sql/money.sql index 952d2bc8fe..13df5ed260 100644 --- a/sql/money.sql +++ b/sql/money.sql @@ -1,3 +1,14 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * money.out - test output for 64-bit systems and + * money_1.out - test output for 32-bit systems. + * + */ + + set enable_seqscan=off; CREATE TABLE test_money ( diff --git a/sql/orderby.sql b/sql/orderby.sql index 28e5b6038b..a2bd227873 100644 --- a/sql/orderby.sql +++ b/sql/orderby.sql @@ -1,3 +1,14 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * orderby.out - test output for 64-bit systems and + * orderby_1.out - test output for 32-bit systems. + * + */ + + CREATE TABLE tsts (id int, t tsvector, d timestamp); \copy tsts from 'data/tsts.data' @@ -95,6 +106,13 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d ASC LIMIT 3; SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d DESC LIMIT 3; +-- Test "ORDER BY" error message +DROP INDEX tsts_idx; + +CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d); + +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; + -- Test multicolumn index RESET enable_indexscan; diff --git a/sql/orderby_hash.sql b/sql/orderby_hash.sql index f7e9808538..dba8f17ca1 100644 --- a/sql/orderby_hash.sql +++ b/sql/orderby_hash.sql @@ -1,3 +1,14 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * orderby_hash.out - test output for 64-bit systems and + * orderby_hash_1.out - test output for 32-bit systems. + * + */ + + CREATE TABLE tstsh (id int, t tsvector, d timestamp); \copy tstsh from 'data/tsts.data' diff --git a/sql/timestamp.sql b/sql/timestamp.sql index 8025774b82..3386229ddc 100644 --- a/sql/timestamp.sql +++ b/sql/timestamp.sql @@ -1,3 +1,13 @@ +/* + * ------------------------------------ + * NOTE: This test behaves differenly + * ------------------------------------ + * + * timestamp.out - test output for 64-bit systems and + * timestamp_1.out - test output for 32-bit systems. + * + */ + CREATE TABLE test_timestamp ( i timestamp diff --git a/src/disable_core_macro.h b/src/disable_core_macro.h index 922ad4cf75..0d6c4a8a3b 100644 --- a/src/disable_core_macro.h +++ b/src/disable_core_macro.h @@ -3,7 +3,7 @@ * disable_core_macro.h * Support including tuplesort.c from postgresql core code. * - * Copyright (c) 2022, Postgres Professional + * Copyright (c) 2022-2024, Postgres Professional * *------------------------------------------------------------------------- */ diff --git a/src/rum.h b/src/rum.h index 7bcfa18221..2139774d08 100644 --- a/src/rum.h +++ b/src/rum.h @@ -3,7 +3,7 @@ * rum.h * Exported definitions for RUM index. * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 2006-2022, PostgreSQL Global Development Group * *------------------------------------------------------------------------- diff --git a/src/rum_arr_utils.c b/src/rum_arr_utils.c index 1ee57dbe29..d8dc00699a 100644 --- a/src/rum_arr_utils.c +++ b/src/rum_arr_utils.c @@ -3,7 +3,7 @@ * rum_arr_utils.c * various anyarray-search functions * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * *------------------------------------------------------------------------- diff --git a/src/rum_ts_utils.c b/src/rum_ts_utils.c index 3133a92c5a..d3b9c5478a 100644 --- a/src/rum_ts_utils.c +++ b/src/rum_ts_utils.c @@ -3,7 +3,7 @@ * rum_ts_utils.c * various text-search functions * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group * *------------------------------------------------------------------------- diff --git a/src/rumbtree.c b/src/rumbtree.c index f513848da4..dfe2f10c30 100644 --- a/src/rumbtree.c +++ b/src/rumbtree.c @@ -4,7 +4,7 @@ * page utilities routines for the postgres inverted index access method. * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumbulk.c b/src/rumbulk.c index ee93df9fe9..7a03bf64b4 100644 --- a/src/rumbulk.c +++ b/src/rumbulk.c @@ -4,7 +4,7 @@ * routines for fast build of inverted index * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumdatapage.c b/src/rumdatapage.c index 43fc1feb65..922bb7d19a 100644 --- a/src/rumdatapage.c +++ b/src/rumdatapage.c @@ -4,7 +4,7 @@ * page utilities routines for the postgres inverted index access method. * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumentrypage.c b/src/rumentrypage.c index 5b0139d95e..29e1dd25bb 100644 --- a/src/rumentrypage.c +++ b/src/rumentrypage.c @@ -4,7 +4,7 @@ * page utilities routines for the postgres inverted index access method. * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumget.c b/src/rumget.c index 70773ed712..ca5d83ee00 100644 --- a/src/rumget.c +++ b/src/rumget.c @@ -4,7 +4,7 @@ * fetch tuples from a RUM scan. * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/ruminsert.c b/src/ruminsert.c index e8b209dadf..255e616c99 100644 --- a/src/ruminsert.c +++ b/src/ruminsert.c @@ -4,7 +4,7 @@ * insert routines for the postgres inverted index access method. * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumscan.c b/src/rumscan.c index 42bca53822..089730fac4 100644 --- a/src/rumscan.c +++ b/src/rumscan.c @@ -4,7 +4,7 @@ * routines to manage scans of inverted index relations * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * @@ -214,7 +214,7 @@ rumFillScanKey(RumScanOpaque so, OffsetNumber attnum, } if (scanKey == NULL) - elog(ERROR, "cannot order without attribute %d in WHERE clause", + elog(ERROR, "cannot order without attribute %d in ORDER BY clause", key->attnum); else if (scanKey->nentries > 1) elog(ERROR, "scan key should contain only one value"); diff --git a/src/rumsort.c b/src/rumsort.c index b5691301c9..0c395f03e7 100644 --- a/src/rumsort.c +++ b/src/rumsort.c @@ -8,7 +8,7 @@ * src/backend/utils/sort/tuplesort.c. * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * @@ -488,11 +488,23 @@ rum_tuplesort_putrum(RumTuplesortstate *state, RumSortItem *item) { MemoryContext oldcontext; SortTuple stup; +#if PG_VERSION_NUM >= 170000 + MinimalTuple tuple = (MinimalTuple)item; + Size tuplen; + TuplesortPublic *base = TuplesortstateGetPublic((TuplesortPublic *)state); +#endif oldcontext = MemoryContextSwitchTo(rum_tuplesort_get_memorycontext(state)); copytup_rum(state, &stup, item); -#if PG_VERSION_NUM >= 160000 +#if PG_VERSION_NUM >= 170000 + /* GetMemoryChunkSpace is not supported for bump contexts */ + if (TupleSortUseBumpTupleCxt(base->sortopt)) + tuplen = MAXALIGN(tuple->t_len); + else + tuplen = GetMemoryChunkSpace(tuple); + tuplesort_puttuple_common(state, &stup, false, tuplen); +#elif PG_VERSION_NUM >= 160000 tuplesort_puttuple_common(state, &stup, false); #else puttuple_common(state, &stup); @@ -506,11 +518,23 @@ rum_tuplesort_putrumitem(RumTuplesortstate *state, RumScanItem *item) { MemoryContext oldcontext; SortTuple stup; +#if PG_VERSION_NUM >= 170000 + MinimalTuple tuple = (MinimalTuple)item; + Size tuplen; + TuplesortPublic *base = TuplesortstateGetPublic((TuplesortPublic *)state); +#endif oldcontext = MemoryContextSwitchTo(rum_tuplesort_get_memorycontext(state)); copytup_rumitem(state, &stup, item); -#if PG_VERSION_NUM >= 160000 +#if PG_VERSION_NUM >= 170000 + /* GetMemoryChunkSpace is not supported for bump contexts */ + if (TupleSortUseBumpTupleCxt(base->sortopt)) + tuplen = MAXALIGN(tuple->t_len); + else + tuplen = GetMemoryChunkSpace(tuple); + tuplesort_puttuple_common(state, &stup, false, tuplen); +#elif PG_VERSION_NUM >= 160000 tuplesort_puttuple_common(state, &stup, false); #else puttuple_common(state, &stup); diff --git a/src/rumsort.h b/src/rumsort.h index dfa5117bf1..160aa5c8da 100644 --- a/src/rumsort.h +++ b/src/rumsort.h @@ -7,7 +7,7 @@ * It contains copy of static functions from * src/backend/utils/sort/tuplesort.c. * - * Portions Copyright (c) 2015-2021, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumtsquery.c b/src/rumtsquery.c index 55cd49d19d..6c6b3c86d0 100644 --- a/src/rumtsquery.c +++ b/src/rumtsquery.c @@ -3,7 +3,7 @@ * rumtsquery.c * Inverted fulltext search: indexing tsqueries. * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * *------------------------------------------------------------------------- diff --git a/src/rumutil.c b/src/rumutil.c index 9048918d12..4a239c85c7 100644 --- a/src/rumutil.c +++ b/src/rumutil.c @@ -4,7 +4,7 @@ * utilities routines for the postgres inverted index access method. * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumvacuum.c b/src/rumvacuum.c index cce9cb09ee..fd5e4206b4 100644 --- a/src/rumvacuum.c +++ b/src/rumvacuum.c @@ -4,7 +4,7 @@ * delete & vacuum routines for the postgres RUM * * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/src/rumvalidate.c b/src/rumvalidate.c index c4e7dc145f..0adbb10ac7 100644 --- a/src/rumvalidate.c +++ b/src/rumvalidate.c @@ -3,7 +3,7 @@ * rumvalidate.c * Opclass validator for RUM. * - * Portions Copyright (c) 2015-2022, Postgres Professional + * Portions Copyright (c) 2015-2024, Postgres Professional * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * diff --git a/t/002_pglist.pl b/t/002_pglist.pl new file mode 100644 index 0000000000..7b2d76c058 --- /dev/null +++ b/t/002_pglist.pl @@ -0,0 +1,207 @@ +# Test RUM index with big base 'pglist'. +use strict; +use warnings; +use Config; +use Test::More; + +plan skip_all => 'This test requires downloading a 1GB archive. ' . + 'The unpacked file weighs almost 3GB. ' . + 'Perform only if the big_values is enabled in PG_TEST_EXTRA' + unless $ENV{PG_TEST_EXTRA} && $ENV{PG_TEST_EXTRA} =~ /\bbig_values\b/; + +plan tests => 4; + +my $node; + +# Utility function + +sub file_exists +{ + my ($file) = @_; + return -e $file; +} + +# Check the existence of the test base, install if necessary + +sub install_pglist +{ + my $dir = Cwd->getcwd; #current directory + + my %config = ( + #directory with pglist dump must be inside the current directory + pglist_tmp_dir => $dir . '/pglist_tmp/', + dump_name => 'pglist-28-04-16.dump', + dump_url => 'http://www.sai.msu.su/~megera/postgres/files/pglist-28-04-16.dump.gz', + pglist_archive => $dir . '/pglist_tmp/' . 'pglist-28-04-16.dump.gz', + ); + + my $path_to_dump = $config{pglist_tmp_dir} . $config{dump_name}; + + if (file_exists($path_to_dump)) + { + note($config{dump_name} . ' already installed'); + } + else + { + # Create folder /contrib/rum/pglist_tmp if not already exists + mkdir($config{pglist_tmp_dir}, 0700) + unless file_exists($config{pglist_tmp_dir}); + + # Download archive pglist-28-04-16.dump.gz if not already exists + unless (file_exists($config{pglist_archive})) + { + note('Downloading pglist dump in ' . $config{pglist_archive}); + + # Flag "-nv" allows us to avoid frequent messages + # about the download status in the log. + # But it can be enabled for debugging purposes. + system("wget -P $config{pglist_tmp_dir} -nv $config{dump_url}") == 0 + or die "Couldn't get archive by link: $?"; + } + + # Unzip the dump. Delete archive to save memory + system("gzip -d $config{pglist_archive}") == 0 + or die "Couldn't extract archive: $?"; + + file_exists($path_to_dump) + or die "Failed to get " . $config{dump_name}; + + note($config{dump_name} . ' is ready to use'); + } + + $node->psql("postgres", "CREATE DATABASE pglist"); + $node->psql("postgres", "CREATE ROLE oleg"); + my $command = "'" . $path_to_dump . "'"; + my $result = $node->psql("pglist", '\i ' . $command); +} + +# Tests SELECT constructions to 'pglist' base + +sub test_select +{ + note("Creating index 'rumidx_orderby_sent'"); + + $node->safe_psql("pglist", "CREATE INDEX rumidx_orderby_sent ON pglist " . + "USING rum (fts rum_tsvector_timestamp_ops, sent) " . + "WITH (attach=sent, to=fts, order_by_attach=t)"); + + note("Test ORDER BY timestamp"); + + my $result1 = $node->safe_psql("pglist", + "SELECT sent, subject FROM pglist WHERE fts @@ " . + "to_tsquery('english', 'backend <-> crushed') " . + "ORDER BY sent <=| '2016-01-01 00:01' LIMIT 5"); + + is($result1, '1999-06-02 11:52:46|Re: [HACKERS] PID of backend'); + + note("Test tsvector filter"); + + my $result2 = $node->safe_psql("pglist", + "SELECT count(*) FROM pglist " . + "WHERE fts @@ to_tsquery('english', 'tom & lane')"); + + is($result2, '222813'); + + $node->safe_psql("pglist", "DROP INDEX rumidx_orderby_sent"); +} + +sub test_order_by +{ + note("Creating index 'pglist_rum_idx'"); + + $node->safe_psql("pglist", + "CREATE INDEX pglist_rum_idx ON pglist " . + "USING rum (fts rum_tsvector_ops)"); + + note("Test ORDER BY tsvector"); + + my $result3 = $node->safe_psql("pglist", + "SELECT id FROM pglist " . + "WHERE fts @@ to_tsquery('english', 'postgres:*') " . + "ORDER BY fts <=> " . + "to_tsquery('english', 'postgres:*') LIMIT 9"); + + is((split(" ", $result3))[0], '816114'); + + # Autovacuum after large update, with active RUM index crashes postgres + note("Test Issue #19"); + + my $stderr; + $node->safe_psql("pglist", "DELETE FROM pglist WHERE id < 100000"); + $node->safe_psql("pglist", "vacuum", stderr => \$stderr); + + is($stderr, undef); + + $node->safe_psql("pglist", "DROP INDEX pglist_rum_idx"); +} + +# Start backend + +my $pg_15_modules; + +BEGIN +{ + $pg_15_modules = eval + { + require PostgreSQL::Test::Cluster; + require PostgreSQL::Test::Utils; + return 1; + }; + + unless (defined $pg_15_modules) + { + $pg_15_modules = 0; + + require PostgresNode; + require TestLib; + } +} + +note('PostgreSQL 15 modules are used: ' . ($pg_15_modules ? 'yes' : 'no')); + +if ($pg_15_modules) +{ + $node = PostgreSQL::Test::Cluster->new("master"); +} +else +{ + $node = PostgresNode::get_new_node("master"); +} + +$node->init(allows_streaming => 1); +$node->append_conf("postgresql.conf", "shared_buffers='4GB'\n" . + "maintenance_work_mem='2GB'\n" . + "max_wal_size='2GB'\n" . + "work_mem='50MB'"); +$node->start; + +# Check the existence of the pglist base + +note('Check the existence of the pglist base...'); +my $check_pglist = $node->psql('postgres', "SELECT count(*) FROM pg_database " . + "WHERE datistemplate = false AND " . + "datname = 'pglist'"); +if ($check_pglist == 1) +{ + note("pglist already exists"); +} +else +{ + note("Create pglist database"); + install_pglist(); +} + +$node->psql("pglist", "CREATE EXTENSION rum"); +note('Setup is completed successfully'); + +eval +{ + test_select(); + test_order_by(); + $node->stop(); + done_testing(); + 1; +} or do { + note('Something went wrong: $@\n'); +}; + diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 77b7d78e88..0000000000 --- a/tests/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## Running tests - -Install testgres: - -``` -pip install testgres==0.4.0 -``` - -Run command: - -``` -python -m unittest pglist_tests -``` - diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/pglist_tests.py b/tests/pglist_tests.py deleted file mode 100644 index 7b8e4558e0..0000000000 --- a/tests/pglist_tests.py +++ /dev/null @@ -1,157 +0,0 @@ -# coding: utf-8 -""" - Test RUM index with big base 'pglist' - - Copyright (c) 2015-2021, Postgres Professional -""" -import unittest -import os -import sys -import gzip -import testgres as tg - -if sys.version_info[0] < 3: - import urllib as request -else: - import urllib.request as request - -from os.path import expanduser - - -class PglistTests(unittest.TestCase): - - def setUp(self): - current_dir = os.path.dirname(os.path.abspath(__file__)) - - self.node = tg.get_new_node("pglist", - os.path.join(current_dir, "tmp_install")) - try: - self.node.init() - self.node.append_conf("postgresql.conf", - "shared_buffers='4GB'\n" - "maintenance_work_mem='2GB'\n" - "max_wal_size='2GB'\n" - "work_mem='50MB'") - self.node.start() - except Exception as e: - self.printlog(os.path.join(self.node.logs_dir, "postgresql.log")) - raise e - - def tearDown(self): - tg.stop_all() - - def init_pglist_data(self, node): - # Check if 'pglist' base exists - bases = node.execute("postgres", - "SELECT count(*) FROM pg_database " - "WHERE datistemplate = false AND " - " datname = 'pglist'") - if bases[0][0] != 0: - return - - # Check if 'pglist' dump exists - home = expanduser("~") - pglist_dump = os.path.join(home, "pglist-28-04-16.dump") - if not os.path.isfile(pglist_dump): - pglist_dumpgz = pglist_dump + ".gz" - if not os.path.isfile(pglist_dumpgz): - print("Downloading: {0}".format(pglist_dumpgz)) - request.urlretrieve( - "http://www.sai.msu.su/~megera/postgres/files/pglist-28-04-16.dump.gz", - pglist_dumpgz) - - print("Decompressing: {0}".format(pglist_dumpgz)) - gz = gzip.open(pglist_dumpgz, 'rb') - with open(pglist_dump, 'wb') as f: - f.write(gz.read()) - - os.remove(pglist_dumpgz) - - # Restore dump file - print("Restoring 'pglist'") - node.safe_psql("postgres", "CREATE DATABASE pglist") - node.psql("pglist", filename=pglist_dump) - - node.safe_psql("pglist", "CREATE EXTENSION rum") - - def printlog(self, logfile): - with open(logfile, 'r') as log: - for line in log.readlines(): - print(line) - - def test_order_by(self): - """Tests SELECT constructions to 'pglist' base""" - try: - self.init_pglist_data(self.node) - - print("Creating index 'rumidx_orderby_sent'") - - self.node.safe_psql( - "pglist", - "CREATE INDEX rumidx_orderby_sent ON pglist USING rum (" - " fts rum_tsvector_timestamp_ops, sent) " - " WITH (attach=sent, to=fts, order_by_attach=t)") - - print("Running tests") - - self.assertEqual( - self.node.safe_psql( - "pglist", - "SELECT sent, subject " - " FROM pglist " - " WHERE fts @@ " - " to_tsquery('english', 'backend <-> crushed') " - " ORDER BY sent <=| '2016-01-01 00:01' LIMIT 5" - ), - b'1999-06-02 11:52:46|Re: [HACKERS] PID of backend\n' - ) - - self.assertEqual( - self.node.safe_psql( - "pglist", - "SELECT count(*) FROM pglist " - "WHERE fts @@ to_tsquery('english', 'tom & lane')" - ), - b'222813\n' - ) - - self.node.safe_psql("pglist", "DROP INDEX rumidx_orderby_sent"); - - print("Creating index 'pglist_rum_idx'") - - self.node.safe_psql( - "pglist", - "CREATE INDEX pglist_rum_idx ON pglist USING rum (" - " fts rum_tsvector_ops)") - - print("Running tests") - - self.assertEqual( - self.node.execute( - "pglist", - "SELECT id FROM pglist " - "WHERE fts @@ to_tsquery('english', 'postgres:*') " - "ORDER BY fts <=> to_tsquery('english', 'postgres:*') " - "LIMIT 9" - )[0][0], - 816114 - ) - - # Autovacuum after large update, with active RUM index crashes postgres - print("Test Issue #19") - - self.node.safe_psql( - "pglist", - "DELETE FROM pglist WHERE id < 100000") - self.node.safe_psql( - "pglist", - "vacuum") - - self.node.safe_psql("pglist", "DROP INDEX pglist_rum_idx"); - - except Exception as e: - self.printlog(os.path.join(self.node.logs_dir, "postgresql.log")) - raise e - -if __name__ == "__main__": - unittest.main() diff --git a/travis/docker-compose.yml b/travis/docker-compose.yml index 471ab779f2..0544d8597d 100644 --- a/travis/docker-compose.yml +++ b/travis/docker-compose.yml @@ -1,2 +1,3 @@ -tests: +services: + tests: build: . diff --git a/travis/run_tests.sh b/travis/run_tests.sh index a1ea1e3e45..37bba84d64 100644 --- a/travis/run_tests.sh +++ b/travis/run_tests.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# Copyright (c) 2019, Postgres Professional +# Copyright (c) 2019-2024, Postgres Professional # # supported levels: # * standard @@ -38,6 +38,7 @@ if [ "$LEVEL" = "hardcore" ]; then ./configure \ CFLAGS='-fno-omit-frame-pointer' \ --enable-cassert \ + --enable-tap-tests \ --prefix=$CUSTOM_PG_BIN \ --quiet