diff -Nru prefix-1.2.1/.gitignore prefix-1.2.2/.gitignore --- prefix-1.2.1/.gitignore 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -prefix.so -prefix.o -.deps -results/ -debian/files -debian/*.log -debian/*.substvars -debian/postgresql-*-prefix/ diff -Nru prefix-1.2.1/debian/changelog prefix-1.2.2/debian/changelog --- prefix-1.2.1/debian/changelog 2013-11-04 12:37:58.000000000 +0000 +++ prefix-1.2.2/debian/changelog 2014-01-26 17:17:21.000000000 +0000 @@ -1,3 +1,12 @@ +prefix (1.2.2-1) unstable; urgency=medium + + * New upstream release + + Allows building on 9.4+. + + Regression test updates. + * Add make to the test dependencies. + + -- Christoph Berg Sun, 26 Jan 2014 18:13:59 +0100 + prefix (1.2.1-1) unstable; urgency=low * debian/rules: Use "pg_buildext loop". diff -Nru prefix-1.2.1/debian/tests/control prefix-1.2.2/debian/tests/control --- prefix-1.2.1/debian/tests/control 2013-11-04 11:46:32.000000000 +0000 +++ prefix-1.2.2/debian/tests/control 2014-01-26 17:14:36.000000000 +0000 @@ -1,3 +1,3 @@ -Depends: @, postgresql-server-dev-all +Depends: @, make, postgresql-server-dev-all Tests: installcheck Restrictions: needs-root allow-stderr diff -Nru prefix-1.2.1/expected/explain.out prefix-1.2.2/expected/explain.out --- prefix-1.2.1/expected/explain.out 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/expected/explain.out 2014-01-26 17:08:47.000000000 +0000 @@ -7,6 +7,18 @@ Index Cond: (prefix @> '0146640123'::prefix_range) (4 rows) +explain (costs off) select * from ranges where prefix @> '0146640123' order by length(prefix) desc limit 1; + QUERY PLAN +------------------------------------------------------------------------ + Limit + -> Sort + Sort Key: (length(prefix)) + -> Bitmap Heap Scan on ranges + Recheck Cond: (prefix @> '0146640123'::prefix_range) + -> Bitmap Index Scan on idx_prefix + Index Cond: (prefix @> '0146640123'::prefix_range) +(7 rows) + explain (costs off) select * from ranges where prefix @> '0100091234'; QUERY PLAN ------------------------------------------------------------ @@ -16,6 +28,18 @@ Index Cond: (prefix @> '0100091234'::prefix_range) (4 rows) +explain (costs off) select * from ranges where prefix @> '0100091234' order by length(prefix) desc limit 1; + QUERY PLAN +------------------------------------------------------------------------ + Limit + -> Sort + Sort Key: (length(prefix)) + -> Bitmap Heap Scan on ranges + Recheck Cond: (prefix @> '0100091234'::prefix_range) + -> Bitmap Index Scan on idx_prefix + Index Cond: (prefix @> '0100091234'::prefix_range) +(7 rows) + explain (costs off) select * from numbers n join ranges r on r.prefix @> n.number; QUERY PLAN ---------------------------------------------------------- diff -Nru prefix-1.2.1/expected/prefix.out prefix-1.2.2/expected/prefix.out --- prefix-1.2.1/expected/prefix.out 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/expected/prefix.out 2014-01-26 17:08:47.000000000 +0000 @@ -60,23 +60,63 @@ (8 rows) create table numbers(number text primary key); -select setseed(0); - setseed ---------- - -(1 row) - insert into numbers - select '01' || to_char((random()*100)::int, 'FM09') - || to_char((random()*100)::int, 'FM09') - || to_char((random()*100)::int, 'FM09') - || to_char((random()*100)::int, 'FM09') - from generate_series(1, 5000); + select '01' || substr(regexp_replace(md5(i::text), '[a-f]', '', 'g'), 1, 8) + from generate_series(1, 5000) i; analyze numbers; select count(*) from numbers n join ranges r on r.prefix @> n.number; count ------- - 2027 + 2019 (1 row) reset client_min_messages; +-- Debian Bug 690160 regarding the symetry of <@ and @> +SELECT count(*) FROM ranges WHERE prefix <@ '01000'; + count +------- + 9 +(1 row) + +SELECT count(*) FROM ranges WHERE prefix @> '01000'; + count +------- + 0 +(1 row) + +SELECT count(*) FROM ranges WHERE '01000' <@ prefix; + count +------- + 0 +(1 row) + +SELECT count(*) FROM ranges WHERE '01000' @> prefix; + count +------- + 9 +(1 row) + +SELECT count(*) FROM ranges WHERE '010009888' @> prefix; + count +------- + 0 +(1 row) + +SELECT count(*) FROM ranges WHERE '010009888' <@ prefix; + count +------- + 1 +(1 row) + +SELECT count(*) FROM ranges WHERE prefix @> '010009888'; + count +------- + 1 +(1 row) + +SELECT count(*) FROM ranges WHERE prefix <@ '010009888'; + count +------- + 0 +(1 row) + diff -Nru prefix-1.2.1/expected/queries.out prefix-1.2.2/expected/queries.out --- prefix-1.2.1/expected/queries.out 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/expected/queries.out 2014-01-26 17:08:47.000000000 +0000 @@ -1,3 +1,4 @@ +-- operators select a, b, a <= b as "<=", a < b as "<", a = b as "=", a <> b as "<>", a >= b as ">=", a > b as ">", a @> b as "@>", a <@ b as "<@", a && b as "&&" @@ -17,6 +18,7 @@ 123 | [2-3] | t | t | f | t | f | f | f | f | f (5 rows) +-- transitivity select a, b, c, a <= b as "a <= b", b <= c as "b <= c", a <= c as "a <= c" from (select a::prefix_range, b::prefix_range, c::prefix_range from (values('123', '123', '123'), @@ -34,6 +36,7 @@ 123 | [2-3] | 4 | t | t | t (5 rows) +-- set operations select a, b, a | b as union, a & b as intersect from (select a::prefix_range, b::prefix_range from (values('123', '123'), @@ -51,3 +54,60 @@ 123 | [2-3] | [1-3] | (5 rows) +-- casting to and from text +select prefix_range('123'); + prefix_range +-------------- + 123 +(1 row) + +select prefix_range('123[4-5]'); + prefix_range +-------------- + 123[4-5] +(1 row) + +select prefix_range('[2-3]'); + prefix_range +-------------- + [2-3] +(1 row) + +select prefix_range('123', '4', '5'); + prefix_range +-------------- + 123[4-5] +(1 row) + +select length('12345'::prefix_range); + length +-------- + 5 +(1 row) + +select length('12345[]'::prefix_range); + length +-------- + 5 +(1 row) + +select length('123[4-5]'::prefix_range); + length +-------- + 5 +(1 row) + +select length('1234'::prefix_range); + length +-------- + 4 +(1 row) + +\dC *prefix* + List of casts + Source type | Target type | Function | Implicit? +--------------+--------------+--------------+----------- + prefix_range | text | text | no + text | prefix_range | prefix_range | yes +(2 rows) + diff -Nru prefix-1.2.1/prefix.c prefix-1.2.2/prefix.c --- prefix-1.2.1/prefix.c 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/prefix.c 2014-01-26 17:08:47.000000000 +0000 @@ -44,8 +44,8 @@ */ /** - * This code has only been tested with PostgreSQL 8.2 and 8.3, and a 8.1 - * backport has been requested. + * This code has only been developped initially against PostgreSQL 8.2 and 8.3, + * and a 8.1 backport has been requested. * * 8.1 didn't have PG_VERSION_NUM, so we'll avoid ugly Makefiles hack by * saying that if we don't have PG_VERSION_NUM, it must be 8.1 @@ -56,14 +56,13 @@ #define PG_MAJOR_VERSION PREFIX_PGVER #endif -#if PG_MAJOR_VERSION != 801 && PG_MAJOR_VERSION != 802 \ - && PG_MAJOR_VERSION != 803 && PG_MAJOR_VERSION != 804 \ - && PG_MAJOR_VERSION != 900 && PG_MAJOR_VERSION != 901 \ - && PG_MAJOR_VERSION != 902 && PG_MAJOR_VERSION != 903 -#error "Unknown or unsupported postgresql version" -#endif - -/* PG_MODULE_MAGIC was introduced in 8.2. */ +/* + * PG_MODULE_MAGIC was introduced in 8.2. + * + * This particular module began its life in the 8.1 era, and as supporting + * those now ancient versions is not costing much in terms of code maintenance, + * we keep the support for 8.1 on. + */ #if PG_MAJOR_VERSION >= 802 PG_MODULE_MAGIC; #endif diff -Nru prefix-1.2.1/sql/explain.sql prefix-1.2.2/sql/explain.sql --- prefix-1.2.1/sql/explain.sql 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/sql/explain.sql 2014-01-26 17:08:47.000000000 +0000 @@ -1,5 +1,7 @@ explain (costs off) select * from ranges where prefix @> '0146640123'; +explain (costs off) select * from ranges where prefix @> '0146640123' order by length(prefix) desc limit 1; explain (costs off) select * from ranges where prefix @> '0100091234'; +explain (costs off) select * from ranges where prefix @> '0100091234' order by length(prefix) desc limit 1; explain (costs off) select * from numbers n join ranges r on r.prefix @> n.number; diff -Nru prefix-1.2.1/sql/prefix.sql prefix-1.2.2/sql/prefix.sql --- prefix-1.2.1/sql/prefix.sql 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/sql/prefix.sql 2014-01-26 17:08:47.000000000 +0000 @@ -37,15 +37,21 @@ create table numbers(number text primary key); -select setseed(0); insert into numbers - select '01' || to_char((random()*100)::int, 'FM09') - || to_char((random()*100)::int, 'FM09') - || to_char((random()*100)::int, 'FM09') - || to_char((random()*100)::int, 'FM09') - from generate_series(1, 5000); + select '01' || substr(regexp_replace(md5(i::text), '[a-f]', '', 'g'), 1, 8) + from generate_series(1, 5000) i; analyze numbers; select count(*) from numbers n join ranges r on r.prefix @> n.number; reset client_min_messages; + +-- Debian Bug 690160 regarding the symetry of <@ and @> +SELECT count(*) FROM ranges WHERE prefix <@ '01000'; +SELECT count(*) FROM ranges WHERE prefix @> '01000'; +SELECT count(*) FROM ranges WHERE '01000' <@ prefix; +SELECT count(*) FROM ranges WHERE '01000' @> prefix; +SELECT count(*) FROM ranges WHERE '010009888' @> prefix; +SELECT count(*) FROM ranges WHERE '010009888' <@ prefix; +SELECT count(*) FROM ranges WHERE prefix @> '010009888'; +SELECT count(*) FROM ranges WHERE prefix <@ '010009888'; diff -Nru prefix-1.2.1/sql/queries.sql prefix-1.2.2/sql/queries.sql --- prefix-1.2.1/sql/queries.sql 2013-11-04 12:38:47.000000000 +0000 +++ prefix-1.2.2/sql/queries.sql 2014-01-26 17:08:47.000000000 +0000 @@ -1,3 +1,4 @@ +-- operators select a, b, a <= b as "<=", a < b as "<", a = b as "=", a <> b as "<>", a >= b as ">=", a > b as ">", a @> b as "@>", a <@ b as "<@", a && b as "&&" @@ -9,6 +10,7 @@ ('123', '[2-3]')) as t(a, b) ) as x; +-- transitivity select a, b, c, a <= b as "a <= b", b <= c as "b <= c", a <= c as "a <= c" from (select a::prefix_range, b::prefix_range, c::prefix_range from (values('123', '123', '123'), @@ -18,6 +20,7 @@ ('123', '[2-3]', '4')) as t(a, b, c) ) as x; +-- set operations select a, b, a | b as union, a & b as intersect from (select a::prefix_range, b::prefix_range from (values('123', '123'), @@ -27,3 +30,13 @@ ('123', '[2-3]')) as t(a, b) ) as x; +-- casting to and from text +select prefix_range('123'); +select prefix_range('123[4-5]'); +select prefix_range('[2-3]'); +select prefix_range('123', '4', '5'); +select length('12345'::prefix_range); +select length('12345[]'::prefix_range); +select length('123[4-5]'::prefix_range); +select length('1234'::prefix_range); +\dC *prefix*