diff --git a/pgtap/astar/aStarCostMatrix/inner_query.pg b/pgtap/astar/aStarCostMatrix/inner_query.pg index e4b3ad89b9c..152dd0c8343 100644 --- a/pgtap/astar/aStarCostMatrix/inner_query.pg +++ b/pgtap/astar/aStarCostMatrix/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(102); -- ONE MATRIX diff --git a/pgtap/astar/aStarCostMatrix/no_crash_test.pg b/pgtap/astar/aStarCostMatrix/no_crash_test.pg index 6268993df9d..8342a119d80 100644 --- a/pgtap/astar/aStarCostMatrix/no_crash_test.pg +++ b/pgtap/astar/aStarCostMatrix/no_crash_test.pg @@ -19,23 +19,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(15); -PREPARE edges AS -SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table; +PREPARE edges_q AS +SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges; PREPARE null_ret AS -SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT id FROM vertices WHERE id IN (-1); PREPARE null_ret_arr AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); -SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); +SELECT isnt_empty('edges_q', 'Should be not empty to tests be meaningful'); SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); SELECT set_eq('null_ret_arr', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); - CREATE OR REPLACE FUNCTION test_function() RETURNS SETOF TEXT AS $BODY$ @@ -44,10 +43,10 @@ params TEXT[]; subs TEXT[]; BEGIN - params = ARRAY['$$edges$$','ARRAY[1,2]::BIGINT[]']::TEXT[]; + params = ARRAY['$$edges_q$$','ARRAY[5,6]::BIGINT[]']::TEXT[]; subs = ARRAY[ 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_astarCostMatrix', params, subs); diff --git a/pgtap/astar/astar/compare_dijkstra/combinations.pg b/pgtap/astar/astar/compare_dijkstra/combinations.pg new file mode 100644 index 00000000000..e26e6f9aec6 --- /dev/null +++ b/pgtap/astar/astar/compare_dijkstra/combinations.pg @@ -0,0 +1,88 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2023 pgRouting developers +Mail: project@pgrouting.org + +------ + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +********************************************************************PGR-GNU*/ + +BEGIN; + +SELECT CASE WHEN min_version('3.2.0') THEN plan(4) ELSE plan(1) END; + +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; + +CREATE or REPLACE FUNCTION astarCompareDijkstra(cant INTEGER default 17) +RETURNS SETOF TEXT AS +$BODY$ +DECLARE +inner_sql TEXT; +dijkstra_sql TEXT; +astar_sql TEXT; +vids TEXT; +data TEXT; +BEGIN + IF NOT min_version('3.2.0') THEN + RETURN query + SELECT skip(1, 'Combinations signature added on version 3.2'); + RETURN; + END IF; + + data := ' path_seq, start_vid, end_vid, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost '; + vids := ' SELECT * FROM combinations '; + + + ----------------------- + -- with reverse cost + ----------------------- + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; + -- DIRECTED + dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, true)'; + astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, true, heuristic := 0)'; + RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql); + + -- UNDIRECTED + dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, false)'; + astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, false, heuristic := 0)'; + RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql); + + ----------------------- + -- NO reverse cost + ----------------------- + -- DIRECTED + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; + dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, true)'; + astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, true, heuristic := 0)'; + RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql); + + -- UNDIRECTED + dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, false)'; + astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, false, heuristic := 0)'; + RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql); + + RETURN; +END +$BODY$ +language plpgsql; + +SELECT * from astarCompareDijkstra(); + + +SELECT * FROM finish(); +ROLLBACK; + diff --git a/pgtap/astar/astar/compare_dijkstra/many_to_many.pg b/pgtap/astar/astar/compare_dijkstra/many_to_many.pg index 944298c6a17..bcd15bb190e 100644 --- a/pgtap/astar/astar/compare_dijkstra/many_to_many.pg +++ b/pgtap/astar/astar/compare_dijkstra/many_to_many.pg @@ -25,7 +25,7 @@ BEGIN; SELECT plan(4); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE or REPLACE FUNCTION astarCompareDijkstra(cant INTEGER default 17) RETURNS SETOF TEXT AS @@ -45,7 +45,7 @@ BEGIN -- with reverse cost ----------------------- -- DIRECTED - inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || vids || ',' || vids || ', true)'; @@ -65,7 +65,7 @@ BEGIN -- NO reverse cost ----------------------- -- DIRECTED - inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || vids || ',' || vids || ', true)'; diff --git a/pgtap/astar/astar/compare_dijkstra/many_to_one.pg b/pgtap/astar/astar/compare_dijkstra/many_to_one.pg index 4f35e718dca..5ab2a68684e 100644 --- a/pgtap/astar/astar/compare_dijkstra/many_to_one.pg +++ b/pgtap/astar/astar/compare_dijkstra/many_to_one.pg @@ -27,7 +27,7 @@ SELECT plan(68); SET client_min_messages TO ERROR; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE or REPLACE FUNCTION astarCompareDijkstra(cant INTEGER default 17) RETURNS SETOF TEXT AS @@ -39,7 +39,8 @@ astar_sql TEXT; vids TEXT; data TEXT; BEGIN - data := ' seq, start_vid, cost::text, agg_cost::text '; + data := ' seq, path_seq, start_vid, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost '; + vids := ' ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18] '; FOR i IN 1.. cant LOOP @@ -48,7 +49,7 @@ BEGIN -- with reverse cost ----------------------- -- DIRECTED - inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || vids || ',' || i || ', true)'; @@ -68,7 +69,7 @@ BEGIN -- NO reverse cost ----------------------- -- DIRECTED - inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || vids || ',' || i || ', true)'; diff --git a/pgtap/astar/astar/compare_dijkstra/one_to_many.pg b/pgtap/astar/astar/compare_dijkstra/one_to_many.pg index f6727c742a0..a3da3510fda 100644 --- a/pgtap/astar/astar/compare_dijkstra/one_to_many.pg +++ b/pgtap/astar/astar/compare_dijkstra/one_to_many.pg @@ -27,7 +27,7 @@ SELECT plan(68); SET client_min_messages TO ERROR; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE or REPLACE FUNCTION astarCompareDijkstra(cant INTEGER default 17) RETURNS SETOF TEXT AS @@ -39,7 +39,8 @@ astar_sql TEXT; vids TEXT; data TEXT; BEGIN - data = ' seq, end_vid, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost '; + data := ' seq, path_seq, end_vid, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost '; + vids = ' ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18] '; FOR i IN 1.. cant LOOP @@ -48,7 +49,7 @@ BEGIN -- with reverse cost ----------------------- -- DIRECTED - inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || vids || ', true)'; @@ -68,7 +69,7 @@ BEGIN -- NO reverse cost ----------------------- -- DIRECTED - inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || vids || ', true)'; diff --git a/pgtap/astar/astar/compare_dijkstra/one_to_one.pg b/pgtap/astar/astar/compare_dijkstra/one_to_one.pg index 2d55517207f..5ab5d51d97a 100644 --- a/pgtap/astar/astar/compare_dijkstra/one_to_one.pg +++ b/pgtap/astar/astar/compare_dijkstra/one_to_one.pg @@ -25,7 +25,7 @@ BEGIN; SELECT plan(612); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE or REPLACE FUNCTION astarCompareDijkstra(cant INTEGER default 17) RETURNS SETOF TEXT AS @@ -42,7 +42,7 @@ BEGIN FOR j IN 1.. cant LOOP -- DIRECTED WITH REVERSE COST - inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', true)'; @@ -52,7 +52,7 @@ BEGIN -- DIRECTED WITHOUT REVERSE COST - inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', true)'; @@ -62,7 +62,7 @@ BEGIN -- UNDIRECTED WITH REVERSE COST - inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', false)'; @@ -72,7 +72,7 @@ BEGIN -- UNDIRECTED WITHOUT REVERSE COST - inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', false)'; diff --git a/pgtap/astar/astar/edge_cases/empty_combinations_empty_result.pg b/pgtap/astar/astar/edge_cases/empty_combinations_empty_result.pg deleted file mode 100644 index ff9dd72743c..00000000000 --- a/pgtap/astar/astar/edge_cases/empty_combinations_empty_result.pg +++ /dev/null @@ -1,49 +0,0 @@ - -/*PGR-GNU***************************************************************** - -Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org - ------- -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ********************************************************************PGR-GNU*/ - -BEGIN; - -SELECT plan(1); - -CREATE OR REPLACE FUNCTION test_function() -RETURNS SETOF TEXT AS -$BODY$ -BEGIN - IF NOT min_version('3.2.0') THEN - RETURN query - SELECT skip(1, 'Combinations signature added on version 3.2'); - RETURN; - END IF; - - RETURN query - SELECT is_empty( - 'SELECT path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_aStar( - $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table$$, - $$SELECT * FROM combinations_table WHERE source IN (-1)$$)' - ); - -END -$BODY$ -language plpgsql; - -SELECT test_function(); - -SELECT finish(); -ROLLBACK; diff --git a/pgtap/astar/astar/edge_cases/empty_inner_queries_empty_result.pg b/pgtap/astar/astar/edge_cases/empty_inner_queries_empty_result.pg new file mode 100644 index 00000000000..5fa843b79fb --- /dev/null +++ b/pgtap/astar/astar/edge_cases/empty_inner_queries_empty_result.pg @@ -0,0 +1,88 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2018 pgRouting developers +Mail: project@pgrouting.org + +------ +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + ********************************************************************PGR-GNU*/ + +BEGIN; + +SELECT CASE WHEN min_version('3.2.0') THEN plan(6) ELSE plan(5) END; + +CREATE OR REPLACE FUNCTION test_function() +RETURNS SETOF TEXT AS +$BODY$ +DECLARE result1 TEXT = ' seq, path_seq, node, edge, cost, agg_cost '; +DECLARE result2 TEXT = ' seq, path_seq, end_vid, node, edge, cost, agg_cost '; +DECLARE result3 TEXT = ' seq, path_seq, start_vid, node, edge, cost, agg_cost '; +DECLARE result_all TEXT = ' seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost '; +BEGIN + + RETURN query + SELECT is_empty( + 'SELECT ' || result1 || ' FROM pgr_aStar( + $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges WHERE id > 20$$, + 1, 3, false)' + ); + + RETURN query + SELECT is_empty( + 'SELECT ' || result2 || ' FROM pgr_aStar( + $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges WHERE id > 20$$, + 1, ARRAY[3,12], false)' + ); + + RETURN query + SELECT is_empty( + 'SELECT ' || result3 || ' FROM pgr_aStar( + $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges WHERE id > 20$$, + ARRAY[1,2], 3, false)' + ); + + RETURN query + SELECT is_empty( + 'SELECT ' || result_all || ' FROM pgr_aStar( + $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges WHERE id > 20$$, + ARRAY[1, 2], ARRAY[3,12], false)' + ); + + IF NOT min_version('3.2.0') THEN + RETURN query + SELECT skip(1, 'Combinations signature added on version 3.2'); + RETURN; + END IF; + + RETURN query + SELECT is_empty( + 'SELECT path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_aStar( + $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges WHERE id > 20$$, + $$SELECT * FROM combinations$$)' + ); + + RETURN query + SELECT is_empty( + 'SELECT path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_aStar( + $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$, + $$SELECT * FROM combinations WHERE source IN (-1)$$)' + ); + +END +$BODY$ +language plpgsql; + +SELECT test_function(); + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/astar/astar/edge_cases/remaining_tests.pg b/pgtap/astar/astar/edge_cases/remaining_tests.pg index 166084d1676..0c6c1b30238 100644 --- a/pgtap/astar/astar/edge_cases/remaining_tests.pg +++ b/pgtap/astar/astar/edge_cases/remaining_tests.pg @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(116); SET client_min_messages TO ERROR; @@ -75,7 +75,7 @@ BEGIN END IF; start_sql = start_sql || p || ', '; END LOOP; - end_sql = ' FROM edge_table $$, 2, 3, true)'; + end_sql = ' FROM edges $$, 2, 3, true)'; query := start_sql || parameter || '::SMALLINT ' || end_sql; RETURN query SELECT lives_ok(query); @@ -112,7 +112,7 @@ BEGIN END IF; start_sql = start_sql || p || ', '; END LOOP; - end_sql = ' FROM edge_table $$, 2, 3, true)'; + end_sql = ' FROM edges $$, 2, 3, true)'; query := start_sql || parameter || '::SMALLINT ' || end_sql; RETURN query SELECT lives_ok(query); @@ -191,7 +191,7 @@ SELECT test_anyNumerical('pgr_astar', 'y2'); SELECT throws_ok( - $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', + $$SELECT * FROM pgr_astar('SELECT * FROM edges', 2, 3, true, 6, 1, 1)$$, 'XX000', @@ -200,7 +200,7 @@ SELECT throws_ok( ); SELECT throws_ok( - $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', + $$SELECT * FROM pgr_astar('SELECT * FROM edges', 2, 3, true, -1, 1, 1)$$, 'XX000', @@ -209,7 +209,7 @@ SELECT throws_ok( ); SELECT throws_ok( - $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', + $$SELECT * FROM pgr_astar('SELECT * FROM edges', 2, 3, true, 0, 0, 1)$$, 'XX000', @@ -218,7 +218,7 @@ SELECT throws_ok( ); SELECT throws_ok( - $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', + $$SELECT * FROM pgr_astar('SELECT * FROM edges', 2, 3, true, 0, -1.4, 1)$$, 'XX000', @@ -227,7 +227,7 @@ SELECT throws_ok( ); SELECT throws_ok( - $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', + $$SELECT * FROM pgr_astar('SELECT * FROM edges', 2, 3, true, 0, 1, -3)$$, 'XX000', @@ -235,7 +235,7 @@ SELECT throws_ok( 'SHOULD THROW because epsilon < 0' ); SELECT throws_ok( - $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', + $$SELECT * FROM pgr_astar('SELECT * FROM edges', 2, 3, true, 0, 1, 0.9)$$, 'XX000', diff --git a/pgtap/astar/astar/inner_query.pg b/pgtap/astar/astar/inner_query.pg index 8486816528b..d3c63e108cc 100644 --- a/pgtap/astar/astar/inner_query.pg +++ b/pgtap/astar/astar/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(522) ELSE plan(410) END; @@ -37,8 +37,8 @@ CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN IF min_version('3.2.0') THEN - RETURN QUERY SELECT style_astar('pgr_astar(', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_astar($$SELECT * FROM edge_table$$,',', true)'); + RETURN QUERY SELECT style_astar('pgr_astar(', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_astar($$SELECT * FROM edges$$,',', true)'); ELSE RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.2.0'); END IF; diff --git a/pgtap/astar/astar/no_crash_test.pg b/pgtap/astar/astar/no_crash_test.pg index 4bc6fc93aca..246ad7f2e33 100644 --- a/pgtap/astar/astar/no_crash_test.pg +++ b/pgtap/astar/astar/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(97) ELSE plan(84) END; SELECT general_no_crash('pgr_aStar'); diff --git a/pgtap/astar/astar/types_check.pg b/pgtap/astar/astar/types_check.pg index 199271151ea..a9e085afed1 100644 --- a/pgtap/astar/astar/types_check.pg +++ b/pgtap/astar/astar/types_check.pg @@ -1,4 +1,3 @@ - /*PGR-GNU***************************************************************** Copyright (c) 2018 pgRouting developers @@ -20,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -SET client_min_messages TO WARNING; - SELECT plan(13); SELECT astar_types_check('pgr_astar'); diff --git a/pgtap/astar/astarCost/edge_cases/empty_combinations_empty_result.pg b/pgtap/astar/astarCost/edge_cases/empty_combinations_empty_result.pg index 95bf283ca43..cf89ad99dae 100644 --- a/pgtap/astar/astarCost/edge_cases/empty_combinations_empty_result.pg +++ b/pgtap/astar/astarCost/edge_cases/empty_combinations_empty_result.pg @@ -35,8 +35,8 @@ BEGIN RETURN query SELECT is_empty( 'SELECT start_vid, end_vid, agg_cost FROM pgr_aStarCost( - $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table$$, - $$SELECT * FROM combinations_table WHERE source IN (-1)$$ ) ' + $$SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges$$, + $$SELECT * FROM combinations WHERE source IN (-1)$$ ) ' ); END $BODY$ diff --git a/pgtap/astar/astarCost/inner_query.pg b/pgtap/astar/astarCost/inner_query.pg index cc929771a24..72ff20f1bdb 100644 --- a/pgtap/astar/astarCost/inner_query.pg +++ b/pgtap/astar/astarCost/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(522) ELSE plan(410) END; @@ -37,8 +37,8 @@ CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN IF min_version('3.2.0') THEN - RETURN QUERY SELECT style_astar('pgr_astarCost(', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_astarCost($$SELECT * FROM edge_table$$,',', true)'); + RETURN QUERY SELECT style_astar('pgr_astarCost(', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_astarCost($$SELECT * FROM edges$$,',', true)'); ELSE RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.2.0'); END IF; diff --git a/pgtap/astar/astarCost/no_crash_test.pg b/pgtap/astar/astarCost/no_crash_test.pg index ec98116a994..464bca4b0dc 100644 --- a/pgtap/astar/astarCost/no_crash_test.pg +++ b/pgtap/astar/astarCost/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(97) ELSE plan(84) END; diff --git a/pgtap/astar/edge_cases/many_to_many_eq_combinations.pg b/pgtap/astar/edge_cases/many_to_many_eq_combinations.pg index 16aff3f577d..9b197cfe81c 100644 --- a/pgtap/astar/edge_cases/many_to_many_eq_combinations.pg +++ b/pgtap/astar/edge_cases/many_to_many_eq_combinations.pg @@ -22,7 +22,7 @@ BEGIN; SELECT plan(2); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE OR REPLACE FUNCTION astar_combinations(sql_TestFunction TEXT, cant INTEGER DEFAULT 18 ) RETURNS SETOF TEXT AS @@ -56,11 +56,11 @@ BEGIN sql_Combinations := trim(trailing ',' from sql_Combinations); sql_Many := ( sql_TestFunction || '( - ''SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'', + ''SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'', ARRAY[' || sql_Many ||'], ARRAY[' || sql_Many || '] ) '); sql_Combinations := ( sql_TestFunction || '( - ''SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'', + ''SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'', ''SELECT * FROM (VALUES' || sql_Combinations ||') AS combinations (source, target)'' ) '); RETURN query diff --git a/pgtap/dijkstra/dijkstra/edge_cases/empty_combinations_empty_result.pg b/pgtap/dijkstra/dijkstra/edge_cases/empty_combinations_empty_result.pg index 7d62937132d..275f78cdb77 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/empty_combinations_empty_result.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/empty_combinations_empty_result.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(1); create or REPLACE FUNCTION foo() @@ -37,8 +37,8 @@ BEGIN RETURN query SELECT is_empty( 'SELECT path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_dijkstra( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', - ''SELECT * FROM combinations_table WHERE source=-1'' ) ' + ''SELECT id, source, target, cost, reverse_cost FROM edges'', + ''SELECT * FROM combinations WHERE source=-1'' ) ' ); END $BODY$ diff --git a/pgtap/dijkstra/dijkstra/edge_cases/infinity_alt_cost.pg b/pgtap/dijkstra/dijkstra/edge_cases/infinity_alt_cost.pg index 2bf9519fd9a..9daff3c58a2 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/infinity_alt_cost.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/infinity_alt_cost.pg @@ -19,22 +19,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(4); PREPARE q0 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 7, 6) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 1, 11) ORDER BY seq DESC LIMIT 1; PREPARE update2infinity9 AS -UPDATE edge_table SET cost = 'Infinity' WHERE id = 9; +UPDATE edges SET cost = 'Infinity' WHERE id = 9; PREPARE update2k13 AS -UPDATE edge_table SET cost = 10 WHERE id = 13; +UPDATE edges SET cost = 10 WHERE id = 13; PREPARE q1 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 5, 12) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 7, 17) ORDER BY seq DESC LIMIT 1; -- test for infinity if alternative is available SELECT results_eq('q0', 'SELECT cast(3 as double precision) as agg_cost;'); diff --git a/pgtap/dijkstra/dijkstra/edge_cases/infinity_cost.pg b/pgtap/dijkstra/dijkstra/edge_cases/infinity_cost.pg index b78a99a6c5c..d3b7fc143dd 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/infinity_cost.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/infinity_cost.pg @@ -19,39 +19,39 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(8); PREPARE q0 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 7, 6) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 1, 11) ORDER BY seq DESC LIMIT 1; PREPARE update2infinity AS -UPDATE edge_table SET cost = 'Infinity' WHERE id = 7; +UPDATE edges SET cost = 'Infinity' WHERE id = 7; PREPARE q1 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 7, 8) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 1, 3) ORDER BY seq DESC LIMIT 1; PREPARE q2 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 8, 5) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 3, 7) ORDER BY seq DESC LIMIT 1; PREPARE q3 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 5, 6) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 7, 11) ORDER BY seq DESC LIMIT 1; PREPARE q4 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 7, 5) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 1, 7) ORDER BY seq DESC LIMIT 1; PREPARE q5 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 8, 6) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 3, 11) ORDER BY seq DESC LIMIT 1; PREPARE q6 AS -SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - 7, 6) ORDER BY seq DESC LIMIT 1; +SELECT agg_cost FROM pgr_dijkstra( 'select id, source, target, cost from edges', + 1, 11) ORDER BY seq DESC LIMIT 1; -- test for infinity if there is no alternative SELECT results_eq('q0', 'SELECT cast(3 as double precision) as agg_cost;'); diff --git a/pgtap/dijkstra/dijkstra/edge_cases/issue_353.pg b/pgtap/dijkstra/dijkstra/edge_cases/issue_353.pg index 1e948bbca21..4f51c749d5c 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/issue_353.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/issue_353.pg @@ -19,27 +19,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(3); PREPARE q1 AS -SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - array[2,7], array[5,6]); +SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edges', + array[1,6], array[7,11]); PREPARE q2 AS -SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - array[2,7], array[17,18]); +SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edges', + array[1,6], array[14,18]); Prepare q3 AS -(SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - array[2,7], array[5,6])) +(SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edges', + array[1,6], array[7,11])) UNION -(SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - array[2,7], array[17,18])); +(SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edges', + array[1,6], array[14,18])); PREPARE q4 AS -SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edge_table', - array[2,7], array[5,6,17,18]); +SELECT * FROM pgr_dijkstra( 'select id, source, target, cost from edges', + array[1,6], array[7,11,14,18]); SELECT is_empty( 'q2', '1'); SELECT set_eq( 'q1', 'q3', '2'); diff --git a/pgtap/dijkstra/dijkstra/edge_cases/manyToMany_equiv_combinations.pg b/pgtap/dijkstra/dijkstra/edge_cases/manyToMany_equiv_combinations.pg index 8610c1a0e5a..c6f8e1ba87c 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/manyToMany_equiv_combinations.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/manyToMany_equiv_combinations.pg @@ -22,7 +22,7 @@ BEGIN; SELECT plan(2); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; create or REPLACE FUNCTION foo( sql_TestFunction TEXT, cant INTEGER default 18 ) RETURNS SETOF TEXT AS @@ -57,12 +57,12 @@ BEGIN sql_Combinations := trim(trailing ',' from sql_Combinations); sql_Many := ( sql_TestFunction || '( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table''::text, ' + ''SELECT id, source, target, cost, reverse_cost FROM edges''::text, ' || ' ARRAY[' || sql_Many ||'], ARRAY[' || sql_Many || '] ) '); sql_Combinations := ( sql_TestFunction || '( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table''::text, + ''SELECT id, source, target, cost, reverse_cost FROM edges''::text, ''SELECT * FROM (VALUES' || sql_Combinations ||') AS combinations (source, target)'' ) '); RETURN query SELECT set_eq( sql_Many, sql_Combinations ); diff --git a/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToMany.pg b/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToMany.pg index 270a08ac6f6..3569e029aaa 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToMany.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToMany.pg @@ -22,7 +22,7 @@ BEGIN; SELECT plan(1); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; create or REPLACE FUNCTION foo(cant INTEGER default 18 ) @@ -47,15 +47,15 @@ BEGIN sql_OneToOne := sql_OneToOne ||' UNION ALL'; END IF; sql_OneToOne := sql_OneToOne || - '( SELECT seq, ' || i || ' as start_vid, ' || j || ' as end_vid, node, edge, cost, agg_cost FROM pgr_dijkstra( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', ' + '( SELECT seq, ' || i || ' AS start_vid, ' || j || ' AS end_vid, node, edge, cost, agg_cost FROM pgr_dijkstra( + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ' || i || ', ' || j || ') )'; END LOOP; END LOOP; sql_Many := ' SELECT path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_dijkstra( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', ' + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ' || ' ARRAY[' || sql_Many ||'], ARRAY[' || sql_Many || '] ) '; diff --git a/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToOne.pg b/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToOne.pg index 5fb53eb21db..3271c97cfe0 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToOne.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_manyToOne.pg @@ -22,7 +22,7 @@ BEGIN; SELECT plan(18); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; create or REPLACE FUNCTION foo(cant INTEGER default 18 ) @@ -44,15 +44,15 @@ BEGIN sql_Many := sql_Many ||', '; END IF; sql_OneToOne := sql_OneToOne || - '( SELECT seq, ' || j || ' as start_vid, ' || i || ' as end_vid, node, edge, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost FROM pgr_dijkstra( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', ' + '( SELECT seq, ' || j || ' AS start_vid, ' || i || ' AS end_vid, node, edge, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost FROM pgr_dijkstra( + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ' || j || ', ' || i || ') )'; sql_Many := sql_Many || j ; END LOOP; sql_Many := -' SELECT path_seq, start_vid, ' || i || ' as end_vid, node, edge, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost FROM pgr_dijkstra( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', ' +' SELECT path_seq, start_vid, ' || i || ' AS end_vid, node, edge, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost FROM pgr_dijkstra( + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ' ' ARRAY[' || sql_Many || '], ' || i || ' ) '; diff --git a/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_oneToMany.pg b/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_oneToMany.pg index f97fb94d3a9..304fe89111e 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_oneToMany.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/oneToOne_equiv_oneToMany.pg @@ -21,7 +21,7 @@ BEGIN; SELECT plan(36); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; create or REPLACE FUNCTION foo(cant INTEGER default 18, flag boolean default true ) @@ -45,14 +45,14 @@ BEGIN END IF; sql_OneToOne := sql_OneToOne || '( SELECT seq, ' || i || ' as start_vid, ' || j || ' as end_vid, node, edge, cost, agg_cost FROM pgr_dijkstra( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', ' + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ' || i || ', ' || j || ', ' || flag || ' ) )'; sql_OneToMany := sql_OneToMany || j ; END LOOP; sql_OneToMany := ' SELECT path_seq, ' || i || ' as start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_dijkstra( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', ' + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ' || i || ', ARRAY[' || sql_OneToMany || '], ' || flag || ' ) '; diff --git a/pgtap/dijkstra/dijkstra/edge_cases/remaining_tests.pg b/pgtap/dijkstra/dijkstra/edge_cases/remaining_tests.pg deleted file mode 100644 index 5fa08a40ab2..00000000000 --- a/pgtap/dijkstra/dijkstra/edge_cases/remaining_tests.pg +++ /dev/null @@ -1,316 +0,0 @@ - -/*PGR-GNU***************************************************************** - -Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org - ------- -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ********************************************************************PGR-GNU*/ - -BEGIN; - -SET client_min_messages TO WARNING; - -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(33); - --- testing for the 4 signatures that they return the correct names & columns --- Preparing -PREPARE v21q00 AS -SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2, - pg_typeof(node)::text AS t5, pg_typeof(edge)::text AS t6, - pg_typeof(cost)::text AS t7, pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, 3, true) ) AS a - limit 1 -; -PREPARE v21q01 AS -SELECT 'integer'::text AS t1,'integer'::text AS t2, - 'bigint'::text AS t5, 'bigint'::text AS t6, - 'double precision'::text AS t7, 'double precision'::text AS t8; - -PREPARE v21q10 AS -SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2, - pg_typeof(end_vid)::text AS t4, - pg_typeof(node)::text AS t5, pg_typeof(edge)::text AS t6, - pg_typeof(cost)::text AS t7, pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, ARRAY[3], true) ) AS a - limit 1 -; -PREPARE v21q11 AS -SELECT 'integer'::text AS t1,'integer'::text AS t2, - 'bigint'::text AS t4, - 'bigint'::text AS t5, 'bigint'::text AS t6, - 'double precision'::text AS t7, 'double precision'::text AS t8; - - -PREPARE v21q20 AS -SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2, - pg_typeof(start_vid)::text AS t3, - pg_typeof(node)::text AS t5, pg_typeof(edge)::text AS t6, - pg_typeof(cost)::text AS t7, pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - ARRAY[2], 3, true) ) AS a - limit 1 -; -PREPARE v21q21 AS -SELECT 'integer'::text AS t1,'integer'::text AS t2, - 'bigint'::text AS t3, - 'bigint'::text AS t5, 'bigint'::text AS t6, - 'double precision'::text AS t7, 'double precision'::text AS t8; - -PREPARE v21q30 AS -SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2, - pg_typeof(start_vid)::text AS t3, pg_typeof(end_vid)::text AS t4, - pg_typeof(node)::text AS t5, pg_typeof(edge)::text AS t6, - pg_typeof(cost)::text AS t7, pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - ARRAY[2], ARRAY[3], true) ) AS a - limit 1 -; -PREPARE v21q31 AS -SELECT 'integer'::text AS t1,'integer'::text AS t2, - 'bigint'::text AS t3, 'bigint'::text AS t4, - 'bigint'::text AS t5, 'bigint'::text AS t6, - 'double precision'::text AS t7, 'double precision'::text AS t8; - --- testing -SELECT set_eq('v21q00', 'v21q01','1 to 1: Expected returning, columns names & types'); -SELECT set_eq('v21q10', 'v21q11','1 to many: Expected returning, columns names & types'); -SELECT set_eq('v21q20', 'v21q21','many to 1: Expected returning, columns names & types'); -SELECT set_eq('v21q30', 'v21q31','many to many: Expected returning, columns names & types'); - - --- CHECKING WORKS WITH & WITOUT REVERSE COST - -PREPARE v20q1 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, 3, true); -PREPARE v20q3 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v20q1','with reverse cost 1'); -SELECT lives_ok('v20q3','with reverse cost 3'); - -PREPARE v20q5 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, true); - -PREPARE v20q6 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); - - -SELECT lives_ok('v20q5','without reverse cost 1'); -SELECT lives_ok('v20q6','without reverse cost 2'); - --- V2.0 --- CHECKING INNER QUERY --- ANY-INTEGER, ANY-INTEGER, ANY-INTEGER, ANY-NUMERIC, [ANY-NUMERIC] - -/* TEST USES THE EDGES_INPUT FOR 5 PARAMETERS */ - ---id ANY-INTEGER -PREPARE v200id1 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::SMALLINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id2 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::BIGINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id3 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::FLOAT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id4 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::REAL, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id5 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::TEXT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200id1', - 'lives because id is SMALLINT'); -SELECT lives_ok('v200id2', - 'lives because id is BIGINT'); -SELECT throws_ok('v200id3', - 'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER', - 'throws because id is REAL'); -SELECT throws_ok('v200id4', - 'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER', - 'throws because id is FLOAT'); -SELECT throws_ok('v200id5', - 'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER', - 'throws because id is TEXT'); - ---source is only integer -PREPARE v200s1 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::SMALLINT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s2 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::BIGINT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s3 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::REAL, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s4 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::FLOAT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s5 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::TEXT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200s1', - 'lives because source is SMALLINT'); -SELECT lives_ok('v200s2', - 'lives because source is BIGINT'); -SELECT throws_ok('v200s3', - 'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER', - 'throws because source is REAL'); -SELECT throws_ok('v200s4', - 'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER', - 'throws because source is FLOAT'); -SELECT throws_ok('v200s5', - 'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER', - 'throws because id is TEXT'); - - ---target is only integer -PREPARE v200t1 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::SMALLINT, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t2 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::BIGINT, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t3 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::FLOAT, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t4 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::REAL, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t5 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::TEXT, cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200t1', - 'lives because target is SMALLINT'); -SELECT lives_ok('v200t2', - 'lives because target is BIGINT'); -SELECT throws_ok('v200t3', - 'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER', - 'throws because target is REAL'); -SELECT throws_ok('v200t4', - 'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER', - 'throws because target is FLOAT'); -SELECT throws_ok('v200t5', - 'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER', - 'throws because target is TEXT'); - --- cost -PREPARE v200c1 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::SMALLINT FROM edge_table', - 2, 3, false); -PREPARE v200c2 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER FROM edge_table', - 2, 3, false); -PREPARE v200c3 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::BIGINT FROM edge_table', - 2, 3, false); -PREPARE v200c4 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::REAL FROM edge_table', - 2, 3, false); -PREPARE v200c5 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::TEXT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200c1', - 'lives because cost is SMALLINT'); -SELECT lives_ok('v200c2', - 'lives because cost is INTEGER'); -SELECT lives_ok('v200c3', - 'lives because cost is BIGINT'); -SELECT lives_ok('v200c4', - 'lives because cost is REAL'); -SELECT throws_ok('v200c5', - 'XX000','Unexpected Column ''cost'' type. Expected ANY-NUMERICAL', - 'throws because cost is TEXT'); - --- reverse_cost -PREPARE v200r1 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::SMALLINT FROM edge_table', - 2, 3, false); -PREPARE v200r2 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::INTEGER FROM edge_table', - 2, 3, false); -PREPARE v200r3 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::BIGINT FROM edge_table', - 2, 3, false); -PREPARE v200r4 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::REAL FROM edge_table', - 2, 3, false); -PREPARE v200r5 AS -SELECT * FROM pgr_dijkstra( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::TEXT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200r1', - 'lives because reverse_cost is SMALLINT'); -SELECT lives_ok('v200r2', - 'lives because reverse_cost is INTEGER'); -SELECT lives_ok('v200r3', - 'lives because reverse_cost is BIGINT'); -SELECT lives_ok('v200r4', - 'lives because reverse_cost is REAL'); -SELECT throws_ok('v200r5', - 'XX000','Unexpected Column ''reverse_cost'' type. Expected ANY-NUMERICAL', - 'throws because reverse_cost is TEXT'); - - SELECT finish(); - ROLLBACK; diff --git a/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_has_reverse.pg b/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_has_reverse.pg index 73f2e3b2b24..8431c385663 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_has_reverse.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_has_reverse.pg @@ -19,235 +19,90 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; - UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(79); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('3.1.0') THEN plan(126) ELSE PLAN(102) END; -- 0 edges tests -SELECT is_empty(' SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id>18 ','1'); - --- directed graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '', 5, 6)', '2'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '',array[5], 6)','3'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '',array[5], array[6])', '4'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '', 5, array[6])', '5'); - --- undirected graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '', 5, 6, false)', '6'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '',array[5], 6, false)', '7'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '',array[5], array[6], false)', '8'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id>18 '', 5, array[6], false)', '9'); +PREPARE edges0 AS +SELECT id, source, target, cost, reverse_cost from edges where id>18; + +SELECT is_empty('edges0','Edges 0'); + +SELECT taptest('is_empty','edges0', 7, 11, true); +SELECT taptest('is_empty','edges0', 11, 7, true); +SELECT taptest('is_empty','edges0', 7, 11, false); +SELECT taptest('is_empty','edges0', 11, 7, false); -- 1 edges tests --- edge doesnt have start_vid = 5 but has end_vid = 6 -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 9', -'SELECT 9::BIGINT, 6::BIGINT, 9::BIGINT, true, true', -'10: Edge does not have start_vid = 5 but has end_vid = 6'); - --- directed graph - -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '', 5, 6)', '11'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '',array[5], 6)', '12'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '',array[5], array[6])', '13'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '', 5, array[6])', '14'); - --- undirected graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '', 5, 6, false)', '15'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '',array[5], 6, false)', '16'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '',array[5], array[6], false)', '17'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 9 '', 5, array[6], false)', '18'); - --- edge doesnt have end_vid = 6 but has start_vid = 5 -SELECT results_eq( -'SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 4', -'SELECT 4::BIGINT, 2::BIGINT, 5::BIGINT, true, true', -'19: Edge doesnt have end_vid = 6 but has start_vid = 5'); - - --- directed graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '', 5, 6)', '20'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '',array[5], 6)', '21'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '',array[5], array[6])', '22'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '', 5, array[6])', '23'); - --- undirected graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '', 5, 6, false)', '24'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '',array[5], 6, false)', '25'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '',array[5], array[6], false)', '26'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 4 '', 5, array[6], false)', '27'); - --- edge has start_vid 6 and end_vid 5 - -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 8', -'SELECT 8::BIGINT, 5::BIGINT, 6::BIGINT, true, true', -' 28: Edge has start_vid 6 and end_vid 5'); - -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '', 5, 6)', '29'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '',array[5], 6)', '30'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '',array[5], array[6])', '31'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '', 5, array[6])', '32'); - --- undirected graph -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '', 5, 6, false)', '33'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '',array[5], 6, false)', '34'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '',array[5], array[6], false)', '35'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 8 '', 5, array[6], false)', '36'); - - --- edge has only vid = 6 but really only one edge is inserted the first one -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 5', -'SELECT 5::BIGINT, 3::BIGINT, 6::BIGINT, true, false', -'37: has only vid = 6 but really only one edge is inserted the first one'); - - --- directed graph -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 5, 6)', '38'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[5], 6)', '39'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[5], array[6])', '40'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 5, array[6])', '41'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 6, 5)', '42'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[6], 5)', '43'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[6], array[5])', '44'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 6, array[5])', '45'); - --- undirected graph - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 5, 6, false)', '46'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[5], 6, false)', '47'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[5], array[6], false)', '48'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 5, array[6], false)', '49'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 6, 5, false)', '50'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[6], 5, false)', '51'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[6], array[5], false)', '52'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 6, array[5], false)', '53'); - - --- only answer is from 4 to 3 -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 3', -'SELECT 3::BIGINT, 3::BIGINT, 4::BIGINT, false, true', -'54: only answer is from 4 to 3'); - --- directed graph THIS doesnt get an answer -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 3, 4)', '55'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[3], 4)', '56'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[3], array[4])', '57'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 3, array[4])', '58'); - -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 4, 3)', '59'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[4], 3)', '60'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[4], array[3])', '61'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 4, array[3])', '62'); - --- undirected graph allways gets an answer -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 3, 4, false)', '63'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[3], 4, false)', '64'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[3], array[4], false)', '65'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 3, array[4], false)', '66'); - -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 4, 3, false)', '67'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[4], 3, false)', '68'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '',array[4], array[3], false)', '69'); -SELECT isnt_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 3 '', 4, array[3], false)', '70'); - --- The edge doesnt have any of them -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 3', -'SELECT 3::BIGINT, 3::BIGINT, 4::BIGINT, false, true', -'71: The edge doesnt have any of them'); - - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 5, 6)', '72'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[5], 6)', '73'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[5], array[6])', '74'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 5, array[6])', '75'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 6, 5, false)', '76'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[6], 5, false)', '77'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '',array[6], array[5], false)', '78'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, reverse_cost from edge_table where id = 5 '', 6, array[5], false)', '79'); - - --- Finish the tests and clean up. +-- edge 11-16 +PREPARE edges1 AS +SELECT id, source, target, cost, reverse_cost from edges where id = 9; + +SELECT results_eq('edges1', +'SELECT 9::BIGINT, 11::BIGINT, 16::BIGINT, 1::FLOAT, 1::FLOAT', +'Edges1: 11-16'); + +SELECT taptest('is_empty','edges1', 7, 11, true); +SELECT taptest('is_empty','edges1', 11, 7, true); +SELECT taptest('is_empty','edges1', 7, 11, false); +SELECT taptest('is_empty','edges1', 11, 7, false); + + +-- edge 6-7 +PREPARE edges2 AS +SELECT id, source, target, cost, reverse_cost from edges where id = 4; + +SELECT results_eq('edges2', +'SELECT 4::BIGINT, 6::BIGINT, 7::BIGINT, 1::FLOAT, 1::FLOAT', +'Edges2: 6-7'); + +SELECT taptest('is_empty','edges2', 7, 11, true); +SELECT taptest('is_empty','edges2', 11, 7, true); +SELECT taptest('is_empty','edges2', 7, 11, false); +SELECT taptest('is_empty','edges2', 11, 7, false); + +-- edge 7-11 +PREPARE edges3 AS +SELECT id, source, target, cost, reverse_cost from edges where id = 8; + +SELECT results_eq('edges3', +'SELECT 8::BIGINT, 7::BIGINT, 11::BIGINT, 1::FLOAT, 1::FLOAT', +'Edges3: 7-11'); + +SELECT taptest('isnt_empty','edges3', 7, 11, true); +SELECT taptest('isnt_empty','edges3', 11, 7, true); +SELECT taptest('isnt_empty','edges3', 7, 11, false); +SELECT taptest('isnt_empty','edges3', 11, 7, false); + +-- edge 10->11 +PREPARE edges4 AS +SELECT id, source, target, cost, reverse_cost from edges where id = 5; + +SELECT results_eq('edges4', +'SELECT 5::BIGINT, 10::BIGINT, 11::BIGINT, 1::FLOAT, -1::FLOAT', +'edges4: 10->11'); + +SELECT taptest('is_empty','edges4', 7, 11, true); +SELECT taptest('is_empty','edges4', 11, 7, true); +SELECT taptest('is_empty','edges4', 7, 11, false); +SELECT taptest('is_empty','edges4', 11, 7, false); + +-- only 10<-15 +PREPARE edges5 AS +SELECT id, source, target, cost, reverse_cost from edges where id = 3; + +SELECT results_eq('edges5', +'SELECT 3::BIGINT, 10::BIGINT, 15::BIGINT, -1::FLOAT, 1::FLOAT', +'edges5: 10<-15'); + +SELECT taptest('is_empty','edges5', 10, 15, true); +SELECT taptest('isnt_empty','edges5', 15, 10, true); +SELECT taptest('isnt_empty','edges5', 10, 15, false); +SELECT taptest('isnt_empty','edges5', 15, 10, false); + SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_neg1_reverse.pg b/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_neg1_reverse.pg index 6d366c95acf..24ccdfd92a9 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_neg1_reverse.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_neg1_reverse.pg @@ -19,233 +19,102 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; - UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(79); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('3.1.0') THEN plan(147) ELSE PLAN(119) END; -- 0 edges tests -SELECT is_empty(' SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id>18 ','1'); - --- directed graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '', 5, 6)', '2'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '',array[5], 6)','3'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '',array[5], array[6])', '4'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '', 5, array[6])', '5'); - --- undirected graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '', 5, 6, false)', '6'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '',array[5], 6, false)', '7'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '',array[5], array[6], false)', '8'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id>18 '', 5, array[6], false)', '9'); +PREPARE edges0 AS +SELECT id, source, target, cost, reverse_cost from edges where id>18; + +SELECT is_empty('edges0','Edges 0'); + +SELECT taptest('is_empty','edges0', 7, 11, true); +SELECT taptest('is_empty','edges0', 11, 7, true); +SELECT taptest('is_empty','edges0', 7, 11, false); +SELECT taptest('is_empty','edges0', 11, 7, false); -- 1 edges tests --- edge doesnt have start_vid = 5 but has end_vid = 6 -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 9', -'SELECT 9::BIGINT, 6::BIGINT, 9::BIGINT, true, true', -'10: Edge does not have start_vid = 5 but has end_vid = 6'); - --- directed graph - -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '', 5, 6)', '11'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '',array[5], 6)', '12'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '',array[5], array[6])', '13'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '', 5, array[6])', '14'); - --- undirected graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '', 5, 6, false)', '15'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '',array[5], 6, false)', '16'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '',array[5], array[6], false)', '17'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 9 '', 5, array[6], false)', '18'); - --- edge doesnt have end_vid = 6 but has start_vid = 5 -SELECT results_eq( -'SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 4', -'SELECT 4::BIGINT, 2::BIGINT, 5::BIGINT, true, true', -'19: Edge doesnt have end_vid = 6 but has start_vid = 5'); - - --- directed graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '', 5, 6)', '20'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '',array[5], 6)', '21'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '',array[5], array[6])', '22'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '', 5, array[6])', '23'); - --- undirected graph -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '', 5, 6, false)', '24'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '',array[5], 6, false)', '25'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '',array[5], array[6], false)', '26'); -SELECT is_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 4 '', 5, array[6], false)', '27'); - --- edge has start_vid 6 and end_vid 5 - -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 8', -'SELECT 8::BIGINT, 5::BIGINT, 6::BIGINT, true, true', -' 28: Edge has start_vid 6 and end_vid 5'); - -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '', 5, 6)', '29'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '',array[5], 6)', '30'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '',array[5], array[6])', '31'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '', 5, array[6])', '32'); - --- undirected graph -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '', 5, 6, false)', '33'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '',array[5], 6, false)', '34'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '',array[5], array[6], false)', '35'); -SELECT isnt_empty(' -SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 8 '', 5, array[6], false)', '36'); - - --- edge has only vid = 6 but really only one edge is inserted the first one -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 5', -'SELECT 5::BIGINT, 3::BIGINT, 6::BIGINT, true, false', -'37: has only vid = 6 but really only one edge is inserted the first one'); - - --- directed graph -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 5, 6)', '38'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[5], 6)', '39'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[5], array[6])', '40'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 5, array[6])', '41'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 6, 5)', '42'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[6], 5)', '43'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[6], array[5])', '44'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 6, array[5])', '45'); - --- undirected graph - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 5, 6, false)', '46'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[5], 6, false)', '47'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[5], array[6], false)', '48'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 5, array[6], false)', '49'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 6, 5, false)', '50'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[6], 5, false)', '51'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[6], array[5], false)', '52'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 6, array[5], false)', '53'); - - --- only answer is from 4 to 3 -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 3', -'SELECT 3::BIGINT, 3::BIGINT, 4::BIGINT, false, true', -'54: only answer is from 4 to 3'); - --- directed graph THIS doesnt get an answer -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 3, 4)', '55'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[3], 4)', '56'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[3], array[4])', '57'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 3, array[4])', '58'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 4, 3)', '59'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[4], 3)', '60'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[4], array[3])', '61'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 4, array[3])', '62'); - --- undirected graph allways gets an answer -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 3, 4, false)', '63'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[3], 4, false)', '64'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[3], array[4], false)', '65'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 3, array[4], false)', '66'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 4, 3, false)', '67'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[4], 3, false)', '68'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '',array[4], array[3], false)', '69'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 3 '', 4, array[3], false)', '70'); - --- The edge doesnt have any of them -SELECT results_eq(' -SELECT id, source, target, cost > 0, reverse_cost > 0 from edge_table where id = 3', -'SELECT 3::BIGINT, 3::BIGINT, 4::BIGINT, false, true', -'71: The edge doesnt have any of them'); - - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 5, 6)', '72'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[5], 6)', '73'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[5], array[6])', '74'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 5, array[6])', '75'); - -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 6, 5, false)', '76'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[6], 5, false)', '77'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '',array[6], array[5], false)', '78'); -SELECT is_empty(' - SELECT * from pgr_dijkstra(''SELECT id, source, target, cost, -1 AS reverse_cost from edge_table where id = 5 '', 6, array[5], false)', '79'); +-- edge 11->16 +PREPARE edges1 AS +SELECT id, source, target, cost, -1::FLOAT AS reverse_cost from edges where id = 9; + +SELECT results_eq('edges1', +'SELECT 9::BIGINT, 11::BIGINT, 16::BIGINT, 1::FLOAT, -1::FLOAT', +'Edges1: 11 -> 16'); + +SELECT taptest('is_empty','edges1', 7, 11, true); +SELECT taptest('is_empty','edges1', 11, 7, true); +SELECT taptest('is_empty','edges1', 7, 11, false); +SELECT taptest('is_empty','edges1', 11, 7, false); + +-- edge 6->7 +PREPARE edges2 AS +SELECT id, source, target, cost, -1::FLOAT AS reverse_cost from edges where id = 4; + +SELECT results_eq('edges2', +'SELECT 4::BIGINT, 6::BIGINT, 7::BIGINT, 1::FLOAT, -1::FLOAT', +'Edges2: 6 -> 7'); + +SELECT taptest('is_empty','edges2', 7, 11, true); +SELECT taptest('is_empty','edges2', 11, 7, true); +SELECT taptest('is_empty','edges2', 7, 11, false); +SELECT taptest('is_empty','edges2', 11, 7, false); + +-- edge 7->11 +PREPARE edges3 AS +SELECT id, source, target, cost, -1::FLOAT AS reverse_cost from edges where id = 8; + +SELECT results_eq('edges3', +'SELECT 8::BIGINT, 7::BIGINT, 11::BIGINT, 1::FLOAT, -1::FLOAT', +'Edges3: 7 -> 11'); + +SELECT taptest('isnt_empty','edges3', 7, 11, true); +SELECT taptest('is_empty','edges3', 11, 7, true); +SELECT taptest('isnt_empty','edges3', 7, 11, false); +SELECT taptest('isnt_empty','edges3', 11, 7, false); + + +-- edge 10->11 +PREPARE edges4 AS +SELECT id, source, target, cost, -1::FLOAT AS reverse_cost from edges where id = 5; + +SELECT results_eq('edges4', +'SELECT 5::BIGINT, 10::BIGINT, 11::BIGINT, 1::FLOAT, -1::FLOAT', +'edges4: 10 -> 11'); + +SELECT taptest('is_empty','edges4', 7, 11, true); +SELECT taptest('is_empty','edges4', 11, 7, true); +SELECT taptest('is_empty','edges4', 7, 11, false); +SELECT taptest('is_empty','edges4', 11, 7, false); + +-- vertices 10 15 +PREPARE edges5 AS +SELECT id, source, target, cost, -1::FLOAT AS reverse_cost from edges where id = 3; + +SELECT results_eq('edges5', +'SELECT 3::BIGINT, 10::BIGINT, 15::BIGINT, -1::FLOAT, -1::FLOAT', +'edges5: only vertices 10 15'); + +SELECT taptest('is_empty','edges5', 10, 15, true); +SELECT taptest('is_empty','edges5', 15, 10, true); +SELECT taptest('is_empty','edges5', 10, 15, false); +SELECT taptest('is_empty','edges5', 15, 10, false); + +-- edge 8->12 +PREPARE edges6 AS +SELECT id, source, target, cost, -1::FLOAT AS reverse_cost from edges where id = 12; + +SELECT results_eq('edges6', +'SELECT 12::BIGINT, 8::BIGINT, 12::BIGINT, 1::FLOAT, -1::FLOAT', +'edges5: 8 -> 12'); +SELECT taptest('is_empty','edges6', 7, 11, true); +SELECT taptest('is_empty','edges6', 11, 7, true); +SELECT taptest('is_empty','edges6', 7, 11, false); +SELECT taptest('is_empty','edges6', 11, 7, false); -- Finish the tests and clean up. SELECT * FROM finish(); diff --git a/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_no_reverse.pg b/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_no_reverse.pg index f9e648cb9fa..994c3894b8a 100644 --- a/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_no_reverse.pg +++ b/pgtap/dijkstra/dijkstra/edge_cases/zero_one_edge_no_reverse.pg @@ -19,102 +19,89 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('3.1.0') THEN plan(130) ELSE plan(104) END; - -CREATE OR REPLACE FUNCTION do_test(TEXT, BIGINT, BIGINT) -RETURNS SETOF TEXT AS -$BODY$ -BEGIN - -- directed graph - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, %2$s, %3$s)$$,$1,$2,$3), 'D. One to one ' || $1); - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, ARRAY[%2$s], %3$s)$$,$1,$2,$3), 'D. One to many- ' || $1); - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, %2$s, ARRAY[%3$s])$$,$1,$2,$3), 'D. Many to one- ' || $1); - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, ARRAY[%2$s], ARRAY[%3$s])$$,$1,$2,$3), 'D. Many to Many- ' || $1); - - -- undirected graph - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, %2$s, %3$s, false)$$,$1,$2,$3), 'D. One to one ' || $1); - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, ARRAY[%2$s], %3$s, false)$$,$1,$2,$3), 'D. One to many- ' || $1); - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, %2$s, ARRAY[%3$s], false)$$,$1,$2,$3), 'D. Many to one- ' || $1); - RETURN QUERY - SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, ARRAY[%2$s], ARRAY[%3$s], false)$$,$1,$2,$3), 'D. Many to Many- ' || $1); - - IF min_version('3.1.0') THEN - RETURN QUERY SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, 'combination', false)$$,$1), 'D. Combinations- ' || $1); - RETURN QUERY SELECT is_empty(format($$SELECT * from pgr_dijkstra(%1$L, 'combination')$$,$1), 'D. Combinations- ' || $1); - END IF; - -END; -$BODY$ -LANGUAGE plpgsql VOLATILE; - - -PREPARE combination AS -SELECT 5 AS source, 6 AS target; +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('3.1.0') THEN plan(126) ELSE PLAN(102) END; -- 0 edges tests -PREPARE empty_edges AS -SELECT id, source, target, cost FROM edge_table WHERE id > 18; -SELECT do_test('empty_edges', 5, 6); -SELECT do_test('empty_edges', 6, 5); +PREPARE edges0 AS +SELECT id, source, target, cost from edges where id>18; + +SELECT is_empty('edges0','Edges 0'); + +SELECT taptest('is_empty','edges0', 7, 11, true); +SELECT taptest('is_empty','edges0', 11, 7, true); +SELECT taptest('is_empty','edges0', 7, 11, false); +SELECT taptest('is_empty','edges0', 11, 7, false); -- 1 edges tests -PREPARE edge_9_6 AS -SELECT id, source, target, cost FROM edge_table WHERE id = 9; -SELECT do_test('edge_9_6', 5, 6); -SELECT do_test('edge_9_6', 6, 5); - - -PREPARE edge_4_5 AS -SELECT id, source, target, cost FROM edge_table WHERE id = 4; -SELECT do_test('edge_4_5', 5, 6); -SELECT do_test('edge_4_5', 6, 5); - -PREPARE edge_3_6 AS -SELECT id, source, target, cost FROM edge_table WHERE id = 5; -SELECT do_test('edge_3_6', 5, 6); -SELECT do_test('edge_3_6', 6, 5); - -PREPARE edge_3_4 AS -SELECT id, source, target, cost FROM edge_table WHERE id = 3; -SELECT do_test('edge_3_4', 3, 4); -SELECT do_test('edge_3_4', 4, 3); -SELECT do_test('edge_3_4', 5, 6); -SELECT do_test('edge_3_4', 6, 5); - --- There is a solution -PREPARE edge_5_6 AS -SELECT id, source, target, cost FROM edge_table WHERE id = 8; - --- directed graph -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', 5, 6)$$, 'D. One to one- edge_5_6 -> no result'); -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', ARRAY[5], 6)$$, 'D. One to many- edge_5_6 -> no result'); -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', 5, ARRAY[6])$$, 'D. Many to one- edge_5_6 -> no result'); -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', ARRAY[5], ARRAY[6])$$, 'D. Many to Many- edge_5_6 -> no result'); - --- undirected graph -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', 5, 6, false)$$, 'U. One to one- edge_5_6 -> no result'); -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', ARRAY[5], 6, false)$$, 'U. One to many- edge_5_6 -> no result'); -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', 5, ARRAY[6], false)$$, 'U. Many to one- edge_5_6 -> no result'); -SELECT isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', ARRAY[5], ARRAY[6], false)$$, 'U. Many to Many- edge_5_6 -> no result'); - -SELECT CASE -WHEN min_version('3.1.0') THEN - collect_tap( - isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', 'combination')$$, 'D. Combinations- edge_5_6 -> no result'), - isnt_empty($$SELECT * from pgr_dijkstra('edge_5_6', 'combination', false)$$, 'U. Combinations- edge_5_6 -> no result') - ) -END; +-- edge 11->16 +PREPARE edges1 AS +SELECT id, source, target, cost from edges where id = 9; + +SELECT results_eq('edges1', +'SELECT 9::BIGINT, 11::BIGINT, 16::BIGINT, 1::FLOAT', +'Edges1: 11->16'); + +SELECT taptest('is_empty','edges1', 7, 11, true); +SELECT taptest('is_empty','edges1', 11, 7, true); +SELECT taptest('is_empty','edges1', 7, 11, false); +SELECT taptest('is_empty','edges1', 11, 7, false); + + +-- edge 6->7 +PREPARE edges2 AS +SELECT id, source, target, cost from edges where id = 4; + +SELECT results_eq('edges2', +'SELECT 4::BIGINT, 6::BIGINT, 7::BIGINT, 1::FLOAT', +'Edges2: 6->7'); + +SELECT taptest('is_empty','edges2', 7, 11, true); +SELECT taptest('is_empty','edges2', 11, 7, true); +SELECT taptest('is_empty','edges2', 7, 11, false); +SELECT taptest('is_empty','edges2', 11, 7, false); + +-- edge 7->11 +PREPARE edges3 AS +SELECT id, source, target, cost from edges where id = 8; + +SELECT results_eq('edges3', +'SELECT 8::BIGINT, 7::BIGINT, 11::BIGINT, 1::FLOAT', +'Edges3: 7->11'); + +SELECT taptest('isnt_empty','edges3', 7, 11, true); +SELECT taptest('is_empty','edges3', 11, 7, true); +SELECT taptest('isnt_empty','edges3', 7, 11, false); +SELECT taptest('isnt_empty','edges3', 11, 7, false); + +-- edge 10->11 +PREPARE edges4 AS +SELECT id, source, target, cost from edges where id = 5; + +SELECT results_eq('edges4', +'SELECT 5::BIGINT, 10::BIGINT, 11::BIGINT, 1::FLOAT', +'edges4: 10->11'); + +SELECT taptest('is_empty','edges4', 7, 11, true); +SELECT taptest('is_empty','edges4', 11, 7, true); +SELECT taptest('is_empty','edges4', 7, 11, false); +SELECT taptest('is_empty','edges4', 11, 7, false); + +-- only 10 15 +PREPARE edges5 AS +SELECT id, source, target, cost from edges where id = 3; + +SELECT results_eq('edges5', +'SELECT 3::BIGINT, 10::BIGINT, 15::BIGINT, -1::FLOAT', +'edges5: 10 15'); + +SELECT taptest('is_empty','edges5', 10, 15, true); +SELECT taptest('is_empty','edges5', 15, 10, true); +SELECT taptest('is_empty','edges5', 10, 15, false); +SELECT taptest('is_empty','edges5', 15, 10, false); SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/dijkstra/dijkstra/inner_query.pg b/pgtap/dijkstra/dijkstra/inner_query.pg index c5b6d287bfe..c5b577ce31d 100644 --- a/pgtap/dijkstra/dijkstra/inner_query.pg +++ b/pgtap/dijkstra/dijkstra/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.1.0') THEN plan(282) ELSE plan(218) END; @@ -37,8 +37,8 @@ CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN IF min_version('3.1.0') THEN - RETURN QUERY SELECT style_dijkstra('pgr_dijkstra(', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_dijkstra($$SELECT * FROM edge_table$$,',', true)'); + RETURN QUERY SELECT style_dijkstra('pgr_dijkstra(', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_dijkstra($$SELECT * FROM edges$$,',', true)'); ELSE RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.1.0'); END IF; diff --git a/pgtap/dijkstra/dijkstra/no_crash_test.pg b/pgtap/dijkstra/dijkstra/no_crash_test.pg index 907ad3944a8..58105f220ec 100644 --- a/pgtap/dijkstra/dijkstra/no_crash_test.pg +++ b/pgtap/dijkstra/dijkstra/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.1.0') THEN plan(81) ELSE plan(68) END; SELECT no_crash_dijkstra('pgr_dijkstra'); diff --git a/pgtap/dijkstra/dijkstraCost/edge_cases/empty_combinations_empty_result.pg b/pgtap/dijkstra/dijkstraCost/edge_cases/empty_combinations_empty_result.pg index aff0fb116c0..57627d9e432 100644 --- a/pgtap/dijkstra/dijkstraCost/edge_cases/empty_combinations_empty_result.pg +++ b/pgtap/dijkstra/dijkstraCost/edge_cases/empty_combinations_empty_result.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(1); create or REPLACE FUNCTION foo() @@ -37,8 +37,8 @@ BEGIN RETURN query SELECT is_empty( 'SELECT start_vid, end_vid, agg_cost FROM pgr_dijkstraCost( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', - ''SELECT * FROM combinations_table WHERE source=-1'' ) ' + ''SELECT id, source, target, cost, reverse_cost FROM edges'', + ''SELECT * FROM combinations WHERE source=-1'' ) ' ); END $BODY$ diff --git a/pgtap/dijkstra/dijkstraCost/edge_cases/remaining_tests.pg b/pgtap/dijkstra/dijkstraCost/edge_cases/remaining_tests.pg deleted file mode 100644 index c8b55247fe0..00000000000 --- a/pgtap/dijkstra/dijkstraCost/edge_cases/remaining_tests.pg +++ /dev/null @@ -1,313 +0,0 @@ - -/*PGR-GNU***************************************************************** - -Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org - ------- -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ********************************************************************PGR-GNU*/ - -BEGIN; - -SET client_min_messages TO WARNING; - -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(33); - - - - --- testing for the 4 signatures that they return the correct names & columns --- Preparing -PREPARE v21q00 AS -SELECT - pg_typeof(start_vid)::text AS t3, pg_typeof(end_vid)::text AS t4, - pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, 3, true) ) AS a - limit 1 -; -PREPARE v21q01 AS -SELECT - 'bigint'::text AS t3, 'bigint'::text AS t4, - 'double precision'::text AS t8; - -PREPARE v21q10 AS -SELECT - pg_typeof(start_vid)::text AS t3, pg_typeof(end_vid)::text AS t4, - pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, ARRAY[3], true) ) AS a - limit 1 -; -PREPARE v21q11 AS -SELECT - 'bigint'::text AS t3, 'bigint'::text AS t4, - 'double precision'::text AS t8; - - -PREPARE v21q20 AS -SELECT - pg_typeof(start_vid)::text AS t3, pg_typeof(end_vid)::text AS t4, - pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - ARRAY[2], 3, true) ) AS a - limit 1 -; -PREPARE v21q21 AS -SELECT - 'bigint'::text AS t3, 'bigint'::text AS t4, - 'double precision'::text AS t8; - -PREPARE v21q30 AS -SELECT - pg_typeof(start_vid)::text AS t3, pg_typeof(end_vid)::text AS t4, - pg_typeof(agg_cost)::TEXT AS t8 - FROM ( - SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - ARRAY[2], ARRAY[3], true) ) AS a - limit 1 -; -PREPARE v21q31 AS -SELECT - 'bigint'::text AS t3, 'bigint'::text AS t4, - 'double precision'::text AS t8; - --- testing -SELECT set_eq('v21q00', 'v21q01','1 to 1: Expected returning, columns names & types'); -SELECT set_eq('v21q10', 'v21q11','1 to many: Expected returning, columns names & types'); -SELECT set_eq('v21q20', 'v21q21','many to 1: Expected returning, columns names & types'); -SELECT set_eq('v21q30', 'v21q31','many to many: Expected returning, columns names & types'); - - --- CHECKING WORKS WITH & WITOUT REVERSE COST - -PREPARE v20q1 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, 3, true); -PREPARE v20q3 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v20q1','with reverse cost 1'); -SELECT lives_ok('v20q3','with reverse cost 3'); - -PREPARE v20q5 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, true); - -PREPARE v20q6 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); - - -SELECT lives_ok('v20q5','without reverse cost 1'); -SELECT lives_ok('v20q6','without reverse cost 2'); - --- V2.0 --- CHECKING INNER QUERY --- ANY-INTEGER, ANY-INTEGER, ANY-INTEGER, ANY-NUMERIC, [ANY-NUMERIC] - -/* TEST USES THE EDGES_INPUT FOR 5 PARAMETERS */ - ---id ANY-INTEGER -PREPARE v200id1 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::SMALLINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id2 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::BIGINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id3 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::FLOAT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id4 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::REAL, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200id5 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::TEXT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200id1', - 'lives because id is SMALLINT'); -SELECT lives_ok('v200id2', - 'lives because id is BIGINT'); -SELECT throws_ok('v200id3', - 'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER', - 'throws because id is REAL'); -SELECT throws_ok('v200id4', - 'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER', - 'throws because id is FLOAT'); -SELECT throws_ok('v200id5', - 'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER', - 'throws because id is TEXT'); - ---source is only integer -PREPARE v200s1 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::SMALLINT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s2 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::BIGINT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s3 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::REAL, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s4 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::FLOAT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200s5 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::TEXT, target::INTEGER, cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200s1', - 'lives because source is SMALLINT'); -SELECT lives_ok('v200s2', - 'lives because source is BIGINT'); -SELECT throws_ok('v200s3', - 'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER', - 'throws because source is REAL'); -SELECT throws_ok('v200s4', - 'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER', - 'throws because source is FLOAT'); -SELECT throws_ok('v200s5', - 'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER', - 'throws because id is TEXT'); - - ---target is only integer -PREPARE v200t1 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::SMALLINT, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t2 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::BIGINT, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t3 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::FLOAT, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t4 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::REAL, cost::FLOAT FROM edge_table', - 2, 3, false); -PREPARE v200t5 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::TEXT, cost::FLOAT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200t1', - 'lives because target is SMALLINT'); -SELECT lives_ok('v200t2', - 'lives because target is BIGINT'); -SELECT throws_ok('v200t3', - 'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER', - 'throws because target is REAL'); -SELECT throws_ok('v200t4', - 'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER', - 'throws because target is FLOAT'); -SELECT throws_ok('v200t5', - 'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER', - 'throws because target is TEXT'); - --- cost -PREPARE v200c1 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::SMALLINT FROM edge_table', - 2, 3, false); -PREPARE v200c2 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER FROM edge_table', - 2, 3, false); -PREPARE v200c3 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::BIGINT FROM edge_table', - 2, 3, false); -PREPARE v200c4 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::REAL FROM edge_table', - 2, 3, false); -PREPARE v200c5 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::TEXT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200c1', - 'lives because cost is SMALLINT'); -SELECT lives_ok('v200c2', - 'lives because cost is INTEGER'); -SELECT lives_ok('v200c3', - 'lives because cost is BIGINT'); -SELECT lives_ok('v200c4', - 'lives because cost is REAL'); -SELECT throws_ok('v200c5', - 'XX000','Unexpected Column ''cost'' type. Expected ANY-NUMERICAL', - 'throws because cost is TEXT'); - --- reverse_cost -PREPARE v200r1 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::SMALLINT FROM edge_table', - 2, 3, false); -PREPARE v200r2 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::INTEGER FROM edge_table', - 2, 3, false); -PREPARE v200r3 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::BIGINT FROM edge_table', - 2, 3, false); -PREPARE v200r4 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::REAL FROM edge_table', - 2, 3, false); -PREPARE v200r5 AS -SELECT * FROM pgr_dijkstracost( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::TEXT FROM edge_table', - 2, 3, false); - -SELECT lives_ok('v200r1', - 'lives because reverse_cost is SMALLINT'); -SELECT lives_ok('v200r2', - 'lives because reverse_cost is INTEGER'); -SELECT lives_ok('v200r3', - 'lives because reverse_cost is BIGINT'); -SELECT lives_ok('v200r4', - 'lives because reverse_cost is REAL'); -SELECT throws_ok('v200r5', - 'XX000','Unexpected Column ''reverse_cost'' type. Expected ANY-NUMERICAL', - 'throws because reverse_cost is TEXT'); - -SELECT finish(); -ROLLBACK; diff --git a/pgtap/dijkstra/dijkstraCost/inner_query.pg b/pgtap/dijkstra/dijkstraCost/inner_query.pg index 8029bad285f..e5c33ee1529 100644 --- a/pgtap/dijkstra/dijkstraCost/inner_query.pg +++ b/pgtap/dijkstra/dijkstraCost/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.1.0') THEN plan(282) ELSE plan(218) END; @@ -37,8 +37,8 @@ CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN IF min_version('3.1.0') THEN - RETURN QUERY SELECT style_dijkstra('pgr_dijkstraCost(', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_dijkstraCost($$SELECT * FROM edge_table$$,',', true)'); + RETURN QUERY SELECT style_dijkstra('pgr_dijkstraCost(', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_dijkstraCost($$SELECT * FROM edges$$,',', true)'); ELSE RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.1.0'); END IF; diff --git a/pgtap/dijkstra/dijkstraCost/no_crash_test.pg b/pgtap/dijkstra/dijkstraCost/no_crash_test.pg index 8ed9e80825f..2319fa46d32 100644 --- a/pgtap/dijkstra/dijkstraCost/no_crash_test.pg +++ b/pgtap/dijkstra/dijkstraCost/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.1.0') THEN plan(81) ELSE plan(68) END; SELECT no_crash_dijkstra('pgr_dijkstraCost'); diff --git a/pgtap/dijkstra/dijkstraCostMatrix/inner_query.pg b/pgtap/dijkstra/dijkstraCostMatrix/inner_query.pg index 145d3c9cad9..0b139e86680 100644 --- a/pgtap/dijkstra/dijkstraCostMatrix/inner_query.pg +++ b/pgtap/dijkstra/dijkstraCostMatrix/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(54); -- ONE MATRIX diff --git a/pgtap/dijkstra/dijkstraCostMatrix/no_crash_test.pg b/pgtap/dijkstra/dijkstraCostMatrix/no_crash_test.pg index fc4402b3693..a6a15810711 100644 --- a/pgtap/dijkstra/dijkstraCostMatrix/no_crash_test.pg +++ b/pgtap/dijkstra/dijkstraCostMatrix/no_crash_test.pg @@ -19,14 +19,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(14); PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE null_ret AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT set_eq('null_ret', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); @@ -39,10 +39,10 @@ DECLARE params TEXT[]; subs TEXT[]; BEGIN - params = ARRAY['$$edges$$','ARRAY[1,2]::BIGINT[]']::TEXT[]; + params = ARRAY['$$edges$$','ARRAY[5,6]::BIGINT[]']::TEXT[]; subs = ARRAY[ 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_dijkstraCostMatrix', params, subs); diff --git a/pgtap/dijkstra/dijkstraNear/compare_dijkstra.pg b/pgtap/dijkstra/dijkstraNear/compare_dijkstra.pg index 2d5a50c9518..65fd51c7cc1 100644 --- a/pgtap/dijkstra/dijkstraNear/compare_dijkstra.pg +++ b/pgtap/dijkstra/dijkstraNear/compare_dijkstra.pg @@ -21,7 +21,7 @@ BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(142) END; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; @@ -29,25 +29,25 @@ CREATE TABLE expected AS WITH a AS (SELECT start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2 FROM (VALUES - (1::BIGINT, - ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], - ARRAY[2,5]::BIGINT[], ARRAY[2,3]::BIGINT[], ARRAY[2,5]::BIGINT[], ARRAY[2, 5]::BIGINT[]), - (2, ARRAY[ 1], ARRAY[ 1], ARRAY[ 5], ARRAY[ 1], ARRAY[1, 5], ARRAY[1, 3], ARRAY[5, 6], ARRAY[1, 5]), - (3, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 6], ARRAY[2, 6], ARRAY[2, 4], ARRAY[6, 9], ARRAY[5, 6]), - (4, ARRAY[ 3], ARRAY[ 3], ARRAY[ 9], ARRAY[ 9], ARRAY[3, 9], ARRAY[3, 9], ARRAY[9, 12], ARRAY[6, 9]), - (5, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 2], ARRAY[2, 8], ARRAY[2, 8], ARRAY[6, 10], ARRAY[2, 8]), - (6, ARRAY[ 5], ARRAY[ 3], ARRAY[ 9], ARRAY[ 3], ARRAY[5, 9], ARRAY[3, 5], ARRAY[9, 11], ARRAY[3, 5]), - (7, ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8]), - (8, ARRAY[ 7], ARRAY[ 7], ARRAY[ 5], ARRAY[ 7], ARRAY[5, 7], ARRAY[5, 7], ARRAY[5, 6], ARRAY[5, 7]), - (9, ARRAY[ 6], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[6,12], ARRAY[6, 12], ARRAY[12], ARRAY[6, 12]), - (10, ARRAY[ 5], ARRAY[ 5], ARRAY[11], ARRAY[ 5], ARRAY[5,11], ARRAY[5, 11], ARRAY[11, 13], ARRAY[5, 11]), - (11, ARRAY[12], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[9,12], ARRAY[6, 10], ARRAY[12], ARRAY[6, 10]), - (12, ARRAY[ 9], ARRAY[11], NULL, ARRAY[ 11], ARRAY[6, 9], ARRAY[9, 11], NULL, ARRAY[9, 11]), - (13, ARRAY[10], ARRAY[10], NULL, ARRAY[ 10], ARRAY[5,10], ARRAY[5, 10], NULL, ARRAY[5, 10]), - (14, ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[ 15], ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[15]), - (15, ARRAY[14], ARRAY[14], NULL, ARRAY[ 14], ARRAY[14], ARRAY[14], NULL, ARRAY[14]), - (16, ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[ 17], ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[17]), - (17, ARRAY[16], ARRAY[16], NULL, ARRAY[ 16], ARRAY[16], ARRAY[16], NULL, ARRAY[16]) + (5::BIGINT, + ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], + ARRAY[6,7]::BIGINT[], ARRAY[6,10]::BIGINT[], ARRAY[6,7]::BIGINT[], ARRAY[6, 7]::BIGINT[]), + (6, ARRAY[ 5], ARRAY[ 5], ARRAY[ 7], ARRAY[ 5], ARRAY[5,7], ARRAY[5,10], ARRAY[7,11], ARRAY[5,7]), + (10,ARRAY[ 6], ARRAY[ 6], ARRAY[11], ARRAY[11], ARRAY[6,11], ARRAY[6,15], ARRAY[11,16],ARRAY[7,11]), + (15,ARRAY[10], ARRAY[10], ARRAY[16], ARRAY[16], ARRAY[10,16],ARRAY[10,16],ARRAY[16,17],ARRAY[11,16]), + (7, ARRAY[ 6], ARRAY[ 6], ARRAY[11], ARRAY[ 6], ARRAY[6,3], ARRAY[6,3], ARRAY[11,8], ARRAY[6,3]), + (11,ARRAY[ 7], ARRAY[10], ARRAY[16], ARRAY[10], ARRAY[7,16], ARRAY[10,7], ARRAY[16,12],ARRAY[10,7]), + (1, ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[7,3], ARRAY[7,3], ARRAY[7,3], ARRAY[7,3]), + (3, ARRAY[ 1], ARRAY[ 1], ARRAY[ 7], ARRAY[ 1], ARRAY[7,1], ARRAY[7,1], ARRAY[7,11], ARRAY[7,1]), + (16,ARRAY[11], ARRAY[11], ARRAY[17], ARRAY[11], ARRAY[11,17],ARRAY[11,17],ARRAY[17], ARRAY[11,17]), + (8, ARRAY[ 7], ARRAY[ 7], ARRAY[12], ARRAY[ 7], ARRAY[7,12], ARRAY[7,12], ARRAY[12,9], ARRAY[7,12]), + (12,ARRAY[17], ARRAY[11], ARRAY[17], ARRAY[11], ARRAY[16,17],ARRAY[11,8], ARRAY[17], ARRAY[11,8]), + (17,ARRAY[16], ARRAY[12], NULL, ARRAY[12], ARRAY[11,16],ARRAY[16,12],NULL, ARRAY[16,12]), + (9, ARRAY[8], ARRAY[8], NULL, ARRAY[ 8], ARRAY[7,8], ARRAY[7,8], NULL, ARRAY[7,8]), + (2, ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[ 4], ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[4]), + (4, ARRAY[2], ARRAY[2], NULL, ARRAY[ 2], ARRAY[2], ARRAY[2], NULL, ARRAY[2]), + (13,ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14]), + (14,ARRAY[13], ARRAY[13], NULL, ARRAY[13], ARRAY[13], ARRAY[13], NULL, ARRAY[13]) ) t(start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2)) SELECT * from a; @@ -65,7 +65,7 @@ BEGIN FROM pgr_dijkstraNear( %1$L, %2$s, - (SELECT array_agg(id) FROM edge_table_vertices_pgr where id != %2$s), + (SELECT array_agg(id) FROM vertices where id != %2$s), %3$s); $$, edges_q, id, optionals_n); dijkstra_query := format($$ @@ -98,44 +98,44 @@ IF NOT min_version('3.2.0') THEN END IF; RETURN QUERY -SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table$$); +SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edges$$); RETURN QUERY -SELECT isnt_empty($$SELECT id FROM edge_table_vertices_pgr$$); +SELECT isnt_empty($$SELECT id FROM vertices$$); -- vertex id values that dont exist RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table_vertices_pgr WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM vertices WHERE id > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE source > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE source > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE target > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE target > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM edges WHERE id > 18$$); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_1 AS scnd FROM expected$$, 'directed => true, cap => 1', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_1 AS scnd FROM expected$$, 'directed => false, cap => 1', 'directed => false' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_1 AS scnd FROM expected$$, 'directed => true, cap => 1', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_1 AS scnd FROM expected$$, 'directed => false, cap => 1', 'directed => false' ); @@ -143,28 +143,28 @@ SELECT * from check_compare( RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_2 AS scnd FROM expected$$, 'directed => true, cap => 2', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_2 AS scnd FROM expected$$, 'directed => false, cap => 2', 'directed => false' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_2 AS scnd FROM expected$$, 'directed => true, cap => 2', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_2 AS scnd FROM expected$$, 'directed => false, cap => 2', 'directed => false' ); diff --git a/pgtap/dijkstra/dijkstraNear/edge_cases.pg b/pgtap/dijkstra/dijkstraNear/edge_cases.pg index d2299472e03..f8ee9351014 100644 --- a/pgtap/dijkstra/dijkstraNear/edge_cases.pg +++ b/pgtap/dijkstra/dijkstraNear/edge_cases.pg @@ -21,7 +21,7 @@ BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(122) END; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); @@ -29,24 +29,24 @@ CREATE TABLE expected AS WITH a AS (SELECT start_vid, d_w_1, u_w_1, d_n_1, u_n_1 FROM (VALUES - (1::BIGINT, - ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[]), - (2, ARRAY[ 1, 5], ARRAY[ 1, 3, 5], ARRAY[ 5], ARRAY[ 1, 5]), - (3, ARRAY[ 2, 6], ARRAY[ 2, 4, 6], ARRAY[ 6], ARRAY[ 6]), - (4, ARRAY[ 3, 9], ARRAY[ 3, 9], ARRAY[ 9], ARRAY[ 9]), - (5, ARRAY[ 2, 6, 8, 10], ARRAY[ 2, 6, 8, 10], ARRAY[ 6, 10], ARRAY[ 2, 6, 8, 10]), - (6, ARRAY[ 5, 9, 11], ARRAY[ 3, 5, 9, 11], ARRAY[ 9, 11], ARRAY[ 3, 5, 9, 11]), - (7, ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[ 8]), - (8, ARRAY[ 5, 7], ARRAY[ 5, 7], ARRAY[ 5], ARRAY[ 5, 7]), - (9, ARRAY[ 4, 6, 12], ARRAY[ 4, 6, 12], ARRAY[12], ARRAY[ 4, 6, 12]), - (10, ARRAY[ 5, 11, 13], ARRAY[ 5, 11, 13], ARRAY[11, 13], ARRAY[ 5, 11, 13]), - (11, ARRAY[12], ARRAY[ 6, 10, 12], ARRAY[12], ARRAY[ 6, 10, 12]), - (12, ARRAY[ 9], ARRAY[9, 11], NULL, ARRAY[ 9, 11]), - (13, ARRAY[10], ARRAY[10], NULL, ARRAY[ 10]), - (14, ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[ 15]), - (15, ARRAY[14], ARRAY[14], NULL, ARRAY[ 14]), - (16, ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[ 17]), - (17, ARRAY[16], ARRAY[16], NULL, ARRAY[ 16]) + (5::BIGINT, + ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[]), + (6, ARRAY[ 5, 7], ARRAY[ 5, 10, 7], ARRAY[ 7], ARRAY[ 5, 7]), + (10, ARRAY[ 6, 11], ARRAY[ 6, 15, 11], ARRAY[ 11], ARRAY[ 11]), + (15, ARRAY[ 10, 16], ARRAY[ 10, 16], ARRAY[ 16], ARRAY[ 16]), + (7, ARRAY[ 6, 11, 3, 8], ARRAY[ 6, 11, 3, 8], ARRAY[ 11, 8], ARRAY[ 6, 11, 3, 8]), + (11, ARRAY[ 7, 16, 12], ARRAY[ 10, 7, 16, 12], ARRAY[ 16, 12], ARRAY[ 10, 7, 16, 12]), + (1, ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[ 3]), + (3, ARRAY[ 7, 1], ARRAY[ 7, 1], ARRAY[ 7], ARRAY[ 7, 1]), + (16, ARRAY[ 15, 11, 17], ARRAY[ 15, 11, 17], ARRAY[17], ARRAY[ 15, 11, 17]), + (8, ARRAY[ 7, 12, 9], ARRAY[ 7, 12, 9], ARRAY[12, 9], ARRAY[ 7, 12, 9]), + (12, ARRAY[17], ARRAY[17, 8, 11], ARRAY[17], ARRAY[ 17, 8, 11]), + (11, ARRAY[ 16], ARRAY[16, 12], NULL, ARRAY[ 16, 12]), + (9, ARRAY[8], ARRAY[8], NULL, ARRAY[ 8]), + (2, ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[ 4]), + (4, ARRAY[2], ARRAY[2], NULL, ARRAY[ 2]), + (13, ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[ 14]), + (14, ARRAY[13], ARRAY[13], NULL, ARRAY[ 13]) ) t(start_vid, d_w_1, u_w_1, d_n_1, u_n_1)) SELECT * from a; @@ -79,7 +79,7 @@ BEGIN FROM pgr_dijkstraNear( %1$L, %2$s, - (SELECT array_agg(id) FROM edge_table_vertices_pgr where id != %2$s), + (SELECT array_agg(id) FROM vertices where id != %2$s), %3$s) $$, inner_query, id, optionals); expected_query := format($$ @@ -107,51 +107,51 @@ IF NOT min_version('3.2.0') THEN END IF; RETURN QUERY -SELECT is_empty($$SELECT distinct cost FROM edge_table WHERE cost != 1 AND cost != -1$$); +SELECT is_empty($$SELECT distinct cost FROM edges WHERE cost != 1 AND cost != -1$$); RETURN QUERY -SELECT is_empty($$SELECT distinct reverse_cost FROM edge_table WHERE cost != 1 AND cost != -1$$); +SELECT is_empty($$SELECT distinct reverse_cost FROM edges WHERE cost != 1 AND cost != -1$$); -- Initial tables are good to work RETURN QUERY -SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table$$); +SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edges$$); RETURN QUERY -SELECT isnt_empty($$SELECT id FROM edge_table_vertices_pgr$$); +SELECT isnt_empty($$SELECT id FROM vertices$$); -- vertex id values that dont exist RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table_vertices_pgr WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM vertices WHERE id > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE source > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE source > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE target > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE target > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM edges WHERE id > 18$$); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, d_w_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, u_w_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, d_n_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, u_n_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); diff --git a/pgtap/dijkstra/dijkstraNear/expected_results.pg b/pgtap/dijkstra/dijkstraNear/expected_results.pg index 6ec9cdccfb8..8045353fe31 100644 --- a/pgtap/dijkstra/dijkstraNear/expected_results.pg +++ b/pgtap/dijkstra/dijkstraNear/expected_results.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(142) END; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; @@ -28,25 +28,25 @@ CREATE TABLE expected AS WITH a AS (SELECT start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2 FROM (VALUES - (1::BIGINT, - ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], - ARRAY[2,5]::BIGINT[], ARRAY[2,3]::BIGINT[], ARRAY[2,5]::BIGINT[], ARRAY[2, 5]::BIGINT[]), - (2, ARRAY[ 1], ARRAY[ 1], ARRAY[ 5], ARRAY[ 1], ARRAY[1, 5], ARRAY[1, 3], ARRAY[5, 6], ARRAY[1, 5]), - (3, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 6], ARRAY[2, 6], ARRAY[2, 4], ARRAY[6, 9], ARRAY[5, 6]), - (4, ARRAY[ 3], ARRAY[ 3], ARRAY[ 9], ARRAY[ 9], ARRAY[3, 9], ARRAY[3, 9], ARRAY[9, 12], ARRAY[6, 9]), - (5, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 2], ARRAY[2, 8], ARRAY[2, 8], ARRAY[6, 10], ARRAY[2, 8]), - (6, ARRAY[ 5], ARRAY[ 3], ARRAY[ 9], ARRAY[ 3], ARRAY[5, 9], ARRAY[3, 5], ARRAY[9, 11], ARRAY[3, 5]), - (7, ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8]), - (8, ARRAY[ 7], ARRAY[ 7], ARRAY[ 5], ARRAY[ 7], ARRAY[5, 7], ARRAY[5, 7], ARRAY[5, 6], ARRAY[5, 7]), - (9, ARRAY[ 6], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[6,12], ARRAY[6, 12], ARRAY[12], ARRAY[6, 12]), - (10, ARRAY[ 5], ARRAY[ 5], ARRAY[11], ARRAY[ 5], ARRAY[5,11], ARRAY[5, 11], ARRAY[11, 13], ARRAY[5, 11]), - (11, ARRAY[12], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[9,12], ARRAY[6, 10], ARRAY[12], ARRAY[6, 10]), - (12, ARRAY[ 9], ARRAY[11], NULL, ARRAY[ 11], ARRAY[6, 9], ARRAY[9, 11], NULL, ARRAY[9, 11]), - (13, ARRAY[10], ARRAY[10], NULL, ARRAY[ 10], ARRAY[5,10], ARRAY[5, 10], NULL, ARRAY[5, 10]), - (14, ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[ 15], ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[15]), - (15, ARRAY[14], ARRAY[14], NULL, ARRAY[ 14], ARRAY[14], ARRAY[14], NULL, ARRAY[14]), - (16, ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[ 17], ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[17]), - (17, ARRAY[16], ARRAY[16], NULL, ARRAY[ 16], ARRAY[16], ARRAY[16], NULL, ARRAY[16]) + (5::BIGINT, + ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], + ARRAY[6,7]::BIGINT[], ARRAY[6,10]::BIGINT[], ARRAY[6,7]::BIGINT[], ARRAY[6, 7]::BIGINT[]), + (6, ARRAY[ 5], ARRAY[ 5], ARRAY[ 7], ARRAY[ 5], ARRAY[5, 7], ARRAY[5, 10], ARRAY[7,11], ARRAY[5, 7]), + (10, ARRAY[ 6], ARRAY[ 6], ARRAY[ 11], ARRAY[ 11], ARRAY[6, 11], ARRAY[6, 15], ARRAY[11, 16], ARRAY[7,11]), + (15, ARRAY[ 10], ARRAY[ 10], ARRAY[ 16], ARRAY[ 16], ARRAY[10, 16], ARRAY[10, 16], ARRAY[16, 17], ARRAY[11, 16]), + (7, ARRAY[ 6], ARRAY[ 6], ARRAY[ 11], ARRAY[ 6], ARRAY[3,6], ARRAY[3,6], ARRAY[8,11], ARRAY[3,6]), + (11, ARRAY[ 7], ARRAY[ 10], ARRAY[ 16], ARRAY[ 10], ARRAY[7,16], ARRAY[7,10], ARRAY[12,16], ARRAY[7,10]), + (1, ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[3,7], ARRAY[3,7], ARRAY[3,7], ARRAY[3,7]), + (3, ARRAY[ 1], ARRAY[ 1], ARRAY[ 7], ARRAY[ 1], ARRAY[1,7], ARRAY[1,7], ARRAY[7,11], ARRAY[1,7]), + (16, ARRAY[ 11], ARRAY[ 11], ARRAY[17], ARRAY[ 11], ARRAY[11,17], ARRAY[11, 17], ARRAY[17], ARRAY[11, 17]), + (8, ARRAY[ 7], ARRAY[ 7], ARRAY[12], ARRAY[ 7], ARRAY[7,12], ARRAY[7,12], ARRAY[9,12], ARRAY[7,12]), + (12, ARRAY[17], ARRAY[ 11], ARRAY[17], ARRAY[ 11], ARRAY[16,17], ARRAY[8,11], ARRAY[17], ARRAY[8,11]), + (17, ARRAY[ 16], ARRAY[12], NULL, ARRAY[ 12], ARRAY[11, 16], ARRAY[12,16], NULL, ARRAY[12,16]), + (9, ARRAY[8], ARRAY[8], NULL, ARRAY[ 8], ARRAY[7,8], ARRAY[7, 8], NULL, ARRAY[7, 8]), + (2, ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[ 4], ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[4]), + (4, ARRAY[2], ARRAY[2], NULL, ARRAY[ 2], ARRAY[2], ARRAY[2], NULL, ARRAY[2]), + (13, ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[ 14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14]), + (14, ARRAY[13], ARRAY[13], NULL, ARRAY[ 13], ARRAY[13], ARRAY[13], NULL, ARRAY[13]) ) t(start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2)) SELECT * from a; @@ -64,7 +64,7 @@ BEGIN FROM pgr_dijkstraNear( %1$L, %2$s, - (SELECT array_agg(id) FROM edge_table_vertices_pgr where id != %2$s), + (SELECT array_agg(id) FROM vertices where id != %2$s), %3$s) $$, edges_q, id, optionals); expected_query := format($$ @@ -72,7 +72,7 @@ BEGIN $$, expected_q, id); RETURN QUERY - SELECT set_eq(dijstraNear_query, expected_query, id::TEXT || ' ' || optionals); + SELECT set_eq(dijstraNear_query, expected_query, id::TEXT || ' ' || optionals || ' ' || expected_q); END LOOP; END @@ -93,44 +93,44 @@ END IF; -- Initial tables are good to work RETURN QUERY -SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table$$); +SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edges$$); RETURN QUERY -SELECT isnt_empty($$SELECT id FROM edge_table_vertices_pgr$$); +SELECT isnt_empty($$SELECT id FROM vertices$$); -- vertex id values that dont exist RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table_vertices_pgr WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM vertices WHERE id > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE source > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE source > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE target > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE target > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM edges WHERE id > 18$$); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); @@ -138,28 +138,28 @@ SELECT * from check_expected( RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_2 AS scnd FROM expected$$, 'directed => true, cap => 2' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_2 AS scnd FROM expected$$, 'directed => false, cap => 2' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_2 AS scnd FROM expected$$, 'directed => true, cap => 2' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_2 AS scnd FROM expected$$, 'directed => false, cap => 2' ); diff --git a/pgtap/dijkstra/dijkstraNear/inner_query.pg b/pgtap/dijkstra/dijkstraNear/inner_query.pg index 5d079b9adab..8e1e2163606 100644 --- a/pgtap/dijkstra/dijkstraNear/inner_query.pg +++ b/pgtap/dijkstra/dijkstraNear/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(228) ELSE plan(1) END; @@ -34,8 +34,8 @@ BEGIN -- MANY TO MANY RETURN QUERY SELECT style_dijkstra('pgr_dijkstraNear(', ', ARRAY[2], ARRAY[3], true)'); -- COMBINATIONS - RETURN QUERY SELECT style_dijkstra('pgr_dijkstraNear(', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_dijkstraNear($$SELECT * FROM edge_table$$,',', true)'); + RETURN QUERY SELECT style_dijkstra('pgr_dijkstraNear(', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_dijkstraNear($$SELECT * FROM edges$$,',', true)'); ELSE diff --git a/pgtap/dijkstra/dijkstraNear/no_crash_test.pg b/pgtap/dijkstra/dijkstraNear/no_crash_test.pg index 5dcdd5f8a75..94366a3e60d 100644 --- a/pgtap/dijkstra/dijkstraNear/no_crash_test.pg +++ b/pgtap/dijkstra/dijkstraNear/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(126) END; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); @@ -40,43 +40,43 @@ BEGIN END IF; PREPARE edges AS - SELECT id, source, target, cost, reverse_cost FROM edge_table; + SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE combs AS - SELECT source, target FROM combinations_table; + SELECT source, target FROM combinations; RETURN QUERY SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); RETURN QUERY SELECT isnt_empty('combs', 'Should be not empty to tests be meaningful'); PREPARE null_id AS - SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); + SELECT id FROM vertices WHERE id IN (-1); RETURN QUERY SELECT is_empty('null_id', 'Should be empty to tests be meaningful'); PREPARE null_id_arr AS - SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); + SELECT array_agg(id) FROM vertices WHERE id IN (-1); RETURN QUERY SELECT set_eq('null_id_arr', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); PREPARE null_edges AS - SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (-1); + SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (-1); RETURN QUERY SELECT is_empty('null_edges', 'Should be empty to tests be meaningful'); PREPARE null_comb AS - SELECT source, target FROM combinations_table WHERE source IN (-1); + SELECT source, target FROM combinations WHERE source IN (-1); RETURN QUERY SELECT is_empty('null_comb', 'Should be empty to tests be meaningful'); -- one to many params1 = ARRAY['$$edges$$','1', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '(SELECT 1)', '(SELECT ARRAY[2,5]::BIGINT[])']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; subs2 = ARRAY[ 'NULL', @@ -92,13 +92,13 @@ BEGIN -- many to one params1 = ARRAY['$$edges$$', 'ARRAY[2,5]::BIGINT[]', '1']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '(SELECT ARRAY[2,5]::BIGINT[])', '(SELECT 1)']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))' ]::TEXT[]; subs2 = ARRAY[ 'NULL', @@ -113,13 +113,13 @@ BEGIN -- many to many params1 = ARRAY['$$edges$$','ARRAY[1]::BIGINT[]', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '(SELECT ARRAY[2,5]::BIGINT[])', '(SELECT ARRAY[1]::BIGINT[])']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; subs2 = ARRAY[ 'NULL', @@ -134,8 +134,8 @@ BEGIN -- combinations params1 = ARRAY['$$edges$$','$$combs$$']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', - '$$SELECT source, target FROM edge_table$$']::TEXT[]; + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', + '$$SELECT source, target FROM edges$$']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', '$$null_comb$$' diff --git a/pgtap/dijkstra/dijkstraNearCost/compare_dijkstra.pg b/pgtap/dijkstra/dijkstraNearCost/compare_dijkstra.pg index e8133088b8b..84f51045e17 100644 --- a/pgtap/dijkstra/dijkstraNearCost/compare_dijkstra.pg +++ b/pgtap/dijkstra/dijkstraNearCost/compare_dijkstra.pg @@ -21,32 +21,32 @@ BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(142) END; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE TABLE expected AS WITH a AS (SELECT start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2 FROM (VALUES - (1::BIGINT, - ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], - ARRAY[2,5]::BIGINT[], ARRAY[2,3]::BIGINT[], ARRAY[2,5]::BIGINT[], ARRAY[2, 5]::BIGINT[]), - (2, ARRAY[ 1], ARRAY[ 1], ARRAY[ 5], ARRAY[ 1], ARRAY[1, 5], ARRAY[1, 3], ARRAY[5, 6], ARRAY[1, 5]), - (3, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 6], ARRAY[2, 6], ARRAY[2, 4], ARRAY[6, 9], ARRAY[5, 6]), - (4, ARRAY[ 3], ARRAY[ 3], ARRAY[ 9], ARRAY[ 9], ARRAY[3, 9], ARRAY[3, 9], ARRAY[9, 12], ARRAY[6, 9]), - (5, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 2], ARRAY[2, 8], ARRAY[2, 8], ARRAY[6, 10], ARRAY[2, 8]), - (6, ARRAY[ 5], ARRAY[ 3], ARRAY[ 9], ARRAY[ 3], ARRAY[5, 9], ARRAY[3, 5], ARRAY[9, 11], ARRAY[3, 5]), - (7, ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8]), - (8, ARRAY[ 7], ARRAY[ 7], ARRAY[ 5], ARRAY[ 7], ARRAY[5, 7], ARRAY[5, 7], ARRAY[5, 6], ARRAY[5, 7]), - (9, ARRAY[ 6], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[6,12], ARRAY[6, 12], ARRAY[12], ARRAY[6, 12]), - (10, ARRAY[ 5], ARRAY[ 5], ARRAY[11], ARRAY[ 5], ARRAY[5,11], ARRAY[5, 11], ARRAY[11, 13], ARRAY[5, 11]), - (11, ARRAY[12], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[9,12], ARRAY[6, 10], ARRAY[12], ARRAY[6, 10]), - (12, ARRAY[ 9], ARRAY[11], NULL, ARRAY[ 11], ARRAY[6, 9], ARRAY[9, 11], NULL, ARRAY[9, 11]), - (13, ARRAY[10], ARRAY[10], NULL, ARRAY[ 10], ARRAY[5,10], ARRAY[5, 10], NULL, ARRAY[5, 10]), - (14, ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[ 15], ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[15]), - (15, ARRAY[14], ARRAY[14], NULL, ARRAY[ 14], ARRAY[14], ARRAY[14], NULL, ARRAY[14]), - (16, ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[ 17], ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[17]), - (17, ARRAY[16], ARRAY[16], NULL, ARRAY[ 16], ARRAY[16], ARRAY[16], NULL, ARRAY[16]) + (5::BIGINT, + ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], + ARRAY[6,7]::BIGINT[], ARRAY[6,10]::BIGINT[], ARRAY[6,7]::BIGINT[], ARRAY[6, 7]::BIGINT[]), + (6, ARRAY[ 5], ARRAY[ 5], ARRAY[ 7], ARRAY[ 5], ARRAY[5,7], ARRAY[5,10], ARRAY[7,11], ARRAY[5,7]), + (10,ARRAY[ 6], ARRAY[ 6], ARRAY[11], ARRAY[11], ARRAY[6,11], ARRAY[6,15], ARRAY[11,16],ARRAY[7,11]), + (15,ARRAY[10], ARRAY[10], ARRAY[16], ARRAY[16], ARRAY[10,16],ARRAY[10,16],ARRAY[16,17],ARRAY[11,16]), + (7, ARRAY[ 6], ARRAY[ 6], ARRAY[11], ARRAY[ 6], ARRAY[6,3], ARRAY[6,3], ARRAY[11,8], ARRAY[6,3]), + (11,ARRAY[ 7], ARRAY[10], ARRAY[16], ARRAY[10], ARRAY[7,16], ARRAY[10,7], ARRAY[16,12],ARRAY[10,7]), + (1, ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[7,3], ARRAY[7,3], ARRAY[7,3], ARRAY[7,3]), + (3, ARRAY[ 1], ARRAY[ 1], ARRAY[ 7], ARRAY[ 1], ARRAY[7,1], ARRAY[7,1], ARRAY[7,11], ARRAY[7,1]), + (16,ARRAY[11], ARRAY[11], ARRAY[17], ARRAY[11], ARRAY[11,17],ARRAY[11,17],ARRAY[17], ARRAY[11,17]), + (8, ARRAY[ 7], ARRAY[ 7], ARRAY[12], ARRAY[ 7], ARRAY[7,12], ARRAY[7,12], ARRAY[12,9], ARRAY[7,12]), + (12,ARRAY[17], ARRAY[11], ARRAY[17], ARRAY[11], ARRAY[16,17],ARRAY[11,8], ARRAY[17], ARRAY[11,8]), + (17,ARRAY[16], ARRAY[12], NULL, ARRAY[12], ARRAY[11,16],ARRAY[16,12],NULL, ARRAY[16,12]), + (9, ARRAY[8], ARRAY[8], NULL, ARRAY[ 8], ARRAY[7,8], ARRAY[7,8], NULL, ARRAY[7,8]), + (2, ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[ 4], ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[4]), + (4, ARRAY[2], ARRAY[2], NULL, ARRAY[ 2], ARRAY[2], ARRAY[2], NULL, ARRAY[2]), + (13,ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14]), + (14,ARRAY[13], ARRAY[13], NULL, ARRAY[13], ARRAY[13], ARRAY[13], NULL, ARRAY[13]) ) t(start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2)) SELECT * from a; @@ -64,7 +64,7 @@ BEGIN FROM pgr_dijkstraNearCost( %1$L, %2$s, - (SELECT array_agg(id) FROM edge_table_vertices_pgr where id != %2$s), + (SELECT array_agg(id) FROM vertices where id != %2$s), %3$s); $$, edges_q, id, optionals_n); dijkstra_query := format($$ @@ -101,44 +101,44 @@ END IF; -- Initial tables are good to work RETURN QUERY -SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table$$); +SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edges$$); RETURN QUERY -SELECT isnt_empty($$SELECT id FROM edge_table_vertices_pgr$$); +SELECT isnt_empty($$SELECT id FROM vertices$$); -- vertex id values that dont exist RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table_vertices_pgr WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM vertices WHERE id > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE source > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE source > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE target > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE target > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM edges WHERE id > 18$$); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_1 AS scnd FROM expected$$, 'directed => true, cap => 1', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_1 AS scnd FROM expected$$, 'directed => false, cap => 1', 'directed => false' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_1 AS scnd FROM expected$$, 'directed => true, cap => 1', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_1 AS scnd FROM expected$$, 'directed => false, cap => 1', 'directed => false' ); @@ -146,28 +146,28 @@ SELECT * from check_compare( RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_2 AS scnd FROM expected$$, 'directed => true, cap => 2', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_2 AS scnd FROM expected$$, 'directed => false, cap => 2', 'directed => false' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_2 AS scnd FROM expected$$, 'directed => true, cap => 2', 'directed => true' ); RETURN QUERY SELECT * from check_compare( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_2 AS scnd FROM expected$$, 'directed => false, cap => 2', 'directed => false' ); diff --git a/pgtap/dijkstra/dijkstraNearCost/edge_cases.pg b/pgtap/dijkstra/dijkstraNearCost/edge_cases.pg index 9804653e985..2c71757ae40 100644 --- a/pgtap/dijkstra/dijkstraNearCost/edge_cases.pg +++ b/pgtap/dijkstra/dijkstraNearCost/edge_cases.pg @@ -21,31 +21,31 @@ BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(122) END; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); CREATE TABLE expected AS WITH a AS (SELECT start_vid, d_w_1, u_w_1, d_n_1, u_n_1 FROM (VALUES - (1::BIGINT, - ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[]), - (2, ARRAY[ 1, 5], ARRAY[ 1, 3, 5], ARRAY[ 5], ARRAY[ 1, 5]), - (3, ARRAY[ 2, 6], ARRAY[ 2, 4, 6], ARRAY[ 6], ARRAY[ 6]), - (4, ARRAY[ 3, 9], ARRAY[ 3, 9], ARRAY[ 9], ARRAY[ 9]), - (5, ARRAY[ 2, 6, 8, 10], ARRAY[ 2, 6, 8, 10], ARRAY[ 6, 10], ARRAY[ 2, 6, 8, 10]), - (6, ARRAY[ 5, 9, 11], ARRAY[ 3, 5, 9, 11], ARRAY[ 9, 11], ARRAY[ 3, 5, 9, 11]), - (7, ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[ 8]), - (8, ARRAY[ 5, 7], ARRAY[ 5, 7], ARRAY[ 5], ARRAY[ 5, 7]), - (9, ARRAY[ 4, 6, 12], ARRAY[ 4, 6, 12], ARRAY[12], ARRAY[ 4, 6, 12]), - (10, ARRAY[ 5, 11, 13], ARRAY[ 5, 11, 13], ARRAY[11, 13], ARRAY[ 5, 11, 13]), - (11, ARRAY[12], ARRAY[ 6, 10, 12], ARRAY[12], ARRAY[ 6, 10, 12]), - (12, ARRAY[ 9], ARRAY[9, 11], NULL, ARRAY[ 9, 11]), - (13, ARRAY[10], ARRAY[10], NULL, ARRAY[ 10]), - (14, ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[ 15]), - (15, ARRAY[14], ARRAY[14], NULL, ARRAY[ 14]), - (16, ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[ 17]), - (17, ARRAY[16], ARRAY[16], NULL, ARRAY[ 16]) + (5::BIGINT, + ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[]), + (6, ARRAY[ 5, 7], ARRAY[ 5, 10, 7], ARRAY[ 7], ARRAY[ 5, 7]), + (10, ARRAY[ 6, 11], ARRAY[ 6, 15, 11], ARRAY[ 11], ARRAY[ 11]), + (15, ARRAY[ 10, 16], ARRAY[ 10, 16], ARRAY[ 16], ARRAY[ 16]), + (7, ARRAY[ 6, 11, 3, 8], ARRAY[ 6, 11, 3, 8], ARRAY[ 11, 8], ARRAY[ 6, 11, 3, 8]), + (11, ARRAY[ 7, 16, 12], ARRAY[ 10, 7, 16, 12], ARRAY[ 16, 12], ARRAY[ 10, 7, 16, 12]), + (1, ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[ 3]), + (3, ARRAY[ 7, 1], ARRAY[ 7, 1], ARRAY[ 7], ARRAY[ 7, 1]), + (16, ARRAY[ 15, 11, 17], ARRAY[ 15, 11, 17], ARRAY[17], ARRAY[ 15, 11, 17]), + (8, ARRAY[ 7, 12, 9], ARRAY[ 7, 12, 9], ARRAY[12, 9], ARRAY[ 7, 12, 9]), + (12, ARRAY[17], ARRAY[17, 8, 11], ARRAY[17], ARRAY[ 17, 8, 11]), + (11, ARRAY[ 16], ARRAY[16, 12], NULL, ARRAY[ 16, 12]), + (9, ARRAY[8], ARRAY[8], NULL, ARRAY[ 8]), + (2, ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[ 4]), + (4, ARRAY[2], ARRAY[2], NULL, ARRAY[ 2]), + (13, ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[ 14]), + (14, ARRAY[13], ARRAY[13], NULL, ARRAY[ 13]) ) t(start_vid, d_w_1, u_w_1, d_n_1, u_n_1)) SELECT * from a; @@ -84,7 +84,7 @@ BEGIN FROM pgr_dijkstraNearCost( %1$L, %2$s, - (SELECT array_agg(id) FROM edge_table_vertices_pgr where id != %2$s), + (SELECT array_agg(id) FROM vertices where id != %2$s), %3$s) $$, inner_query, id, optionals); expected_query := format($$ @@ -112,52 +112,52 @@ IF NOT min_version('3.2.0') THEN END IF; RETURN QUERY -SELECT is_empty($$SELECT distinct cost FROM edge_table WHERE cost != 1 AND cost != -1$$); +SELECT is_empty($$SELECT distinct cost FROM edges WHERE cost != 1 AND cost != -1$$); RETURN QUERY -SELECT is_empty($$SELECT distinct reverse_cost FROM edge_table WHERE cost != 1 AND cost != -1$$); +SELECT is_empty($$SELECT distinct reverse_cost FROM edges WHERE cost != 1 AND cost != -1$$); -- Initial tables are good to work RETURN QUERY -SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table$$); +SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edges$$); RETURN QUERY -SELECT isnt_empty($$SELECT id FROM edge_table_vertices_pgr$$); +SELECT isnt_empty($$SELECT id FROM vertices$$); -- vertex id values that dont exist RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table_vertices_pgr WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM vertices WHERE id > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE source > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE source > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE target > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE target > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM edges WHERE id > 18$$); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, d_w_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, u_w_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, d_n_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table ORDER BY id DESC$$, + $$SELECT id, source, target, cost FROM edges ORDER BY id DESC$$, $$SELECT start_vid AS frst, u_n_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); diff --git a/pgtap/dijkstra/dijkstraNearCost/expected_results.pg b/pgtap/dijkstra/dijkstraNearCost/expected_results.pg index be457e7aad7..70fa8251f9d 100644 --- a/pgtap/dijkstra/dijkstraNearCost/expected_results.pg +++ b/pgtap/dijkstra/dijkstraNearCost/expected_results.pg @@ -21,7 +21,7 @@ BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(142) END; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; @@ -29,25 +29,25 @@ CREATE TABLE expected AS WITH a AS (SELECT start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2 FROM (VALUES - (1::BIGINT, - ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], ARRAY[2]::BIGINT[], - ARRAY[2,5]::BIGINT[], ARRAY[2,3]::BIGINT[], ARRAY[2,5]::BIGINT[], ARRAY[2, 5]::BIGINT[]), - (2, ARRAY[ 1], ARRAY[ 1], ARRAY[ 5], ARRAY[ 1], ARRAY[1, 5], ARRAY[1, 3], ARRAY[5, 6], ARRAY[1, 5]), - (3, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 6], ARRAY[2, 6], ARRAY[2, 4], ARRAY[6, 9], ARRAY[5, 6]), - (4, ARRAY[ 3], ARRAY[ 3], ARRAY[ 9], ARRAY[ 9], ARRAY[3, 9], ARRAY[3, 9], ARRAY[9, 12], ARRAY[6, 9]), - (5, ARRAY[ 2], ARRAY[ 2], ARRAY[ 6], ARRAY[ 2], ARRAY[2, 8], ARRAY[2, 8], ARRAY[6, 10], ARRAY[2, 8]), - (6, ARRAY[ 5], ARRAY[ 3], ARRAY[ 9], ARRAY[ 3], ARRAY[5, 9], ARRAY[3, 5], ARRAY[9, 11], ARRAY[3, 5]), - (7, ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[ 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8], ARRAY[5, 8]), - (8, ARRAY[ 7], ARRAY[ 7], ARRAY[ 5], ARRAY[ 7], ARRAY[5, 7], ARRAY[5, 7], ARRAY[5, 6], ARRAY[5, 7]), - (9, ARRAY[ 6], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[6,12], ARRAY[6, 12], ARRAY[12], ARRAY[6, 12]), - (10, ARRAY[ 5], ARRAY[ 5], ARRAY[11], ARRAY[ 5], ARRAY[5,11], ARRAY[5, 11], ARRAY[11, 13], ARRAY[5, 11]), - (11, ARRAY[12], ARRAY[ 6], ARRAY[12], ARRAY[ 6], ARRAY[9,12], ARRAY[6, 10], ARRAY[12], ARRAY[6, 10]), - (12, ARRAY[ 9], ARRAY[11], NULL, ARRAY[ 11], ARRAY[6, 9], ARRAY[9, 11], NULL, ARRAY[9, 11]), - (13, ARRAY[10], ARRAY[10], NULL, ARRAY[ 10], ARRAY[5,10], ARRAY[5, 10], NULL, ARRAY[5, 10]), - (14, ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[ 15], ARRAY[15], ARRAY[15], ARRAY[15], ARRAY[15]), - (15, ARRAY[14], ARRAY[14], NULL, ARRAY[ 14], ARRAY[14], ARRAY[14], NULL, ARRAY[14]), - (16, ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[ 17], ARRAY[17], ARRAY[17], ARRAY[17], ARRAY[17]), - (17, ARRAY[16], ARRAY[16], NULL, ARRAY[ 16], ARRAY[16], ARRAY[16], NULL, ARRAY[16]) + (5::BIGINT, + ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], ARRAY[6]::BIGINT[], + ARRAY[6,7]::BIGINT[], ARRAY[6,10]::BIGINT[], ARRAY[6,7]::BIGINT[], ARRAY[6, 7]::BIGINT[]), + (6, ARRAY[ 5], ARRAY[ 5], ARRAY[ 7], ARRAY[ 5], ARRAY[5, 7], ARRAY[5, 10], ARRAY[7,11], ARRAY[5, 7]), + (10, ARRAY[ 6], ARRAY[ 6], ARRAY[ 11], ARRAY[ 11], ARRAY[6, 11], ARRAY[6, 15], ARRAY[11, 16], ARRAY[7,11]), + (15, ARRAY[ 10], ARRAY[ 10], ARRAY[ 16], ARRAY[ 16], ARRAY[10, 16], ARRAY[10, 16], ARRAY[16, 17], ARRAY[11, 16]), + (7, ARRAY[ 6], ARRAY[ 6], ARRAY[ 11], ARRAY[ 6], ARRAY[3,6], ARRAY[3,6], ARRAY[8,11], ARRAY[3,6]), + (11, ARRAY[ 7], ARRAY[ 10], ARRAY[ 16], ARRAY[ 10], ARRAY[7,16], ARRAY[7,10], ARRAY[12,16], ARRAY[7,10]), + (1, ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[ 3], ARRAY[3,7], ARRAY[3,7], ARRAY[3,7], ARRAY[3,7]), + (3, ARRAY[ 1], ARRAY[ 1], ARRAY[ 7], ARRAY[ 1], ARRAY[1,7], ARRAY[1,7], ARRAY[7,11], ARRAY[1,7]), + (16, ARRAY[ 11], ARRAY[ 11], ARRAY[17], ARRAY[ 11], ARRAY[11,17], ARRAY[11, 17], ARRAY[17], ARRAY[11, 17]), + (8, ARRAY[ 7], ARRAY[ 7], ARRAY[12], ARRAY[ 7], ARRAY[7,12], ARRAY[7,12], ARRAY[9,12], ARRAY[7,12]), + (12, ARRAY[17], ARRAY[ 11], ARRAY[17], ARRAY[ 11], ARRAY[16,17], ARRAY[8,11], ARRAY[17], ARRAY[8,11]), + (17, ARRAY[ 16], ARRAY[12], NULL, ARRAY[ 12], ARRAY[11, 16], ARRAY[12,16], NULL, ARRAY[12,16]), + (9, ARRAY[8], ARRAY[8], NULL, ARRAY[ 8], ARRAY[7,8], ARRAY[7, 8], NULL, ARRAY[7, 8]), + (2, ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[ 4], ARRAY[4], ARRAY[4], ARRAY[4], ARRAY[4]), + (4, ARRAY[2], ARRAY[2], NULL, ARRAY[ 2], ARRAY[2], ARRAY[2], NULL, ARRAY[2]), + (13, ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[ 14], ARRAY[14], ARRAY[14], ARRAY[14], ARRAY[14]), + (14, ARRAY[13], ARRAY[13], NULL, ARRAY[ 13], ARRAY[13], ARRAY[13], NULL, ARRAY[13]) ) t(start_vid, d_w_1, u_w_1, d_n_1, u_n_1, d_w_2, u_w_2, d_n_2, u_n_2)) SELECT * from a; @@ -65,7 +65,7 @@ BEGIN FROM pgr_dijkstraNearCost( %1$L, %2$s, - (SELECT array_agg(id) FROM edge_table_vertices_pgr where id != %2$s), + (SELECT array_agg(id) FROM vertices where id != %2$s), %3$s) $$, edges_q, id, optionals); expected_query := format($$ @@ -96,44 +96,44 @@ END IF; -- Initial tables are good to work RETURN QUERY -SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table$$); +SELECT isnt_empty($$SELECT id, source, target, cost, reverse_cost FROM edges$$); RETURN QUERY -SELECT isnt_empty($$SELECT id FROM edge_table_vertices_pgr$$); +SELECT isnt_empty($$SELECT id FROM vertices$$); -- vertex id values that dont exist RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table_vertices_pgr WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM vertices WHERE id > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE source > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE source > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE target > 18$$); +SELECT is_empty($$SELECT id, source, target, cost, reverse_cost FROM edges WHERE target > 18$$); RETURN QUERY -SELECT is_empty($$SELECT id FROM edge_table WHERE id > 18$$); +SELECT is_empty($$SELECT id FROM edges WHERE id > 18$$); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_1 AS scnd FROM expected$$, 'directed => true, cap => 1' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_1 AS scnd FROM expected$$, 'directed => false, cap => 1' ); @@ -141,28 +141,28 @@ SELECT * from check_expected( RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, d_w_2 AS scnd FROM expected$$, 'directed => true, cap => 2' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$, + $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT start_vid AS frst, u_w_2 AS scnd FROM expected$$, 'directed => false, cap => 2' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, d_n_2 AS scnd FROM expected$$, 'directed => true, cap => 2' ); RETURN QUERY SELECT * from check_expected( - $$SELECT id, source, target, cost FROM edge_table$$, + $$SELECT id, source, target, cost FROM edges$$, $$SELECT start_vid AS frst, u_n_2 AS scnd FROM expected$$, 'directed => false, cap => 2' ); diff --git a/pgtap/dijkstra/dijkstraNearCost/inner_query.pg b/pgtap/dijkstra/dijkstraNearCost/inner_query.pg index 17d3f2f88c3..94593c70fa0 100644 --- a/pgtap/dijkstra/dijkstraNearCost/inner_query.pg +++ b/pgtap/dijkstra/dijkstraNearCost/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(228) ELSE plan(1) END; @@ -34,8 +34,8 @@ BEGIN -- MANY TO MANY RETURN QUERY SELECT style_dijkstra('pgr_dijkstraNearCost(', ', ARRAY[2], ARRAY[3], true)'); -- COMBINATIONS - RETURN QUERY SELECT style_dijkstra('pgr_dijkstraNearCost(', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_dijkstraNearCost($$SELECT * FROM edge_table$$,',', true)'); + RETURN QUERY SELECT style_dijkstra('pgr_dijkstraNearCost(', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_dijkstraNearCost($$SELECT * FROM edges$$,',', true)'); ELSE diff --git a/pgtap/dijkstra/dijkstraNearCost/no_crash_test.pg b/pgtap/dijkstra/dijkstraNearCost/no_crash_test.pg index d68287caeb4..f0d0b174854 100644 --- a/pgtap/dijkstra/dijkstraNearCost/no_crash_test.pg +++ b/pgtap/dijkstra/dijkstraNearCost/no_crash_test.pg @@ -21,7 +21,7 @@ BEGIN; SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(126) END; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE OR REPLACE FUNCTION no_crash() @@ -40,10 +40,10 @@ BEGIN END IF; PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE combs AS -SELECT source, target FROM combinations_table; +SELECT source, target FROM combinations; RETURN QUERY SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); @@ -52,37 +52,37 @@ RETURN QUERY SELECT isnt_empty('combs', 'Should be not empty to tests be meaningful'); PREPARE null_id AS -SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT id FROM vertices WHERE id IN (-1); RETURN QUERY SELECT is_empty('null_id', 'Should be empty to tests be meaningful'); PREPARE null_id_arr AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); RETURN QUERY SELECT set_eq('null_id_arr', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); PREPARE null_edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (-1); +SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (-1); RETURN QUERY SELECT is_empty('null_edges', 'Should be empty to tests be meaningful'); PREPARE null_comb AS -SELECT source, target FROM combinations_table WHERE source IN (-1); +SELECT source, target FROM combinations WHERE source IN (-1); RETURN QUERY SELECT is_empty('null_comb', 'Should be empty to tests be meaningful'); -- one to many params1 = ARRAY['$$edges$$','1', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '(SELECT 1)', '(SELECT ARRAY[2,5]::BIGINT[])']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; subs2 = ARRAY[ 'NULL', @@ -98,13 +98,13 @@ SELECT is_empty('null_comb', 'Should be empty to tests be meaningful'); -- many to one params1 = ARRAY['$$edges$$', 'ARRAY[2,5]::BIGINT[]', '1']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '(SELECT ARRAY[2,5]::BIGINT[])', '(SELECT 1)']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))' ]::TEXT[]; subs2 = ARRAY[ 'NULL', @@ -119,13 +119,13 @@ SELECT is_empty('null_comb', 'Should be empty to tests be meaningful'); -- many to many params1 = ARRAY['$$edges$$','ARRAY[1]::BIGINT[]', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '(SELECT ARRAY[2,5]::BIGINT[])', '(SELECT ARRAY[1]::BIGINT[])']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; subs2 = ARRAY[ 'NULL', @@ -140,8 +140,8 @@ SELECT is_empty('null_comb', 'Should be empty to tests be meaningful'); -- combinations params1 = ARRAY['$$edges$$','$$combs$$']::TEXT[]; - params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', - '$$SELECT source, target FROM edge_table$$']::TEXT[]; + params2 = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', + '$$SELECT source, target FROM edges$$']::TEXT[]; subs1 = ARRAY[ '$$null_edges$$', '$$null_comb$$' diff --git a/pgtap/dijkstra/dijkstraVia/compare_dijkstra.pg b/pgtap/dijkstra/dijkstraVia/compare_dijkstra.pg index 0234892dafb..db7b16bf755 100644 --- a/pgtap/dijkstra/dijkstraVia/compare_dijkstra.pg +++ b/pgtap/dijkstra/dijkstraVia/compare_dijkstra.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(8); @@ -31,13 +31,13 @@ PREPARE q1 AS WITH union_data AS ( (SELECT 1 AS path_id,* FROM pgr_dijkstra( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', ARRAY[1], ARRAY[3])) UNION (SELECT 2 AS path_id,* FROM pgr_dijkstra( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', ARRAY[3], ARRAY[11] ))), data AS (SELECT * FROM union_data ORDER BY path_id, path_seq) @@ -49,7 +49,7 @@ PREPARE q2 AS SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', array[1, 3, 11] ); @@ -57,7 +57,7 @@ PREPARE q3 AS SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', array[1, 3, 11], directed:=TRUE ); @@ -74,14 +74,14 @@ PREPARE q11 AS WITH union_data AS ( (SELECT 1 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', ARRAY[1], ARRAY[3], FALSE)) UNION (SELECT 2 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', ARRAY[3], ARRAY[11], FALSE))), data AS (SELECT * FROM union_data ORDER BY path_id, path_seq) @@ -94,7 +94,7 @@ PREPARE q12 AS SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', array[1, 3, 11], directed:=FALSE ); @@ -109,12 +109,12 @@ PREPARE q21 AS WITH union_data AS ( (SELECT 1 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost FROM edge_table', + 'SELECT id, source, target, cost FROM edges', ARRAY[1], ARRAY[3])) UNION (SELECT 2 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost FROM edge_table', + 'SELECT id, source, target, cost FROM edges', ARRAY[3], ARRAY[11]))), data AS (SELECT * FROM union_data ORDER BY path_id, path_seq) @@ -127,7 +127,7 @@ PREPARE q22 AS SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost FROM edge_table', + 'SELECT id, source, target, cost FROM edges', array[1, 3, 11] ); @@ -135,7 +135,7 @@ PREPARE q23 AS SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost FROM edge_table', + 'SELECT id, source, target, cost FROM edges', array[1, 3, 11], directed:=TRUE ); @@ -152,14 +152,14 @@ PREPARE q31 AS WITH union_data AS ( (SELECT 1 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost FROM edge_table', + 'SELECT id, source, target, cost FROM edges', ARRAY[1], ARRAY[3], FALSE)) UNION (SELECT 2 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost FROM edge_table', + 'SELECT id, source, target, cost FROM edges', ARRAY[3], ARRAY[11], directed:=FALSE))), data AS (SELECT * FROM union_data ORDER BY path_id, path_seq) @@ -173,7 +173,7 @@ SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost FROM edge_table', + 'SELECT id, source, target, cost FROM edges', array[1, 3, 11], directed:=FALSE ); @@ -187,11 +187,11 @@ PREPARE q41 AS WITH union_data AS ( (SELECT 1 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', array[1], array[3])) UNION (SELECT 2 AS path_id, * FROM pgr_dijkstra( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', array[3], array[11] ))), data AS (SELECT * FROM union_data ORDER BY path_id, path_seq) @@ -204,7 +204,7 @@ SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', array[1, 3, 11] ); @@ -213,7 +213,7 @@ SELECT seq, path_id, path_seq, start_vid, end_vid, node, CASE WHEN edge = -2 THEN -1 ELSE edge END, cost, agg_cost FROM pgr_dijkstraVia( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', array[1, 3, 11], directed:=TRUE ); diff --git a/pgtap/dijkstra/dijkstraVia/edge_cases/remaining_tests.pg b/pgtap/dijkstra/dijkstraVia/edge_cases/remaining_tests.pg index 3404d63a0c6..d3be03c2a8a 100644 --- a/pgtap/dijkstra/dijkstraVia/edge_cases/remaining_tests.pg +++ b/pgtap/dijkstra/dijkstraVia/edge_cases/remaining_tests.pg @@ -22,7 +22,7 @@ BEGIN; SET client_min_messages TO WARNING; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(30); @@ -35,7 +35,7 @@ SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_id)::text AS path_id, pg_typeo pg_typeof(route_agg_cost)::TEXT AS t9 FROM ( SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edges', ARRAY[2,3,11]) ) AS a limit 1 ; @@ -54,11 +54,11 @@ SELECT set_eq('v21q30', 'v21q31','many to many: Expected returning, columns name PREPARE v20q1 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v20q3 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edges', ARRAY[2,3,11]); SELECT lives_ok('v20q1','with reverse cost 1'); @@ -66,12 +66,12 @@ SELECT lives_ok('v20q3','with reverse cost 3'); PREPARE v20q5 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v20q6 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); @@ -87,23 +87,23 @@ SELECT lives_ok('v20q6','without reverse cost 2'); --id ANY-INTEGER PREPARE v200id1 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::SMALLINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::SMALLINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200id2 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::BIGINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::BIGINT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200id3 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::FLOAT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::FLOAT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200id4 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::REAL, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::REAL, source::INTEGER, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200id5 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::TEXT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::TEXT, source::INTEGER, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); SELECT lives_ok('v200id1', @@ -123,23 +123,23 @@ SELECT throws_ok('v200id5', --source is only integer PREPARE v200s1 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::SMALLINT, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::SMALLINT, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200s2 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::BIGINT, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::BIGINT, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200s3 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::REAL, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::REAL, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200s4 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::FLOAT, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::FLOAT, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200s5 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::TEXT, target::INTEGER, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::TEXT, target::INTEGER, cost::FLOAT FROM edges', ARRAY[2,3,11]); SELECT lives_ok('v200s1', @@ -160,23 +160,23 @@ SELECT throws_ok('v200s5', --target is only integer PREPARE v200t1 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::SMALLINT, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::SMALLINT, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200t2 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::BIGINT, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::BIGINT, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200t3 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::FLOAT, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::FLOAT, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200t4 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::REAL, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::REAL, cost::FLOAT FROM edges', ARRAY[2,3,11]); PREPARE v200t5 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::TEXT, cost::FLOAT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::TEXT, cost::FLOAT FROM edges', ARRAY[2,3,11]); SELECT lives_ok('v200t1', @@ -196,23 +196,23 @@ SELECT throws_ok('v200t5', -- cost PREPARE v200c1 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::SMALLINT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::SMALLINT FROM edges', ARRAY[2,3,11]); PREPARE v200c2 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER FROM edges', ARRAY[2,3,11]); PREPARE v200c3 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::BIGINT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::BIGINT FROM edges', ARRAY[2,3,11]); PREPARE v200c4 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::REAL FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::REAL FROM edges', ARRAY[2,3,11]); PREPARE v200c5 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::TEXT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::TEXT FROM edges', ARRAY[2,3,11]); SELECT lives_ok('v200c1', @@ -230,23 +230,23 @@ SELECT throws_ok('v200c5', -- reverse_cost PREPARE v200r1 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::SMALLINT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::SMALLINT FROM edges', ARRAY[2,3,11]); PREPARE v200r2 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::INTEGER FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::INTEGER FROM edges', ARRAY[2,3,11]); PREPARE v200r3 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::BIGINT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::BIGINT FROM edges', ARRAY[2,3,11]); PREPARE v200r4 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::REAL FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::REAL FROM edges', ARRAY[2,3,11]); PREPARE v200r5 AS SELECT * FROM pgr_dijkstravia( - 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::TEXT FROM edge_table', + 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::TEXT FROM edges', ARRAY[2,3,11]); SELECT lives_ok('v200r1', diff --git a/pgtap/dijkstra/dijkstraVia/inner_query.pg b/pgtap/dijkstra/dijkstraVia/inner_query.pg index a883fbd8e82..4fb0c287343 100644 --- a/pgtap/dijkstra/dijkstraVia/inner_query.pg +++ b/pgtap/dijkstra/dijkstraVia/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(54); -- ONE VIA diff --git a/pgtap/dijkstra/dijkstraVia/no_crash_test.pg b/pgtap/dijkstra/dijkstraVia/no_crash_test.pg index e109e9c8eda..23f6be27f69 100644 --- a/pgtap/dijkstra/dijkstraVia/no_crash_test.pg +++ b/pgtap/dijkstra/dijkstraVia/no_crash_test.pg @@ -19,17 +19,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(15); PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE null_ret AS -SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT id FROM vertices WHERE id IN (-1); PREPARE null_ret_arr AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); @@ -44,12 +44,12 @@ params TEXT[]; subs TEXT[]; BEGIN -- one to many - params = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', - 'ARRAY[2,5]::BIGINT[]' + params = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', + 'ARRAY[6,7]::BIGINT[]' ]::TEXT[]; subs = ARRAY[ 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_dijkstraVia', params, subs); diff --git a/pgtap/dijkstra/driving_distance/edge_cases/issue_1152.pg b/pgtap/dijkstra/driving_distance/edge_cases/issue_1152.pg deleted file mode 100644 index fab460d83f3..00000000000 --- a/pgtap/dijkstra/driving_distance/edge_cases/issue_1152.pg +++ /dev/null @@ -1,130 +0,0 @@ - -/*PGR-GNU***************************************************************** - -Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org - ------- -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ********************************************************************PGR-GNU*/ -BEGIN; - - -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(71); - - -CREATE or REPLACE FUNCTION issue1154() -RETURNS SETOF TEXT AS -$BODY$ -DECLARE - dd_query TEXT; - dijkstra_sql TEXT; - astar_sql TEXT; - vids TEXT; - data INTEGER[]; - cant INTEGER; -BEGIN - data := ARRAY[ - 28143,37447,43401,50409,91800, - 98234,108908,1888,1897,85914, - 1898,112714,11851,31406, - 37961,43534,50994,57875,71749, - 77860,4424,4641,35309,53002, - 57762,75549,79856,80019,88626, - 89435,116859,37736,51812,97808]::INTEGER[]; - - RETURN QUERY - SELECT is_empty($$ - SELECT * FROM tmp_net WHERE target = 85930 - UNION - SELECT * FROM tmp_net WHERE target = 85930 - $$); - - cant := array_length(data, 1); - - FOR i IN 1.. cant LOOP - - dd_query := format($$ - SELECT - route.node AS node_id, - route.agg_cost - FROM pgr_drivingdistance( - 'SELECT * FROM tmp_net', - ARRAY[%1$s, %2$s]::INTEGER[], - 2680, equicost:=TRUE, directed:=TRUE) route; - $$, 85930, data[i]); - - - RETURN QUERY SELECT lives_ok(dd_query, 'i=' || data[i]); - - dd_query := format($$ - SELECT - route.node AS node_id, - route.agg_cost - FROM pgr_drivingdistance( - 'SELECT * FROM tmp_net', - ARRAY[%1$s, %2$s]::INTEGER[], - 2680, equicost:=TRUE, directed:=TRUE) route; - $$, data[i], 85930); - - - RETURN QUERY SELECT lives_ok(dd_query, 'i=' || data[i]); - - END LOOP; - -RETURN; -END -$BODY$ -language plpgsql; - -SELECT * FROM issue1154(); -SELECT lives_ok($$ - SELECT * - FROM pgr_drivingdistance( - 'SELECT * FROM tmp_net', - ARRAY[ - 28143,37447,43401,50409,91800, - 98234,108908,1888,1897,85914, - 1898,85930,112714,11851,31406, - 37961,43534,50994,57875,71749, - 77860,4424,4641,35309,53002, - 57762,75549,79856,80019,88626, - 89435,116859,37736,51812,97808]::INTEGER[], - 2680, - equicost:=TRUE, - directed:=TRUE - ) - $$); - -SELECT bag_has($$ - SELECT from_v, node, edge, cost, agg_cost - FROM pgr_drivingdistance( - 'SELECT * FROM tmp_net', - ARRAY[ - 28143,37447,43401,50409,91800, - 98234,108908,1888,1897,85914, - 1898,85930,112714,11851,31406, - 37961,43534,50994,57875,71749, - 77860,4424,4641,35309,53002, - 57762,75549,79856,80019,88626, - 89435,116859,37736,51812,97808]::INTEGER[], - 2680, - equicost:=TRUE, - directed:=TRUE - )$$, - $$ VALUES (85930, 85930, -1, 0, 0) $$ -); - -SELECT finish(); -ROLLBACK; diff --git a/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg b/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg index 645da8532b8..ae737874b75 100644 --- a/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg +++ b/pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg @@ -1,4 +1,3 @@ - /*PGR-GNU***************************************************************** Copyright (c) 2018 pgRouting developers @@ -19,32 +18,32 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(3); -PREPARE q1 AS -SELECT 1 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table', - 1, 3.5); - -PREPARE q2 AS -SELECT 5 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table', - 5, 3.5); - -PREPARE q3 AS -SELECT 25 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table', - 25, 3.5); - -Prepare q4 AS -SELECT from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance( 'select id, source, target, cost from edge_table', - ARRAY[1, 5, 25], 3.5); +CREATE OR REPLACE FUNCTION test_function() RETURNS SETOF TEXT AS +$BODY$ +BEGIN + PREPARE q1 AS + SELECT 1 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance('SELECT id, source, target, cost FROM edges', 1, 3.5); + PREPARE q2 AS + SELECT 5 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance('SELECT id, source, target, cost FROM edges', 5, 3.5); + PREPARE q3 AS + SELECT 25 AS from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance('SELECT id, source, target, cost FROM edges', 25, 3.5); -SELECT bag_has( 'q4', 'q1', '1: DD from [1, 5, 25] should have results of DD from 1'); -SELECT bag_has( 'q4', 'q2', '2: DD from [1, 5, 25] should have results of DD from 5'); -SELECT bag_has( 'q4', 'q3', '3: DD from [1, 5, 25] should have results of DD from 25'); + PREPARE q4 AS + SELECT from_v, node, edge, cost, agg_cost FROM pgr_drivingDistance('SELECT id, source, target, cost FROM edges', ARRAY[1, 5, 25], 3.5); + RETURN QUERY SELECT bag_has('q4', 'q1', '1: DD from [1, 5, 25] should have results of DD from 1'); + RETURN QUERY SELECT bag_has('q4', 'q2', '2: DD from [1, 5, 25] should have results of DD from 5'); + RETURN QUERY SELECT bag_has('q4', 'q3', '3: DD from [1, 5, 25] should have results of DD from 25'); +END; +$BODY$ +LANGUAGE plpgsql; -- Finish the tests and clean up. +SELECT * FROM test_function(); SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/dijkstra/driving_distance/inner_query.pg b/pgtap/dijkstra/driving_distance/inner_query.pg index 9fa95222ba9..58b147ac008 100644 --- a/pgtap/dijkstra/driving_distance/inner_query.pg +++ b/pgtap/dijkstra/driving_distance/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(108); diff --git a/pgtap/dijkstra/driving_distance/no_crash_test.pg b/pgtap/dijkstra/driving_distance/no_crash_test.pg index ba713c2a4a9..ea2324d34d4 100644 --- a/pgtap/dijkstra/driving_distance/no_crash_test.pg +++ b/pgtap/dijkstra/driving_distance/no_crash_test.pg @@ -19,14 +19,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(34); PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE null_ret AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT set_eq('null_ret', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); @@ -40,10 +40,10 @@ params TEXT[]; subs TEXT[]; BEGIN -- 1 to distance - params = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$','1', '1.3::FLOAT']::TEXT[]; + params = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$','1', '1.3::FLOAT']::TEXT[]; subs = ARRAY[ 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))', 'NULL' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_drivingDistance', params, subs); @@ -56,11 +56,11 @@ BEGIN RETURN query SELECT * FROM no_crash_test('pgr_drivingDistance', params, subs); -- many to distance - params = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + params = ARRAY['$$SELECT id, source, target, cost, reverse_cost FROM edges$$', 'ARRAY[1]', '1.3::FLOAT']::TEXT[]; subs = ARRAY[ 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', 'NULL' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_drivingDistance', params, subs); diff --git a/pgtap/ksp/ksp/edge_cases/issue_1010.pg b/pgtap/ksp/ksp/edge_cases/issue_1010.pg index 988fd797351..da62f9fbe71 100644 --- a/pgtap/ksp/ksp/edge_cases/issue_1010.pg +++ b/pgtap/ksp/ksp/edge_cases/issue_1010.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(6); diff --git a/pgtap/ksp/ksp/edge_cases/issue_1891.pg b/pgtap/ksp/ksp/edge_cases/issue_1891.pg index 090531cc7b2..9285de5f8de 100644 --- a/pgtap/ksp/ksp/edge_cases/issue_1891.pg +++ b/pgtap/ksp/ksp/edge_cases/issue_1891.pg @@ -44,7 +44,7 @@ RETURN QUERY SELECT is(have, 5); prepare q2 AS -SELECT * FROM +SELECT seq, path_id, path_seq, node, edge, cost, agg_cost FROM pgr_ksp('SELECT * FROM fiber', 1, 4, 10, directed => false, heap_paths => true); PREPARE r2 AS diff --git a/pgtap/ksp/ksp/edge_cases/issue_285_v2.pg b/pgtap/ksp/ksp/edge_cases/issue_285_v2.pg deleted file mode 100644 index 50a4357fbea..00000000000 --- a/pgtap/ksp/ksp/edge_cases/issue_285_v2.pg +++ /dev/null @@ -1,125 +0,0 @@ - -/*PGR-GNU***************************************************************** - -Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org - ------- -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ********************************************************************PGR-GNU*/ -BEGIN; -SET client_min_messages=WARNING; - - --- SAMPLE DATA FROM THE ISSUE 285 - -drop table if exists parallel; -CREATE TABLE parallel ( - id serial, - source integer, - target integer, - cost double precision, - reverse_cost double precision, - x1 double precision, - y1 double precision, - x2 double precision, - y2 double precision, - the_geom geometry -); - -INSERT INTO parallel (x1,y1,x2,y2) -VALUES (1,0,1,1),(1,1,1,3),(1,1,1,3),(1,1,1,3),(1,3,1,4); - -UPDATE parallel SET the_geom = ST_makeline(ST_point(x1,y1),ST_point(x2,y2)); -UPDATE parallel SET the_geom = ST_makeline(ARRAY[ST_point(1,1),ST_point(0,2),ST_point(1,3)]) WHERE id = 3; -UPDATE parallel SET the_geom = ST_makeline(ARRAY[ST_point(1,1),ST_point(2,1),ST_point(2,3),ST_point(1,3)]) WHERE id = 4; -UPDATE parallel SET cost = ST_length(the_geom), reverse_cost = ST_length(the_geom); -SELECT pgr_createTopology('parallel',0.001); - -SELECT PLAN(7); - -PREPARE q1 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 2, 3, 1, true -); - -PREPARE q2 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 2, 3, 2, true -); - -PREPARE q3 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 2, 3, 3, true -); - -PREPARE q4 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 2, 3, 4, true -); - - -PREPARE q5 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 2, 3, 100, true -); - -SELECT set_eq('q1', 'q2'); -SELECT set_eq('q1', 'q3'); -SELECT set_eq('q1', 'q4'); -SELECT set_eq('q1', 'q5'); - -PREPARE q6 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 1, 4, 1, true -); - -PREPARE q7 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 1, 4, 2, true -); - -PREPARE q8 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 1, 4, 3, true -); - -PREPARE q9 AS -SELECT * -FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM parallel', - 1, 4, 100, true -); - -SELECT set_eq('q6', 'q7'); -SELECT set_eq('q6', 'q8'); -SELECT set_eq('q6', 'q9'); - -SELECT finish(); -ROLLBACK; diff --git a/pgtap/ksp/ksp/inner_query.pg b/pgtap/ksp/ksp/inner_query.pg index 0e4c6cdcbf7..6308c19d209 100644 --- a/pgtap/ksp/ksp/inner_query.pg +++ b/pgtap/ksp/ksp/inner_query.pg @@ -19,11 +19,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(54); --- ONE TO ONE -SELECT style_dijkstra('pgr_ksp(', ', 2, 3, 2, true)'); +CREATE OR REPLACE FUNCTION KSP_inner_query() RETURNS SETOF TEXT AS +$BODY$ +BEGIN + + + -- ONE TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_ksp(', ', 6, 10, 2, true)'); + +END +$BODY$ +LANGUAGE plpgsql VOLATILE; + +SELECT KSP_inner_query(); SELECT finish(); ROLLBACK; diff --git a/pgtap/ksp/ksp/no_crash_test.pg b/pgtap/ksp/ksp/no_crash_test.pg index 13c74384984..9a2a1fc725a 100644 --- a/pgtap/ksp/ksp/no_crash_test.pg +++ b/pgtap/ksp/ksp/no_crash_test.pg @@ -19,17 +19,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(23); PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE null_ret AS -SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT id FROM vertices WHERE id IN (-1); PREPARE null_ret_arr AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); + +PREPARE combinations AS +SELECT source, target FROM combinations; + +PREPARE null_combinations AS +SELECT source, target FROM combinations WHERE source IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); @@ -45,15 +51,15 @@ subs TEXT[]; BEGIN -- one to one params = ARRAY[ - '$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$' - ,'1::BIGINT', - '2::BIGINT', + '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', + '5::BIGINT', + '6::BIGINT', '3' ]::TEXT[]; subs = ARRAY[ 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))', 'NULL::INTEGER' ]::TEXT[]; diff --git a/pgtap/ksp/ksp/one_route.pg b/pgtap/ksp/ksp/one_route.pg index cea4de8e064..917aebf8e01 100644 --- a/pgtap/ksp/ksp/one_route.pg +++ b/pgtap/ksp/ksp/one_route.pg @@ -20,21 +20,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SET extra_float_digits = -3; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; SELECT plan(7); PREPARE q2 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1, + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1, directed:=true -- takes the new signature ); PREPARE q3 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1 + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1 ); SELECT set_eq('q2','q3','1: With and with out directed flag gives the same result'); @@ -43,45 +44,45 @@ SELECT set_eq('q2','q3','1: With and with out directed flag gives the same resul PREPARE q4 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1 + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1 ); PREPARE q5 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1, heap_paths:=true + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1, heap_paths:=true ); PREPARE q6 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1, true, true + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1, true, false ); SELECT set_eq('q4','q5','2: no flags vs with heap paths, gives the same result'); -SELECT set_eq('q4','q6','3: no flags vs true true gives the same result'); +SELECT set_eq('q5','q6','3: no flags vs true true gives the same result'); ------------------------------------------------------------------------------- PREPARE q7 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1, directed:=false + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1, directed:=false ); PREPARE q8 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1, directed:=false, heap_paths:=true + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1, directed:=false, heap_paths:=true ); PREPARE q9 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', - 2, 12, 1, false, true + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 6, 17, 1, false, true ); SELECT set_eq('q7','q8','4: Undirected vs directed heappaths gives the same result'); @@ -94,14 +95,14 @@ SELECT set_eq('q7','q9','5: Unirected vs 2 flags gives the same result'); PREPARE q12 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost FROM edge_table', - 2, 12, 1, heap_paths:=true + 'SELECT id, source, target, cost FROM edges', + 6, 17, 1, heap_paths:=true ); PREPARE q13 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost FROM edge_table', - 2, 12, 1, true, true + 'SELECT id, source, target, cost FROM edges', + 6, 17, 1, true, true ); SELECT set_eq('q12','q13','6: (No rev_costs) noflags vs 2 flags gives the same result'); @@ -113,14 +114,14 @@ SELECT set_eq('q12','q13','6: (No rev_costs) noflags vs 2 flags gives the same r PREPARE q15 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost FROM edge_table', - 2, 12, 1, directed:=false, heap_paths:=true + 'SELECT id, source, target, cost FROM edges', + 6, 17, 1, directed:=false, heap_paths:=true ); PREPARE q16 AS SELECT * FROM pgr_ksp( - 'SELECT id, source, target, cost FROM edge_table', - 2, 12, 1, false, true + 'SELECT id, source, target, cost FROM edges', + 6, 17, 1, false, true ); SELECT set_eq('q15','q16','7:(No rev_costs) undirected vs 2 flags gives the same result'); diff --git a/pgtap/ksp/turnRestrictedPath/compare_dijkstra.pg b/pgtap/ksp/turnRestrictedPath/compare_dijkstra.pg index f15340cb068..260020d175e 100644 --- a/pgtap/ksp/turnRestrictedPath/compare_dijkstra.pg +++ b/pgtap/ksp/turnRestrictedPath/compare_dijkstra.pg @@ -21,7 +21,7 @@ BEGIN; SELECT plan(1156); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE or REPLACE FUNCTION turnrestricted_compare_dijkstra() RETURNS SETOF TEXT AS diff --git a/pgtap/ksp/turnRestrictedPath/edge_cases/custom.pg b/pgtap/ksp/turnRestrictedPath/edge_cases/custom.pg index b7ce48a62b8..eb8520f199e 100644 --- a/pgtap/ksp/turnRestrictedPath/edge_cases/custom.pg +++ b/pgtap/ksp/turnRestrictedPath/edge_cases/custom.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(9); SET client_min_messages TO WARNING; @@ -30,19 +30,19 @@ SET client_min_messages TO WARNING; PREPARE r1 AS SELECT path_seq, node::BIGINT, edge::BIGINT, agg_cost FROM ( VALUES - (1, 2, 4, 0), - (2, 5, 8, 1), - (3, 6, 9, 2), - (4, 9, 15, 3), - (5, 12, -1, 4)) + (1, 6, 4, 0), + (2, 7, 8, 1), + (3, 11, 9, 2), + (4, 16, 15, 3), + (5, 17, -1, 4)) AS t(path_seq, node, edge, agg_cost); PREPARE q1 AS SELECT path_seq, node, edge, agg_cost FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions WHERE id < 3', - 2, 12, + 6, 17, 1 ); @@ -50,9 +50,9 @@ FROM pgr_turnRestrictedPath( PREPARE q2 AS SELECT path_seq, node, edge, agg_cost FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions WHERE id < 3', - 2, 12, + 6, 17, 1, stop_on_first:=false ); @@ -65,24 +65,24 @@ SELECT set_eq('q2', 'r1', 'Should return r1 result (one cycle, Dont stop_on_firs PREPARE r2 AS SELECT path_seq, node::BIGINT, edge::BIGINT, agg_cost FROM ( VALUES - (1, 2, 4, 0), - (2, 5, 8, 1), - (3, 6, 9, 2), - (4, 9, 15, 3), - (5, 12, -1, 4), - (1, 2, 4, 0), - (2, 5, 10, 1), - (3, 10, 12, 2), - (4, 11, 13, 3), - (5, 12, -1, 4)) + (1, 6, 4, 0), + (2, 7, 8, 1), + (3, 11, 9, 2), + (4, 16, 15, 3), + (5, 17, -1, 4), + (1, 6, 4, 0), + (2, 7, 10, 1), + (3, 8, 12, 2), + (4, 12, 13, 3), + (5, 17, -1, 4)) AS t(path_seq, node, edge, agg_cost); PREPARE q3 AS SELECT path_seq, node, edge, agg_cost FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions WHERE id < 3', - 2, 12, + 6, 17, 3, stop_on_first:=false ); @@ -94,25 +94,25 @@ SELECT set_eq('q3', 'r2', 'Should return r2 result (3 cycle, Dont stop_on_first) PREPARE r3 AS SELECT path_seq, node::BIGINT, edge::BIGINT FROM (VALUES - (2, 8, 7)) + (2, 3, 7)) AS t(path_seq, node, edge); PREPARE q4 AS SELECT path_seq, node, edge FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions', - 7, 10, + 1, 8, 1 ) WHERE agg_cost = FLOAT8 '+infinity'; PREPARE q7 AS SELECT path_seq, node, edge FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions', - 7, 10, + 1, 8, 1, heap_paths:=true ) WHERE agg_cost = FLOAT8 '+infinity'; @@ -125,15 +125,15 @@ SELECT set_eq('q7', 'r3', 'Should return r3 result (1 cycle, Heap paths)'); PREPARE r4 AS SELECT path_seq, node::BIGINT, edge::BIGINT FROM ( VALUES - (2, 8, 7)) + (2, 3, 7)) AS t(path_seq, node, edge); PREPARE q5 AS SELECT path_seq, node, edge FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions', - 7,10, + 1, 8, 2, stop_on_first:=false ) WHERE agg_cost = FLOAT8 '+infinity'; @@ -143,9 +143,9 @@ FROM pgr_turnRestrictedPath( PREPARE q6 AS SELECT path_seq, node, edge FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions', - 7, 10, + 1, 8, 3, stop_on_first:=false ) WHERE agg_cost = FLOAT8 '+infinity'; @@ -159,15 +159,15 @@ SELECT set_eq('q6', 'r4', 'q6 Should return r4 result (2 cycle, Dont stop_on_fir PREPARE r5 AS SELECT path_seq, node::BIGINT, edge::BIGINT FROM ( VALUES - (2, 8, 7)) + (2, 3, 7)) AS t(path_seq, node, edge); PREPARE q8 AS SELECT path_seq, node, edge FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions', - 7, 10, + 1, 8, 2, heap_paths:=true, stop_on_first:=false @@ -176,16 +176,16 @@ FROM pgr_turnRestrictedPath( PREPARE q9 AS SELECT path_seq, node, edge FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT * FROM restrictions', - 7, 10, + 1, 8, 3, heap_paths:=true, stop_on_first:=false ) WHERE agg_cost = FLOAT8 '+infinity'; -SELECT set_eq('q8', 'r5', 'Should return r4 result (2 cycle, Dont stop_on_first, heap paths)'); -SELECT set_eq('q9', 'r5', 'Should return r4 result (3 cycle, Dont stop_on_first, heap paths)'); +SELECT set_eq('q8', 'r5', 'Should return r5 result (2 cycle, Dont stop_on_first, heap paths)'); +SELECT set_eq('q9', 'r5', 'Should return r5 result (3 cycle, Dont stop_on_first, heap paths)'); SELECT finish(); diff --git a/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_default_strict.pg b/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_default_strict.pg index d0393301f18..3d4f1204b3c 100644 --- a/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_default_strict.pg +++ b/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_default_strict.pg @@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(16); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT plan(20); ---------------------------------------------------------------------------------------------------------------- -- testing from an existing starting vertex to a non-existing destination @@ -30,9 +30,9 @@ SELECT plan(16); -- with restrictions PREPARE q1 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 3, + 6, 10, 3 ); @@ -40,9 +40,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q2 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 3, + 6, 10, 3, FALSE ); @@ -51,9 +51,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q3 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 3, + 6, 10, 3 ); @@ -61,9 +61,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q4 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 3, + 6, 10, 3, FALSE ); @@ -80,7 +80,7 @@ SELECT is_empty('q4'); -- with restrictions PREPARE q5 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', 6, 8, 3 @@ -90,7 +90,7 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q6 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', 6, 8, 3, @@ -101,7 +101,7 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q7 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', 6, 8, 3 @@ -111,7 +111,7 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q8 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', 6, 8, 3, @@ -130,9 +130,9 @@ SELECT is_empty('q8'); -- with restrictions PREPARE q9 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 1, 17, + 5, 14, 3 ); @@ -140,9 +140,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q10 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 1, 17, + 5, 14, 3, FALSE ); @@ -151,9 +151,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q11 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 1, 17, + 5, 14, 3 ); @@ -161,9 +161,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q12 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 1, 17, + 5, 14, 3, FALSE ); @@ -180,9 +180,9 @@ SELECT is_empty('q12'); -- with restrictions PREPARE q13 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 2, + 6, 6, 3 ); @@ -190,9 +190,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q14 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 2, + 6, 6, 3, FALSE ); @@ -201,9 +201,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q15 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 2, + 6, 6, 3 ); @@ -211,9 +211,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q16 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 2, + 6, 6, 3, FALSE ); @@ -229,9 +229,9 @@ SELECT is_empty('q16'); -- with restrictions PREPARE q17 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 14, + 6, 2, 3 ); @@ -239,9 +239,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q18 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 14, + 6, 2, 3, FALSE ); @@ -250,9 +250,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q19 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions where id > 10', - 2, 14, + 6, 2, 3 ); @@ -260,19 +260,18 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q20 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions where id > 10', - 2, 14, + 6, 2, 3, FALSE ); -/* + SELECT is_empty('q17'); SELECT is_empty('q18'); SELECT is_empty('q19'); SELECT is_empty('q20'); ---------------------------------------------------------------------------------------------------------------- -*/ SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_no_default_strict.pg b/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_no_default_strict.pg index dafc2067799..d27e5822288 100644 --- a/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_no_default_strict.pg +++ b/pgtap/ksp/turnRestrictedPath/edge_cases/empty_set_no_default_strict.pg @@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(16); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT plan(20); ---------------------------------------------------------------------------------------------------------------- -- testing from an existing starting vertex to a non-existing destination @@ -30,9 +30,9 @@ SELECT plan(16); -- with restrictions PREPARE q1 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 3, + 6, 10, 3, strict := false ); @@ -42,9 +42,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q2 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 3, + 6, 10, 3, FALSE, strict := false @@ -54,9 +54,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q3 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 3, + 6, 10, 3, strict := false ); @@ -65,9 +65,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q4 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 3, + 6, 10, 3, FALSE, strict := false @@ -86,9 +86,9 @@ SELECT is_empty('q4'); -- with restrictions PREPARE q5 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 6, 8, + 11, 3, 3, strict := false ); @@ -97,9 +97,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q6 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 6, 8, + 11, 3, 3, FALSE, strict := false @@ -109,9 +109,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q7 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 6, 8, + 11, 3, 3, strict := false ); @@ -120,9 +120,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q8 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 6, 8, + 11, 3, 3, FALSE, strict := false @@ -141,9 +141,9 @@ SELECT is_empty('q8'); -- with restrictions PREPARE q9 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 1, 17, + 5, 14, 3, strict := false ); @@ -152,9 +152,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q10 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 1, 17, + 5, 14, 3, FALSE, strict := false @@ -164,9 +164,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q11 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 1, 17, + 5, 14, 3, strict := false ); @@ -175,9 +175,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q12 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 1, 17, + 5, 14, 3, FALSE, strict := false @@ -196,9 +196,9 @@ SELECT is_empty('q12'); -- with restrictions PREPARE q13 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 2, + 6, 6, 3, strict := false ); @@ -207,9 +207,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q14 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 2, + 6, 6, 3, FALSE, strict := false @@ -219,9 +219,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q15 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 2, + 6, 6, 3, strict := false ); @@ -230,9 +230,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q16 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 OR id = 7', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = 4 OR id = 7', 'SELECT * FROM restrictions where id > 10', - 2, 2, + 6, 6, 3, FALSE, strict := false @@ -250,9 +250,9 @@ SELECT is_empty('q16'); -- with restrictions PREPARE q17 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 14, + 6, 2, 3, strict := false ); @@ -261,9 +261,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- with restrictions PREPARE q18 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions WHERE id IN (1)', - 2, 14, + 6, 2, 3, FALSE, strict := false @@ -273,9 +273,9 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q19 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions where id > 10', - 2, 14, + 6, 2, 3, strict := false ); @@ -284,21 +284,19 @@ SELECT * FROM pgr_turnRestrictedPath( -- without restrictions PREPARE q20 AS SELECT * FROM pgr_turnRestrictedPath( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id IN (4, 7, 17)', + 'SELECT id, source, target, cost, reverse_cost FROM edges WHERE id IN (4, 7, 17)', 'SELECT * FROM restrictions where id > 10', - 2, 14, + 6, 2, 3, FALSE, strict := false ); -/* + SELECT is_empty('q17'); SELECT is_empty('q18'); SELECT is_empty('q19'); SELECT is_empty('q20'); ----------------------------------------------------------------------------------------------------------------- -*/ SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/ksp/turnRestrictedPath/inner_query.pg b/pgtap/ksp/turnRestrictedPath/inner_query.pg index 05e68eb792b..31a8b90da24 100644 --- a/pgtap/ksp/turnRestrictedPath/inner_query.pg +++ b/pgtap/ksp/turnRestrictedPath/inner_query.pg @@ -19,12 +19,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(66); -- ONE TO ONE -SELECT style_dijkstra('pgr_turnRestrictedPath(', ', $$SELECT * FROM restrictions$$, 2, 3, 2, true)'); -SELECT innerquery_restrictions('pgr_turnRestrictedPath($$SELECT * FROM edge_table$$, ', ', 2, 3, 2, true)'); +SELECT style_dijkstra('pgr_turnRestrictedPath(', ', $$SELECT * FROM restrictions$$, 6, 10, 2, true)'); +SELECT innerquery_restrictions('pgr_turnRestrictedPath($$SELECT * FROM edges$$, ', ', 6, 10, 2, true)'); SELECT finish(); ROLLBACK; diff --git a/pgtap/ksp/turnRestrictedPath/types_check.pg b/pgtap/ksp/turnRestrictedPath/types_check.pg index e9a05a1a157..f8c6b8c5ee0 100644 --- a/pgtap/ksp/turnRestrictedPath/types_check.pg +++ b/pgtap/ksp/turnRestrictedPath/types_check.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(5); SELECT has_function('pgr_turnrestrictedpath'); diff --git a/pgtap/ksp/withPointsKSP/inner_query.pg b/pgtap/ksp/withPointsKSP/inner_query.pg index 03eb475607c..9db5e4ec87f 100644 --- a/pgtap/ksp/withPointsKSP/inner_query.pg +++ b/pgtap/ksp/withPointsKSP/inner_query.pg @@ -19,12 +19,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(84); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT plan(252); --- ONE TO ONE -SELECT style_dijkstra('pgr_withPointsKSP(', ', $$SELECT * from pointsOfInterest$$, 2, 3, 2, true)'); -SELECT innerquery_points('pgr_withPointsKSP($$SELECT * FROM edge_table$$,', ', 2, 3, 2, true)'); +CREATE OR REPLACE FUNCTION withPointsKSP_inner_query() RETURNS SETOF TEXT AS +$BODY$ +BEGIN + -- ONE TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_withPointsKSP(', ', $$SELECT * from pointsOfInterest$$, 5, 10, 2, driving_side => $$r$$, directed => true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsKSP($$SELECT * FROM edges$$,', ', 5, 10, 2, driving_side => $$r$$, directed => true)'); + RETURN QUERY SELECT style_dijkstra('pgr_withPointsKSP(', ', $$SELECT * from pointsOfInterest$$, 5, 10, 2, true, true, $$r$$)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsKSP($$SELECT * FROM edges$$,', ', 5, 10, 2, true, true, $$r$$)'); + RETURN QUERY SELECT style_dijkstra('pgr_withPointsKSP(', ', $$SELECT * from pointsOfInterest$$, 5, 10, 2, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsKSP($$SELECT * FROM edges$$,', ', 5, 10, 2, true)'); +END +$BODY$ +LANGUAGE plpgsql VOLATILE; +SELECT withPointsKSP_inner_query(); SELECT finish(); ROLLBACK; diff --git a/pgtap/ksp/withPointsKSP/no_crash_test.pg b/pgtap/ksp/withPointsKSP/no_crash_test.pg index 7ee92b365e2..e30310d4e11 100644 --- a/pgtap/ksp/withPointsKSP/no_crash_test.pg +++ b/pgtap/ksp/withPointsKSP/no_crash_test.pg @@ -1,4 +1,3 @@ - /*PGR-GNU***************************************************************** Copyright (c) 2018 pgRouting developers @@ -19,22 +18,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(26); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT plan(26) END; PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE pois AS SELECT pid, edge_id, fraction from pointsOfInterest; PREPARE null_ret AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); + +PREPARE null_ret_arr AS +SELECT array_agg(id) FROM vertices WHERE id IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT set_eq('null_ret', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); - CREATE OR REPLACE FUNCTION test_function() RETURNS SETOF TEXT AS $BODY$ @@ -42,19 +43,20 @@ DECLARE params TEXT[]; subs TEXT[]; BEGIN + -- 1 to distance params = ARRAY[ - '$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '1', - '2', + '5', + '6', '2' ]::TEXT[]; subs = ARRAY[ 'NULL', 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))', 'NULL' ]::TEXT[]; diff --git a/pgtap/tsp/tsp/edge_cases/edge_cases.pg b/pgtap/tsp/tsp/edge_cases/edge_cases.pg index ef9e157b3fd..cea7faa343f 100644 --- a/pgtap/tsp/tsp/edge_cases/edge_cases.pg +++ b/pgtap/tsp/tsp/edge_cases/edge_cases.pg @@ -126,25 +126,25 @@ BEGIN RETURN QUERY SELECT set_eq( - $q$SELECT * FROM pgr_TSP( + $q$SELECT node, cost FROM pgr_TSP( $$ SELECT source AS start_vid, target AS end_vid, 1 AS agg_cost FROM edges WHERE id IN (2,4,5,8,9,15) ORDER BY start_vid $$) $q$, - $q$ SELECT seq::INTEGER, node::BIGINT, cost::FLOAT, agg_cost::FLOAT + $q$ SELECT node::BIGINT, cost::FLOAT FROM (VALUES - (1, 6, 0, 0), - (2, 7, 1, 1), - (3, 11, 1, 2), - (4, 17, 1, 3), - (5, 16, 1, 4), - (6, 10, 1, 5), - (7, 6, 1, 6)) - AS t (seq, node, cost, agg_cost) + ( 6, 0), + ( 7, 1), + (16, 1), + (17, 1), + (11, 1), + (10, 1), + ( 6, 1)) + AS t (node, cost) $q$, - 'The cost from 16 to 17 is 3'); + 'Expected results'); ELSE diff --git a/pgtap/withPoints/edge_cases/many_to_many_eq_combinations.pg b/pgtap/withPoints/edge_cases/many_to_many_eq_combinations.pg index 4b48f28c026..3b15450ea64 100644 --- a/pgtap/withPoints/edge_cases/many_to_many_eq_combinations.pg +++ b/pgtap/withPoints/edge_cases/many_to_many_eq_combinations.pg @@ -22,7 +22,7 @@ BEGIN; SELECT plan(2); -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE OR REPLACE FUNCTION test_function(sql_TestFunction TEXT, cant INTEGER default 18) RETURNS SETOF TEXT AS @@ -57,12 +57,12 @@ BEGIN sql_Combinations := trim(trailing ',' from sql_Combinations); sql_Many := ( sql_TestFunction || '( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table''::text, + ''SELECT id, source, target, cost, reverse_cost FROM edges''::text, ''SELECT pid, edge_id, fraction, side from pointsOfInterest'', ARRAY[' || sql_Many ||'], ARRAY[' || sql_Many || '] ) '); sql_Combinations := ( sql_TestFunction || '( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table''::text, + ''SELECT id, source, target, cost, reverse_cost FROM edges''::text, ''SELECT pid, edge_id, fraction, side from pointsOfInterest'', ''SELECT * FROM (VALUES' || sql_Combinations ||') AS combinations (source, target)'' ) '); diff --git a/pgtap/withPoints/withPoints/compare_dijkstra/one_to_one.pg b/pgtap/withPoints/withPoints/compare_dijkstra/one_to_one.pg index 4579adee422..089ad1a2812 100644 --- a/pgtap/withPoints/withPoints/compare_dijkstra/one_to_one.pg +++ b/pgtap/withPoints/withPoints/compare_dijkstra/one_to_one.pg @@ -29,7 +29,7 @@ ELSE plan(1156) END; SET extra_float_digits = -3; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE or REPLACE FUNCTION withPointsCompareDijkstra(cant INTEGER default 17) RETURNS SETOF TEXT AS @@ -54,7 +54,7 @@ BEGIN FOR j IN 1.. cant LOOP -- DIRECTED WITH REVERSE COST - inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', directed => true)'; @@ -63,7 +63,7 @@ BEGIN RETURN query SELECT set_eq(withPoints_sql, dijkstra_sql, withPoints_sql); -- DIRECTED WITHOUT REVERSE COST - inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', directed => true)'; @@ -73,7 +73,7 @@ BEGIN -- UNDIRECTED WITH REVERSE COST - inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', directed => false)'; @@ -82,7 +82,7 @@ BEGIN RETURN query SELECT set_eq(withPoints_sql, dijkstra_sql, withPoints_sql); -- UNDIRECTED WITHOUT REVERSE COST - inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table'; + inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges'; dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j || ', directed => false)'; diff --git a/pgtap/withPoints/withPoints/edge_cases/any_to_many_eq_one_to_one.pg b/pgtap/withPoints/withPoints/edge_cases/any_to_many_eq_one_to_one.pg index 1c3f74fc8c4..b7c71711a86 100644 --- a/pgtap/withPoints/withPoints/edge_cases/any_to_many_eq_one_to_one.pg +++ b/pgtap/withPoints/withPoints/edge_cases/any_to_many_eq_one_to_one.pg @@ -24,7 +24,7 @@ SELECT PLAN(13); PREPARE q1 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-1], ARRAY[-5], driving_side := 'r', @@ -33,7 +33,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q11 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-1], ARRAY[-3], driving_side := 'r', @@ -42,7 +42,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q2 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', @@ -51,7 +51,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q21 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -3, driving_side := 'r', @@ -63,7 +63,7 @@ SELECT set_eq('q11', 'q21', '2: Right: from point ARRAY[-1] to -3 same as one to PREPARE q3 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-4], ARRAY[-5], driving_side := 'r', @@ -72,7 +72,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q31 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-4], ARRAY[-3], driving_side := 'r', @@ -81,7 +81,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q4 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -4, -5, driving_side := 'r', @@ -90,7 +90,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q41 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -4, -3, driving_side := 'r', @@ -102,7 +102,7 @@ SELECT set_eq('q31','q41','4: Right: from ARRAY[-4] to -3 same as one to one'); PREPARE q5 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-1, -4], ARRAY[-5,-3], driving_side := 'r', @@ -122,7 +122,7 @@ SELECT set_has('q5', 'q41', '12: Right: from point ARRAY[-1,-4] to -5 has result PREPARE q9 AS SELECT -1 AS start_vid, -5 AS end_vid, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-1], ARRAY[-5], driving_side := 'r', @@ -132,7 +132,7 @@ SELECT -1 AS start_vid, -5 AS end_vid, agg_cost FROM pgr_withPoints( PREPARE q10 AS SELECT * FROM pgr_withPointsCost( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', diff --git a/pgtap/withPoints/withPoints/edge_cases/empty_combinations_empty_result.pg b/pgtap/withPoints/withPoints/edge_cases/empty_combinations_empty_result.pg index 58c00c0445c..8aa18e0f0c1 100644 --- a/pgtap/withPoints/withPoints/edge_cases/empty_combinations_empty_result.pg +++ b/pgtap/withPoints/withPoints/edge_cases/empty_combinations_empty_result.pg @@ -35,9 +35,9 @@ BEGIN RETURN query SELECT is_empty( 'SELECT path_seq, start_pid, end_pid, node, edge, cost, agg_cost FROM pgr_withPoints( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ''SELECT pid, edge_id, fraction, side from pointsOfInterest'', - ''SELECT * FROM combinations_table WHERE source IN (-1)'' ) ' + ''SELECT * FROM combinations WHERE source IN (-1)'' ) ' ); RETURN; END diff --git a/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg b/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg index 08b47796bb1..f9c4f46f619 100644 --- a/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg +++ b/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg @@ -33,7 +33,7 @@ END IF; PREPARE q1 AS SELECT * FROM pgr_withPoints ( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', 1, -2 ); @@ -45,9 +45,9 @@ SELECT * FROM is_empty('q1'); PREPARE q2 AS SELECT * FROM pgr_withPoints ( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table', + 'SELECT id, source, target, cost, reverse_cost FROM edges', 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', - 1, 2 + 5, 6 ); RETURN QUERY diff --git a/pgtap/withPoints/withPoints/edge_cases/many_to_one_eq_one_to_one.pg b/pgtap/withPoints/withPoints/edge_cases/many_to_one_eq_one_to_one.pg index 7e5fce6e290..a83cd59fe05 100644 --- a/pgtap/withPoints/withPoints/edge_cases/many_to_one_eq_one_to_one.pg +++ b/pgtap/withPoints/withPoints/edge_cases/many_to_one_eq_one_to_one.pg @@ -26,7 +26,7 @@ SELECT PLAN(7); PREPARE q1 AS SELECT path_seq, node, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-1], -5, driving_side := 'r', @@ -35,7 +35,7 @@ SELECT path_seq, node, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPo PREPARE q2 AS SELECT path_seq, node, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', @@ -46,7 +46,7 @@ SELECT set_eq('q1', 'q2', '1: Right: from point ARRAY[-1] to -5 same as one to o PREPARE q3 AS SELECT path_seq, node, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-4], -5, driving_side := 'r', @@ -55,7 +55,7 @@ SELECT path_seq, node, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoi PREPARE q4 AS SELECT path_seq, node, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -4, -5, driving_side := 'r', @@ -66,7 +66,7 @@ SELECT set_eq('q3','q4','2: Right: from ARRAY[-4] to -5 same as one to one'); PREPARE q5 AS SELECT path_seq, node, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-1, -4], -5, driving_side := 'r', @@ -82,7 +82,7 @@ SELECT set_has('q5', 'q4', '6: Right: from point ARRAY[-1,-4] to -5 has results PREPARE q9 AS SELECT -1 AS start_vid, -5 AS end_vid, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', ARRAY[-1], -5, driving_side := 'r', @@ -92,7 +92,7 @@ SELECT -1 AS start_vid, -5 AS end_vid, round(agg_cost::numeric, 12) AS agg_cos PREPARE q10 AS SELECT start_pid, end_pid, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsCost( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', diff --git a/pgtap/withPoints/withPoints/edge_cases/one_to_many.pg b/pgtap/withPoints/withPoints/edge_cases/one_to_many.pg index 2323e5b8828..b9a8924d836 100644 --- a/pgtap/withPoints/withPoints/edge_cases/one_to_many.pg +++ b/pgtap/withPoints/withPoints/edge_cases/one_to_many.pg @@ -26,7 +26,7 @@ SELECT PLAN(8); PREPARE q1 AS WITH the_union AS ( (SELECT path_seq, -2 AS end_pid, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-2], driving_side := 'r', @@ -34,7 +34,7 @@ WITH the_union AS ( details := true)) UNION ALL (SELECT path_seq, -5 AS end_pid, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-5], driving_side := 'r', @@ -46,7 +46,7 @@ select row_number() OVER() AS seq, * FROM the_ordered; PREPARE q2 AS SELECT seq, path_seq, end_pid AS end_pid, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-2, -5], driving_side := 'r', @@ -55,7 +55,7 @@ SELECT seq, path_seq, end_pid AS end_pid, node, agg_cost FROM pgr_withPoints( PREPARE q3 AS SELECT seq, path_seq, end_pid AS end_pid, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-5, -2], driving_side := 'r', @@ -64,7 +64,7 @@ SELECT seq, path_seq, end_pid AS end_pid, node, agg_cost FROM pgr_withPoints( PREPARE q4 AS SELECT seq, path_seq, end_pid AS end_pid, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-5, -2, -2, -2, -5, -5, -2], driving_side := 'r', @@ -81,7 +81,7 @@ SELECT set_eq('q2', 'q4', '5: From point 1 to 2 and 5 the 2,5 vs 5,2 eliminate r PREPARE q5 AS SELECT seq, path_seq, -end_pid AS end_pid, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', '(SELECT pid, edge_id, fraction, side from pointsOfInterest) UNION ALL (SELECT pid, edge_id, fraction, side from pointsOfInterest)', 3, ARRAY[5, 1, 1, 5, 5, 1], driving_side := 'r', @@ -92,7 +92,7 @@ SELECT lives_ok('q5'); PREPARE q6 AS SELECT seq, path_seq, -end_pid AS end_pid, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', '(SELECT pid, edge_id, fraction, side from pointsOfInterest) UNION ALL (SELECT 1 as pid, edge_id, fraction, side from pointsOfInterest)', 3, ARRAY[5, 1, 1, 5, 5, 1], driving_side := 'r', @@ -105,7 +105,7 @@ SELECT throws_ok('q6', 'XX000', PREPARE q7 AS SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', '(SELECT pid, edge_id, fraction, side from pointsOfInterest) UNION ALL (SELECT 1 as pid, edge_id, fraction, side from pointsOfInterest)', 3, 5, driving_side := 'r', @@ -119,7 +119,7 @@ SELECT throws_ok('q7', 'XX000', /* PREPARE q3 AS SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[4], driving_side := 'r', @@ -130,7 +130,7 @@ SELECT set_has('q3','q2','2: Right: from 3 to 4 it passes in front of point 1'); PREPARE q4 AS SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[4], driving_side := 'l', @@ -139,7 +139,7 @@ SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q5 AS SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[4], driving_side := 'l', @@ -151,7 +151,7 @@ SELECT set_eq('q4', 'q5', '3: Left: from point 3 to 4 it does not pass in front PREPARE q6 AS SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[1], driving_side := 'l', @@ -163,7 +163,7 @@ SELECT set_has('q6','q5','4: Left: from 3 to 1 it passes in front of point 4'); PREPARE q7 AS SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[1], driving_side := 'b', @@ -172,7 +172,7 @@ SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q8 AS SELECT seq, path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[4], driving_side := 'b', @@ -183,7 +183,7 @@ SELECT set_has('q7','q8','Both: from 3 to 1 it passes in front of point 4'); PREPARE q9 AS SELECT -3 AS start_vid, -1 AS end_vid, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[1], driving_side := 'r', @@ -193,7 +193,7 @@ SELECT -3 AS start_vid, -1 AS end_vid, agg_cost FROM pgr_withPoints( PREPARE q10 AS SELECT * FROM pgr_withPointsCost( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', 3, ARRAY[1], driving_side := 'r', diff --git a/pgtap/withPoints/withPoints/edge_cases/one_to_many_eq_one_to_one.pg b/pgtap/withPoints/withPoints/edge_cases/one_to_many_eq_one_to_one.pg index 6e4e08242b8..f36c636b4d5 100644 --- a/pgtap/withPoints/withPoints/edge_cases/one_to_many_eq_one_to_one.pg +++ b/pgtap/withPoints/withPoints/edge_cases/one_to_many_eq_one_to_one.pg @@ -26,7 +26,7 @@ SELECT PLAN(7); PREPARE q1 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-5], driving_side := 'r', @@ -35,7 +35,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q2 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', @@ -46,7 +46,7 @@ SELECT set_eq('q1', 'q2', '1: Right: from point -1 to -5 same as one to one'); PREPARE q3 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-4], driving_side := 'r', @@ -55,7 +55,7 @@ SELECT path_seq, node, agg_cost FROM pgr_withPoints( PREPARE q4 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -4, driving_side := 'r', @@ -66,7 +66,7 @@ SELECT set_eq('q3','q4','2: Right: from -1 to -4 same as one to one'); PREPARE q5 AS SELECT path_seq, node, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-4, -5], driving_side := 'r', @@ -82,7 +82,7 @@ SELECT set_has('q5', 'q4', '6: Right: from point -1 to -4 & -5 has results of fr PREPARE q9 AS SELECT -1 AS start_vid, -5 AS end_vid, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, ARRAY[-5], driving_side := 'r', @@ -92,7 +92,7 @@ SELECT -1 AS start_vid, -5 AS end_vid, agg_cost FROM pgr_withPoints( PREPARE q10 AS SELECT * FROM pgr_withPointsCost( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', diff --git a/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg b/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg index 300e52b1fc2..60bce6506ec 100644 --- a/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg +++ b/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg @@ -24,7 +24,7 @@ SELECT PLAN(6); PREPARE q1 AS SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', @@ -33,7 +33,7 @@ SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( PREPARE q2 AS SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'r', @@ -48,7 +48,7 @@ SELECT set_has('q1', 'q21', '2: Right: from p1 to p5 pass in front of p6'); PREPARE q3 AS SELECT seq, path_seq, node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'l', @@ -58,7 +58,7 @@ SELECT seq, path_seq, node, edge, round(cost::numeric, 12) AS cost, round(agg_co PREPARE q4 AS SELECT seq, path_seq, node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'l', @@ -69,7 +69,7 @@ SELECT set_has('q1', 'q2', '3: Right: from p1 to p5 pass dont pass in front of p PREPARE q5 AS SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'b', @@ -78,7 +78,7 @@ SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( PREPARE q6 AS SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, driving_side := 'b', @@ -94,7 +94,7 @@ SELECT set_has('q5', 'q61', '5: both: from p1 to p5 pass in front of p6'); PREPARE q7 AS SELECT -3 AS start_vid, -1 AS end_vid, agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -3, -1, driving_side := 'r', @@ -104,7 +104,7 @@ SELECT -3 AS start_vid, -1 AS end_vid, agg_cost FROM pgr_withPoints( PREPARE q8 AS SELECT * FROM pgr_withPointsCost( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -3, -1, driving_side := 'r', diff --git a/pgtap/withPoints/withPoints/edge_cases/undirected.pg b/pgtap/withPoints/withPoints/edge_cases/undirected.pg index e6ca1e209ee..b3191166398 100644 --- a/pgtap/withPoints/withPoints/edge_cases/undirected.pg +++ b/pgtap/withPoints/withPoints/edge_cases/undirected.pg @@ -43,10 +43,10 @@ INTO test1 FROM (VALUES ( 1 , -1 , 1 , 0.6 , 0), - ( 2 , 2 , 4 , 1 , 0.6), - ( 3 , 5 , 7 , 1 , 1.6), - ( 4 , 8 , 6 , 1 , 2.6), - ( 5 , 7 , -1 , 0 , 3.6) + ( 2 , 6 , 4 , 1 , 0.6), + ( 3 , 7 , 7 , 1 , 1.6), + ( 4 , 3 , 6 , 1 , 2.6), + ( 5 , 1 , -1 , 0 , 3.6) ) AS t (seq, node, edge, cost, agg_cost) ORDER BY seq; @@ -54,9 +54,9 @@ ORDER BY seq; PREPARE q1 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 7, driving_side := 'b', details := false, directed:=false) + -1, 1, driving_side := 'b', details := false, directed:=false) ORDER BY seq; SELECT set_eq('q1', @@ -69,9 +69,9 @@ SELECT set_eq('q1', PREPARE q2 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 7, driving_side := 'r', details := false, directed:=false) + -1, 1, driving_side := 'r', details := false, directed:=false) ORDER BY seq; @@ -83,9 +83,9 @@ SELECT set_eq('q2', PREPARE q3 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 7, driving_side := 'l', details := false, directed:=false) + -1, 1, driving_side := 'l', details := false, directed:=false) ORDER BY seq; @@ -105,11 +105,11 @@ SELECT INTO test2 FROM (VALUES - ( 1 , 12 , 15 , 1 , 0), - ( 2 , 9 , 16 , 1 , 1), - ( 3 , 4 , 3 , 1 , 2), - ( 4 , 3 , 2 , 1 , 3), - ( 5 , 2 , 1 , 0.6 , 4), + ( 1 , 17 , 15 , 1 , 0), + ( 2 , 16 , 16 , 1 , 1), + ( 3 , 15 , 3 , 1 , 2), + ( 4 , 10 , 2 , 1 , 3), + ( 5 , 6 , 1 , 0.6 , 4), ( 6 , -1 , -1 , 0 , 4.6) ) AS t (seq, node, edge, cost, agg_cost) ORDER BY seq; @@ -118,9 +118,9 @@ ORDER BY seq; PREPARE q4 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 12, -1, driving_side := 'b', details := false, directed:=false) + 17, -1, driving_side := 'b', details := false, directed:=false) ORDER BY seq; SELECT set_eq('q4', @@ -133,9 +133,9 @@ SELECT set_eq('q4', PREPARE q5 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 12, -1, driving_side := 'r', details := false, directed:=false) + 17, -1, driving_side := 'r', details := false, directed:=false) ORDER BY seq; @@ -147,9 +147,9 @@ SELECT set_eq('q5', PREPARE q6 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 12, -1, driving_side := 'l', details := false, directed:=false) + 17, -1, driving_side := 'l', details := false, directed:=false) ORDER BY seq; @@ -171,27 +171,27 @@ SELECT INTO test3 FROM (VALUES - ( 1 , 1 , 0.4 , 0), + ( 5 , 1 , 0.4 , 0), ( -1 , 1 , 0.6 , 0.4), - ( 2 , 4 , 0.7 , 1), + ( 6 , 4 , 0.7 , 1), ( -6 , 4 , 0.3 , 1.7), - ( 5 , 7 , 1 , 2), - ( 8 , 6 , 0.7 , 3), + ( 7 , 7 , 1 , 2), + ( 3 , 6 , 0.7 , 3), ( -4 , 6 , 0.3 , 3.7), - ( 7 , -1 , 0 , 4) + ( 1 , -1 , 0 , 4) ) AS t (node, edge, cost, agg_cost); -------- both driving sides PREPARE q7 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 1, 7, driving_side := 'b', details := true, directed:=false); + 5, 1, driving_side := 'b', details := true, directed:=false); SELECT set_eq('q7', $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, - '1, 7, driving_side := b, details := true, directed:=false'); + '5, 1, driving_side := b, details := true, directed:=false'); @@ -200,29 +200,29 @@ SELECT set_eq('q7', PREPARE q8 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 1, 7, driving_side := 'r', details := true, directed:=false) + 5, 1, driving_side := 'r', details := true, directed:=false) ORDER BY seq; SELECT set_eq('q8', $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, - '1, 7, driving_side := r, details := true, directed:=false'); + '5, 1, driving_side := r, details := true, directed:=false'); -------- left driving side PREPARE q9 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 1, 7, driving_side := 'l', details := true, directed:=false) + 5, 1, driving_side := 'l', details := true, directed:=false) ORDER BY seq; SELECT set_eq('q9', $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, - '1, 7, driving_side := l, details := true, directed:=false'); + '5, 1, driving_side := l, details := true, directed:=false'); ------------------ @@ -235,12 +235,12 @@ SELECT INTO test4 FROM (VALUES - ( 12 , 15 , 0.6 , 0), + ( 17 , 15 , 0.6 , 0), ( -2 , 15 , 0.4 , 0.6), - ( 9 , 16 , 1 , 1), - ( 4 , 3 , 1 , 2), - ( 3 , 2 , 1 , 3), - ( 2 , 1 , 0.6 , 4), + ( 16 , 16 , 1 , 1), + ( 15 , 3 , 1 , 2), + ( 10 , 2 , 1 , 3), + ( 6 , 1 , 0.6 , 4), ( -1 , -1 , 0 , 4.6) ) AS t (node, edge, cost, agg_cost); @@ -248,13 +248,13 @@ FROM PREPARE q10 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 12, -1, driving_side := 'b', details := true, directed:=false); + 17, -1, driving_side := 'b', details := true, directed:=false); SELECT set_eq('q10', $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - '12, -1, driving_side := b, details := true, directed:=false'); + '17, -1, driving_side := b, details := true, directed:=false'); @@ -262,27 +262,27 @@ SELECT set_eq('q10', PREPARE q11 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 12, -1, driving_side := 'r', details := true, directed:=false); + 17, -1, driving_side := 'r', details := true, directed:=false); SELECT set_eq('q11', $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - '12, -1, driving_side := r, details := true, directed:=false'); + '17, -1, driving_side := r, details := true, directed:=false'); -------- left driving side PREPARE q12 AS SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 12, -1, driving_side := 'l', details := true, directed:=false); + 17, -1, driving_side := 'l', details := true, directed:=false); SELECT set_eq('q12', $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - '12, -1, driving_side := l, details := true, directed:=false'); + '17, -1, driving_side := l, details := true, directed:=false'); diff --git a/pgtap/withPoints/withPoints/inner_query.pg b/pgtap/withPoints/withPoints/inner_query.pg index 51c78dd7ef7..2e3ef4027dd 100644 --- a/pgtap/withPoints/withPoints/inner_query.pg +++ b/pgtap/withPoints/withPoints/inner_query.pg @@ -19,31 +19,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(432) ELSE plan(338) END; -- ONE TO ONE SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, 3, true)'); -SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edge_table$$,', ', 2, 3, true)'); +SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, 3, true)'); -- ONE TO MANY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], true)'); -SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edge_table$$,', ', 2, ARRAY[3], true)'); +SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, ARRAY[3], true)'); -- MANY TO ONE SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, true)'); -SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edge_table$$,', ', ARRAY[2], 3, true)'); +SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], 3, true)'); -- MANY TO MANY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], true)'); -SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edge_table$$,', ', ARRAY[2], ARRAY[3], true)'); +SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], true)'); -- COMBINATIONS CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN IF min_version('3.2.0') THEN - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edge_table$$,', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_withPoints($$SELECT * FROM edge_table$$, $$SELECT * from pointsOfInterest$$,',', true)'); + RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_withPoints($$SELECT * FROM edges$$, $$SELECT * from pointsOfInterest$$,',', true)'); ELSE RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.2.0'); END IF; diff --git a/pgtap/withPoints/withPoints/no_crash_test.pg b/pgtap/withPoints/withPoints/no_crash_test.pg index 36c47802a05..c40b63a9822 100644 --- a/pgtap/withPoints/withPoints/no_crash_test.pg +++ b/pgtap/withPoints/withPoints/no_crash_test.pg @@ -19,26 +19,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan (102) ELSE plan(85) END; PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE combinations AS -SELECT source, target FROM combinations_table; +SELECT source, target FROM combinations; PREPARE pois AS SELECT pid, edge_id, fraction from pointsOfInterest; PREPARE null_ret AS -SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT id FROM vertices WHERE id IN (-1); PREPARE null_ret_arr AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); PREPARE null_combinations AS -SELECT source, target FROM combinations_table WHERE source IN (-1); +SELECT source, target FROM combinations WHERE source IN (-1); CREATE OR REPLACE FUNCTION test_function() @@ -62,14 +62,14 @@ BEGIN params = ARRAY[ '$$edges$$', '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '1::BIGINT', - '2::BIGINT' + '5::BIGINT', + '6::BIGINT' ]::TEXT[]; subs = ARRAY[ 'NULL', 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); @@ -89,8 +89,8 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); @@ -110,8 +110,8 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); @@ -131,8 +131,8 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); @@ -163,7 +163,7 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '$$(SELECT source, target FROM combinations_table WHERE source IN (-1))$$' + '$$(SELECT source, target FROM combinations WHERE source IN (-1))$$' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); diff --git a/pgtap/withPoints/withPointsCost/edge_cases/empty_combinations_empty_result.pg b/pgtap/withPoints/withPointsCost/edge_cases/empty_combinations_empty_result.pg index 55fb3e2d408..a52dc4d7434 100644 --- a/pgtap/withPoints/withPointsCost/edge_cases/empty_combinations_empty_result.pg +++ b/pgtap/withPoints/withPointsCost/edge_cases/empty_combinations_empty_result.pg @@ -35,9 +35,9 @@ BEGIN RETURN query SELECT is_empty( 'SELECT start_pid, end_pid, agg_cost FROM pgr_withPointsCost( - ''SELECT id, source, target, cost, reverse_cost FROM edge_table'', + ''SELECT id, source, target, cost, reverse_cost FROM edges'', ''SELECT pid, edge_id, fraction, side from pointsOfInterest'', - ''SELECT * FROM combinations_table WHERE source IN (-1)'' ) ' + ''SELECT * FROM combinations WHERE source IN (-1)'' ) ' ); RETURN; END diff --git a/pgtap/withPoints/withPointsCost/inner_query.pg b/pgtap/withPoints/withPointsCost/inner_query.pg index c20a59a04d1..59d01c8031a 100644 --- a/pgtap/withPoints/withPointsCost/inner_query.pg +++ b/pgtap/withPoints/withPointsCost/inner_query.pg @@ -19,31 +19,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan(432) ELSE plan(338) END; -- ONE TO ONE SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, 3, true)'); -SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edge_table$$,', ', 2, 3, true)'); +SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, 3, true)'); -- ONE TO MANY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], true)'); -SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edge_table$$,', ', 2, ARRAY[3], true)'); +SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, ARRAY[3], true)'); -- MANY TO ONE SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, true)'); -SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edge_table$$,', ', ARRAY[2], 3, true)'); +SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], 3, true)'); -- MANY TO MANY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], true)'); -SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edge_table$$,', ', ARRAY[2], ARRAY[3], true)'); +SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], true)'); -- COMBINATIONS CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN IF min_version('3.2.0') THEN - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edge_table$$,', ', $$SELECT * FROM combinations_table$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_withPointsCost($$SELECT * FROM edge_table$$, $$SELECT * from pointsOfInterest$$,',', true)'); + RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', $$SELECT * FROM combinations$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_withPointsCost($$SELECT * FROM edges$$, $$SELECT * from pointsOfInterest$$,',', true)'); ELSE RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.2.0'); END IF; diff --git a/pgtap/withPoints/withPointsCost/no_crash_test.pg b/pgtap/withPoints/withPointsCost/no_crash_test.pg index fc050af25cf..754b61de846 100644 --- a/pgtap/withPoints/withPointsCost/no_crash_test.pg +++ b/pgtap/withPoints/withPointsCost/no_crash_test.pg @@ -19,26 +19,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.2.0') THEN plan (102) ELSE plan(85) END; PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE combinations AS -SELECT source, target FROM combinations_table; +SELECT source, target FROM combinations; PREPARE pois AS SELECT pid, edge_id, fraction from pointsOfInterest; PREPARE null_ret AS -SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT id FROM vertices WHERE id IN (-1); PREPARE null_ret_arr AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); PREPARE null_combinations AS -SELECT source, target FROM combinations_table WHERE source IN (-1); +SELECT source, target FROM combinations WHERE source IN (-1); CREATE OR REPLACE FUNCTION test_function() @@ -62,14 +62,14 @@ BEGIN params = ARRAY[ '$$edges$$', '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '1::BIGINT', - '2::BIGINT' + '5::BIGINT', + '6::BIGINT' ]::TEXT[]; subs = ARRAY[ 'NULL', 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); @@ -89,8 +89,8 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT id FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); @@ -110,8 +110,8 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); @@ -131,8 +131,8 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); @@ -163,7 +163,7 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '$$(SELECT source, target FROM combinations_table WHERE source IN (-1))$$' + '$$(SELECT source, target FROM combinations WHERE source IN (-1))$$' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); diff --git a/pgtap/withPoints/withPointsCostMatrix/inner_query.pg b/pgtap/withPoints/withPointsCostMatrix/inner_query.pg index 992c117cac5..baf47fa73cf 100644 --- a/pgtap/withPoints/withPointsCostMatrix/inner_query.pg +++ b/pgtap/withPoints/withPointsCostMatrix/inner_query.pg @@ -19,13 +19,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(84); -- ONE MATRIX SELECT style_dijkstra('pgr_withPointsCostMatrix(', ', $$SELECT * from pointsOfInterest$$, ARRAY[1,2,3,4], true)'); -SELECT innerquery_points('pgr_withPointsCostMatrix($$SELECT * FROM edge_table$$,', ', ARRAY[1,2,3,4], true)'); +SELECT innerquery_points('pgr_withPointsCostMatrix($$SELECT * FROM edges$$,', ', ARRAY[1,2,3,4], true)'); SELECT finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg b/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg index d978843ec42..c1101014ddd 100644 --- a/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg +++ b/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg @@ -19,17 +19,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(19); PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE pois AS SELECT pid, edge_id, fraction from pointsOfInterest; PREPARE null_ret AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT isnt_empty('pois', 'Should be not empty to tests be meaningful'); @@ -44,13 +44,13 @@ params TEXT[]; subs TEXT[]; BEGIN params = ARRAY[ - '$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - 'ARRAY[1,2]']::TEXT[]; + 'ARRAY[5,6]']::TEXT[]; subs = ARRAY[ 'NULL', 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPointsCostMatrix', params, subs); diff --git a/pgtap/withPoints/withPointsDD/edge_cases/allowed_driving_side.pg b/pgtap/withPoints/withPointsDD/edge_cases/allowed_driving_side.pg new file mode 100644 index 00000000000..b4fafbc1a65 --- /dev/null +++ b/pgtap/withPoints/withPointsDD/edge_cases/allowed_driving_side.pg @@ -0,0 +1,140 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2023 pgRouting developers +Mail: project at pgrouting.org + +------ +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + ********************************************************************PGR-GNU*/ + +BEGIN; + +SELECT plan(16); + +CREATE OR REPLACE FUNCTION test_cases() +RETURNS SETOF TEXT AS +$BODY$ +BEGIN + +-- everything lives as it gets a default +-- directed r, R +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'r', directed => true)$$, 'old lives: directed right'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'R', directed => true)$$, 'old lives: directed Right'); + +-- directed l, L +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'l', directed => true)$$, 'old lives: directed left'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'L', directed => true)$$, 'old lives: directed Left'); + +-- directed b, B +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'b', directed => true)$$, 'old lives: directed both'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'B', directed => true)$$, 'old lives: directed Both'); + +-- directed Invalid +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'i', directed => true)$$, 'old lives: directed invalid'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'I', directed => true)$$, 'old lives: directed Invalid'); + +-- undirected r, R +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'r', directed => false)$$, 'old lives: undirected right'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'R', directed => false)$$, 'old lives: undirected Right'); + +-- undirected l, L +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'l', directed => false)$$, 'old lives: undirected left'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'L', directed => false)$$, 'old lives: undirected Left'); + +-- undirected b, B +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'b', directed => false)$$, 'old lives: undirected both'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'B', directed => false)$$, 'old lives: undirected Both'); + +-- undirected Invalid +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'i', directed => false)$$, 'old lives: undirected invalid'); + +RETURN QUERY SELECT lives_ok($$ +SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + -1, 4.8, driving_side => 'I', directed => false)$$, 'old lives: undirected Invalid'); + +END; +$BODY$ +language plpgsql; + +SELECT test_cases(); +SELECT finish(); +ROLLBACK; diff --git a/pgtap/withPoints/withPointsDD/edge_cases/issue_979.pg b/pgtap/withPoints/withPointsDD/edge_cases/issue_979.pg index 5c11f349bf0..829fd51625d 100644 --- a/pgtap/withPoints/withPointsDD/edge_cases/issue_979.pg +++ b/pgtap/withPoints/withPointsDD/edge_cases/issue_979.pg @@ -1,8 +1,7 @@ - /*PGR-GNU***************************************************************** Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org +Mail: project at pgrouting.org ------ This program is free software; you can redistribute it and/or modify @@ -20,186 +19,110 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -SELECT PLAN(6); - +SET extra_float_digits = -3; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +SELECT plan(3) END; ---- ---- DIRECTED GRAPH ---- --------- both driving sides +CREATE OR REPLACE FUNCTION test_expected_results() +RETURNS SETOF TEXT AS +$BODY$ +BEGIN -PREPARE q1 AS -SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 6.8, driving_side := 'b', details := false) -ORDER BY seq; - - -SELECT - node::BIGINT, edge::BIGINT, round(cost, 12) AS cost, round(agg_cost, 12) AS agg_cost -INTO test1 -FROM -(VALUES - ( -1 , -1 , 0 , 0), - ( 1 , 1 , 0.4 , 0.4), - ( 2 , 1 , 0.6 , 0.6), - ( 5 , 4 , 1 , 1.6), - ( 6 , 8 , 1 , 2.6), - ( 8 , 7 , 1 , 2.6), - ( 10 , 10 , 1 , 2.6), - ( 7 , 6 , 1 , 3.6), - ( 9 , 9 , 1 , 3.6), - ( 11 , 11 , 1 , 3.6), - ( 13 , 14 , 1 , 3.6), - ( 4 , 16 , 1 , 4.6), - ( 12 , 13 , 1 , 4.6), - ( 3 , 3 , 1 , 5.6) -) AS t (node, edge, cost, agg_cost); - - -SELECT set_eq('q1', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test1$$, - 'Should be aggregating individual costs: both driving sides, DIR'); - - - --------- right driving side - -PREPARE q2 AS -SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 6.8, driving_side := 'r', details := false); - - -SELECT - node::BIGINT, edge::BIGINT, cost::FLOAT, agg_cost::FLOAT -INTO test2 -FROM -(VALUES - ( -1 , -1 , 0 , 0), - ( 1 , 1 , 0.4 , 0.4), - ( 2 , 1 , 1 , 1.4), - ( 5 , 4 , 1 , 2.4), - ( 6 , 8 , 1 , 3.4), - ( 8 , 7 , 1 , 3.4), - ( 10 , 10 , 1 , 3.4), - ( 7 , 6 , 1 , 4.4), - ( 9 , 9 , 1 , 4.4), - ( 11 , 11 , 1 , 4.4), - ( 13 , 14 , 1 , 4.4), - ( 4 , 16 , 1 , 5.4), - ( 12 , 13 , 1 , 5.4), - ( 3 , 3 , 1 , 6.4) -) AS t (node, edge, cost, agg_cost); - - -SELECT set_eq('q2', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test2$$, - 'Should be aggregating individual costs: right driving side, DIR'); - --------- left driving side - -PREPARE q3 AS -SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + PREPARE q1 AS + SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 6.8, driving_side := 'l', details := false) -ORDER BY seq; - - -SELECT - node::BIGINT, edge::BIGINT, cost::FLOAT, agg_cost::FLOAT -INTO test3 -FROM -(VALUES - (-1 , -1 , 0 , 0), - ( 2 , 1 , 0.6 , 0.6), - ( 5 , 4 , 1 , 1.6), - ( 1 , 1 , 1 , 1.6), - ( 6 , 8 , 1 , 2.6), - ( 8 , 7 , 1 , 2.6), - (10 , 10 , 1 , 2.6), - ( 7 , 6 , 1 , 3.6), - ( 9 , 9 , 1 , 3.6), - ( 11 , 11 , 1 , 3.6), - ( 13 , 14 , 1 , 3.6), - ( 4 , 16 , 1 , 4.6), - ( 12 , 15 , 1 , 4.6), - ( 3 , 3 , 1 , 5.6) -) AS t (node, edge, cost, agg_cost); - - -SELECT set_eq('q3', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, - 'Should be aggregating individual costs: left driving side, DIR'); - ---- ---- UNDIRECTED GRAPH ---- - --- all results on udirected graph are "allegedly" equal -SELECT - node::BIGINT, cost::FLOAT, agg_cost::FLOAT -INTO test4 -FROM -(VALUES - ( -1 , 0 , 0), - ( 1 , 0.4 , 0.4), - ( 2 , 0.6 , 0.6), - ( 5 , 1 , 1.6), - ( 3 , 1 , 1.6), - ( 6 , 1 , 2.6), - ( 8 , 1 , 2.6), - ( 10 , 1 , 2.6), - ( 4 , 1 , 2.6), - ( 7 , 1 , 3.6), - ( 9 , 1 , 3.6), - ( 11 , 1 , 3.6), - ( 13 , 1 , 3.6), - ( 12 , 1 , 4.6) -) AS t (node, cost, agg_cost); - --------- both driving sides - -PREPARE q4 AS -SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 6.8, driving_side := 'b', details := false, directed:=false); - -SELECT set_eq('q4', - $$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - 'Should be aggregating individual costs: both driving sides, UNDI'); - - + -1, 6.8, driving_side => 'r', details := false); --------- right driving side - -PREPARE q5 AS -SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + PREPARE q2 AS + SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 6.8, driving_side := 'r', details := false, directed:=false); - - -SELECT set_eq('q5', - $$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - 'Should be aggregating individual costs: right driving side, UNDI'); - --------- left driving side + -1, 6.8, driving_side => 'l', details := false); -PREPARE q6 AS -SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + PREPARE q3 AS + SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPointsDD( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 6.8, driving_side := 'l', details := false, directed:=false); - - -SELECT set_eq('q6', - $$SELECT node, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - 'Should be aggregating individual costs: left driving side, UNDI'); - -SELECT * FROM finish(); + -1, 6.8, driving_side => 'b', details := false, directed:=false); + + PREPARE e1 AS + SELECT + node::BIGINT, edge::BIGINT, cost::FLOAT, agg_cost::FLOAT + FROM + (VALUES + ( -1, -1, 0, 0), + ( 5, 1, 0.4004, 0.4004), + ( 6, 1, 1.0010, 1.4014), + ( 7, 4, 1.0160, 2.4174), + ( 3, 7, 1.0490, 3.4664), + ( 11, 8, 1.0640, 3.4814), + ( 8, 10, 1.1000, 3.5174), + ( 1, 6, 1.0360, 4.5024), + ( 16, 9, 1.0810, 4.5624), + ( 12, 11, 1.1210, 4.6024), + ( 9, 14, 1.1960, 4.7134), + ( 17, 13, 1.1690, 5.7714), + ( 15, 16, 1.2560, 5.8184) + ) AS t (node, edge, cost, agg_cost); + + PREPARE e2 AS + SELECT + node, edge::BIGINT, cost::FLOAT, agg_cost::FLOAT + FROM + (VALUES + ( -1, -1, 0, 0), + ( 6, 1, 0.6006, 0.6006), + ( 5, 1, 1.001, 1.6016), + ( 7, 4, 1.016, 1.6166), + ( 3, 7, 1.049, 2.6656), + ( 8, 10, 1.1, 2.7166), + ( 11, 8, 1.064, 2.6806), + ( 1, 6, 1.036, 3.7016), + ( 16, 9, 1.081, 3.7616), + ( 12, 11, 1.121, 3.8016), + ( 9, 14, 1.196, 3.9126), + ( 17, 13, 1.169, 4.9706), + ( 15, 16, 1.256, 5.0176), + ( 10, 3, 1.009, 6.0266) + ) AS t (node, edge, cost, agg_cost); + + PREPARE e3 AS + SELECT + node::BIGINT, edge::BIGINT, cost::FLOAT, agg_cost::FLOAT + FROM + (VALUES + ( -1, -1, 0, 0), + ( 6, 1, 0.6006, 0.6006), + ( 5, 1, 0.4004, 0.4004), + ( 10, 2, 1.0040, 1.6046), + ( 7, 4, 1.0160, 1.6166), + ( 15, 3, 1.0090, 2.6136), + ( 11, 5, -0.9750, 2.6296), + ( 3, 7, 1.0490, 2.6656), + ( 8, 10, 1.1000, 2.7166), + ( 1, 6, 1.0360, 3.7016), + ( 16, 9, 1.0810, 3.7106), + ( 12, 11, 1.1210, 3.7506), + ( 9, 14, 1.1960, 3.9126), + ( 17, 13, 1.1690, 4.9196) + ) AS t (node, edge, cost, agg_cost); + + + RETURN QUERY + SELECT set_eq('q1', 'e1', 'right driving side, DIR'); + + RETURN QUERY + SELECT set_eq('q2', 'e2', 'left driving side, DIR'); + + RETURN QUERY + SELECT set_eq('q3', 'e3', 'both driving sides, UNDI'); + + +END; +$BODY$ +language plpgsql; + +SELECT test_expected_results(); +SELECT finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPointsDD/edge_cases/undirected_driving_side.pg b/pgtap/withPoints/withPointsDD/edge_cases/undirected_driving_side.pg index 2346bc37d90..4b9411771cb 100644 --- a/pgtap/withPoints/withPointsDD/edge_cases/undirected_driving_side.pg +++ b/pgtap/withPoints/withPointsDD/edge_cases/undirected_driving_side.pg @@ -2,7 +2,7 @@ /*PGR-GNU***************************************************************** Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org +Mail: project at pgrouting.org ------ This program is free software; you can redistribute it and/or modify @@ -17,22 +17,24 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ - +/* TODO remove in v4 */ BEGIN; SELECT PLAN(3); - +-- TEST of deprecated signature +-- This test does not make sense on new signatures due to the fact that +-- if graph is undircted then the only valid parameter of driving side can only be 'b' +SET client_min_messages TO ERROR; -- because the graph is undirected, It will not matter the side of the point --- UNDIRECTED GRAPH --- - -------- both driving sides PREPARE q1 AS SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, 4.8, driving_side := 'b', details := true, directed:=false) ORDER BY seq; @@ -41,7 +43,7 @@ ORDER BY seq; PREPARE q2 AS SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, 4.8, driving_side := 'r', details := true, directed:=false) ORDER BY seq; @@ -51,7 +53,7 @@ ORDER BY seq; PREPARE q3 AS SELECT seq, node, edge, cost::TEXT, agg_cost::TEXT FROM pgr_withPointsDD( - 'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id', + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, 4.8, driving_side := 'l', details := true, directed:=false) ORDER BY seq; diff --git a/pgtap/withPoints/withPointsDD/inner_query.pg b/pgtap/withPoints/withPointsDD/inner_query.pg index 5b5407e8bea..f489b7d46bb 100644 --- a/pgtap/withPoints/withPointsDD/inner_query.pg +++ b/pgtap/withPoints/withPointsDD/inner_query.pg @@ -2,7 +2,7 @@ /*PGR-GNU***************************************************************** Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org +Mail: project at pgrouting.org ------ This program is free software; you can redistribute it and/or modify @@ -19,15 +19,29 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(168); --- SINGLE VERTEX -SELECT style_dijkstra('pgr_withPointsDD(', ', $$SELECT * from pointsOfInterest$$, 2, 3.8, true)'); -SELECT innerquery_points('pgr_withPointsDD($$SELECT * FROM edge_table$$,', ', 2, 3.8, true)'); --- MULTIPLE VERTEX -SELECT style_dijkstra('pgr_withPointsDD(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2,3], 3.8, true)'); -SELECT innerquery_points('pgr_withPointsDD($$SELECT * FROM edge_table$$,', ', ARRAY[2,3], 3.8, true)'); +CREATE OR REPLACE FUNCTION test_innerquery() +RETURNS SETOF TEXT AS +$BODY$ +BEGIN + -- SINGLE VERTEX + RETURN QUERY + SELECT style_dijkstra('pgr_withPointsDD(', ', $$SELECT * from pointsOfInterest$$, 5, 3.8, true)'); + RETURN QUERY + SELECT innerquery_points('pgr_withPointsDD($$SELECT * FROM edges$$,', ', 5, 3.8, true)'); + -- MULTIPLE VERTEX + RETURN QUERY + SELECT style_dijkstra('pgr_withPointsDD(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2,10], 3.8, true)'); + RETURN QUERY + SELECT innerquery_points('pgr_withPointsDD($$SELECT * FROM edges$$,', ', ARRAY[5,10], 3.8, true)'); + +END; +$BODY$ +language plpgsql; + +SELECT test_innerquery(); SELECT finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPointsDD/no_crash_test.pg b/pgtap/withPoints/withPointsDD/no_crash_test.pg index e551d58315c..0d302c1691f 100644 --- a/pgtap/withPoints/withPointsDD/no_crash_test.pg +++ b/pgtap/withPoints/withPointsDD/no_crash_test.pg @@ -2,7 +2,7 @@ /*PGR-GNU***************************************************************** Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org +Mail: project at pgrouting.org ------ This program is free software; you can redistribute it and/or modify @@ -19,17 +19,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT plan(42); PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE pois AS SELECT pid, edge_id, fraction from pointsOfInterest; PREPARE null_ret AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT set_eq('null_ret', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); @@ -44,7 +44,7 @@ subs TEXT[]; BEGIN -- 1 to distance params = ARRAY[ - '$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', '1', '1.3::FLOAT' @@ -52,7 +52,7 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1))', + '(SELECT id FROM vertices WHERE id IN (-1))', 'NULL' ]::TEXT[]; @@ -68,7 +68,7 @@ BEGIN -- many to distance params = ARRAY[ - '$$SELECT id, source, target, cost, reverse_cost FROM edge_table$$', + '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', 'ARRAY[1]', '1.3::FLOAT' @@ -76,7 +76,7 @@ BEGIN subs = ARRAY[ 'NULL', 'NULL', - '(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', 'NULL' ]::TEXT[]; diff --git a/pgtap/withPoints/withPointsVia/compare_dijkstraVia/directed.pg b/pgtap/withPoints/withPointsVia/compare_dijkstraVia/directed.pg index 1ac9503a8af..487574fef14 100644 --- a/pgtap/withPoints/withPointsVia/compare_dijkstraVia/directed.pg +++ b/pgtap/withPoints/withPointsVia/compare_dijkstraVia/directed.pg @@ -22,7 +22,7 @@ BEGIN; SELECT CASE WHEN min_version('3.4.0') THEN CASE WHEN version() LIKE '%SQL 10%' OR version() LIKE '%SQL 11%' THEN plan(1024) ELSE plan(2048) END ELSE plan(1) END; SET extra_float_digits = -3; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; SELECT withPointsVia_VS_dijstraVia(16, true); diff --git a/pgtap/withPoints/withPointsVia/compare_dijkstraVia/undirected.pg b/pgtap/withPoints/withPointsVia/compare_dijkstraVia/undirected.pg index a807b3aa8c0..6d82a969d09 100644 --- a/pgtap/withPoints/withPointsVia/compare_dijkstraVia/undirected.pg +++ b/pgtap/withPoints/withPointsVia/compare_dijkstraVia/undirected.pg @@ -22,7 +22,7 @@ BEGIN; SELECT CASE WHEN min_version('3.4.0') THEN CASE WHEN version() LIKE '%SQL 10%' OR version() LIKE '%SQL 11%' THEN plan(1024) ELSE plan(2048) END ELSE plan(1) END; SET extra_float_digits = -3; -UPDATE edge_table SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; SELECT withPointsVia_VS_dijstraVia(16, false); diff --git a/pgtap/withPoints/withPointsVia/inner_query.pg b/pgtap/withPoints/withPointsVia/inner_query.pg index 8536e508527..484d08b29aa 100644 --- a/pgtap/withPoints/withPointsVia/inner_query.pg +++ b/pgtap/withPoints/withPointsVia/inner_query.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.4.0') THEN plan(84) ELSE plan(1) END; CREATE OR REPLACE FUNCTION inner_query() @@ -33,7 +33,7 @@ BEGIN -- ONE VIA RETURN QUERY SELECT style_dijkstra('pgr_withPointsVia(', ', $$SELECT * FROM pointsOfInterest$$, ARRAY[2,9,12])'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsVia($$SELECT * FROM edge_table$$,', ', ARRAY[2,9,12])'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsVia($$SELECT * FROM edges$$,', ', ARRAY[2,9,12])'); END; $BODY$ diff --git a/pgtap/withPoints/withPointsVia/no_crash_test.pg b/pgtap/withPoints/withPointsVia/no_crash_test.pg index d14b25b7f8a..135eb251c1a 100644 --- a/pgtap/withPoints/withPointsVia/no_crash_test.pg +++ b/pgtap/withPoints/withPointsVia/no_crash_test.pg @@ -19,17 +19,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost); +UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); SELECT CASE WHEN min_version('3.4.0') THEN plan(19) ELSE plan(4) END; PREPARE edges AS -SELECT id, source, target, cost, reverse_cost FROM edge_table; +SELECT id, source, target, cost, reverse_cost FROM edges; PREPARE null_ret AS -SELECT id FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT id FROM vertices WHERE id IN (-1); PREPARE null_ret_arr AS -SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1); +SELECT array_agg(id) FROM vertices WHERE id IN (-1); SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); @@ -51,15 +51,15 @@ END IF; -- ONE VIA params = ARRAY[ -'$$SELECT * FROM edge_table$$', +'$$SELECT * FROM edges$$', '$$SELECT * FROM pointsOfInterest$$', -'ARRAY[2,5]::BIGINT[]' +'ARRAY[6,7]::BIGINT[]' ]::TEXT[]; subs = ARRAY[ 'NULL', 'NULL', -'(SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id IN (-1))' +'(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_withPointsvia', params, subs);