From 901a4a607648f2addadb190f299b9314a7cc7f63 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 01/39] (sql, src) pgr_trspVia_withPoints: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/trsp/_trspVia_withPoints.sql | 21 ++--- sql/trsp/trspVia_withPoints.sql | 36 ++++----- src/trsp/trspVia_withPoints.c | 132 +++++++++++++++++++++++++++---- 3 files changed, 148 insertions(+), 41 deletions(-) diff --git a/sql/trsp/_trspVia_withPoints.sql b/sql/trsp/_trspVia_withPoints.sql index bac44cf89d8..4be8c4629b7 100644 --- a/sql/trsp/_trspVia_withPoints.sql +++ b/sql/trsp/_trspVia_withPoints.sql @@ -1,8 +1,12 @@ /*PGR-GNU***************************************************************** File: _trspVia_withPoints.sql +Copyright (c) 2015 pgRouting developers +Mail: project@pgrouting.org + Function's developer: Copyright (c) 2022 Celia Virginia Vergara Castillo +Mail: vicky at erosion.dev ------ @@ -22,18 +26,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ---v3.0 -CREATE FUNCTION _pgr_trspVia_withPoints( +--v4.0 +CREATE FUNCTION _pgr_trspVia_withPoints_v4( TEXT, -- edges TEXT, -- restrictions TEXT, -- points ANYARRAY, -- via - -- via parameters + BOOLEAN, -- directed + BOOLEAN, -- strict BOOLEAN, -- U_turn_on_edge - -- withPoints parameters - CHAR, -- driving_side + + CHAR, -- driving side BOOLEAN, -- details OUT seq INTEGER, @@ -48,9 +53,7 @@ CREATE FUNCTION _pgr_trspVia_withPoints( OUT route_agg_cost FLOAT) RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE c VOLATILE STRICT; - --- COMMENTS +LANGUAGE C VOLATILE STRICT; -COMMENT ON FUNCTION _pgr_trspVia_withPoints(TEXT, TEXT, TEXT, ANYARRAY, BOOLEAN, BOOLEAN, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION _pgr_trspVia_withPoints_v4(TEXT, TEXT, TEXT, ANYARRAY, BOOLEAN, BOOLEAN, BOOLEAN, CHAR, BOOLEAN) IS 'pgRouting internal function'; diff --git a/sql/trsp/trspVia_withPoints.sql b/sql/trsp/trspVia_withPoints.sql index adc6b26aca0..4bd9740aca1 100644 --- a/sql/trsp/trspVia_withPoints.sql +++ b/sql/trsp/trspVia_withPoints.sql @@ -1,8 +1,12 @@ /*PGR-GNU***************************************************************** File: trspVia_withPoints.sql +Copyright (c) 2015 pgRouting developers +Mail: project@pgrouting.org + Function's developer: Copyright (c) 2022 Celia Virginia Vergara Castillo +Mail: vicky at erosion.dev ------ @@ -22,12 +26,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ---v3.4 +--v4.0 CREATE FUNCTION pgr_trspVia_withPoints( - TEXT, -- edges sql - TEXT, -- restrictions sql + TEXT, -- edges + TEXT, -- restrictions TEXT, -- points ANYARRAY, -- via vids + CHAR, -- driving side directed BOOLEAN DEFAULT true, @@ -36,7 +41,6 @@ CREATE FUNCTION pgr_trspVia_withPoints( U_turn_on_edge BOOLEAN DEFAULT true, -- withPoints parameters - driving_side CHAR DEFAULT 'r', -- 'r'/'l' details BOOLEAN DEFAULT false, OUT seq INTEGER, @@ -51,32 +55,28 @@ CREATE FUNCTION pgr_trspVia_withPoints( OUT route_agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ -SELECT seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost, route_agg_cost -FROM _pgr_trspVia_withPoints( - _pgr_get_statement($1), - _pgr_get_statement($2), - _pgr_get_statement($3), - $4, $5, $6, $7, $8, $9); + SELECT seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost, route_agg_cost + FROM _pgr_trspVia_withPoints_v4( + _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), $4, + directed, strict, u_turn_on_edge, $5, details); $BODY$ LANGUAGE SQL VOLATILE STRICT COST 100 ROWS 1000; --- COMMENTS - -COMMENT ON FUNCTION pgr_trspVia_withPoints(TEXT, TEXT, TEXT, ANYARRAY, BOOLEAN, BOOLEAN, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION pgr_trspVia_withPoints(TEXT, TEXT, TEXT, ANYARRAY, CHAR, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN) IS 'pgr_trspVia_withPoints - Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] - Restrictions SQL with columns: cost, path - Points SQL with columns: [pid], edge_id, fraction [,side] - ARRAY[via vertices identifiers] + - driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - - directed := true - - strict := false - - U_turn_on_edge := true - - driving_side := ''r'' - - details := ''false'' + - directed => true + - strict => false + - U_turn_on_edge => true + - details => false - Documentation: - ${PROJECT_DOC_LINK}/pgr_trspVia_withPoints.html '; diff --git a/src/trsp/trspVia_withPoints.c b/src/trsp/trspVia_withPoints.c index f73b97a7816..c424fb3a078 100644 --- a/src/trsp/trspVia_withPoints.c +++ b/src/trsp/trspVia_withPoints.c @@ -34,8 +34,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "drivers/withPoints/get_new_queries.h" #include "drivers/trsp/trspVia_withPoints_driver.h" -PGDLLEXPORT Datum _pgr_trspvia_withpoints(PG_FUNCTION_ARGS); -PG_FUNCTION_INFO_V1(_pgr_trspvia_withpoints); +PGDLLEXPORT Datum _pgr_trspvia_withpoints_v4(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_trspvia_withpoints_v4); static void @@ -54,20 +54,23 @@ process( Routes_t **result_tuples, size_t *result_count) { + char d_side = estimate_drivingSide(driving_side[0]); + if (d_side == ' ') { + pgr_throw_error("Invalid value of 'driving side'", "Valid value are 'r', 'l', 'b'"); + return; + } else if (directed && !(d_side == 'r' || d_side == 'l')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for directed graph are: 'r', 'l'"); + return; + } else if (!directed && !(d_side == 'b')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for undirected graph is: 'b'"); + return; + } + pgr_SPI_connect(); char* log_msg = NULL; char* notice_msg = NULL; char* err_msg = NULL; - - /* - * Estimate driving side - */ - driving_side[0] = estimate_drivingSide(driving_side[0]); - if (driving_side[0] != 'r' && driving_side[0] != 'l') { - driving_side[0] = 'r'; - } - char *edges_of_points_query = NULL; char *edges_no_points_query = NULL; get_new_queries(edges_sql, points_sql, &edges_of_points_query, &edges_no_points_query); @@ -82,7 +85,7 @@ process( directed, - driving_side[0], + d_side, details, strict, @@ -90,7 +93,7 @@ process( result_tuples, result_count, &log_msg, ¬ice_msg, &err_msg); - time_msg("processing pgr_trsp_withPointsVia", start_t, clock()); + time_msg("processing pgr_trspVia_withPoints", start_t, clock()); if (err_msg && (*result_tuples)) { pfree(*result_tuples); @@ -110,7 +113,100 @@ process( pgr_SPI_finish(); } +PGDLLEXPORT Datum +_pgr_trspvia_withpoints_v4(PG_FUNCTION_ARGS) { + FuncCallContext *funcctx; + TupleDesc tuple_desc; + Routes_t *result_tuples = 0; + size_t result_count = 0; + + if (SRF_IS_FIRSTCALL()) { + MemoryContext oldcontext; + funcctx = SRF_FIRSTCALL_INIT(); + oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); + + + process( + text_to_cstring(PG_GETARG_TEXT_P(0)), + text_to_cstring(PG_GETARG_TEXT_P(1)), + text_to_cstring(PG_GETARG_TEXT_P(2)), + PG_GETARG_ARRAYTYPE_P(3), + PG_GETARG_BOOL(4), + + PG_GETARG_BOOL(5), + PG_GETARG_BOOL(6), + + text_to_cstring(PG_GETARG_TEXT_P(7)), + PG_GETARG_BOOL(8), + + &result_tuples, &result_count); + + funcctx->max_calls = result_count; + funcctx->user_fctx = result_tuples; + + if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("function returning record called in context " + "that cannot accept type record"))); + } + + funcctx->tuple_desc = tuple_desc; + MemoryContextSwitchTo(oldcontext); + } + + funcctx = SRF_PERCALL_SETUP(); + tuple_desc = funcctx->tuple_desc; + result_tuples = (Routes_t*) funcctx->user_fctx; + + if (funcctx->call_cntr < funcctx->max_calls) { + HeapTuple tuple; + Datum result; + Datum *values; + bool* nulls; + size_t call_cntr = funcctx->call_cntr; + + size_t numb_out = 10; + values = palloc(numb_out * sizeof(Datum)); + nulls = palloc(numb_out * sizeof(bool)); + size_t i; + for (i = 0; i< numb_out; ++i) { + nulls[i] = false; + } + + values[0] = Int32GetDatum((int32_t)call_cntr + 1); + values[1] = Int32GetDatum(result_tuples[call_cntr].path_id); + values[2] = Int32GetDatum(result_tuples[call_cntr].path_seq + 1); + values[3] = Int64GetDatum(result_tuples[call_cntr].start_vid); + values[4] = Int64GetDatum(result_tuples[call_cntr].end_vid); + values[5] = Int64GetDatum(result_tuples[call_cntr].node); + values[6] = Int64GetDatum(result_tuples[call_cntr].edge); + values[7] = Float8GetDatum(result_tuples[call_cntr].cost); + values[8] = Float8GetDatum(result_tuples[call_cntr].agg_cost); + values[9] = Float8GetDatum(result_tuples[call_cntr].route_agg_cost); + + tuple = heap_form_tuple(tuple_desc, values, nulls); + result = HeapTupleGetDatum(tuple); + + pfree(values); + pfree(nulls); + + SRF_RETURN_NEXT(funcctx, result); + } else { + SRF_RETURN_DONE(funcctx); + } +} + +/* Deprecated code starts here + * This code is used on v3.8 and under + * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING + * TODO(v5) Move to legacy + */ +PGDLLEXPORT Datum _pgr_trspvia_withpoints(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_trspvia_withpoints); PGDLLEXPORT Datum _pgr_trspvia_withpoints(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; @@ -124,6 +220,13 @@ _pgr_trspvia_withpoints(PG_FUNCTION_ARGS) { funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), + errhint("Consider upgrade pgRouting"))); +#endif process( text_to_cstring(PG_GETARG_TEXT_P(0)), @@ -145,11 +248,12 @@ _pgr_trspvia_withpoints(PG_FUNCTION_ARGS) { funcctx->user_fctx = result_tuples; if (get_call_result_type(fcinfo, NULL, &tuple_desc) - != TYPEFUNC_COMPOSITE) + != TYPEFUNC_COMPOSITE) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("function returning record called in context " "that cannot accept type record"))); + } funcctx->tuple_desc = tuple_desc; MemoryContextSwitchTo(oldcontext); From 8221479c23123fae1f3bc650c8ccb839efe60eb9 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 02/39] (pgtap) pgr_trspVia_withPoints: test the new signatures with unamed driving side --- pgtap/trsp/trspVia_withPoints/edge_cases.pg | 33 +++++----- .../edge_cases/point_in_vertex.pg | 54 ++++++---------- pgtap/trsp/trspVia_withPoints/inner_query.pg | 13 ++-- .../trsp/trspVia_withPoints/no_crash_test.pg | 62 +++++++++---------- pgtap/trsp/trspVia_withPoints/types_check.pg | 2 +- 5 files changed, 73 insertions(+), 91 deletions(-) diff --git a/pgtap/trsp/trspVia_withPoints/edge_cases.pg b/pgtap/trsp/trspVia_withPoints/edge_cases.pg index a914594d1bd..f01852b26b9 100644 --- a/pgtap/trsp/trspVia_withPoints/edge_cases.pg +++ b/pgtap/trsp/trspVia_withPoints/edge_cases.pg @@ -20,20 +20,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('3.4.0') THEN plan(5) ELSE plan(1) END; -SET client_min_messages TO ERROR; +SELECT CASE WHEN min_version('4.0.0') THEN plan(5) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE restrictions_sql AS +SELECT path, cost FROM restrictions; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + CREATE OR REPLACE FUNCTION edge_cases() RETURNS SETOF TEXT AS $BODY$ -DECLARE - restriction TEXT; - unrelated_restriction TEXT; - empty_restriction TEXT; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'New function on 3.4'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trspVia_withPoints: New signatures on 4.0.0'); RETURN; END IF; @@ -42,35 +47,35 @@ BEGIN $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, ARRAY[]::BIGINT[] AS path$$, $$SELECT * FROM pointsOfInterest$$, - ARRAY[6,10])$q$, $q$empty restriction path lives$q$); + ARRAY[6,10],'r')$q$, $q$empty restriction path lives$q$); RETURN QUERY SELECT isnt_empty($q$ SELECT * FROM pgr_trspVia_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, ARRAY[]::BIGINT[] AS path$$, $$SELECT * FROM pointsOfInterest$$, - ARRAY[6,10])$q$, $q$empty restriction path gives non empty result$q$); + ARRAY[6,10],'r')$q$, $q$empty restriction path gives non empty result$q$); RETURN QUERY SELECT lives_ok($q$ SELECT * FROM pgr_trspVia_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, NULL::BIGINT[] AS path$$, $$SELECT * FROM pointsOfInterest$$, - ARRAY[6,10])$q$, $q$null restriction path lives$q$); + ARRAY[6,10],'r')$q$, $q$null restriction path lives$q$); RETURN QUERY SELECT isnt_empty($q$ SELECT * FROM pgr_trspVia_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, NULL::BIGINT[] AS path$$, $$SELECT * FROM pointsOfInterest$$, - ARRAY[6,10])$q$, $q$null restriction path gives non empty result$q$); + ARRAY[6,10],'r')$q$, $q$null restriction path gives non empty result$q$); RETURN QUERY SELECT throws_ok($q$ SELECT * FROM pgr_trspVia_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, ARRAY[NULL]::BIGINT[] AS path$$, $$SELECT * FROM pointsOfInterest$$, - ARRAY[6,10])$q$, + ARRAY[6,10],'r')$q$, $$XX000$$,$$NULL value found in Array!$$, $q$array containing a null path throws$q$); @@ -79,7 +84,5 @@ $BODY$ LANGUAGE plpgsql; SELECT edge_cases(); - - SELECT finish(); ROLLBACK; diff --git a/pgtap/trsp/trspVia_withPoints/edge_cases/point_in_vertex.pg b/pgtap/trsp/trspVia_withPoints/edge_cases/point_in_vertex.pg index 0a95f2d8822..752b0ff44a6 100644 --- a/pgtap/trsp/trspVia_withPoints/edge_cases/point_in_vertex.pg +++ b/pgtap/trsp/trspVia_withPoints/edge_cases/point_in_vertex.pg @@ -20,7 +20,7 @@ BEGIN; SET extra_float_digits=-3; -SELECT CASE WHEN min_version('3.4.0') THEN plan(38) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(38) ELSE plan(1) END; CREATE VIEW four_edges AS SELECT * FROM edges WHERE id IN (1,4,10,14); @@ -29,8 +29,8 @@ CREATE OR REPLACE FUNCTION test_vertex_points() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'Not testing deprecated signatures on v < 4.0.0'); RETURN; END IF; @@ -53,7 +53,7 @@ SELECT agg_cost::TEXT FROM pgr_trspVia_withPoints( $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, $$ SELECT path, cost FROM restrictions$$, $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, - ARRAY[-1, $1], true) WHERE node = $1 and edge < 0; + ARRAY[-1, $1], 'r', true) WHERE node = $1 and edge < 0; RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); @@ -68,7 +68,7 @@ SELECT agg_cost::TEXT FROM pgr_trspVia_withPoints( $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, $$ SELECT path, cost FROM restrictions$$, $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, - ARRAY[-2, $1], true) WHERE node = $1 and edge < 0; + ARRAY[-2, $1], 'r', true) WHERE node = $1 and edge < 0; RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); @@ -84,22 +84,16 @@ SELECT agg_cost::TEXT FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, $$ SELECT path, cost FROM restrictions$$, $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); -RETURN QUERY SELECT CASE WHEN min_version('3.7.1') -THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) -ELSE skip('Fix implemented on 3.7.1',3) -END; +RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); +RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); +RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); /* UNION data is sorted midpoint of edge 1 (-1 by default) @@ -111,7 +105,7 @@ SELECT agg_cost::TEXT FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, $$ SELECT path, cost FROM restrictions$$, $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); @@ -138,22 +132,16 @@ SELECT agg_cost::TEXT FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, $$ SELECT path, cost FROM restrictions$$, $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); -RETURN QUERY SELECT CASE WHEN min_version('3.7.1') -THEN - collect_tap( - set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) -ELSE skip('Fix implemented on 3.7.1',3) -END; +RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); +RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); +RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); /* Points midpoint of edge 1 (-2 assigned) @@ -165,22 +153,16 @@ SELECT agg_cost::TEXT FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, $$ SELECT path, cost FROM restrictions$$, $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); -RETURN QUERY SELECT CASE WHEN min_version('3.7.1') -THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) -ELSE skip('Fix implemented on 3.7.1',3) -END; +RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); +RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); +RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); END $BODY$ diff --git a/pgtap/trsp/trspVia_withPoints/inner_query.pg b/pgtap/trsp/trspVia_withPoints/inner_query.pg index e44ab454990..53aef404f89 100644 --- a/pgtap/trsp/trspVia_withPoints/inner_query.pg +++ b/pgtap/trsp/trspVia_withPoints/inner_query.pg @@ -20,24 +20,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('3.4.0') THEN plan(96) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(96) ELSE plan(1) END; CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trspVia_withPoints: official signatures on 4.0.0'); RETURN; END IF; - -- ONE VIA RETURN QUERY SELECT style_dijkstra( - 'pgr_trspVia_withPoints(', ', $$SELECT * from restrictions$$, $$SELECT * FROM pointsOfInterest$$, ARRAY[2,9,12])'); + 'pgr_trspVia_withPoints(', ', $$SELECT * from restrictions$$, $$SELECT * FROM pointsOfInterest$$, ARRAY[2,9,12], $$r$$)'); RETURN QUERY SELECT innerquery_restrictions( - 'pgr_trspVia_withPoints($$SELECT * FROM edges$$,', ', $$SELECT * FROM pointsOfInterest$$, ARRAY[2,9,12])'); + 'pgr_trspVia_withPoints($$SELECT * FROM edges$$,', ', $$SELECT * FROM pointsOfInterest$$, ARRAY[2,9,12], $$r$$)'); RETURN QUERY SELECT innerquery_points( - 'pgr_trspVia_withPoints($$SELECT * FROM edges$$, $$SELECT * from restrictions$$,', ', ARRAY[2,9,12])'); + 'pgr_trspVia_withPoints($$SELECT * FROM edges$$, $$SELECT * from restrictions$$,', ', ARRAY[2,9,12], $$r$$)'); END; $BODY$ diff --git a/pgtap/trsp/trspVia_withPoints/no_crash_test.pg b/pgtap/trsp/trspVia_withPoints/no_crash_test.pg index ad3d79dac4c..0e4ae2764ec 100644 --- a/pgtap/trsp/trspVia_withPoints/no_crash_test.pg +++ b/pgtap/trsp/trspVia_withPoints/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('3.4.0') THEN plan(23) ELSE plan(4) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(24) ELSE plan(1) END; PREPARE edges AS SELECT id, source, target, cost, reverse_cost FROM edges; @@ -31,11 +31,6 @@ SELECT 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 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,35 +39,39 @@ params TEXT[]; subs TEXT[]; BEGIN -IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); RETURN; -END IF; - --- ONE VIA -params = ARRAY[ -'$$SELECT id, source, target, cost, reverse_cost FROM edges$$', -'$$SELECT path, cost FROM restrictions$$', -'$$SELECT * FROM pointsofinterest$$', -'ARRAY[5,6]::BIGINT[]' -]::TEXT[]; - -subs = ARRAY[ -'NULL', -'NULL', -'NULL', -'(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' -]::TEXT[]; + END IF; + + -- ONE VIA + params = ARRAY[ + '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', + '$$SELECT path, cost FROM restrictions$$', + '$$SELECT * FROM pointsofinterest$$', + 'ARRAY[5,6]::BIGINT[]', + '$$r$$' + ]::TEXT[]; + + subs = ARRAY[ + 'NULL', + 'NULL', + 'NULL', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + 'NULL' + ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trspvia_withPoints', params, subs); -subs = ARRAY[ -'NULL', -'NULL', -'NULL', -'NULL::BIGINT[]' -]::TEXT[]; -RETURN query SELECT * FROM no_crash_test('pgr_trspvia_withPoints', params, subs); + subs = ARRAY[ + 'NULL', + 'NULL', + 'NULL', + 'NULL::BIGINT[]', + 'NULL' + ]::TEXT[]; + RETURN query SELECT * FROM no_crash_test('pgr_trspvia_withPoints', params, subs); + END $BODY$ @@ -80,6 +79,5 @@ LANGUAGE plpgsql VOLATILE; SELECT * FROM test_function(); - SELECT finish(); ROLLBACK; diff --git a/pgtap/trsp/trspVia_withPoints/types_check.pg b/pgtap/trsp/trspVia_withPoints/types_check.pg index dfe42a43e0c..fe4571f5daf 100644 --- a/pgtap/trsp/trspVia_withPoints/types_check.pg +++ b/pgtap/trsp/trspVia_withPoints/types_check.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(5) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(5) ELSE plan(1) END; SELECT types_check_via('pgr_trspvia_withpoints'); From 794f40063b02140f95c64ec7a44f193a22838932 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:52:16 -0600 Subject: [PATCH 03/39] (docqueries) pgr_trspVia_withPoints: Adjusting documentation examples --- docqueries/trsp/trspVia_withPoints.pg | 43 ++++----- docqueries/trsp/trspVia_withPoints.result | 106 +++++++++++----------- 2 files changed, 72 insertions(+), 77 deletions(-) diff --git a/docqueries/trsp/trspVia_withPoints.pg b/docqueries/trsp/trspVia_withPoints.pg index 1ca7943e3f7..f91371c3c2a 100644 --- a/docqueries/trsp/trspVia_withPoints.pg +++ b/docqueries/trsp/trspVia_withPoints.pg @@ -6,29 +6,26 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]); + ARRAY[-6, 15, -5], 'R'); /* -- q1 */ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -); + ARRAY[-6, 7, -4, 8, -2], 'L', directed => true); /* -- q2 */ SELECT agg_cost FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) -WHERE path_id = 3 AND edge <0; + ARRAY[-6, 7, -4, 8, -2], 'B', false) +WHERE path_id = 3; /* -- q3 */ SELECT route_agg_cost FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE path_id = 3 AND edge < 0; /* -- q4 */ SELECT row_number() over () as node_seq, node @@ -36,19 +33,17 @@ FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge <> -1 ORDER BY seq; /* -- q5 */ SELECT path_id, route_agg_cost FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge < 0; /* -- q6 */ -SELECT seq, route_agg_cost, node, agg_cost , +SELECT seq, node, agg_cost, route_agg_cost, CASE WHEN edge = -1 THEN $$visits$$ ELSE $$passes in front$$ END as status @@ -56,20 +51,20 @@ FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2]) -WHERE agg_cost <> 0 or seq = 1; + ARRAY[-6, 7, -4, 8, -2], 'r', details => true) +WHERE agg_cost <> 0 or seq = 1; /* -- q7 */ SELECT * FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]); + ARRAY[-6, 15, -5], 'r'); /* -- q8 */ SELECT 1 AS path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_trsp_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - -6, 15); + -6, 15, 'r'); /* -- q9 */ WITH solutions AS ( @@ -77,7 +72,7 @@ solutions AS ( FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]) WHERE path_id != 1 + ARRAY[-6, 15, -5], 'r') WHERE path_id != 1 UNION @@ -86,7 +81,7 @@ solutions AS ( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - -6, 15)), + -6, 15, 'r')), with_seq AS ( SELECT row_number() over(ORDER BY path_id, path_seq) AS seq, * FROM solutions), @@ -99,25 +94,25 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]); + ARRAY[-6, 15, -5], 'r'); /* -- q11 */ SELECT * FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[6, 7, 6], U_turn_on_edge => false); + ARRAY[6, 7, 6], 'r', U_turn_on_edge => false); /* -- q12 */ SELECT 5 AS path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_trsp_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - 7, 6); + 7, 6, 'r'); /* -- q13 */ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[6, 7, 6], U_turn_on_edge => false); + ARRAY[6, 7, 6], 'r', U_turn_on_edge => false); /* -- q14 */ SELECT * FROM pgr_trspVia_withPoints( $e$ SELECT * FROM edges $e$, @@ -128,5 +123,5 @@ SELECT * FROM pgr_trspVia_withPoints( (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - ARRAY[1, -1, -2], details => true); + ARRAY[1, -1, -2], 'r', details => true); /* -- q15 */ diff --git a/docqueries/trsp/trspVia_withPoints.result b/docqueries/trsp/trspVia_withPoints.result index f685ce3a9f6..47a9fa8fb35 100644 --- a/docqueries/trsp/trspVia_withPoints.result +++ b/docqueries/trsp/trspVia_withPoints.result @@ -9,7 +9,7 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]); + ARRAY[-6, 15, -5], 'R'); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | -6 | 15 | -6 | 4 | 0.3 | 0 | 0 @@ -29,47 +29,47 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -); + ARRAY[-6, 7, -4, 8, -2], 'L', directed => true); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | -6 | 7 | -6 | 4 | 0.3 | 0 | 0 2 | 1 | 2 | -6 | 7 | 7 | -1 | 0 | 0.3 | 0.3 3 | 2 | 1 | 7 | -4 | 7 | 7 | 1 | 0 | 0.3 - 4 | 2 | 2 | 7 | -4 | 3 | 6 | 1.3 | 1 | 1.3 - 5 | 2 | 3 | 7 | -4 | -4 | -1 | 0 | 2.3 | 2.6 - 6 | 3 | 1 | -4 | 8 | -4 | 6 | 0.7 | 0 | 2.6 - 7 | 3 | 2 | -4 | 8 | 3 | 7 | 1 | 0.7 | 3.3 - 8 | 3 | 3 | -4 | 8 | 7 | 4 | 0.6 | 1.7 | 4.3 - 9 | 3 | 4 | -4 | 8 | 7 | 10 | 1 | 2.3 | 4.9 - 10 | 3 | 5 | -4 | 8 | 8 | -1 | 0 | 3.3 | 5.9 - 11 | 4 | 1 | 8 | -2 | 8 | 10 | 1 | 0 | 5.9 - 12 | 4 | 2 | 8 | -2 | 7 | 8 | 1 | 1 | 6.9 - 13 | 4 | 3 | 8 | -2 | 11 | 9 | 1 | 2 | 7.9 - 14 | 4 | 4 | 8 | -2 | 16 | 15 | 0.4 | 3 | 8.9 - 15 | 4 | 5 | 8 | -2 | -2 | -2 | 0 | 3.4 | 9.3 -(15 rows) + 4 | 2 | 2 | 7 | -4 | 3 | 6 | 0.7 | 1 | 1.3 + 5 | 2 | 3 | 7 | -4 | -4 | -1 | 0 | 1.7 | 2 + 6 | 3 | 1 | -4 | 8 | -4 | 6 | 1.3 | 0 | 2 + 7 | 3 | 2 | -4 | 8 | 3 | 7 | 1 | 1.3 | 3.3 + 8 | 3 | 3 | -4 | 8 | 7 | 4 | 0.6 | 2.3 | 4.3 + 9 | 3 | 4 | -4 | 8 | 7 | 10 | 1 | 2.9 | 4.9 + 10 | 3 | 5 | -4 | 8 | 8 | -1 | 0 | 3.9 | 5.9 + 11 | 4 | 1 | 8 | -2 | 8 | 12 | 1 | 0 | 5.9 + 12 | 4 | 2 | 8 | -2 | 12 | 13 | 1 | 1 | 6.9 + 13 | 4 | 3 | 8 | -2 | 17 | 15 | 0.6 | 2 | 7.9 + 14 | 4 | 4 | 8 | -2 | -2 | -2 | 0 | 2.6 | 8.5 +(14 rows) /* -- q2 */ SELECT agg_cost FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) -WHERE path_id = 3 AND edge <0; + ARRAY[-6, 7, -4, 8, -2], 'B', false) +WHERE path_id = 3; agg_cost ---------- + 0 + 0.7 + 1.7 + 2.3 3.3 -(1 row) +(5 rows) /* -- q3 */ SELECT route_agg_cost FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE path_id = 3 AND edge < 0; route_agg_cost ---------------- @@ -82,8 +82,7 @@ FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge <> -1 ORDER BY seq; node_seq | node ----------+------ @@ -106,8 +105,7 @@ SELECT path_id, route_agg_cost FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2] -) + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge < 0; path_id | route_agg_cost ---------+---------------- @@ -118,7 +116,7 @@ WHERE edge < 0; (4 rows) /* -- q6 */ -SELECT seq, route_agg_cost, node, agg_cost , +SELECT seq, node, agg_cost, route_agg_cost, CASE WHEN edge = -1 THEN $$visits$$ ELSE $$passes in front$$ END as status @@ -126,29 +124,31 @@ FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 7, -4, 8, -2]) -WHERE agg_cost <> 0 or seq = 1; - seq | route_agg_cost | node | agg_cost | status ------+----------------+------+----------+----------------- - 1 | 0 | -6 | 0 | passes in front - 2 | 0.3 | 7 | 0.3 | visits - 4 | 1.3 | 3 | 1 | passes in front - 5 | 2.6 | -4 | 2.3 | visits - 7 | 3.3 | 3 | 0.7 | passes in front - 8 | 4.3 | 7 | 1.7 | passes in front - 9 | 4.9 | 7 | 2.3 | passes in front - 10 | 5.9 | 8 | 3.3 | visits - 12 | 6.9 | 7 | 1 | passes in front - 13 | 7.9 | 11 | 2 | passes in front - 14 | 8.9 | 16 | 3 | passes in front - 15 | 9.3 | -2 | 3.4 | passes in front -(12 rows) + ARRAY[-6, 7, -4, 8, -2], 'r', details => true) +WHERE agg_cost <> 0 or seq = 1; + seq | node | agg_cost | route_agg_cost | status +-----+------+----------+----------------+----------------- + 1 | -6 | 0 | 0 | passes in front + 2 | 7 | 0.3 | 0.3 | visits + 4 | 3 | 1 | 1.3 | passes in front + 5 | 1 | 2 | 2.3 | passes in front + 6 | -4 | 2.3 | 2.6 | visits + 8 | 3 | 0.7 | 3.3 | passes in front + 9 | 7 | 1.7 | 4.3 | passes in front + 10 | -6 | 2 | 4.6 | passes in front + 11 | 7 | 2.3 | 4.9 | passes in front + 12 | 8 | 3.3 | 5.9 | visits + 14 | 7 | 1 | 6.9 | passes in front + 15 | 11 | 2 | 7.9 | passes in front + 16 | 16 | 3 | 8.9 | passes in front + 17 | -2 | 3.4 | 9.3 | passes in front +(14 rows) /* -- q7 */ SELECT * FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]); + ARRAY[-6, 15, -5], 'r'); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | -6 | 15 | -6 | 4 | 0.3 | 0 | 0 @@ -167,7 +167,7 @@ FROM pgr_trsp_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - -6, 15); + -6, 15, 'r'); path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost ---------+----------+-----------+---------+------+------+------+---------- 1 | 1 | -6 | 15 | -6 | 4 | 0.3 | 0 @@ -186,14 +186,14 @@ solutions AS ( FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]) WHERE path_id != 1 + ARRAY[-6, 15, -5], 'r') WHERE path_id != 1 UNION SELECT 1 AS path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_trsp_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - -6, 15)), + -6, 15, 'r')), with_seq AS ( SELECT row_number() over(ORDER BY path_id, path_seq) AS seq, * FROM solutions), @@ -219,7 +219,7 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[-6, 15, -5]); + ARRAY[-6, 15, -5], 'r'); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | -6 | 15 | -6 | 4 | 0.3 | 0 | 0 @@ -238,7 +238,7 @@ SELECT * FROM pgr_trspVia_withPoints( SELECT * FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[6, 7, 6], U_turn_on_edge => false); + ARRAY[6, 7, 6], 'r', U_turn_on_edge => false); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | 6 | 7 | 6 | 4 | 1 | 0 | 0 @@ -257,7 +257,7 @@ FROM pgr_trsp_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - 7, 6); + 7, 6, 'r'); path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost ---------+----------+-----------+---------+------+------+------+---------- 5 | 1 | 7 | 6 | 7 | 4 | 1 | 0 @@ -269,7 +269,7 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, $$SELECT path, cost FROM restrictions$$, $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, - ARRAY[6, 7, 6], U_turn_on_edge => false); + ARRAY[6, 7, 6], 'r', U_turn_on_edge => false); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | 6 | 7 | 6 | 4 | 1 | 0 | 0 @@ -288,7 +288,7 @@ SELECT * FROM pgr_trspVia_withPoints( (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - ARRAY[1, -1, -2], details => true); + ARRAY[1, -1, -2], 'r', details => true); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | 1 | -1 | 1 | 6 | 1 | 0 | 0 From 920139e1e38d00874b436a26e055da9250ff8a77 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:17:43 -0600 Subject: [PATCH 04/39] (doc) pgr_trspVia_withPoints: Adjusting documentation about driving side --- doc/trsp/pgr_trspVia_withPoints.rst | 30 ++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/doc/trsp/pgr_trspVia_withPoints.rst b/doc/trsp/pgr_trspVia_withPoints.rst index b4e310f0fc9..80265b7c9f3 100644 --- a/doc/trsp/pgr_trspVia_withPoints.rst +++ b/doc/trsp/pgr_trspVia_withPoints.rst @@ -24,13 +24,25 @@ points with restrictions. .. rubric:: Availability -* Version 4.0.0 +.. rubric:: Version 4.0.0 - * Function promoted to official. +* Function promoted to official. +* **Driving side** parameter is positional unnamed and compulsory. -* Version 3.4.0 + * Valid values depend on kind of graph - * New proposed function. +* Breaking change, signatures no longer available: + + * pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) + * pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) + + +.. rubric:: Version 3.4.0 + +* New proposed function. +* Deprecated signatures + + * pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) Description ------------------------------------------------------------------------------- @@ -73,8 +85,8 @@ One Via .. admonition:: \ \ :class: signatures - | pgr_trspVia_withPoints(`Edges SQL`_, `Restrictions SQL`_, `Points SQL`_, **via vertices**, [**options**]) - | **options:** ``[directed, strict, U_turn_on_edge]`` + | pgr_trspVia_withPoints(`Edges SQL`_, `Restrictions SQL`_, `Points SQL`_, **via vertices**, **driving side** [**options**]) + | **options:** ``[directed, strict, U_turn_on_edge, details]`` | Returns set of |via-result| | OR EMPTY SET @@ -110,9 +122,9 @@ Via optional parameters With points optional parameters ............................................................................... -.. include:: pgr_trsp_withPoints.rst - :start-after: withPoints_parameters_start - :end-before: withPoints_parameters_end +.. include:: withPoints-category.rst + :start-after: withPoints_optionals_start + :end-before: withPoints_optionals_end Inner Queries ------------------------------------------------------------------------------- From 45c603e64f6bd8b726b3f0fed41894a1e3ee54c8 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 05/39] (sql, src) pgr_trsp_withPoints: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/trsp/_trsp_withPoints.sql | 30 ++++--- sql/trsp/trsp_withPoints.sql | 109 ++++++++++++------------ src/trsp/trsp_withPoints.c | 151 ++++++++++++++++++++++++++++++---- 3 files changed, 202 insertions(+), 88 deletions(-) diff --git a/sql/trsp/_trsp_withPoints.sql b/sql/trsp/_trsp_withPoints.sql index 21c71ad27a3..fdfacba38d4 100644 --- a/sql/trsp/_trsp_withPoints.sql +++ b/sql/trsp/_trsp_withPoints.sql @@ -23,22 +23,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ - ---v3.4 -CREATE FUNCTION _pgr_trsp_withPoints( +--v4.0 +CREATE FUNCTION _pgr_trsp_withPoints_v4( TEXT, -- edges_sql TEXT, -- restrictions_sql TEXT, -- points_sql ANYARRAY, -- start_vid ANYARRAY, -- end_vids - directed BOOLEAN, - driving_side CHAR, - details BOOLEAN, + BOOLEAN, -- directed + CHAR, -- driving side + BOOLEAN, -- details OUT seq INTEGER, OUT path_seq INTEGER, - OUT departure BIGINT, + OUT start_vid BIGINT, OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, @@ -49,20 +48,20 @@ RETURNS SETOF RECORD AS LANGUAGE c VOLATILE; ---v3.4 -CREATE FUNCTION _pgr_trsp_withPoints( +--v4.0 +CREATE FUNCTION _pgr_trsp_withPoints_v4( TEXT, -- edges_sql TEXT, -- restrictions_sql TEXT, -- points_sql TEXT, -- combinations_sql - directed BOOLEAN, - driving_side CHAR, - details BOOLEAN, + BOOLEAN, -- directed + CHAR, -- driving side + BOOLEAN, -- details OUT seq INTEGER, OUT path_seq INTEGER, - OUT departure BIGINT, + OUT start_vid BIGINT, OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, @@ -72,9 +71,8 @@ RETURNS SETOF RECORD AS 'MODULE_PATHNAME' LANGUAGE C VOLATILE STRICT; --- COMMENTS -COMMENT ON FUNCTION _pgr_trsp_withPoints(TEXT, TEXT, TEXT, ANYARRAY, ANYARRAY, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION _pgr_trsp_withPoints_v4(TEXT, TEXT, TEXT, ANYARRAY, ANYARRAY, BOOLEAN, CHAR, BOOLEAN) IS 'pgRouting internal function'; -COMMENT ON FUNCTION _pgr_trsp_withPoints(TEXT, TEXT, TEXT, TEXT, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION _pgr_trsp_withPoints_v4(TEXT, TEXT, TEXT, TEXT, BOOLEAN, CHAR, BOOLEAN) IS 'pgRouting internal function'; diff --git a/sql/trsp/trsp_withPoints.sql b/sql/trsp/trsp_withPoints.sql index ab45ba4bc72..cba8ab6ba8a 100644 --- a/sql/trsp/trsp_withPoints.sql +++ b/sql/trsp/trsp_withPoints.sql @@ -1,9 +1,12 @@ /*PGR-GNU***************************************************************** File: trsp_withPoints.sql +Copyright (c) 2015 pgRouting developers +Mail: project@pgrouting.org + Function's developer: Copyright (c) 2022 Celia Virginia Vergara Castillo -Mail: +Mail: vicky at erosion.dev ------ @@ -24,17 +27,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ --- ONE TO ONE ---v3.4 +--v4.0 CREATE FUNCTION pgr_trsp_withPoints( TEXT, -- Edges SQL TEXT, -- Restrictions SQL TEXT, -- Points SQL BIGINT, -- start_vid BIGINT, -- end_vid + CHAR, -- driving side directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'r', -- 'r'/'l' details BOOLEAN DEFAULT false, OUT seq INTEGER, @@ -47,29 +49,27 @@ CREATE FUNCTION pgr_trsp_withPoints( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ -SELECT seq, path_seq, departure, end_vid, node, edge, cost, agg_cost -FROM _pgr_trsp_withPoints( +SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost +FROM _pgr_trsp_withPoints_v4( _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), - ARRAY[$4]::BIGINT[], ARRAY[$5]::BIGINT[], $6, $7, $8); + ARRAY[$4]::BIGINT[], ARRAY[$5]::BIGINT[], directed, $6, details); $BODY$ LANGUAGE SQL VOLATILE STRICT COST 100 ROWS 1000; - --- ONE TO MANY ---v3.4 +--v4.0 CREATE FUNCTION pgr_trsp_withPoints( TEXT, -- Edges SQL TEXT, -- Restrictions SQL TEXT, -- Points SQL BIGINT, -- start_vid ANYARRAY, -- end_vids + CHAR, -- driving side directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'r', -- 'r'/'l' details BOOLEAN DEFAULT false, OUT seq INTEGER, @@ -82,28 +82,27 @@ CREATE FUNCTION pgr_trsp_withPoints( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ -SELECT seq, path_seq, departure, end_vid, node, edge, cost, agg_cost -FROM _pgr_trsp_withPoints( +SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost +FROM _pgr_trsp_withPoints_v4( _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), - ARRAY[$4]::BIGINT[], $5::BIGINT[], $6, $7, $8); + ARRAY[$4]::BIGINT[], $5::BIGINT[], directed, $6, details); $BODY$ LANGUAGE SQL VOLATILE STRICT COST 100 ROWS 1000; --- MANY TO ONE ---v3.4 +--v4.0 CREATE FUNCTION pgr_trsp_withPoints( TEXT, -- Edges SQL TEXT, -- Restrictions SQL TEXT, -- Points SQL ANYARRAY, -- start_vids BIGINT, -- end_vid + CHAR, -- driving side directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'r', -- 'r'/'l' details BOOLEAN DEFAULT false, OUT seq INTEGER, @@ -116,28 +115,27 @@ CREATE FUNCTION pgr_trsp_withPoints( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ -SELECT seq, path_seq, departure, end_vid, node, edge, cost, agg_cost -FROM _pgr_trsp_withPoints( +SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost +FROM _pgr_trsp_withPoints_v4( _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), - $4::BIGINT[], ARRAY[$5]::BIGINT[], $6, $7, $8); + $4::BIGINT[], ARRAY[$5]::BIGINT[], directed, $6, details); $BODY$ LANGUAGE SQL VOLATILE STRICT COST 100 ROWS 1000; --- MANY TO MANY ---v3.4 +--v4.0 CREATE FUNCTION pgr_trsp_withPoints( TEXT, -- Edges SQL TEXT, -- Restrictions SQL TEXT, -- Points SQL ANYARRAY, -- start_vids ANYARRAY, -- end_vids + CHAR, -- driving side directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'r', -- 'r'/'l' details BOOLEAN DEFAULT false, OUT seq INTEGER, @@ -150,28 +148,26 @@ CREATE FUNCTION pgr_trsp_withPoints( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ -SELECT seq, path_seq, departure, end_vid, node, edge, cost, agg_cost -FROM _pgr_trsp_withPoints( +SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost +FROM _pgr_trsp_withPoints_v4( _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), - $4::BIGINT[], $5::BIGINT[], $6, $7, $8); + $4::BIGINT[], $5::BIGINT[], directed, $6, details); $BODY$ LANGUAGE SQL VOLATILE STRICT COST 100 ROWS 1000; - --- Combinations ---v3.4 +--v4.0 CREATE FUNCTION pgr_trsp_withPoints( TEXT, -- Edges SQL TEXT, -- Restrictions SQL TEXT, -- Points SQL TEXT, -- combinations SQL + CHAR, -- driving side directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'r', -- 'r'/'l' details BOOLEAN DEFAULT false, OUT seq INTEGER, @@ -184,20 +180,19 @@ CREATE FUNCTION pgr_trsp_withPoints( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ -SELECT seq, path_seq, departure, end_vid, node, edge, cost, agg_cost -FROM _pgr_trsp_withPoints( +SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost +FROM _pgr_trsp_withPoints_v4( _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), _pgr_get_statement($4), - $5, $6, $7); + directed, $5, details); $BODY$ LANGUAGE SQL VOLATILE STRICT COST 100 ROWS 1000; --- COMMENTS -COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, BIGINT, BIGINT, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, BIGINT, BIGINT, CHAR, BOOLEAN, BOOLEAN) IS 'pgr_trsp_withPoints (One to One) - Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] @@ -205,16 +200,16 @@ IS 'pgr_trsp_withPoints (One to One) - Points SQL with columns: [pid], edge_id, fraction [,side] - Departure vertex/point identifier - Destination vertex/point identifier + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters: - - directed := ''true'' - - driving_side := ''r'' - - details := ''false'' + - directed => true + - details => false - Documentation: - ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html '; -COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, BIGINT, ANYARRAY, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, BIGINT, ANYARRAY, CHAR, BOOLEAN, BOOLEAN) IS 'pgr_trsp_withPoints(One to Many) - Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] @@ -222,15 +217,15 @@ IS 'pgr_trsp_withPoints(One to Many) - Points SQL with columns: [pid], edge_id, fraction [,side] - Departure vertex/point identifier - Destinations ARRAY[vertices/Points identifier] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters: - - directed := ''true'' - - driving_side := ''r'' - - details := ''false'' + - directed => true + - details => false - Documentation: - ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html '; -COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, ANYARRAY, BIGINT, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, ANYARRAY, BIGINT, CHAR, BOOLEAN, BOOLEAN) IS 'pgr_trsp_withPoints(Many to One) - Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] @@ -238,15 +233,15 @@ IS 'pgr_trsp_withPoints(Many to One) - Points SQL with columns: [pid], edge_id, fraction [,side] - Departures ARRAY[vertices/Points identifier] - Destination vertex/point identifier + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters: - - directed := ''true'' - - driving_side := ''r'' - - details := ''false'' + - directed => true + - details => false - Documentation: -- ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html + - ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html '; -COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, ANYARRAY, ANYARRAY, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, ANYARRAY, ANYARRAY, CHAR, BOOLEAN, BOOLEAN) IS 'pgr_trsp_withPoints(Many to Many) - Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] @@ -254,25 +249,25 @@ IS 'pgr_trsp_withPoints(Many to Many) - Points SQL with columns: [pid], edge_id, fraction [,side] - Departures ARRAY[vertices/Points identifier] - Destinations ARRAY[vertices/Points identifier] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters: - - directed := ''true'' - - driving_side := ''r'' - - details := ''false'' + - directed => true + - details => false - Documentation: -- ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html + - ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html '; -COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, TEXT, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION pgr_trsp_withPoints(TEXT, TEXT, TEXT, TEXT, CHAR, BOOLEAN, BOOLEAN) IS 'pgr_trsp_withPoints(Combinations) - Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] - Restrictions SQL with columns: id, path, cost - Points SQL with columns: [pid], edge_id, fraction [,side] - Combinations SQL with columns: source, target + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters: - - directed := ''true'' - - driving_side := ''r'' - - details := ''false'' + - directed => true + - details => false - Documentation: -- ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html + - ${PROJECT_DOC_LINK}/pgr_trsp_withPoints.html '; diff --git a/src/trsp/trsp_withPoints.c b/src/trsp/trsp_withPoints.c index 87052fd311b..a028b418ee1 100644 --- a/src/trsp/trsp_withPoints.c +++ b/src/trsp/trsp_withPoints.c @@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "drivers/withPoints/get_new_queries.h" #include "drivers/trsp/trsp_withPoints_driver.h" -PGDLLEXPORT Datum _pgr_trsp_withpoints(PG_FUNCTION_ARGS); -PG_FUNCTION_INFO_V1(_pgr_trsp_withpoints); +PGDLLEXPORT Datum _pgr_trsp_withpoints_v4(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_trsp_withpoints_v4); static @@ -55,23 +55,25 @@ process( bool directed, char *driving_side, bool details, - Path_rt **result_tuples, size_t *result_count) { + char d_side = estimate_drivingSide(driving_side[0]); + if (d_side == ' ') { + pgr_throw_error("Invalid value of 'driving side'", "Valid value are 'r', 'l', 'b'"); + return; + } else if (directed && !(d_side == 'r' || d_side == 'l')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for directed graph are: 'r', 'l'"); + return; + } else if (!directed && !(d_side == 'b')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for undirected graph is: 'b'"); + return; + } + pgr_SPI_connect(); char* log_msg = NULL; char* notice_msg = NULL; char* err_msg = NULL; - - /* - * Estimate driving side - */ - driving_side[0] = estimate_drivingSide(driving_side[0]); - if (driving_side[0] != 'r' && driving_side[0] != 'l') { - driving_side[0] = 'l'; - } - char *edges_of_points_query = NULL; char *edges_no_points_query = NULL; get_new_queries( @@ -91,7 +93,7 @@ process( directed, - driving_side[0], + d_side, details, result_tuples, result_count, @@ -99,7 +101,7 @@ process( ¬ice_msg, &err_msg); - time_msg("processing pgr_trps_withPoints", start_t, clock()); + time_msg("processing pgr_trsp_withPoints", start_t, clock()); if (err_msg && (*result_tuples)) { pfree(*result_tuples); @@ -122,6 +124,117 @@ process( +PGDLLEXPORT Datum +_pgr_trsp_withpoints_v4(PG_FUNCTION_ARGS) { + FuncCallContext *funcctx; + TupleDesc tuple_desc; + + Path_rt *result_tuples = 0; + size_t result_count = 0; + + if (SRF_IS_FIRSTCALL()) { + MemoryContext oldcontext; + funcctx = SRF_FIRSTCALL_INIT(); + oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); + + + if (PG_NARGS() == 8) { + /* + * many to many + */ + + process( + text_to_cstring(PG_GETARG_TEXT_P(0)), + text_to_cstring(PG_GETARG_TEXT_P(1)), + text_to_cstring(PG_GETARG_TEXT_P(2)), + NULL, // combinations + PG_GETARG_ARRAYTYPE_P(3), + PG_GETARG_ARRAYTYPE_P(4), + PG_GETARG_BOOL(5), + text_to_cstring(PG_GETARG_TEXT_P(6)), + PG_GETARG_BOOL(7), + &result_tuples, + &result_count); + + } else if (PG_NARGS() == 7) { + /* + * Combinations + */ + + process( + text_to_cstring(PG_GETARG_TEXT_P(0)), + text_to_cstring(PG_GETARG_TEXT_P(1)), + text_to_cstring(PG_GETARG_TEXT_P(2)), + text_to_cstring(PG_GETARG_TEXT_P(3)), + NULL, NULL, // starts & ends + PG_GETARG_BOOL(4), + text_to_cstring(PG_GETARG_TEXT_P(5)), + PG_GETARG_BOOL(6), + &result_tuples, + &result_count); + } + + funcctx->max_calls = result_count; + funcctx->user_fctx = result_tuples; + if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) { + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("function returning record called in context " + "that cannot accept type record"))); + } + + funcctx->tuple_desc = tuple_desc; + MemoryContextSwitchTo(oldcontext); + } + + funcctx = SRF_PERCALL_SETUP(); + tuple_desc = funcctx->tuple_desc; + result_tuples = (Path_rt*) funcctx->user_fctx; + + if (funcctx->call_cntr < funcctx->max_calls) { + HeapTuple tuple; + Datum result; + Datum *values; + bool* nulls; + size_t call_cntr = funcctx->call_cntr; + + size_t numb = 8; + values = palloc(numb * sizeof(Datum)); + nulls = palloc(numb * sizeof(bool)); + + size_t i; + for (i = 0; i < numb; ++i) { + nulls[i] = false; + } + + int64_t seq = call_cntr == 0? 1 : result_tuples[call_cntr - 1].start_id; + values[0] = Int32GetDatum((int32_t)call_cntr + 1); + values[1] = Int32GetDatum((int32_t)seq); + values[2] = Int64GetDatum(result_tuples[call_cntr].start_id); + values[3] = Int64GetDatum(result_tuples[call_cntr].end_id); + values[4] = Int64GetDatum(result_tuples[call_cntr].node); + values[5] = Int64GetDatum(result_tuples[call_cntr].edge); + values[6] = Float8GetDatum(result_tuples[call_cntr].cost); + values[7] = Float8GetDatum(result_tuples[call_cntr].agg_cost); + + result_tuples[call_cntr].start_id = result_tuples[call_cntr].edge < 0? 1 : seq + 1; + + tuple = heap_form_tuple(tuple_desc, values, nulls); + result = HeapTupleGetDatum(tuple); + SRF_RETURN_NEXT(funcctx, result); + } else { + SRF_RETURN_DONE(funcctx); + } +} + +/* Deprecated code starts here + * This code is used on v3.8 and under + * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING + * TODO(v5) Move to legacy + */ +PGDLLEXPORT Datum _pgr_trsp_withpoints(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_trsp_withpoints); PGDLLEXPORT Datum _pgr_trsp_withpoints(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; @@ -135,6 +248,13 @@ _pgr_trsp_withpoints(PG_FUNCTION_ARGS) { funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), + errhint("Consider upgrade pgRouting"))); +#endif if (PG_NARGS() == 8) { /* @@ -175,11 +295,12 @@ _pgr_trsp_withpoints(PG_FUNCTION_ARGS) { funcctx->max_calls = result_count; funcctx->user_fctx = result_tuples; if (get_call_result_type(fcinfo, NULL, &tuple_desc) - != TYPEFUNC_COMPOSITE) + != TYPEFUNC_COMPOSITE) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("function returning record called in context " "that cannot accept type record"))); + } funcctx->tuple_desc = tuple_desc; MemoryContextSwitchTo(oldcontext); From 67efde88445bb8b038a1592d25fa3857b4b9c482 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 06/39] (pgtap) pgr_trsp_withpoints: test the new signatures with unamed driving side --- .../compare/dijkstra/many_to_many.pg | 80 +++++++------- .../compare/dijkstra/many_to_one.pg | 101 +++++++++-------- .../compare/dijkstra/one_to_many.pg | 101 +++++++++-------- .../compare/dijkstra/one_to_one.pg | 102 +++++++++--------- .../compare/withpoints/many_to_many.pg | 86 ++++++--------- .../compare/withpoints/many_to_one.pg | 101 +++++++---------- .../compare/withpoints/one_to_many.pg | 101 ++++++++--------- .../compare/withpoints/one_to_one.pg | 94 ++++++++-------- pgtap/trsp/trsp_withpoints/edge_cases.pg | 24 ++--- pgtap/trsp/trsp_withpoints/inner_query.pg | 38 +++---- pgtap/trsp/trsp_withpoints/no_crash_test.pg | 82 +++++++------- pgtap/trsp/trsp_withpoints/types_check.pg | 6 +- 12 files changed, 413 insertions(+), 503 deletions(-) diff --git a/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_many.pg b/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_many.pg index 2ab9e5245ff..a56ce86b2d2 100644 --- a/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_many.pg +++ b/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_many.pg @@ -19,64 +19,61 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(4) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(4) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; -CREATE or REPLACE FUNCTION compareDijkstra(cant INTEGER default 17) +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + +CREATE or REPLACE FUNCTION compareDijkstra() RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -empty_points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -dijkstra_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; -arr TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; +drv_right TEXT := $$, 'r'$$; +drv_both TEXT := $$, 'b'$$; +arr TEXT := 'ARRAY[1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,16,17,18]'; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, start_vid, end_vid, node, edge, cost'; - empty_points := 'SELECT * FROM pointsofinterest WHERE pid IN (-1)'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - - arr := 'ARRAY[1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,16,17,18]'; - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' - || arr || ', ' || arr || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' || arr || ', ' || arr || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' || arr || ', ' || arr || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || arr || ', ' || arr || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || arr || ', ' || arr || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' || arr || ', ' || arr || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || arr || ', ' || arr || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' || arr || ', ' || arr || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); RETURN; END @@ -84,8 +81,5 @@ $BODY$ language plpgsql; SELECT * from compareDijkstra(); - - SELECT * FROM finish(); ROLLBACK; - diff --git a/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_one.pg b/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_one.pg index 0c4160c569b..e00222fab34 100644 --- a/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_one.pg +++ b/pgtap/trsp/trsp_withpoints/compare/dijkstra/many_to_one.pg @@ -19,67 +19,65 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(68) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(68) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; -CREATE or REPLACE FUNCTION compareDijkstra(cant INTEGER default 17) +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + +CREATE or REPLACE FUNCTION compareDijkstra(INTEGER default 17) RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -empty_points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -dijkstra_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; -arr TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; +drv_right TEXT := $$, 'r'$$; +drv_both TEXT := $$, 'b'$$; +i TEXT := 'ARRAY[1,2,3,4,5,6,7,8]'; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, start_vid, node, edge, cost'; - empty_points := 'SELECT * FROM pointsofinterest WHERE pid IN (-1)'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - - FOR j IN 1.. cant LOOP - arr := 'ARRAY[1,2,3,4,5,6,7,8]'; - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' - || arr || ', ' || j || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || arr || ', ' || j || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' - || arr || ', ' || j || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || arr || ', ' || j || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || arr || ', ' || j || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || arr || ', ' || j || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || arr || ', ' || j || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || arr || ', ' || j || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - -END LOOP; + FOR j IN 1.. $1 LOOP + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' + || i || ', ' || j || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' + || i || ', ' || j || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' + || i || ', ' || j || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' + || i || ', ' || j || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + END LOOP; RETURN; END @@ -87,8 +85,5 @@ $BODY$ language plpgsql; SELECT * from compareDijkstra(); - - SELECT * FROM finish(); ROLLBACK; - diff --git a/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_many.pg b/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_many.pg index 9608fbafdac..76f6ac95445 100644 --- a/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_many.pg +++ b/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_many.pg @@ -19,67 +19,65 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(68) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(68) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; -CREATE or REPLACE FUNCTION compareDijkstra(cant INTEGER default 17) +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + +CREATE or REPLACE FUNCTION compareDijkstra(INTEGER default 17) RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -empty_points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -dijkstra_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; -arr TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; +drv_right TEXT := $$, 'r'$$; +drv_both TEXT := $$, 'b'$$; +j TEXT := 'ARRAY[1,2,3,4,5,6,7,8]'; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, end_vid, node, edge, cost, agg_cost'; - empty_points := 'SELECT * FROM pointsofinterest WHERE pid IN (-1)'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - - FOR i IN 1.. cant LOOP - arr := 'ARRAY[1,2,3,4,5,6,7,8]'; - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' - || i || ', ' || arr || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || arr || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' - || i || ', ' || arr || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || arr || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || i || ', ' || arr || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || arr || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || i || ', ' || arr || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || arr || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - -END LOOP; + FOR i IN 1.. $1 LOOP + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' + || i || ', ' || j || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' + || i || ', ' || j || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' + || i || ', ' || j || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' + || i || ', ' || j || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + END LOOP; RETURN; END @@ -87,8 +85,5 @@ $BODY$ language plpgsql; SELECT * from compareDijkstra(); - - SELECT * FROM finish(); ROLLBACK; - diff --git a/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_one.pg b/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_one.pg index 8ceb1644b71..8d5ba0d8c6e 100644 --- a/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_one.pg +++ b/pgtap/trsp/trsp_withpoints/compare/dijkstra/one_to_one.pg @@ -19,76 +19,72 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(1156) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(1156) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; -CREATE or REPLACE FUNCTION compareDijkstra(cant INTEGER default 17) +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + +CREATE or REPLACE FUNCTION compareDijkstra(INTEGER default 17) RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -empty_points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -dijkstra_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; +drv_right TEXT := $$, 'r'$$; +drv_both TEXT := $$, 'b'$$; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, path_seq, node, edge, cost, agg_cost'; - empty_points := 'SELECT * FROM pointsofinterest WHERE pid IN (-1)'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - - FOR i IN 1.. cant LOOP - FOR j IN 1.. cant LOOP - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' - || i || ', ' || j || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || j || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || with_reverse || '$$, ' - || i || ', ' || j || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || j || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || i || ', ' || j || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || j || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - dijkstra_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$' || no_reverse || '$$, ' - || i || ', ' || j || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || empty_points || '$$, ' - || i || ', ' || j || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, dijkstra_sql, trsp_sql); - - END LOOP; + FOR i IN 1.. $1 LOOP + FOR j IN 1.. $1 LOOP + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' + || i || ', ' || j || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$with_reverse$$, ' + || i || ', ' || j || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' + || i || ', ' || j || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_dijkstra($$no_reverse$$, ' + || i || ', ' || j || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + END LOOP; END LOOP; - RETURN; +RETURN; END $BODY$ language plpgsql; SELECT * from compareDijkstra(); - - SELECT * FROM finish(); ROLLBACK; - diff --git a/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_many.pg b/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_many.pg index 409e8c0c4c0..4a709251982 100644 --- a/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_many.pg +++ b/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_many.pg @@ -18,84 +18,66 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(4) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(4) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; -CREATE or REPLACE FUNCTION compareDijkstra(INTEGER default 17) +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + +CREATE or REPLACE FUNCTION compareDijkstra() RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -points_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; -result_columns_vid TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; drv_right TEXT := $$, 'r'$$; drv_both TEXT := $$, 'b'$$; -tdrv_right TEXT := $$, driving_side => 'r'$$; -tdrv_both TEXT := $$, driving_side => 'b'$$; arr TEXT := 'ARRAY[1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,16,17,18]'; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, start_vid, end_vid, node, edge, cost, agg_cost'; - result_columns_vid := 'seq, start_pid AS start_vid, end_pid AS end_vid, node, edge, cost, agg_cost'; - - IF min_version('4.0.0') THEN - result_columns_vid = replace(result_columns_vid, 'pid', 'vid'); - ELSE - drv_right := $$, driving_side => 'r'$$; - drv_both := $$, driving_side => 'b'$$; - END IF; - points := 'SELECT * FROM pointsofinterest WHERE pid IN (-1)'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' || arr || ', ' || arr || drv_right || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || arr || tdrv_right || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' || arr || ', ' || arr || drv_both || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || arr || tdrv_both || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' || arr || ', ' || arr || drv_right || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || arr || tdrv_right || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' + || arr || ', ' || arr || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' || arr || ', ' || arr || drv_both || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || arr || tdrv_both || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); -RETURN; END $BODY$ language plpgsql; SELECT * from compareDijkstra(); - - SELECT * FROM finish(); ROLLBACK; - diff --git a/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_one.pg b/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_one.pg index d75b35f36a9..8e0d01f982b 100644 --- a/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_one.pg +++ b/pgtap/trsp/trsp_withpoints/compare/withpoints/many_to_one.pg @@ -18,89 +18,70 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(68) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(68) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + CREATE or REPLACE FUNCTION compareDijkstra(INTEGER default 17) RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -points_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; -result_columns_vid TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; drv_right TEXT := $$, 'r'$$; drv_both TEXT := $$, 'b'$$; -tdrv_right TEXT := $$, driving_side => 'r'$$; -tdrv_both TEXT := $$, driving_side => 'b'$$; -arr TEXT := 'ARRAY[1,2,3,4,5,6,7,8]'; +i TEXT := 'ARRAY[1,2,3,4,5,6,7,8]'; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, start_vid, node, edge, cost, agg_cost'; - result_columns_vid := 'seq, start_pid AS start_vid, node, edge, cost, agg_cost'; - - IF min_version('4.0.0') THEN - result_columns_vid = replace(result_columns_vid, 'pid', 'vid'); - ELSE - drv_right := $$, driving_side => 'r'$$; - drv_both := $$, driving_side => 'b'$$; - END IF; - - points := 'SELECT * FROM pointsofinterest WHERE pid IN (-1)'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - FOR j IN 1.. $1 LOOP - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' - || arr || ', ' || j || drv_right || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || j || tdrv_right || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' - || arr || ', ' || j || drv_both || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || j || tdrv_both || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' - || arr || ', ' || j || drv_right || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || j || tdrv_right || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' - || arr || ', ' || j || drv_both || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || arr || ', ' || j || tdrv_both || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); END LOOP; -RETURN; END $BODY$ language plpgsql; SELECT * from compareDijkstra(); - - SELECT * FROM finish(); ROLLBACK; - diff --git a/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_many.pg b/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_many.pg index c1753baf0d8..2cf12b9da6f 100644 --- a/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_many.pg +++ b/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_many.pg @@ -18,77 +18,63 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(68) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(68) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + CREATE or REPLACE FUNCTION compareDijkstra(INTEGER default 17) RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -points_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; -result_columns_vid TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; drv_right TEXT := $$, 'r'$$; drv_both TEXT := $$, 'b'$$; -tdrv_right TEXT := $$, driving_side => 'r'$$; -tdrv_both TEXT := $$, driving_side => 'b'$$; -arr TEXT := 'ARRAY[1,2,3,4,5,6,7,8]'; +j TEXT := 'ARRAY[1,2,3,4,5,6,7,8]'; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, end_vid, node, edge, cost, agg_cost'; - result_columns_vid := 'seq, end_pid AS end_vid, node, edge, cost, agg_cost'; - - IF min_version('4.0.0') THEN - result_columns_vid = replace(result_columns_vid, 'pid', 'vid'); - ELSE - drv_right := $$, driving_side => 'r'$$; - drv_both := $$, driving_side => 'b'$$; - END IF; - - points := 'SELECT * FROM pointsofinterest WHERE pid IN (-1)'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - FOR i IN 1.. $1 LOOP - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || arr || drv_right || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || arr || tdrv_right || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || arr || drv_both || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || arr || tdrv_both || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || arr || drv_right || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || arr || tdrv_right || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns_vid || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || arr || drv_both || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || arr || tdrv_both || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); END LOOP; @@ -98,8 +84,5 @@ $BODY$ language plpgsql; SELECT * from compareDijkstra(); - - SELECT * FROM finish(); ROLLBACK; - diff --git a/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_one.pg b/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_one.pg index bb818fbb351..0a2e1d3c380 100644 --- a/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_one.pg +++ b/pgtap/trsp/trsp_withpoints/compare/withpoints/one_to_one.pg @@ -19,69 +19,67 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(1156) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(1156) ELSE plan(1) END; SET extra_float_digits = -3; UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; +PREPARE empty_points AS +SELECT * FROM pointsofinterest WHERE pid IN (-1); + +PREPARE empty_restrictions AS +SELECT * FROM restrictions WHERE id > 10; + +PREPARE with_reverse AS +SELECT id, source, target, cost, reverse_cost FROM edges; + +PREPARE no_reverse AS +SELECT id, source, target, cost FROM edges; + CREATE or REPLACE FUNCTION compareDijkstra(INTEGER default 17) RETURNS SETOF TEXT AS $BODY$ DECLARE -inner_sql TEXT; -points TEXT; -empty_restrictions TEXT; -with_reverse TEXT; -no_reverse TEXT; -points_sql TEXT; +other_sql TEXT; trsp_sql TEXT; -result_columns TEXT; +result_columns TEXT := 'seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost'; +drv_right TEXT := $$, 'r'$$; +drv_both TEXT := $$, 'b'$$; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; - result_columns := 'seq, path_seq, node, edge, cost, agg_cost'; - points := 'SELECT * FROM pointsofinterest'; - empty_restrictions := 'SELECT * FROM restrictions WHERE id > 10'; - with_reverse := 'SELECT * FROM edges'; - no_reverse := 'SELECT id, source, target, cost FROM edges'; - FOR i IN 1.. $1 LOOP - FOR j IN 1.. $1 LOOP - - points_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$' || with_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || with_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => true)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => true)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - points_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$' || no_reverse || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => false)'; - trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$' || no_reverse || '$$, $$' - || empty_restrictions || '$$, $$' || points || '$$, ' - || i || ', ' || j || ', directed => false)'; - RETURN query SELECT set_eq(trsp_sql, points_sql, trsp_sql); - - END LOOP; + FOR j IN 1.. $1 LOOP + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$with_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$with_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_right || ', directed => true)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + other_sql := 'SELECT ' || result_columns || ' FROM pgr_withpoints($$no_reverse$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + trsp_sql := 'SELECT ' || result_columns || ' FROM pgr_trsp_withPoints($$no_reverse$$, $$empty_restrictions$$, $$empty_points$$, ' + || i || ', ' || j || drv_both || ', directed => false)'; + RETURN query SELECT set_eq(trsp_sql, other_sql, trsp_sql); + + END LOOP; END LOOP; - RETURN; END $BODY$ language plpgsql; diff --git a/pgtap/trsp/trsp_withpoints/edge_cases.pg b/pgtap/trsp/trsp_withpoints/edge_cases.pg index 9870d3d8c03..16574017d1d 100644 --- a/pgtap/trsp/trsp_withpoints/edge_cases.pg +++ b/pgtap/trsp/trsp_withpoints/edge_cases.pg @@ -21,20 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('3.4.0') THEN plan(5) ELSE plan(1) END; -SET client_min_messages TO ERROR; +SELECT CASE WHEN min_version('4.0.0') THEN plan(5) ELSE plan(1) END; CREATE OR REPLACE FUNCTION edge_cases() RETURNS SETOF TEXT AS $BODY$ -DECLARE - restriction TEXT; - unrelated_restriction TEXT; - empty_restriction TEXT; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'New function on 3.4'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; @@ -43,37 +38,37 @@ BEGIN $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, ARRAY[]::BIGINT[] AS path$$, $$SELECT * FROM pointsofinterest$$, - 6,10)$q$, $q$empty restriction path lives$q$); + 6,10,'r')$q$, $q$empty restriction path lives$q$); RETURN QUERY SELECT isnt_empty($q$ SELECT * FROM pgr_trsp_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, ARRAY[]::BIGINT[] AS path$$, $$SELECT * FROM pointsofinterest$$, - 6,10)$q$, $q$empty restriction path gives non empty result$q$); + 6,10,'r')$q$, $q$empty restriction path gives non empty result$q$); RETURN QUERY SELECT lives_ok($q$ SELECT * FROM pgr_trsp_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, NULL::BIGINT[] AS path$$, $$SELECT * FROM pointsofinterest$$, - 6,10)$q$, $q$null restriction path lives$q$); + 6,10,'r')$q$, $q$null restriction path lives$q$); RETURN QUERY SELECT isnt_empty($q$ SELECT * FROM pgr_trsp_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, NULL::BIGINT[] AS path$$, $$SELECT * FROM pointsofinterest$$, - 6,10)$q$, $q$null restriction path gives non empty result$q$); + 6,10,'r')$q$, $q$null restriction path gives non empty result$q$); RETURN QUERY SELECT throws_ok($q$ SELECT * FROM pgr_trsp_withPoints( $$SELECT * FROM edges$$, $$SELECT 100::FLOAT AS cost, ARRAY[NULL]::BIGINT[] AS path$$, $$SELECT * FROM pointsofinterest$$, - 6,10)$q$, + 6,10,'r')$q$, $$XX000$$,$$NULL value found in Array!$$, -$q$array containing a null path throws$q$); + $q$array containing a null path throws$q$); END; $BODY$ @@ -81,6 +76,5 @@ LANGUAGE plpgsql; SELECT edge_cases(); - SELECT finish(); ROLLBACK; diff --git a/pgtap/trsp/trsp_withpoints/inner_query.pg b/pgtap/trsp/trsp_withpoints/inner_query.pg index 528c86aa5ae..d37ef35c4ef 100644 --- a/pgtap/trsp/trsp_withpoints/inner_query.pg +++ b/pgtap/trsp/trsp_withpoints/inner_query.pg @@ -20,38 +20,38 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('3.4.0') THEN plan(492) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(492) ELSE plan(1) END; CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withPoints: official signatures on 4.0.0'); RETURN; END IF; -- ONE TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$, $$SELECT * from pointsOfInterest$$, 2, 3, false)'); - RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, 2, 3, false)'); - RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', 2, 3, false)'); + RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$, $$SELECT * from pointsOfInterest$$, 2, 3, $$b$$, false)'); + RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, 2, 3, $$b$$, false)'); + RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', 2, 3, $$b$$, false)'); -- ONE TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, 2, ARRAY[3], false)'); - RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, 2, ARRAY[3], false)'); - RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', 2, ARRAY[3], false)'); + RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, 2, ARRAY[3], $$b$$, false)'); + RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, 2, ARRAY[3], $$b$$, false)'); + RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', 2, ARRAY[3], $$b$$, false)'); -- MANY TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, ARRAY[2], 3, false)'); - RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, ARRAY[2], 3, false)'); - RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', ARRAY[2], 3, false)'); + RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, ARRAY[2], 3, $$b$$, false)'); + RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, ARRAY[2], 3, $$b$$, false)'); + RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', ARRAY[2], 3, $$b$$, false)'); -- MANY TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], false)'); - RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], false)'); - RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', ARRAY[2], ARRAY[3], false)'); + RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], $$b$$, false)'); + RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], $$b$$, false)'); + RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', ARRAY[2], ARRAY[3], $$b$$, false)'); -- COMBINATIONS - RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, false)'); - RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, false)'); - RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', $$SELECT * FROM combinations$$, false)'); - RETURN QUERY SELECT innerquery_combinations('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$,',', false)'); + RETURN QUERY SELECT style_dijkstra('pgr_trsp_withPoints(', ', $$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, $$b$$, false)'); + RETURN QUERY SELECT innerquery_restrictions('pgr_trsp_withPoints($$SELECT * FROM edges$$,', ',$$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, $$b$$, false)'); + RETURN QUERY SELECT innerquery_points('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,', ', $$SELECT * FROM combinations$$, $$b$$, false)'); + RETURN QUERY SELECT innerquery_combinations('pgr_trsp_withPoints($$SELECT * FROM edges$$,$$SELECT * from restrictions$$,$$SELECT * from pointsOfInterest$$,',', $$b$$, false)'); END $BODY$ diff --git a/pgtap/trsp/trsp_withpoints/no_crash_test.pg b/pgtap/trsp/trsp_withpoints/no_crash_test.pg index ef574d91994..9cb3e5c337a 100644 --- a/pgtap/trsp/trsp_withpoints/no_crash_test.pg +++ b/pgtap/trsp/trsp_withpoints/no_crash_test.pg @@ -20,8 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('3.4.0') THEN plan(479) ELSE plan(1) END; -SET client_min_messages TO ERROR; +SELECT CASE WHEN min_version('4.0.0') THEN plan(549) ELSE plan(1) END; + PREPARE all_edges AS SELECT id, source, target, cost, reverse_cost FROM edges; @@ -100,30 +100,32 @@ params1 TEXT[]; params2 TEXT[]; subs TEXT[]; BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'New signatures on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_trsp_withpoints: official signatures on 4.0.0'); RETURN; END IF; + -- SET client_min_messages TO WARNING; + RETURN QUERY SELECT isnt_empty('all_edges', 'Should not be empty to tests be meaningful'); RETURN QUERY SELECT isnt_empty('all_points', 'Should not be empty to tests be meaningful'); RETURN QUERY SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); -- ONE TO ONE - params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','5', '6', 'false']::TEXT[]; - params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$', '$$all_points$$', '5', '6', 'false']::TEXT[]; - params2 = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$empty_points$$', '5', '6', 'false']::TEXT[]; + params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','5', '6', '$$b$$', 'false']::TEXT[]; + params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$', '$$all_points$$', '5', '6', '$$b$$', 'false']::TEXT[]; + params2 = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$empty_points$$', '5', '6', '$$b$$', 'false']::TEXT[]; subs = ARRAY['$$empty_edges$$', 'NULL', 'NULL', '(SELECT id FROM vertices WHERE id IN (-1))', '(SELECT id FROM vertices WHERE id IN (-1))', - 'NULL' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params2, subs); - subs = ARRAY[ 'NULL', 'NULL', 'NULL', 'NULL::BIGINT', 'NULL::BIGINT', 'NULL' ]::TEXT[]; + subs = ARRAY[ 'NULL', 'NULL', 'NULL', 'NULL::BIGINT', 'NULL::BIGINT', 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params2, subs); @@ -132,21 +134,19 @@ BEGIN '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT * FROM restrictions$$', '$$SELECT * FROM pointsofinterest$$', - '5', - '6', - 'false' + '5', '6', '$$b$$', 'false' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); -- ONE TO MANY - params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','5', 'ARRAY[6,10]', 'false']::TEXT[]; - params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$all_points$$', '5', 'ARRAY[6,10]', 'false']::TEXT[]; - params2 = ARRAY['$$all_edges$$', '$$all_restrictions$$','$$empty_points$$', '5', 'ARRAY[6,10]', 'false']::TEXT[]; + params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','5', 'ARRAY[6,10]', '$$b$$', 'false']::TEXT[]; + params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$all_points$$', '5', 'ARRAY[6,10]', '$$b$$', 'false']::TEXT[]; + params2 = ARRAY['$$all_edges$$', '$$all_restrictions$$','$$empty_points$$', '5', 'ARRAY[6,10]', '$$b$$', 'false']::TEXT[]; subs = ARRAY['$$empty_edges$$', 'NULL','NULL', '(SELECT id FROM vertices WHERE id IN (-1))', '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', - 'NULL' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); @@ -158,7 +158,7 @@ BEGIN 'NULL', 'NULL::BIGINT', 'NULL::BIGINT[]', - 'NULL' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); @@ -168,21 +168,18 @@ BEGIN '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT * FROM restrictions$$', '$$SELECT * FROM pointsofinterest$$', - '1', - 'ARRAY[6,10]', - 'false' - ]::TEXT[]; + '1', 'ARRAY[6,10]', '$$b$$', 'false']::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); -- MANY TO ONE - params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','ARRAY[6,10]', '5', 'false']::TEXT[]; - params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$', '$$all_points$$','ARRAY[6,10]', '5', 'false']::TEXT[]; - params2 = ARRAY['$$all_edges$$', '$$empty_restrictions$$', '$$empty_points$$','ARRAY[6,10]', '5', 'false']::TEXT[]; + params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','ARRAY[6,10]', '5', '$$b$$', 'false']::TEXT[]; + params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$', '$$all_points$$','ARRAY[6,10]', '5', '$$b$$', 'false']::TEXT[]; + params2 = ARRAY['$$all_edges$$', '$$empty_restrictions$$', '$$empty_points$$','ARRAY[6,10]', '5', '$$b$$', 'false']::TEXT[]; subs = ARRAY['$$empty_edges$$', 'NULL','NULL', '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', '(SELECT id FROM vertices WHERE id IN (-1))', - 'NULL' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); @@ -194,7 +191,7 @@ BEGIN 'NULL', 'NULL::BIGINT[]', 'NULL::BIGINT', - 'NULL' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); @@ -204,21 +201,18 @@ BEGIN '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT * FROM restrictions$$', '$$SELECT * FROM pointsofinterest$$', - 'ARRAY[6,10]', - '1', - 'false' - ]::TEXT[]; + 'ARRAY[6,10]', '1', '$$b$$', 'false']::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); -- MANY TO MANY - params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','ARRAY[6,10]::BIGINT[]', 'ARRAY[5,8]::BIGINT[]', 'false']::TEXT[]; - params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$all_points$$', 'ARRAY[6,10]::BIGINT[]', 'ARRAY[5,8]::BIGINT[]', 'false']::TEXT[]; - params2 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$empty_points$$', 'ARRAY[6,10]::BIGINT[]', 'ARRAY[5,8]::BIGINT[]', 'false']::TEXT[]; + params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','ARRAY[6,10]::BIGINT[]', 'ARRAY[5,8]::BIGINT[]', '$$b$$', 'false']::TEXT[]; + params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$all_points$$', 'ARRAY[6,10]::BIGINT[]', 'ARRAY[5,8]::BIGINT[]', '$$b$$', 'false']::TEXT[]; + params2 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$empty_points$$', 'ARRAY[6,10]::BIGINT[]', 'ARRAY[5,8]::BIGINT[]', '$$b$$', 'false']::TEXT[]; subs = ARRAY['$$empty_edges$$', 'NULL','NULL', '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', - 'NULL' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); @@ -230,7 +224,7 @@ BEGIN 'NULL', 'NULL::BIGINT[]', 'NULL::BIGINT[]', - 'NULL' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); @@ -240,18 +234,16 @@ BEGIN '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', '$$SELECT * FROM restrictions$$', '$$SELECT * FROM pointsofinterest$$', - 'ARRAY[6,10]::BIGINT[]', - 'ARRAY[5,8]::BIGINT[]', - 'false' + 'ARRAY[6,10]::BIGINT[]', 'ARRAY[5,8]::BIGINT[]', '$$b$$', 'false' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); -- COMBINATIONS - params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','$$all_combinations$$', 'false']::TEXT[]; - params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$all_points$$', '$$all_combinations$$', 'false']::TEXT[]; - params2 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$empty_points$$', '$$all_combinations$$', 'false']::TEXT[]; + params = ARRAY['$$all_edges$$', '$$all_restrictions$$', '$$all_points$$','$$all_combinations$$', '$$b$$', 'false']::TEXT[]; + params1 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$all_points$$', '$$all_combinations$$', '$$b$$', 'false']::TEXT[]; + params2 = ARRAY['$$all_edges$$', '$$empty_restrictions$$','$$empty_points$$', '$$all_combinations$$', '$$b$$', 'false']::TEXT[]; - subs = ARRAY['$$empty_edges$$', 'NULL', 'NULL::TEXT', 'NULL::TEXT','NULL::BOOLEAN']::TEXT[]; + subs = ARRAY['$$empty_edges$$', 'NULL', 'NULL::TEXT', 'NULL::TEXT', 'NULL::CHAR', 'NULL::BOOLEAN']::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params2, subs); @@ -261,7 +253,7 @@ BEGIN 'NULL', 'NULL', 'NULL::TEXT', - 'NULL::BOOLEAN' + 'NULL::CHAR', 'NULL::BOOLEAN' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params1, subs); @@ -272,7 +264,7 @@ BEGIN '$$SELECT * FROM restrictions$$', '$$SELECT * FROM pointsofinterest$$', '$$SELECT * FROM combinations$$', - 'false' + '$$b$$', 'false' ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_trsp_withpoints', params, subs); @@ -280,8 +272,6 @@ END $BODY$ LANGUAGE plpgsql VOLATILE; - SELECT * FROM test_function(); - SELECT finish(); ROLLBACK; diff --git a/pgtap/trsp/trsp_withpoints/types_check.pg b/pgtap/trsp/trsp_withpoints/types_check.pg index 90f142bad1b..ae35732b66e 100644 --- a/pgtap/trsp/trsp_withpoints/types_check.pg +++ b/pgtap/trsp/trsp_withpoints/types_check.pg @@ -20,9 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(13) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.4.0') THEN plan(2) ELSE plan(1) END; -SELECT types_check_general('pgr_trsp_withpoints'); +SELECT single_path_types_check( + 'pgr_trsp_withpoints', '{"",directed,details}'::TEXT[], '{bpchar,bool,bool}'::TEXT[], + created_v => '3.4.0', standard_v => '4.0.0'); SELECT finish(); ROLLBACK; From 44f9e3d7a8ee6dd6d705b2f413898907d5cc5a49 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:52:16 -0600 Subject: [PATCH 07/39] (docqueries) pgr_trsp_withPoints: Adjusting documentation examples --- docqueries/trsp/trsp_withPoints.pg | 119 +++++---- docqueries/trsp/trsp_withPoints.result | 343 +++++++++++++++---------- 2 files changed, 266 insertions(+), 196 deletions(-) diff --git a/docqueries/trsp/trsp_withPoints.pg b/docqueries/trsp/trsp_withPoints.pg index fbbc170e111..c4905a606ee 100644 --- a/docqueries/trsp/trsp_withPoints.pg +++ b/docqueries/trsp/trsp_withPoints.pg @@ -1,76 +1,83 @@ -- CopyRight(c) pgRouting developers -- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/ SET extra_float_digits=-3; - -/* --e1 */ +/* -- q1 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - -1, 10, - details => true); -/* --e2 */ + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + -1, 10, 'r'); +/* -- q2 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - -1, ARRAY[-3, 7]); -/* --e3 */ + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + -1, ARRAY[-3, 7], 'B', directed => false); +/* -- q3 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[-1, 6], -3); -/* --e4 */ + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[-1, 6], -3, 'R'); +/* -- q4 */ +SELECT * FROM pgr_trsp_withPoints( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[-1, 6], ARRAY[-3, 1], 'L'); +/* -- q5 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[-1, 6], ARRAY[-3, 1]); - -/* --e5 */ + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + 'SELECT * FROM (VALUES (-1, 10), (6, -3)) AS combinations(source, target)', + 'r', details => true); +/* -- q6 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - $$SELECT * FROM (VALUES (-1, 10), (6, -3)) AS t(source, target)$$, - driving_side => 'r', - details => true); -/* --q1 */ -SELECT ('(' || start_vid || ' => ' || end_vid ||') at ' || path_seq || 'th step:')::TEXT AS path_at, -CASE WHEN edge = -1 THEN ' visits' -ELSE ' passes in front of' + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + ARRAY[5, -1], ARRAY[-2, -3, -6, 10, 11], + 'r', details => true); +/* -- q7 */ +SELECT (start_vid || ' -> ' || end_vid ||' at ' || path_seq || 'th step:')::TEXT AS path_at, + CASE WHEN edge = -1 THEN ' visits' + ELSE ' passes in front of' END as status, CASE WHEN node < 0 THEN 'Point' - ELSE 'Vertex' + ELSE 'Vertex' END as is_a, abs(node) as id - FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[5, -1], ARRAY[-6, -3, -6, 10, 11], - driving_side => 'r', - details => true) - WHERE node IN (-6, 11); -/* --q2 */ -SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[-1, 6], ARRAY[-3, 1], - directed => false, - details => true); -/* --q3 */ +FROM pgr_trsp_withPoints( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[5, -1], ARRAY[-6, -3, -6, 10, 11], 'r', details => true) +WHERE node IN (-6, 11); +/* -- q8 */ +SELECT (start_vid || ' => ' || end_vid ||' at ' || path_seq || 'th step')::TEXT AS path_at, + CASE WHEN edge = -1 THEN ' visits' + ELSE ' passes in front of' + END as status, + CASE WHEN node < 0 THEN 'Point' + ELSE 'Vertex' + END as is_a, + abs(node) as id +FROM pgr_trsp_withPoints( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[5, -1], ARRAY[-2, -3, -6, 10, 11], 'l', details => true) +WHERE node IN (-6, 11); +/* -- q9 */ SELECT * FROM pgr_trsp_withPoints( $e$ SELECT * FROM edges $e$, $r$ SELECT id, path, cost FROM restrictions $r$, $p$ SELECT edge_id, round(fraction::numeric, 2) AS fraction, side FROM pgr_findCloseEdges( - $$SELECT id, geom FROM edges$$, + 'SELECT id, geom FROM edges', (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - 1, ARRAY[-1, -2], - driving_side => 'r'); -/* -- q4 */ + 1, ARRAY[-1, -2], 'B', false); +/* -- q10 */ diff --git a/docqueries/trsp/trsp_withPoints.result b/docqueries/trsp/trsp_withPoints.result index 364d45241d0..5133460dc65 100644 --- a/docqueries/trsp/trsp_withPoints.result +++ b/docqueries/trsp/trsp_withPoints.result @@ -4,53 +4,49 @@ SET client_min_messages TO NOTICE; SET SET extra_float_digits=-3; SET -/* --e1 */ +/* -- q1 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - -1, 10, - details => true); + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + -1, 10, 'r'); seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost -----+----------+-----------+---------+------+------+------+---------- - 1 | 1 | -1 | 10 | -1 | 1 | 0.4 | 0 - 2 | 2 | -1 | 10 | 5 | 1 | 1 | 0.4 - 3 | 3 | -1 | 10 | 6 | 4 | 0.7 | 1.4 - 4 | 4 | -1 | 10 | -6 | 4 | 0.3 | 2.1 - 5 | 5 | -1 | 10 | 7 | 10 | 1 | 2.4 - 6 | 6 | -1 | 10 | 8 | 12 | 0.6 | 3.4 - 7 | 7 | -1 | 10 | -3 | 12 | 0.4 | 4 - 8 | 8 | -1 | 10 | 12 | 13 | 1 | 4.4 - 9 | 9 | -1 | 10 | 17 | 15 | 1 | 5.4 - 10 | 10 | -1 | 10 | 16 | 16 | 1 | 6.4 - 11 | 11 | -1 | 10 | 15 | 3 | 1 | 7.4 - 12 | 12 | -1 | 10 | 10 | -1 | 0 | 8.4 -(12 rows) + 1 | 1 | -1 | 10 | -1 | 1 | 1.4 | 0 + 2 | 2 | -1 | 10 | 6 | 4 | 1 | 1.4 + 3 | 3 | -1 | 10 | 7 | 10 | 1 | 2.4 + 4 | 4 | -1 | 10 | 8 | 12 | 1 | 3.4 + 5 | 5 | -1 | 10 | 12 | 13 | 1 | 4.4 + 6 | 6 | -1 | 10 | 17 | 15 | 1 | 5.4 + 7 | 7 | -1 | 10 | 16 | 16 | 1 | 6.4 + 8 | 8 | -1 | 10 | 15 | 3 | 1 | 7.4 + 9 | 9 | -1 | 10 | 10 | -1 | 0 | 8.4 +(9 rows) -/* --e2 */ +/* -- q2 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - -1, ARRAY[-3, 7]); + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + -1, ARRAY[-3, 7], 'B', directed => false); seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost -----+----------+-----------+---------+------+------+------+---------- - 1 | 1 | -1 | -3 | -1 | 1 | 1.4 | 0 - 2 | 2 | -1 | -3 | 6 | 4 | 1 | 1.4 - 3 | 3 | -1 | -3 | 7 | 10 | 1 | 2.4 - 4 | 4 | -1 | -3 | 8 | 12 | 0.6 | 3.4 - 5 | 5 | -1 | -3 | -3 | -1 | 0 | 4 - 6 | 1 | -1 | 7 | -1 | 1 | 1.4 | 0 - 7 | 2 | -1 | 7 | 6 | 4 | 1 | 1.4 - 8 | 3 | -1 | 7 | 7 | -1 | 0 | 2.4 + 1 | 1 | -1 | -3 | -1 | 1 | 0.6 | 0 + 2 | 2 | -1 | -3 | 6 | 4 | 1 | 0.6 + 3 | 3 | -1 | -3 | 7 | 10 | 1 | 1.6 + 4 | 4 | -1 | -3 | 8 | 12 | 0.6 | 2.6 + 5 | 5 | -1 | -3 | -3 | -1 | 0 | 3.2 + 6 | 1 | -1 | 7 | -1 | 1 | 0.6 | 0 + 7 | 2 | -1 | 7 | 6 | 4 | 1 | 0.6 + 8 | 3 | -1 | 7 | 7 | -1 | 0 | 1.6 (8 rows) -/* --e3 */ +/* -- q3 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[-1, 6], -3); + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[-1, 6], -3, 'R'); seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost -----+----------+-----------+---------+------+------+------+---------- 1 | 1 | -1 | -3 | -1 | 1 | 1.4 | 0 @@ -64,30 +60,30 @@ SELECT * FROM pgr_trsp_withPoints( 9 | 4 | 6 | -3 | -3 | -1 | 0 | 2.6 (9 rows) -/* --e4 */ +/* -- q4 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[-1, 6], ARRAY[-3, 1]); + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[-1, 6], ARRAY[-3, 1], 'L'); seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost -----+----------+-----------+---------+------+------+------+---------- - 1 | 1 | -1 | -3 | -1 | 1 | 1.4 | 0 - 2 | 2 | -1 | -3 | 6 | 4 | 1 | 1.4 - 3 | 3 | -1 | -3 | 7 | 10 | 1 | 2.4 - 4 | 4 | -1 | -3 | 8 | 12 | 0.6 | 3.4 - 5 | 5 | -1 | -3 | -3 | -1 | 0 | 4 - 6 | 1 | -1 | 1 | -1 | 1 | 1.4 | 0 - 7 | 2 | -1 | 1 | 6 | 4 | 1 | 1.4 - 8 | 3 | -1 | 1 | 7 | 10 | 1 | 2.4 - 9 | 4 | -1 | 1 | 8 | 12 | 1 | 3.4 - 10 | 5 | -1 | 1 | 12 | 13 | 1 | 4.4 - 11 | 6 | -1 | 1 | 17 | 15 | 1 | 5.4 - 12 | 7 | -1 | 1 | 16 | 9 | 1 | 6.4 - 13 | 8 | -1 | 1 | 11 | 8 | 1 | 7.4 - 14 | 9 | -1 | 1 | 7 | 7 | 1 | 8.4 - 15 | 10 | -1 | 1 | 3 | 6 | 1 | 9.4 - 16 | 11 | -1 | 1 | 1 | -1 | 0 | 10.4 + 1 | 1 | -1 | -3 | -1 | 1 | 0.6 | 0 + 2 | 2 | -1 | -3 | 6 | 4 | 1 | 0.6 + 3 | 3 | -1 | -3 | 7 | 10 | 1 | 1.6 + 4 | 4 | -1 | -3 | 8 | 12 | 0.6 | 2.6 + 5 | 5 | -1 | -3 | -3 | -1 | 0 | 3.2 + 6 | 1 | -1 | 1 | -1 | 1 | 0.6 | 0 + 7 | 2 | -1 | 1 | 6 | 4 | 1 | 0.6 + 8 | 3 | -1 | 1 | 7 | 10 | 1 | 1.6 + 9 | 4 | -1 | 1 | 8 | 12 | 1 | 2.6 + 10 | 5 | -1 | 1 | 12 | 13 | 1 | 3.6 + 11 | 6 | -1 | 1 | 17 | 15 | 1 | 4.6 + 12 | 7 | -1 | 1 | 16 | 9 | 1 | 5.6 + 13 | 8 | -1 | 1 | 11 | 8 | 1 | 6.6 + 14 | 9 | -1 | 1 | 7 | 7 | 1 | 7.6 + 15 | 10 | -1 | 1 | 3 | 6 | 1 | 8.6 + 16 | 11 | -1 | 1 | 1 | -1 | 0 | 9.6 17 | 1 | 6 | -3 | 6 | 4 | 1 | 0 18 | 2 | 6 | -3 | 7 | 10 | 1 | 1 19 | 3 | 6 | -3 | 8 | 12 | 0.6 | 2 @@ -104,14 +100,13 @@ SELECT * FROM pgr_trsp_withPoints( 30 | 10 | 6 | 1 | 1 | -1 | 0 | 9 (30 rows) -/* --e5 */ +/* -- q5 */ SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - $$SELECT * FROM (VALUES (-1, 10), (6, -3)) AS t(source, target)$$, - driving_side => 'r', - details => true); + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + 'SELECT * FROM (VALUES (-1, 10), (6, -3)) AS combinations(source, target)', + 'r', details => true); seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost -----+----------+-----------+---------+------+------+------+---------- 1 | 1 | -1 | 10 | -1 | 1 | 0.4 | 0 @@ -133,85 +128,159 @@ SELECT * FROM pgr_trsp_withPoints( 17 | 5 | 6 | -3 | -3 | -1 | 0 | 2.6 (17 rows) -/* --q1 */ -SELECT ('(' || start_vid || ' => ' || end_vid ||') at ' || path_seq || 'th step:')::TEXT AS path_at, -CASE WHEN edge = -1 THEN ' visits' -ELSE ' passes in front of' +/* -- q6 */ +SELECT * FROM pgr_trsp_withPoints( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side from pointsOfInterest', + ARRAY[5, -1], ARRAY[-2, -3, -6, 10, 11], + 'r', details => true); + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | -1 | -6 | -1 | 1 | 0.4 | 0 + 2 | 2 | -1 | -6 | 5 | 1 | 1 | 0.4 + 3 | 3 | -1 | -6 | 6 | 4 | 0.7 | 1.4 + 4 | 4 | -1 | -6 | -6 | -1 | 0 | 2.1 + 5 | 1 | -1 | -3 | -1 | 1 | 0.4 | 0 + 6 | 2 | -1 | -3 | 5 | 1 | 1 | 0.4 + 7 | 3 | -1 | -3 | 6 | 4 | 0.7 | 1.4 + 8 | 4 | -1 | -3 | -6 | 4 | 0.3 | 2.1 + 9 | 5 | -1 | -3 | 7 | 10 | 1 | 2.4 + 10 | 6 | -1 | -3 | 8 | 12 | 0.6 | 3.4 + 11 | 7 | -1 | -3 | -3 | -1 | 0 | 4 + 12 | 1 | -1 | -2 | -1 | 1 | 0.4 | 0 + 13 | 2 | -1 | -2 | 5 | 1 | 1 | 0.4 + 14 | 3 | -1 | -2 | 6 | 4 | 0.7 | 1.4 + 15 | 4 | -1 | -2 | -6 | 4 | 0.3 | 2.1 + 16 | 5 | -1 | -2 | 7 | 8 | 1 | 2.4 + 17 | 6 | -1 | -2 | 11 | 9 | 1 | 3.4 + 18 | 7 | -1 | -2 | 16 | 15 | 0.4 | 4.4 + 19 | 8 | -1 | -2 | -2 | -1 | 0 | 4.8 + 20 | 1 | -1 | 10 | -1 | 1 | 0.4 | 0 + 21 | 2 | -1 | 10 | 5 | 1 | 1 | 0.4 + 22 | 3 | -1 | 10 | 6 | 4 | 0.7 | 1.4 + 23 | 4 | -1 | 10 | -6 | 4 | 0.3 | 2.1 + 24 | 5 | -1 | 10 | 7 | 10 | 1 | 2.4 + 25 | 6 | -1 | 10 | 8 | 12 | 0.6 | 3.4 + 26 | 7 | -1 | 10 | -3 | 12 | 0.4 | 4 + 27 | 8 | -1 | 10 | 12 | 13 | 1 | 4.4 + 28 | 9 | -1 | 10 | 17 | 15 | 1 | 5.4 + 29 | 10 | -1 | 10 | 16 | 16 | 1 | 6.4 + 30 | 11 | -1 | 10 | 15 | 3 | 1 | 7.4 + 31 | 12 | -1 | 10 | 10 | -1 | 0 | 8.4 + 32 | 1 | -1 | 11 | -1 | 1 | 0.4 | 0 + 33 | 2 | -1 | 11 | 5 | 1 | 1 | 0.4 + 34 | 3 | -1 | 11 | 6 | 4 | 0.7 | 1.4 + 35 | 4 | -1 | 11 | -6 | 4 | 0.3 | 2.1 + 36 | 5 | -1 | 11 | 7 | 8 | 1 | 2.4 + 37 | 6 | -1 | 11 | 11 | -1 | 0 | 3.4 + 38 | 1 | 5 | -6 | 5 | 1 | 1 | 0 + 39 | 2 | 5 | -6 | 6 | 4 | 0.7 | 1 + 40 | 3 | 5 | -6 | -6 | -1 | 0 | 1.7 + 41 | 1 | 5 | -3 | 5 | 1 | 1 | 0 + 42 | 2 | 5 | -3 | 6 | 4 | 0.7 | 1 + 43 | 3 | 5 | -3 | -6 | 4 | 0.3 | 1.7 + 44 | 4 | 5 | -3 | 7 | 10 | 1 | 2 + 45 | 5 | 5 | -3 | 8 | 12 | 0.6 | 3 + 46 | 6 | 5 | -3 | -3 | -1 | 0 | 3.6 + 47 | 1 | 5 | -2 | 5 | 1 | 1 | 0 + 48 | 2 | 5 | -2 | 6 | 4 | 0.7 | 1 + 49 | 3 | 5 | -2 | -6 | 4 | 0.3 | 1.7 + 50 | 4 | 5 | -2 | 7 | 8 | 1 | 2 + 51 | 5 | 5 | -2 | 11 | 9 | 1 | 3 + 52 | 6 | 5 | -2 | 16 | 15 | 0.4 | 4 + 53 | 7 | 5 | -2 | -2 | -1 | 0 | 4.4 + 54 | 1 | 5 | 10 | 5 | 1 | 1 | 0 + 55 | 2 | 5 | 10 | 6 | 4 | 0.7 | 1 + 56 | 3 | 5 | 10 | -6 | 4 | 0.3 | 1.7 + 57 | 4 | 5 | 10 | 7 | 10 | 1 | 2 + 58 | 5 | 5 | 10 | 8 | 12 | 0.6 | 3 + 59 | 6 | 5 | 10 | -3 | 12 | 0.4 | 3.6 + 60 | 7 | 5 | 10 | 12 | 13 | 1 | 4 + 61 | 8 | 5 | 10 | 17 | 15 | 1 | 5 + 62 | 9 | 5 | 10 | 16 | 16 | 1 | 6 + 63 | 10 | 5 | 10 | 15 | 3 | 1 | 7 + 64 | 11 | 5 | 10 | 10 | -1 | 0 | 8 + 65 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 66 | 2 | 5 | 11 | 6 | 4 | 0.7 | 1 + 67 | 3 | 5 | 11 | -6 | 4 | 0.3 | 1.7 + 68 | 4 | 5 | 11 | 7 | 8 | 1 | 2 + 69 | 5 | 5 | 11 | 11 | -1 | 0 | 3 +(69 rows) + +/* -- q7 */ +SELECT (start_vid || ' -> ' || end_vid ||' at ' || path_seq || 'th step:')::TEXT AS path_at, + CASE WHEN edge = -1 THEN ' visits' + ELSE ' passes in front of' END as status, CASE WHEN node < 0 THEN 'Point' - ELSE 'Vertex' + ELSE 'Vertex' END as is_a, abs(node) as id - FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[5, -1], ARRAY[-6, -3, -6, 10, 11], - driving_side => 'r', - details => true) - WHERE node IN (-6, 11); - path_at | status | is_a | id --------------------------+---------------------+--------+---- - (-1 => -6) at 4th step: | visits | Point | 6 - (-1 => -3) at 4th step: | passes in front of | Point | 6 - (-1 => 10) at 4th step: | passes in front of | Point | 6 - (-1 => 11) at 4th step: | passes in front of | Point | 6 - (-1 => 11) at 6th step: | visits | Vertex | 11 - (5 => -6) at 3th step: | visits | Point | 6 - (5 => -3) at 3th step: | passes in front of | Point | 6 - (5 => 10) at 3th step: | passes in front of | Point | 6 - (5 => 11) at 3th step: | passes in front of | Point | 6 - (5 => 11) at 5th step: | visits | Vertex | 11 +FROM pgr_trsp_withPoints( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[5, -1], ARRAY[-6, -3, -6, 10, 11], 'r', details => true) +WHERE node IN (-6, 11); + path_at | status | is_a | id +-----------------------+---------------------+--------+---- + -1 -> -6 at 4th step: | visits | Point | 6 + -1 -> -3 at 4th step: | passes in front of | Point | 6 + -1 -> 10 at 4th step: | passes in front of | Point | 6 + -1 -> 11 at 4th step: | passes in front of | Point | 6 + -1 -> 11 at 6th step: | visits | Vertex | 11 + 5 -> -6 at 3th step: | visits | Point | 6 + 5 -> -3 at 3th step: | passes in front of | Point | 6 + 5 -> 10 at 3th step: | passes in front of | Point | 6 + 5 -> 11 at 3th step: | passes in front of | Point | 6 + 5 -> 11 at 5th step: | visits | Vertex | 11 (10 rows) -/* --q2 */ -SELECT * FROM pgr_trsp_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, - $$SELECT id, path, cost FROM restrictions$$, - $$SELECT pid, edge_id, fraction, side FROM pointsOfInterest$$, - ARRAY[-1, 6], ARRAY[-3, 1], - directed => false, - details => true); - seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost ------+----------+-----------+---------+------+------+------+---------- - 1 | 1 | -1 | -3 | -1 | 1 | 0.6 | 0 - 2 | 2 | -1 | -3 | 6 | 4 | 0.7 | 0.6 - 3 | 3 | -1 | -3 | -6 | 4 | 0.3 | 1.3 - 4 | 4 | -1 | -3 | 7 | 10 | 1 | 1.6 - 5 | 5 | -1 | -3 | 8 | 12 | 0.6 | 2.6 - 6 | 6 | -1 | -3 | -3 | -1 | 0 | 3.2 - 7 | 1 | -1 | 1 | -1 | 1 | 0.6 | 0 - 8 | 2 | -1 | 1 | 6 | 4 | 0.7 | 0.6 - 9 | 3 | -1 | 1 | -6 | 4 | 0.3 | 1.3 - 10 | 4 | -1 | 1 | 7 | 7 | 1 | 1.6 - 11 | 5 | -1 | 1 | 3 | 6 | 0.7 | 2.6 - 12 | 6 | -1 | 1 | -4 | 6 | 0.3 | 3.3 - 13 | 7 | -1 | 1 | 1 | -1 | 0 | 3.6 - 14 | 1 | 6 | -3 | 6 | 4 | 0.7 | 0 - 15 | 2 | 6 | -3 | -6 | 4 | 0.3 | 0.7 - 16 | 3 | 6 | -3 | 7 | 10 | 1 | 1 - 17 | 4 | 6 | -3 | 8 | 12 | 0.6 | 2 - 18 | 5 | 6 | -3 | -3 | -1 | 0 | 2.6 - 19 | 1 | 6 | 1 | 6 | 4 | 0.7 | 0 - 20 | 2 | 6 | 1 | -6 | 4 | 0.3 | 0.7 - 21 | 3 | 6 | 1 | 7 | 7 | 1 | 1 - 22 | 4 | 6 | 1 | 3 | 6 | 0.7 | 2 - 23 | 5 | 6 | 1 | -4 | 6 | 0.3 | 2.7 - 24 | 6 | 6 | 1 | 1 | -1 | 0 | 3 -(24 rows) +/* -- q8 */ +SELECT (start_vid || ' => ' || end_vid ||' at ' || path_seq || 'th step')::TEXT AS path_at, + CASE WHEN edge = -1 THEN ' visits' + ELSE ' passes in front of' + END as status, + CASE WHEN node < 0 THEN 'Point' + ELSE 'Vertex' + END as is_a, + abs(node) as id +FROM pgr_trsp_withPoints( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT id, path, cost FROM restrictions', + 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', + ARRAY[5, -1], ARRAY[-2, -3, -6, 10, 11], 'l', details => true) +WHERE node IN (-6, 11); + path_at | status | is_a | id +----------------------+---------------------+--------+---- + -1 => -6 at 3th step | visits | Point | 6 + -1 => -3 at 3th step | passes in front of | Point | 6 + -1 => -2 at 3th step | passes in front of | Point | 6 + -1 => -2 at 5th step | passes in front of | Vertex | 11 + -1 => 10 at 3th step | passes in front of | Point | 6 + -1 => 11 at 3th step | passes in front of | Point | 6 + -1 => 11 at 5th step | visits | Vertex | 11 + 5 => -6 at 4th step | visits | Point | 6 + 5 => -3 at 4th step | passes in front of | Point | 6 + 5 => -2 at 4th step | passes in front of | Point | 6 + 5 => -2 at 6th step | passes in front of | Vertex | 11 + 5 => 10 at 4th step | passes in front of | Point | 6 + 5 => 11 at 4th step | passes in front of | Point | 6 + 5 => 11 at 6th step | visits | Vertex | 11 +(14 rows) -/* --q3 */ +/* -- q9 */ SELECT * FROM pgr_trsp_withPoints( $e$ SELECT * FROM edges $e$, $r$ SELECT id, path, cost FROM restrictions $r$, $p$ SELECT edge_id, round(fraction::numeric, 2) AS fraction, side FROM pgr_findCloseEdges( - $$SELECT id, geom FROM edges$$, + 'SELECT id, geom FROM edges', (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - 1, ARRAY[-1, -2], - driving_side => 'r'); + 1, ARRAY[-1, -2], 'B', false); seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost -----+----------+-----------+---------+------+------+------+---------- 1 | 1 | 1 | -2 | 1 | 6 | 1 | 0 @@ -220,17 +289,11 @@ SELECT * FROM pgr_trsp_withPoints( 4 | 4 | 1 | -2 | -2 | -1 | 0 | 2.9 5 | 1 | 1 | -1 | 1 | 6 | 1 | 0 6 | 2 | 1 | -1 | 3 | 7 | 1 | 1 - 7 | 3 | 1 | -1 | 7 | 8 | 2 | 2 - 8 | 4 | 1 | -1 | 7 | 10 | 1 | 4 - 9 | 5 | 1 | -1 | 8 | 12 | 1 | 5 - 10 | 6 | 1 | -1 | 12 | 13 | 1 | 6 - 11 | 7 | 1 | -1 | 17 | 15 | 1 | 7 - 12 | 8 | 1 | -1 | 16 | 16 | 1 | 8 - 13 | 9 | 1 | -1 | 15 | 3 | 1 | 9 - 14 | 10 | 1 | -1 | 10 | 5 | 0.8 | 10 - 15 | 11 | 1 | -1 | -1 | -1 | 0 | 10.8 -(15 rows) + 7 | 3 | 1 | -1 | 7 | 8 | 1 | 2 + 8 | 4 | 1 | -1 | 11 | 5 | 0.2 | 3 + 9 | 5 | 1 | -1 | -1 | -1 | 0 | 3.2 +(9 rows) -/* -- q4 */ +/* -- q10 */ ROLLBACK; ROLLBACK From 6d40ba870df8f2174725c06617849d31ec3c2f39 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:17:43 -0600 Subject: [PATCH 08/39] (doc) pgr_trsp_withPoints: Adjusting documentation about driving side --- doc/trsp/pgr_trsp_withPoints.rst | 162 ++++++++++++++++--------------- 1 file changed, 82 insertions(+), 80 deletions(-) diff --git a/doc/trsp/pgr_trsp_withPoints.rst b/doc/trsp/pgr_trsp_withPoints.rst index da09cc80197..4bfd9dc1577 100644 --- a/doc/trsp/pgr_trsp_withPoints.rst +++ b/doc/trsp/pgr_trsp_withPoints.rst @@ -23,46 +23,60 @@ .. rubric:: Availability -* Version 4.0.0 +.. rubric:: Version 4.0.0 - * Function promoted to official. +* Function promoted to official. +* **Driving side** parameter is positional unnamed and compulsory. -* Version 3.4.0 + * Valid values depend on kind of graph - * New proposed function. +* Breaking change, signatures no longer available: + + * pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,anyarray,bigint,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,bigint,anyarray,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,bigint,bigint,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) + +.. rubric:: Version 3.4.0 + +* New proposed function. Description ------------------------------------------------------------------------------- -Modify the graph to include points defined by points_sql. -Using Dijkstra algorithm, find the shortest path +Modify the graph to include points defined by `Points SQL`_. +Consider the invalid paths on `Restrictions SQL`_. +Using Dijkstra algorithm, find the shortest path. -Characteristics: +The main characteristics are: +- Process is done only on edges with positive costs. - Vertices of the graph are: - **positive** when it belongs to the `Edges SQL`_ - **negative** when it belongs to the `Points SQL`_ -- Driving side can not be ``b`` - Values are returned when there is a path. - When the starting vertex and ending vertex are the same, there is no path. - - The agg_cost the non included values (v, v) is 0 + - The `agg_cost` in the non included values `(v, v)` is `0` - When the starting vertex and ending vertex are the different and there is no path: - - The agg_cost the non included values (u, v) is ∞ + - The `agg_cost` in the non included values `(u, v)` is :math:`\infty` + +- For optimization purposes, any duplicated value in the input arrays of **start vids** or + **end vids** or are ignored. -- For optimization purposes, any duplicated value in the start_vids or end_vids - are ignored. - The returned values are ordered: - - start_vid ascending - - end_vid ascending -* Running time: :math:`O(|start\_vids|\times(V \log V + E))` + - `start_vid` ascending + - `end_vid` ascending + +- Running time: :math:`O(|start\_vids|\times(V \log V + E))` |Boost| Boost Graph Inside @@ -99,12 +113,12 @@ One to One | Returns set of |short-generic-result| | OR EMPTY SET -:Example: From point :math:`1` to vertex :math:`10` with details on a left - driving side configuration on a directed graph with details. +:Example: From point :math:`1` to vertex :math:`10` with right driving side in directed graph. + (with details) .. literalinclude:: trsp_withPoints.queries - :start-after: --e1 - :end-before: --e2 + :start-after: -- q1 + :end-before: -- q2 .. index:: single: trsp_withPoints ; One to Many @@ -115,17 +129,18 @@ One to Many .. admonition:: \ \ :class: signatures - | pgr_trsp_withPoints(`Edges SQL`_, `Restrictions SQL`_, `Points SQL`_, **start vid**, **end vids**, [**options**]) - | **options:** ``[directed, driving_side, details]`` + | pgr_trsp_withPoints(`Edges SQL`_, `Restrictions SQL`_, `Points SQL`_, **start vid**, **end vids**, **driving side** [**options**]) + | **options:** ``[directed, details]`` | Returns set of |short-generic-result| | OR EMPTY SET -:Example: From point :math:`1` to point :math:`3` and vertex :math:`7`. +:Example: From point :math:`1` to point :math:`3` and vertex :math:`7` on an + undirected graph .. literalinclude:: trsp_withPoints.queries - :start-after: --e2 - :end-before: --e3 + :start-after: -- q2 + :end-before: -- q3 .. index:: single: trsp_withPoints ; Many to One @@ -142,11 +157,12 @@ Many to One | Returns set of |short-generic-result| | OR EMPTY SET -:Example: From point :math:`1` and vertex :math:`6` to point :math:`3`. +:Example: From point :math:`1` and vertex :math:`6` to point :math:`3` with right driving side in directed graph. + (without details) .. literalinclude:: trsp_withPoints.queries - :start-after: --e3 - :end-before: --e4 + :start-after: -- q3 + :end-before: -- q4 .. index:: single: trsp_withPoints ; Many to Many @@ -164,11 +180,11 @@ Many to Many | OR EMPTY SET :Example: From point :math:`1` and vertex :math:`6` to point :math:`3` and - vertex :math:`1`. + vertex :math:`1` with left side driving. .. literalinclude:: trsp_withPoints.queries - :start-after: --e4 - :end-before: --e5 + :start-after: -- q4 + :end-before: -- q5 .. index:: single: trsp_withPoints ; Combinations @@ -185,12 +201,15 @@ Combinations | Returns set of |short-generic-result| | OR EMPTY SET -:Example: From point :math:`1` to vertex :math:`10` and from vertex :math:`6` to - point :math:`3` with right side driving configuration. +:Example: Two combinations + +From point :math:`1` to vertex :math:`10`, and from vertex :math:`6` to point +:math:`3` with right side driving. +(with details) .. literalinclude:: trsp_withPoints.queries - :start-after: --e5 - :end-before: --q1 + :start-after: -- q5 + :end-before: -- q6 Parameters ------------------------------------------------------------------------------- @@ -199,7 +218,6 @@ Parameters :start-after: restriction_parameters_start :end-before: restriction_parameters_end - Optional parameters ............................................................................... @@ -210,33 +228,9 @@ Optional parameters With points optional parameters ............................................................................... -.. withPoints_parameters_start - -.. list-table:: - :width: 81 - :widths: 14 7 7 60 - :header-rows: 1 - - * - Parameter - - Type - - Default - - Description - * - ``driving_side`` - - ``CHAR`` - - ``r`` - - Value in [``r``, ``l``] indicating if the driving side is: - - - ``r`` for right driving side - - ``l`` for left driving side - - Any other value will be considered as ``r`` - * - ``details`` - - ``BOOLEAN`` - - ``false`` - - - When ``true`` the results will include the points that are in the path. - - When ``false`` the results will not include the points that are in the - path. - -.. withPoints_parameters_end +.. include:: withPoints-category.rst + :start-after: withPoints_optionals_start + :end-before: withPoints_optionals_end Inner Queries ------------------------------------------------------------------------------- @@ -273,8 +267,8 @@ Result columns ------------------------------------------------------------------------------- .. include:: pgRouting-concepts.rst - :start-after: return_path_all_columns_start - :end-before: return_path_all_columns_end + :start-after: return_path_complete_start + :end-before: return_path_complete_end Additional Examples ------------------------------------------------------------------------------- @@ -282,40 +276,48 @@ Additional Examples .. contents:: :local: -Use ``pgr_findCloseEdges`` for points on the fly +Use :doc:`pgr_findCloseEdges` in the `Points SQL`_. ............................................................................... -Using :doc:`pgr_findCloseEdges`: - Find the routes from vertex :math:`1` to the two closest locations on the graph of point `(2.9, 1.8)`. .. literalinclude:: trsp_withPoints.queries - :start-after: --q3 - :end-before: -- q4 + :start-after: -- q9 + :end-before: -- q10 * Point :math:`-1` corresponds to the closest edge from point `(2.9, 1.8)`. * Point :math:`-2` corresponds to the next close edge from point `(2.9, 1.8)`. -Pass in front or visits. +Usage variations ............................................................................... -Which path (if any) passes in front of point :math:`6` or vertex :math:`11` with -right side driving topology. +All the examples are about traveling from point :math:`1` and vertex :math:`5` +to points :math:`\{2, 3, 6\}` and vertices :math:`\{10, 11\}` +with restrictions .. literalinclude:: trsp_withPoints.queries - :start-after: --q1 - :end-before: --q2 + :start-after: -- q6 + :end-before: -- q7 -Show details on undirected graph. -............................................................................... +Passes in front or visits with right side driving. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +For point :math:`6` and vertex :math:`11`. -From point :math:`1` and vertex :math:`6` to point :math:`3` to vertex :math:`1` -on an undirected graph, with details. +.. literalinclude:: trsp_withPoints.queries + :start-after: -- q7 + :end-before: -- q8 + +Passes in front or visits with left side driving. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +For point :math:`6` and vertex :math:`11`. .. literalinclude:: trsp_withPoints.queries - :start-after: --q2 - :end-before: --q3 + :start-after: -- q8 + :end-before: -- q9 + See Also ------------------------------------------------------------------------------- From 785d87bd735f4f0bed2d85a359e19b49a82c9299 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 09/39] (sql, src) pgr_withPointsDD: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/driving_distance/_withPointsDD.sql | 2 - sql/driving_distance/withPointsDD.sql | 2 - .../driving_distance_withPoints.c | 101 ++++++++++++++++++ src/legacy/legacy.c | 1 - 4 files changed, 101 insertions(+), 5 deletions(-) diff --git a/sql/driving_distance/_withPointsDD.sql b/sql/driving_distance/_withPointsDD.sql index 0bf0551f43b..0ef49bf8e7c 100644 --- a/sql/driving_distance/_withPointsDD.sql +++ b/sql/driving_distance/_withPointsDD.sql @@ -58,7 +58,5 @@ RETURNS SETOF RECORD AS 'MODULE_PATHNAME' LANGUAGE C VOLATILE STRICT; --- COMMENTS - COMMENT ON FUNCTION _pgr_withPointsDDv4(TEXT, TEXT, ANYARRAY, FLOAT, CHAR, BOOLEAN, BOOLEAN, BOOLEAN) IS 'pgRouting internal function'; diff --git a/sql/driving_distance/withPointsDD.sql b/sql/driving_distance/withPointsDD.sql index e2dbf621888..a14e032f326 100644 --- a/sql/driving_distance/withPointsDD.sql +++ b/sql/driving_distance/withPointsDD.sql @@ -90,8 +90,6 @@ COST 100 ROWS 1000; --- COMMENTS - COMMENT ON FUNCTION pgr_withPointsDD(TEXT, TEXT, BIGINT, FLOAT, CHAR, BOOLEAN, BOOLEAN) IS 'pgr_withPointsDD(Single Vertex) - Parameters: diff --git a/src/driving_distance/driving_distance_withPoints.c b/src/driving_distance/driving_distance_withPoints.c index 9114db1a6ae..00af6016ab0 100644 --- a/src/driving_distance/driving_distance_withPoints.c +++ b/src/driving_distance/driving_distance_withPoints.c @@ -67,6 +67,10 @@ process( return; } + if (distance <= 0) { + pgr_throw_error("Invalid value of 'distance'", "Valid values are greater than 0"); + } + pgr_SPI_connect(); char* log_msg = NULL; char* notice_msg = NULL; @@ -187,3 +191,100 @@ _pgr_withpointsddv4(PG_FUNCTION_ARGS) { SRF_RETURN_DONE(funcctx); } } + + +/* Deprecated code starts here + * This code is used on v3.5 and under + * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING + * TODO(v5) Move to legacy + */ +PGDLLEXPORT Datum _pgr_withpointsdd(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_withpointsdd); + +PGDLLEXPORT Datum +_pgr_withpointsdd(PG_FUNCTION_ARGS) { + FuncCallContext *funcctx; + TupleDesc tuple_desc; + + MST_rt *result_tuples = 0; + size_t result_count = 0; + + if (SRF_IS_FIRSTCALL()) { + MemoryContext oldcontext; + funcctx = SRF_FIRSTCALL_INIT(); + oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); + +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.6.0"), + errhint("Consider upgrade pgRouting"))); +#endif + + process( + text_to_cstring(PG_GETARG_TEXT_P(0)), + text_to_cstring(PG_GETARG_TEXT_P(1)), + PG_GETARG_ARRAYTYPE_P(2), + PG_GETARG_FLOAT8(3), + + PG_GETARG_BOOL(4), + text_to_cstring(PG_GETARG_TEXT_P(5)), + PG_GETARG_BOOL(6), + PG_GETARG_BOOL(7), + + &result_tuples, &result_count); + + funcctx->max_calls = result_count; + + funcctx->user_fctx = result_tuples; + if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("function returning record called in context " + "that cannot accept type record"))); + } + + funcctx->tuple_desc = tuple_desc; + MemoryContextSwitchTo(oldcontext); + } + funcctx = SRF_PERCALL_SETUP(); + + tuple_desc = funcctx->tuple_desc; + result_tuples = (MST_rt*) funcctx->user_fctx; + + if (funcctx->call_cntr < funcctx->max_calls) { + HeapTuple tuple; + Datum result; + Datum *values; + bool* nulls; + + size_t numb = 6; + values = palloc(numb * sizeof(Datum)); + nulls = palloc(numb * sizeof(bool)); + + size_t i; + for (i = 0; i < numb; ++i) { + nulls[i] = false; + } + + values[0] = Int32GetDatum((int32_t)funcctx->call_cntr + 1); + values[1] = Int64GetDatum(result_tuples[funcctx->call_cntr].from_v); + values[2] = Int64GetDatum(result_tuples[funcctx->call_cntr].node); + values[3] = Int64GetDatum(result_tuples[funcctx->call_cntr].edge); + values[4] = Float8GetDatum(result_tuples[funcctx->call_cntr].cost); + values[5] = Float8GetDatum(result_tuples[funcctx->call_cntr].agg_cost); + + tuple = heap_form_tuple(tuple_desc, values, nulls); + result = HeapTupleGetDatum(tuple); + + pfree(values); + pfree(nulls); + + SRF_RETURN_NEXT(funcctx, result); + } else { + SRF_RETURN_DONE(funcctx); + } +} diff --git a/src/legacy/legacy.c b/src/legacy/legacy.c index 6fb6f76894d..50308791aad 100644 --- a/src/legacy/legacy.c +++ b/src/legacy/legacy.c @@ -55,5 +55,4 @@ PGROUTING_DEPRECATE("4.0.0", _pgr_trsp) PGROUTING_DEPRECATE("4.0.0", _v4trsp) PGROUTING_DEPRECATE("4.0.0", _trsp) PGROUTING_DEPRECATE("4.0.0", _pgr_alphashape) -PGROUTING_DEPRECATE("4.0.0", _pgr_withpointsdd) PGROUTING_DEPRECATE("4.0.0", _pgr_dagshortestpath) From b3720af7451e4f7e03ca3efa2c894e0e390a8014 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 10/39] (pgtap) pgr_withPointsDD: test the new signatures with unamed driving side --- pgtap/withPoints/withPointsDD/types_check.pg | 75 ++++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/pgtap/withPoints/withPointsDD/types_check.pg b/pgtap/withPoints/withPointsDD/types_check.pg index a539bb521db..28a0a5d44ac 100644 --- a/pgtap/withPoints/withPointsDD/types_check.pg +++ b/pgtap/withPoints/withPointsDD/types_check.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.6.0') THEN plan(7) ELSE plan(2) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(9) WHEN min_version('3.6.0') THEN plan(7) ELSE plan(2) END; SELECT has_function('pgr_withpointsdd'); @@ -28,52 +28,51 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.6.0') THEN - RETURN QUERY SELECT skip(1, 'pgr_withPointsDD testing only valid signatures on 4.0.0'); - RETURN; - END IF; - -RETURN QUERY -SELECT has_function('pgr_withpointsdd', ARRAY['text','text','bigint','double precision','character','boolean','boolean']); -RETURN QUERY -SELECT has_function('pgr_withpointsdd', ARRAY['text','text','anyarray','double precision','character','boolean','boolean','boolean']); - -RETURN QUERY -SELECT function_returns('pgr_withpointsdd', ARRAY['text','text','bigint','double precision','character','boolean','boolean'],'setof record'); -RETURN QUERY -SELECT function_returns('pgr_withpointsdd', ARRAY['text','text','anyarray','double precision','character','boolean','boolean','boolean'],'setof record'); - -IF min_version('4.0.0') THEN -RETURN QUERY -SELECT function_args_eq('pgr_withpointsdd', - $$VALUES - ('{"","","","","","directed","details","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","","","directed","details","equicost","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}') - $$); - -RETURN QUERY -SELECT function_types_eq('pgr_withpointsdd', - $$VALUES - ('{text,text,anyarray,float8,bpchar,bool,bool,bool,int8,int8,int8,int8,int8,int8,float8,float8}'::TEXT[]), - ('{text,text,int8,float8,bpchar,bool,bool,int8,int8,int8,int8,int8,int8,float8,float8}') - $$); - -ELSE - -RETURN QUERY -SELECT function_args_has('pgr_withpointsdd', + IF NOT min_version('3.6.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPointsDD testing only valid signatures on 4.0.0'); + RETURN; + END IF; + + RETURN QUERY + SELECT has_function('pgr_withpointsdd', ARRAY['text','text','bigint','double precision','character','boolean','boolean']); + RETURN QUERY + SELECT has_function('pgr_withpointsdd', ARRAY['text','text','anyarray','double precision','character','boolean','boolean','boolean']); + + RETURN QUERY + SELECT function_returns('pgr_withpointsdd', ARRAY['text','text','bigint','double precision','character','boolean','boolean'],'setof record'); + RETURN QUERY + SELECT function_returns('pgr_withpointsdd', ARRAY['text','text','anyarray','double precision','character','boolean','boolean','boolean'],'setof record'); + + IF min_version('4.0.0') THEN + RETURN QUERY + SELECT function_args_has('pgr_withpointsdd', + $$VALUES + ('{"","","","","","directed","details","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]), + ('{"","","","","","directed","details","equicost","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}') + $$); + + RETURN QUERY + SELECT function_types_has('pgr_withpointsdd', + $$VALUES + ('{text,text,anyarray,float8,bpchar,bool,bool,bool,int8,int8,int8,int8,int8,int8,float8,float8}'::TEXT[]), + ('{text,text,int8,float8,bpchar,bool,bool,int8,int8,int8,int8,int8,int8,float8,float8}') + $$); + + END IF; + + RETURN QUERY + SELECT function_args_has('pgr_withpointsdd', $$VALUES ('{"","","","","","directed","details","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]), ('{"","","","","","directed","details","equicost","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}') $$); -RETURN QUERY -SELECT function_types_has('pgr_withpointsdd', + RETURN QUERY + SELECT function_types_has('pgr_withpointsdd', $$VALUES ('{text,text,anyarray,float8,bpchar,bool,bool,bool,int8,int8,int8,int8,int8,int8,float8,float8}'::TEXT[]), ('{text,text,int8,float8,bpchar,bool,bool,int8,int8,int8,int8,int8,int8,float8,float8}') $$); -END IF; END; $BODY$ From c6f8f794dd4d5ec627950edd2a6dd4b9f2b4f392 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:04:00 -0600 Subject: [PATCH 11/39] (doc) pgr_withPointsDD: Adjusting documentation about driving side --- doc/withPoints/pgr_withPointsDD.rst | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/doc/withPoints/pgr_withPointsDD.rst b/doc/withPoints/pgr_withPointsDD.rst index abec7848f5e..5816682c2ca 100644 --- a/doc/withPoints/pgr_withPointsDD.rst +++ b/doc/withPoints/pgr_withPointsDD.rst @@ -26,30 +26,25 @@ * Function promoted to official. -.. rubric:: Version 3.6.0 - -* Signature change: ``driving_side`` parameter changed from named optional to - unnamed compulsory **driving side**. +.. Breaking change - * pgr_withPointsDD(Single vertex) - * pgr_withPointsDD(Multiple vertices) +* Breaking change, signatures no longer available: -* Standardizing output columns to |result-spantree| - - * pgr_withPointsDD(Single vertex) + * pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) + * pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) - * Added ``depth``, ``pred`` and ``start_vid`` column. +.. rubric:: Version 3.6.0 - * pgr_withPointsDD(Multiple vertices) +* Output columns standardized to |result-spantree| +* **Driving side** parameter is positional unnamed and compulsory. - * Added ``depth``, ``pred`` columns. + * Valid values depend on kind of graph * When ``details`` is ``false``: - * Only points that are visited are removed, that is, points reached within the - distance are included + * Points reached within the distance are not included. -* Deprecated signatures +* Deprecated signatures: * pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) * pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) @@ -229,7 +224,7 @@ Points SQL Result columns ------------------------------------------------------------------------------- -.. include:: drivingDistance-category.rst +.. include:: pgRouting-concepts.rst :start-after: spantree-result-columns-start :end-before: spantree-result-columns-end From 27fa9d3629b1489c462ad44104d1ba50d7fc6f84 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 12/39] (sql, src) pgr_withPointsVia: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/withPoints/_withPointsVia.sql | 12 ++- sql/withPoints/withPointsVia.sql | 24 +++--- src/withPoints/withPointsVia.c | 127 ++++++++++++++++++++++++++++-- 3 files changed, 142 insertions(+), 21 deletions(-) diff --git a/sql/withPoints/_withPointsVia.sql b/sql/withPoints/_withPointsVia.sql index fa60bba35fb..f049c3ca334 100644 --- a/sql/withPoints/_withPointsVia.sql +++ b/sql/withPoints/_withPointsVia.sql @@ -1,8 +1,12 @@ /*PGR-GNU***************************************************************** File: _withPointsVia.sql +Copyright (c) 2015 pgRouting developers +Mail: project@pgrouting.org + Function's developer: Copyright (c) 2022 Celia Virginia Vergara Castillo +Mail: vicky at erosion.dev ------ @@ -22,8 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ---v3.4 -CREATE FUNCTION _pgr_withPointsVia( +--v4.0 +CREATE FUNCTION _pgr_withPointsVia_v4( TEXT, -- edges_sql TEXT, -- points_sql ANYARRAY, -- via vids @@ -45,7 +49,7 @@ CREATE FUNCTION _pgr_withPointsVia( OUT route_agg_cost FLOAT) RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE c VOLATILE STRICT; +LANGUAGE C VOLATILE STRICT; -COMMENT ON FUNCTION _pgr_withPointsVia(TEXT, TEXT, ANYARRAY, BOOLEAN, BOOLEAN, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION _pgr_withPointsVia_v4(TEXT, TEXT, ANYARRAY, BOOLEAN, BOOLEAN, BOOLEAN, CHAR, BOOLEAN) IS 'pgRouting internal function'; diff --git a/sql/withPoints/withPointsVia.sql b/sql/withPoints/withPointsVia.sql index 4ecd73f1819..5a91d1e208f 100644 --- a/sql/withPoints/withPointsVia.sql +++ b/sql/withPoints/withPointsVia.sql @@ -7,7 +7,7 @@ Mail: project@pgrouting.org Function's developer: Copyright (c) 2022 Celia Virginia Vergara Castillo -Copyright (c) 2015 Celia Virginia Vergara Castillo +Mail: vicky at erosion.dev ------ @@ -27,11 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ---v3.4 +--v4.0 CREATE FUNCTION pgr_withPointsVia( TEXT, -- edges SQL TEXT, -- points SQL ANYARRAY, -- via vids + CHAR, -- driving side directed BOOLEAN DEFAULT true, @@ -40,7 +41,6 @@ CREATE FUNCTION pgr_withPointsVia( U_turn_on_edge BOOLEAN DEFAULT true, -- withPoints parameters - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL details BOOLEAN DEFAULT false, OUT seq INTEGER, @@ -56,24 +56,26 @@ CREATE FUNCTION pgr_withPointsVia( RETURNS SETOF RECORD AS $BODY$ SELECT seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost, route_agg_cost - FROM _pgr_withPointsVia( _pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5, $6, $7, $8); + FROM _pgr_withPointsVia_v4( + _pgr_get_statement($1), _pgr_get_statement($2), $3, + directed, strict, u_turn_on_edge, $4, details); $BODY$ LANGUAGE SQL VOLATILE STRICT COST 100 ROWS 1000; -COMMENT ON FUNCTION pgr_withPointsVia(TEXT, TEXT, ANYARRAY, BOOLEAN, BOOLEAN, BOOLEAN, CHAR, BOOLEAN) +COMMENT ON FUNCTION pgr_withPointsVia(TEXT, TEXT, ANYARRAY, CHAR, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN) IS 'pgr_withPointsVia - Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] - Points SQL with columns: [pid], edge_id, fraction [,side] - ARRAY[via vertices identifiers] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - - directed := true - - strict := false - - U_turn_on_edge := true - - driving_side := ''b'' - - details := ''false'' + - directed => true + - strict => false + - U_turn_on_edge => true + - details => false - Documentation: - - ${PROJECT_DOC_LINK}/pgr_withPointsVia.html + -{PROJECT_DOC_LINK}/pgr_withPointsVia.html '; diff --git a/src/withPoints/withPointsVia.c b/src/withPoints/withPointsVia.c index fa4cdef2075..a7bfd2e1a87 100644 --- a/src/withPoints/withPointsVia.c +++ b/src/withPoints/withPointsVia.c @@ -35,8 +35,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "drivers/withPoints/get_new_queries.h" #include "drivers/withPoints/withPointsVia_driver.h" -PGDLLEXPORT Datum _pgr_withpointsvia(PG_FUNCTION_ARGS); -PG_FUNCTION_INFO_V1(_pgr_withpointsvia); +PGDLLEXPORT Datum _pgr_withpointsvia_v4(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_withpointsvia_v4); static void @@ -51,13 +51,23 @@ process( bool details, Routes_t **result_tuples, size_t *result_count) { + char d_side = estimate_drivingSide(driving_side[0]); + if (d_side == ' ') { + pgr_throw_error("Invalid value of 'driving side'", "Valid value are 'r', 'l', 'b'"); + return; + } else if (directed && !(d_side == 'r' || d_side == 'l')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for directed graph are: 'r', 'l'"); + return; + } else if (!directed && !(d_side == 'b')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for undirected graph is: 'b'"); + return; + } + pgr_SPI_connect(); char* log_msg = NULL; char* notice_msg = NULL; char* err_msg = NULL; - driving_side[0] = estimate_drivingSide(driving_side[0]); - char *edges_of_points_query = NULL; char *edges_no_points_query = NULL; get_new_queries(edges_sql, points_sql, &edges_of_points_query, &edges_no_points_query); @@ -71,7 +81,7 @@ process( directed, - driving_side[0], + d_side, details, strict, @@ -89,10 +99,107 @@ process( pgr_global_report(&log_msg, ¬ice_msg, &err_msg); + if (edges_of_points_query) { + pfree(edges_of_points_query); edges_of_points_query = NULL; + } + if (edges_no_points_query) { + pfree(edges_no_points_query); edges_no_points_query = NULL; + } + pgr_SPI_finish(); } +PGDLLEXPORT Datum +_pgr_withpointsvia_v4(PG_FUNCTION_ARGS) { + FuncCallContext *funcctx; + TupleDesc tuple_desc; + + Routes_t *result_tuples = 0; + size_t result_count = 0; + + if (SRF_IS_FIRSTCALL()) { + MemoryContext oldcontext; + funcctx = SRF_FIRSTCALL_INIT(); + oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); + + + process( + text_to_cstring(PG_GETARG_TEXT_P(0)), + text_to_cstring(PG_GETARG_TEXT_P(1)), + PG_GETARG_ARRAYTYPE_P(2), + PG_GETARG_BOOL(3), + + PG_GETARG_BOOL(4), + PG_GETARG_BOOL(5), + + text_to_cstring(PG_GETARG_TEXT_P(6)), + PG_GETARG_BOOL(7), + + &result_tuples, &result_count); + + funcctx->max_calls = result_count; + funcctx->user_fctx = result_tuples; + if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("function returning record called in context that cannot accept type record"))); + } + + funcctx->tuple_desc = tuple_desc; + MemoryContextSwitchTo(oldcontext); + } + + funcctx = SRF_PERCALL_SETUP(); + tuple_desc = funcctx->tuple_desc; + result_tuples = (Routes_t*) funcctx->user_fctx; + + if (funcctx->call_cntr < funcctx->max_calls) { + HeapTuple tuple; + Datum result; + Datum *values; + bool* nulls; + size_t call_cntr = funcctx->call_cntr; + + size_t numb_out = 10; + values = palloc(numb_out * sizeof(Datum)); + nulls = palloc(numb_out * sizeof(bool)); + size_t i; + for (i = 0; i< numb_out; ++i) { + nulls[i] = false; + } + values[0] = Int32GetDatum((int32_t)call_cntr + 1); + values[1] = Int32GetDatum(result_tuples[call_cntr].path_id); + values[2] = Int32GetDatum(result_tuples[call_cntr].path_seq + 1); + values[3] = Int64GetDatum(result_tuples[call_cntr].start_vid); + values[4] = Int64GetDatum(result_tuples[call_cntr].end_vid); + values[5] = Int64GetDatum(result_tuples[call_cntr].node); + values[6] = Int64GetDatum(result_tuples[call_cntr].edge); + values[7] = Float8GetDatum(result_tuples[call_cntr].cost); + values[8] = Float8GetDatum(result_tuples[call_cntr].agg_cost); + values[9] = Float8GetDatum(result_tuples[call_cntr].route_agg_cost); + + tuple = heap_form_tuple(tuple_desc, values, nulls); + result = HeapTupleGetDatum(tuple); + + pfree(values); + pfree(nulls); + + SRF_RETURN_NEXT(funcctx, result); + } else { + SRF_RETURN_DONE(funcctx); + } +} + +/* Deprecated code starts here + * This code is used on v3.8 and under + * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING + * TODO(v5) Move to legacy + */ +PGDLLEXPORT Datum _pgr_withpointsvia(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_withpointsvia); PGDLLEXPORT Datum _pgr_withpointsvia(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; @@ -106,6 +213,13 @@ _pgr_withpointsvia(PG_FUNCTION_ARGS) { funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), + errhint("Consider upgrade pgRouting"))); +#endif process( text_to_cstring(PG_GETARG_TEXT_P(0)), @@ -126,11 +240,12 @@ _pgr_withpointsvia(PG_FUNCTION_ARGS) { funcctx->user_fctx = result_tuples; if (get_call_result_type(fcinfo, NULL, &tuple_desc) - != TYPEFUNC_COMPOSITE) + != TYPEFUNC_COMPOSITE) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("function returning record called in context " "that cannot accept type record"))); + } funcctx->tuple_desc = tuple_desc; MemoryContextSwitchTo(oldcontext); From 0904d3ae43a592b13cb1a4775d2d878e02599b22 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 13/39] (pgtap) pgr_withPointsVia: test the new signatures with unamed driving side --- .../edge_cases/point_in_vertex.pg | 103 +++++++++++++----- pgtap/withPoints/withPointsVia/inner_query.pg | 11 +- .../withPoints/withPointsVia/no_crash_test.pg | 59 +++++----- pgtap/withPoints/withPointsVia/types_check.pg | 2 +- 4 files changed, 111 insertions(+), 64 deletions(-) diff --git a/pgtap/withPoints/withPointsVia/edge_cases/point_in_vertex.pg b/pgtap/withPoints/withPointsVia/edge_cases/point_in_vertex.pg index 15db9d89847..dd4031748dc 100644 --- a/pgtap/withPoints/withPointsVia/edge_cases/point_in_vertex.pg +++ b/pgtap/withPoints/withPointsVia/edge_cases/point_in_vertex.pg @@ -40,7 +40,7 @@ SELECT agg_cost::TEXT FROM pgr_dijkstraVia( $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; --- its a straigh line and one extreme are reachable +-- its a straight line and one extreme are reachable RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); @@ -48,11 +48,20 @@ RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); /* Points midpoint of edge 1 (-1 by default) */ -PREPARE expectedCost1(BIGINT) AS -SELECT agg_cost::TEXT FROM pgr_withPointsVia( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, - ARRAY[-1, $1], true) WHERE node = $1 and edge < 0; +IF min_version('4.0.0') THEN + PREPARE expectedCost1(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, + ARRAY[-1, $1], 'r', true) WHERE node = $1 and edge < 0; +ELSE + -- SET client_min_messages TO WARNING; + PREPARE expectedCost1(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, + ARRAY[-1, $1], driving_side => 'r', directed => true) WHERE node = $1 and edge < 0; +END IF; RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); @@ -62,11 +71,19 @@ RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost /* Points midpoint of edge 1 (-2 assigned) */ -PREPARE expectedCost2(BIGINT) AS -SELECT agg_cost::TEXT FROM pgr_withPointsVia( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, - ARRAY[-2, $1], true) WHERE node = $1 and edge < 0; +IF min_version('4.0.0') THEN + PREPARE expectedCost2(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, + ARRAY[-2, $1], 'r', true) WHERE node = $1 and edge < 0; +ELSE + PREPARE expectedCost2(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, + ARRAY[-2, $1], driving_side => 'r', directed => true) WHERE node = $1 and edge < 0; +END IF; RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); @@ -77,11 +94,19 @@ RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost source point of edge 10 (-1 by default) midpoint of edge 1 (-2 by default) */ -PREPARE expectedCost3(BIGINT, BIGINT) AS -SELECT agg_cost::TEXT FROM pgr_withPointsVia( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; +IF min_version('4.0.0') THEN + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; +ELSE + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, + ARRAY[$1, $2], driving_side => 'r', directed => true) WHERE node = $2 and edge < 0; +END IF; RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); @@ -103,11 +128,19 @@ END; source point of edge 10 (-2 by default) */ DEALLOCATE PREPARE expectedCost3; -PREPARE expectedCost3(BIGINT, BIGINT) AS -SELECT agg_cost::TEXT FROM pgr_withPointsVia( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; +IF min_version('4.0.0') THEN + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; +ELSE + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, + ARRAY[$1, $2], driving_side => 'r', directed => true) WHERE node = $2 and edge < 0; +END IF; RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); @@ -129,11 +162,19 @@ END; source point of edge 10 (-2 by default) */ DEALLOCATE PREPARE expectedCost3; -PREPARE expectedCost3(BIGINT, BIGINT) AS -SELECT agg_cost::TEXT FROM pgr_withPointsVia( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; +IF min_version('4.0.0') THEN + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; +ELSE + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, + ARRAY[$1, $2], driving_side => 'r', directed => true) WHERE node = $2 and edge < 0; +END IF; RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); @@ -155,11 +196,19 @@ END; source point of edge 10 (-1 assigned) */ DEALLOCATE PREPARE expectedCost3; +IF min_version('4.0.0') THEN PREPARE expectedCost3(BIGINT, BIGINT) AS SELECT agg_cost::TEXT FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, - ARRAY[$1, $2], true) WHERE node = $2 and edge < 0; + ARRAY[$1, $2], 'r', true) WHERE node = $2 and edge < 0; +ELSE +PREPARE expectedCost3(BIGINT, BIGINT) AS +SELECT agg_cost::TEXT FROM pgr_withPointsVia( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, + ARRAY[$1, $2], driving_side => 'r', directed => true) WHERE node = $2 and edge < 0; +END IF; RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); diff --git a/pgtap/withPoints/withPointsVia/inner_query.pg b/pgtap/withPoints/withPointsVia/inner_query.pg index 484d08b29aa..347e6f1bd2f 100644 --- a/pgtap/withPoints/withPointsVia/inner_query.pg +++ b/pgtap/withPoints/withPointsVia/inner_query.pg @@ -20,20 +20,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; 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; +SELECT CASE WHEN min_version('4.0.0') THEN plan(84) ELSE plan(1) END; CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); RETURN; END IF; - -- 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 edges$$,', ', ARRAY[2,9,12])'); + RETURN QUERY SELECT style_dijkstra('pgr_withPointsVia(', ', $$SELECT * FROM pointsOfInterest$$, ARRAY[2,9,12], $$r$$)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsVia($$SELECT * FROM edges$$,', ', ARRAY[2,9,12], $$r$$)'); END; $BODY$ diff --git a/pgtap/withPoints/withPointsVia/no_crash_test.pg b/pgtap/withPoints/withPointsVia/no_crash_test.pg index 135eb251c1a..91d0dfc7d5c 100644 --- a/pgtap/withPoints/withPointsVia/no_crash_test.pg +++ b/pgtap/withPoints/withPointsVia/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; 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; +SELECT CASE WHEN min_version('4.0.0') THEN plan(20) ELSE plan(1) END; PREPARE edges AS SELECT id, source, target, cost, reverse_cost FROM edges; @@ -31,10 +31,6 @@ SELECT 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 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 @@ -44,32 +40,35 @@ params TEXT[]; subs TEXT[]; BEGIN -IF NOT min_version('3.4.0') THEN - RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); RETURN; -END IF; - --- ONE VIA -params = ARRAY[ -'$$SELECT * FROM edges$$', -'$$SELECT * FROM pointsOfInterest$$', -'ARRAY[6,7]::BIGINT[]' -]::TEXT[]; - -subs = ARRAY[ -'NULL', -'NULL', -'(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' -]::TEXT[]; - -RETURN query SELECT * FROM no_crash_test('pgr_withPointsvia', params, subs); - -subs = ARRAY[ -'NULL', -'NULL', -'NULL::BIGINT[]' -]::TEXT[]; -RETURN query SELECT * FROM no_crash_test('pgr_withPointsvia', params, subs); + END IF; + + -- ONE VIA + params = ARRAY[ + '$$SELECT * FROM edges$$', + '$$SELECT * FROM pointsOfInterest$$', + 'ARRAY[6,7]::BIGINT[]', + '$$r$$' + ]::TEXT[]; + + subs = ARRAY[ + 'NULL', + 'NULL', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + 'NULL::TEXT' + ]::TEXT[]; + + RETURN query SELECT * FROM no_crash_test('pgr_withPointsvia', params, subs); + + subs = ARRAY[ + 'NULL', + 'NULL', + 'NULL::BIGINT[]', + 'NULL::TEXT' + ]::TEXT[]; + RETURN query SELECT * FROM no_crash_test('pgr_withPointsvia', params, subs); END $BODY$ diff --git a/pgtap/withPoints/withPointsVia/types_check.pg b/pgtap/withPoints/withPointsVia/types_check.pg index ebdbffa45e8..cd40b55cc76 100644 --- a/pgtap/withPoints/withPointsVia/types_check.pg +++ b/pgtap/withPoints/withPointsVia/types_check.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('3.4.0') THEN plan(5) ELSE plan(1) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(5) ELSE plan(1) END; SELECT types_check_via('pgr_withpointsvia'); From 8452b8ece8cfe4ffebd0ed63f3badd3aabc49449 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:52:16 -0600 Subject: [PATCH 14/39] (docqueries) pgr_withPointsVia: Adjusting documentation examples --- docqueries/withPoints/withPointsVia.pg | 48 +++---- docqueries/withPoints/withPointsVia.result | 150 +++++++++++---------- 2 files changed, 101 insertions(+), 97 deletions(-) diff --git a/docqueries/withPoints/withPointsVia.pg b/docqueries/withPoints/withPointsVia.pg index fdd6613df17..373da590fe4 100644 --- a/docqueries/withPoints/withPointsVia.pg +++ b/docqueries/withPoints/withPointsVia.pg @@ -3,48 +3,48 @@ SET extra_float_digits=-3; /* -- q0 */ SELECT * FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-6, 15, -1]); + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 15, -5], 'R'); /* -- q1 */ SELECT * FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]); + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'L', directed => true); /* -- q2 */ SELECT agg_cost FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'B', false) WHERE path_id = 3 AND edge < 0; /* -- q3 */ SELECT route_agg_cost FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE path_id = 3 AND edge < 0; /* -- q4 */ SELECT row_number() over () as node_seq, node FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge <> -1 ORDER BY seq; /* -- q5 */ SELECT path_id, route_agg_cost FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge < 0; /* -- q6 */ SELECT seq, node, -CASE WHEN edge = -1 THEN 'visits' -ELSE 'passes in front' +CASE WHEN edge = -1 THEN $$visits$$ +ELSE $$passes in front$$ END as status FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15], details => true) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r', details => true) WHERE agg_cost <> 0 or seq = 1; /* -- q7 */ SELECT * FROM pgr_withPointsVia( @@ -55,5 +55,5 @@ SELECT * FROM pgr_withPointsVia( (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - ARRAY[1, -1, -2], details => true); + ARRAY[1, -1, -2], 'r', details => true); /* -- q8 */ diff --git a/docqueries/withPoints/withPointsVia.result b/docqueries/withPoints/withPointsVia.result index a69f59e74c3..b1ccd482da1 100644 --- a/docqueries/withPoints/withPointsVia.result +++ b/docqueries/withPoints/withPointsVia.result @@ -6,9 +6,9 @@ SET extra_float_digits=-3; SET /* -- q0 */ SELECT * FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-6, 15, -1]); + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 15, -5], 'R'); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | -6 | 15 | -6 | 4 | 0.3 | 0 | 0 @@ -16,113 +16,116 @@ SELECT * FROM pgr_withPointsVia( 3 | 1 | 3 | -6 | 15 | 11 | 9 | 1 | 1.3 | 1.3 4 | 1 | 4 | -6 | 15 | 16 | 16 | 1 | 2.3 | 2.3 5 | 1 | 5 | -6 | 15 | 15 | -1 | 0 | 3.3 | 3.3 - 6 | 2 | 1 | 15 | -1 | 15 | 3 | 1 | 0 | 3.3 - 7 | 2 | 2 | 15 | -1 | 10 | 2 | 1 | 1 | 4.3 - 8 | 2 | 3 | 15 | -1 | 6 | 1 | 0.6 | 2 | 5.3 - 9 | 2 | 4 | 15 | -1 | -1 | -2 | 0 | 2.6 | 5.9 -(9 rows) + 6 | 2 | 1 | 15 | -5 | 15 | 3 | 1 | 0 | 3.3 + 7 | 2 | 2 | 15 | -5 | 10 | 5 | 0.8 | 1 | 4.3 + 8 | 2 | 3 | 15 | -5 | -5 | -2 | 0 | 1.8 | 5.1 +(8 rows) /* -- q1 */ SELECT * FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]); + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'L', directed => true); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- - 1 | 1 | 1 | -1 | 7 | -1 | 1 | 0.6 | 0 | 0 - 2 | 1 | 2 | -1 | 7 | 6 | 4 | 1 | 0.6 | 0.6 - 3 | 1 | 3 | -1 | 7 | 7 | -1 | 0 | 1.6 | 1.6 - 4 | 2 | 1 | 7 | -3 | 7 | 10 | 1 | 0 | 1.6 - 5 | 2 | 2 | 7 | -3 | 8 | 12 | 0.6 | 1 | 2.6 - 6 | 2 | 3 | 7 | -3 | -3 | -1 | 0 | 1.6 | 3.2 - 7 | 3 | 1 | -3 | 16 | -3 | 12 | 0.4 | 0 | 3.2 - 8 | 3 | 2 | -3 | 16 | 12 | 13 | 1 | 0.4 | 3.6 - 9 | 3 | 3 | -3 | 16 | 17 | 15 | 1 | 1.4 | 4.6 - 10 | 3 | 4 | -3 | 16 | 16 | -1 | 0 | 2.4 | 5.6 - 11 | 4 | 1 | 16 | 15 | 16 | 16 | 1 | 0 | 5.6 - 12 | 4 | 2 | 16 | 15 | 15 | -2 | 0 | 1 | 6.6 -(12 rows) + 1 | 1 | 1 | -6 | 7 | -6 | 4 | 0.3 | 0 | 0 + 2 | 1 | 2 | -6 | 7 | 7 | -1 | 0 | 0.3 | 0.3 + 3 | 2 | 1 | 7 | -4 | 7 | 7 | 1 | 0 | 0.3 + 4 | 2 | 2 | 7 | -4 | 3 | 6 | 0.7 | 1 | 1.3 + 5 | 2 | 3 | 7 | -4 | -4 | -1 | 0 | 1.7 | 2 + 6 | 3 | 1 | -4 | 8 | -4 | 6 | 1.3 | 0 | 2 + 7 | 3 | 2 | -4 | 8 | 3 | 7 | 1 | 1.3 | 3.3 + 8 | 3 | 3 | -4 | 8 | 7 | 10 | 1 | 2.3 | 4.3 + 9 | 3 | 4 | -4 | 8 | 8 | -1 | 0 | 3.3 | 5.3 + 10 | 4 | 1 | 8 | -2 | 8 | 12 | 1 | 0 | 5.3 + 11 | 4 | 2 | 8 | -2 | 12 | 13 | 1 | 1 | 6.3 + 12 | 4 | 3 | 8 | -2 | 17 | 15 | 0.6 | 2 | 7.3 + 13 | 4 | 4 | 8 | -2 | -2 | -2 | 0 | 2.6 | 7.9 +(13 rows) /* -- q2 */ SELECT agg_cost FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'B', false) WHERE path_id = 3 AND edge < 0; agg_cost ---------- - 2.4 + 2.7 (1 row) /* -- q3 */ SELECT route_agg_cost FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE path_id = 3 AND edge < 0; route_agg_cost ---------------- - 5.6 + 5.3 (1 row) /* -- q4 */ SELECT row_number() over () as node_seq, node FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge <> -1 ORDER BY seq; node_seq | node ----------+------ - 1 | -1 - 2 | 6 - 3 | 7 - 4 | 8 - 5 | -3 - 6 | 12 - 7 | 17 - 8 | 16 - 9 | 15 -(9 rows) + 1 | -6 + 2 | 7 + 3 | 3 + 4 | -4 + 5 | 3 + 6 | 7 + 7 | 8 + 8 | 7 + 9 | 11 + 10 | 16 + 11 | -2 +(11 rows) /* -- q5 */ SELECT path_id, route_agg_cost FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15]) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r') WHERE edge < 0; path_id | route_agg_cost ---------+---------------- - 1 | 1.6 - 2 | 3.2 - 3 | 5.6 - 4 | 6.6 + 1 | 0.3 + 2 | 2.6 + 3 | 5.3 + 4 | 8.7 (4 rows) /* -- q6 */ SELECT seq, node, -CASE WHEN edge = -1 THEN 'visits' -ELSE 'passes in front' +CASE WHEN edge = -1 THEN $$visits$$ +ELSE $$passes in front$$ END as status FROM pgr_withPointsVia( - 'SELECT id, source, target, cost, reverse_cost FROM edges order by id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - ARRAY[-1, 7, -3, 16, 15], details => true) + $$SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id$$, + $$SELECT pid, edge_id, side, fraction FROM pointsOfInterest$$, + ARRAY[-6, 7, -4, 8, -2], 'r', details => true) WHERE agg_cost <> 0 or seq = 1; seq | node | status -----+------+----------------- - 1 | -1 | passes in front - 2 | 6 | passes in front - 3 | -6 | passes in front - 4 | 7 | visits - 6 | 8 | passes in front - 7 | -3 | visits - 9 | 12 | passes in front - 10 | 17 | passes in front - 11 | -2 | passes in front - 12 | 16 | visits - 14 | 15 | passes in front -(11 rows) + 1 | -6 | passes in front + 2 | 7 | visits + 4 | 3 | passes in front + 5 | 1 | passes in front + 6 | -4 | visits + 8 | 3 | passes in front + 9 | 7 | passes in front + 10 | 8 | visits + 12 | 7 | passes in front + 13 | 11 | passes in front + 14 | 16 | passes in front + 15 | -2 | passes in front +(12 rows) /* -- q7 */ SELECT * FROM pgr_withPointsVia( @@ -133,7 +136,7 @@ SELECT * FROM pgr_withPointsVia( (SELECT ST_POINT(2.9, 1.8)), 0.5, cap => 2) $p$, - ARRAY[1, -1, -2], details => true); + ARRAY[1, -1, -2], 'r', details => true); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | 1 | -1 | 1 | 6 | 1 | 0 | 0 @@ -146,9 +149,10 @@ SELECT * FROM pgr_withPointsVia( 8 | 1 | 8 | 1 | -1 | 10 | 5 | 0.8 | 6 | 6 9 | 1 | 9 | 1 | -1 | -1 | -1 | 0 | 6.8 | 6.8 10 | 2 | 1 | -1 | -2 | -1 | 5 | 0.2 | 0 | 6.8 - 11 | 2 | 2 | -1 | -2 | 11 | 8 | 0.1 | 0.2 | 7 - 12 | 2 | 3 | -1 | -2 | -2 | -2 | 0 | 0.3 | 7.1 -(12 rows) + 11 | 2 | 2 | -1 | -2 | 11 | 8 | 1 | 0.2 | 7 + 12 | 2 | 3 | -1 | -2 | 7 | 8 | 0.9 | 1.2 | 8 + 13 | 2 | 4 | -1 | -2 | -2 | -2 | 0 | 2.1 | 8.9 +(13 rows) /* -- q8 */ ROLLBACK; From 2741c111dcee1d35506012c8119f82fdda4e5a8e Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:04:00 -0600 Subject: [PATCH 15/39] (doc) pgr_withPointsVia: Adjusting documentation about driving side --- doc/withPoints/pgr_withPointsVia.rst | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/doc/withPoints/pgr_withPointsVia.rst b/doc/withPoints/pgr_withPointsVia.rst index 1435ee335da..1b78228e41c 100644 --- a/doc/withPoints/pgr_withPointsVia.rst +++ b/doc/withPoints/pgr_withPointsVia.rst @@ -23,13 +23,22 @@ points. .. rubric:: Availability -* Version 4.0.0 +.. rubric:: Version 4.0.0 - * Function promoted to official. +* Function promoted to official. +* **Driving side** parameter is positional unnamed and compulsory. -* Version 3.4.0 + * Valid values depend on kind of graph - * New proposed function. +.. Breaking change + +* Breaking change, signatures no longer available: + + * pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) + +.. rubric:: Version 3.4.0 + +* New proposed function. Description ------------------------------------------------------------------------------- @@ -65,14 +74,14 @@ One Via .. admonition:: \ \ :class: signatures - | pgr_withPointsVia(`Edges SQL`_, `Points SQL`_, **via vertices**, [**options**]) - | **options:** ``[directed, strict, U_turn_on_edge]`` + | pgr_withPointsVia(`Edges SQL`_, `Points SQL`_, **via vertices**, **driving side** [**options**]) + | **options:** ``[directed, strict, U_turn_on_edge, details]`` | Returns set of |via-result| | OR EMPTY SET :Example: Find the route that visits the vertices :math:`\{ -6, 15, -1\}` in - that order on a **directed** graph. + that order with right driving side in directed graph.. .. literalinclude:: withPointsVia.queries :start-after: -- q0 @@ -102,7 +111,7 @@ Via optional parameters With points optional parameters ............................................................................... -.. include:: withPoints-family.rst +.. include:: withPoints-category.rst :start-after: withPoints_optionals_start :end-before: withPoints_optionals_end From ad558825fe1619f4461b32cc8180e9422c0ddf08 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 16/39] (sql, src) pgr_withPoints: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/withPoints/withPoints.sql | 170 +-------------------------- src/dijkstra/shortestPath_driver.cpp | 4 +- src/withPoints/withPoints.c | 17 ++- 3 files changed, 15 insertions(+), 176 deletions(-) diff --git a/sql/withPoints/withPoints.sql b/sql/withPoints/withPoints.sql index 196e8176a65..6a386f6c00b 100644 --- a/sql/withPoints/withPoints.sql +++ b/sql/withPoints/withPoints.sql @@ -192,7 +192,7 @@ IS 'pgr_withPoints (One to One) - Points SQL with columns: [pid], edge_id, fraction [,side] - From vertex/point identifier - To vertex/point identifier - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - details => false @@ -207,7 +207,7 @@ IS 'pgr_withPoints (One to Many) - Points SQL with columns: [pid], edge_id, fraction [,side] - From vertex/point identifier - To ARRAY[vertices/points identifiers] - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - details => false @@ -222,7 +222,7 @@ IS 'pgr_withPoints (Many to One) - Points SQL with columns: [pid], edge_id, fraction [,side] - From ARRAY[vertices/points identifiers] - To vertex/point identifier - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - details => false @@ -238,7 +238,7 @@ IS 'pgr_withPoints (Many to Many) - Points SQL with columns: [pid], edge_id, fraction [,side] - From ARRAY[vertices/points identifiers] - To ARRAY[vertices/points identifiers] - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - details => false @@ -252,170 +252,10 @@ IS 'pgr_withPoints(Combinations) - Edges SQL with columns: id, source, target, cost [,reverse_cost] - Points SQL with columns: [pid], edge_id, fraction [,side] - Combinations SQL with columns: source, target - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - details => false - Documentation: - ${PROJECT_DOC_LINK}/pgr_withPoints.html '; - - -/* TODO remove on v5 */ --- ONE TO ONE ---v3.0 -CREATE FUNCTION pgr_withPoints( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - BIGINT, -- start_vid (required) - BIGINT, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - details BOOLEAN DEFAULT false, - - OUT seq INTEGER, - OUT path_seq INTEGER, - OUT node BIGINT, - OUT edge BIGINT, - OUT cost FLOAT, - OUT agg_cost FLOAT) -RETURNS SETOF RECORD AS -$BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, ARRAY[$3]::bigint[], ARRAY[$4]::bigint[], $5, $6, $7) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- ONE TO MANY ---v3.0 -CREATE FUNCTION pgr_withPoints( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - BIGINT, -- start_vid (required) - ANYARRAY, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - details BOOLEAN DEFAULT false, - - OUT seq INTEGER, - OUT path_seq INTEGER, - OUT end_pid BIGINT, - OUT node BIGINT, - OUT edge BIGINT, - OUT cost FLOAT, - OUT agg_cost FLOAT) -RETURNS SETOF RECORD AS -$BODY$ -SELECT a.seq, a.path_seq, a.end_pid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, ARRAY[$3]::bigint[], $4::bigint[], $5, $6, $7) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- MANY TO ONE ---v3.0 -CREATE FUNCTION pgr_withPoints( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - ANYARRAY, -- start_vid (required) - BIGINT, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - details BOOLEAN DEFAULT false, - - OUT seq INTEGER, - OUT path_seq INTEGER, - OUT start_pid BIGINT, - OUT node BIGINT, - OUT edge BIGINT, - OUT cost FLOAT, - OUT agg_cost FLOAT) -RETURNS SETOF RECORD AS -$BODY$ -SELECT a.seq, a.path_seq, a.start_pid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, $3::bigint[], ARRAY[$4]::bigint[], $5, $6, $7, FALSE, FALSE) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- MANY TO MANY ---v3.0 -CREATE FUNCTION pgr_withPoints( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - ANYARRAY, -- start_vid (required) - ANYARRAY, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - details BOOLEAN DEFAULT false, - - OUT seq INTEGER, - OUT path_seq INTEGER, - OUT start_pid BIGINT, - OUT end_pid BIGINT, - OUT node BIGINT, - OUT edge BIGINT, - OUT cost FLOAT, - OUT agg_cost FLOAT) -RETURNS SETOF RECORD AS -$BODY$ -SELECT a.seq, a.path_seq, a.start_pid, a.end_pid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, $3::bigint[], $4::bigint[], $5, $6, $7) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- Combinations ---v3.2 -CREATE FUNCTION pgr_withPoints( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - TEXT, -- combinations_sql (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - details BOOLEAN DEFAULT false, - - OUT seq INTEGER, - OUT path_seq INTEGER, - OUT start_pid BIGINT, - OUT end_pid BIGINT, - OUT node BIGINT, - OUT edge BIGINT, - OUT cost FLOAT, - OUT agg_cost FLOAT) -RETURNS SETOF RECORD AS -$BODY$ - SELECT a.seq, a.path_seq, a.start_pid, a.end_pid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), - $4, $5, $6) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - - - -COMMENT ON FUNCTION pgr_withPoints(TEXT, TEXT, BIGINT, BIGINT, BOOLEAN, CHAR, BOOLEAN) -IS 'pgr_withPoints (One to One) deprecated signature on v.4.0.0'; - -COMMENT ON FUNCTION pgr_withPoints(TEXT, TEXT, BIGINT, ANYARRAY, BOOLEAN, CHAR, BOOLEAN) -IS 'pgr_withPoints (One to Many) deprecated signature on v.4.0.0'; - -COMMENT ON FUNCTION pgr_withPoints(TEXT, TEXT, ANYARRAY, BIGINT, BOOLEAN, CHAR, BOOLEAN) -IS 'pgr_withPoints (Many to One) deprecated signature on v.4.0.0'; - -COMMENT ON FUNCTION pgr_withPoints(TEXT, TEXT, ANYARRAY, ANYARRAY, BOOLEAN, CHAR, BOOLEAN) -IS 'pgr_withPoints (Many to Many) deprecated signature on v.4.0.0'; - -COMMENT ON FUNCTION pgr_withPoints(TEXT, TEXT, TEXT, BOOLEAN, CHAR, BOOLEAN) -IS 'pgr_withPoints(Combinations) deprecated signature on v4.0.0'; diff --git a/src/dijkstra/shortestPath_driver.cpp b/src/dijkstra/shortestPath_driver.cpp index 5161b62b636..702487928c9 100644 --- a/src/dijkstra/shortestPath_driver.cpp +++ b/src/dijkstra/shortestPath_driver.cpp @@ -69,10 +69,10 @@ estimate_drivingSide(char driving_side, bool directed, int32_t which) { std::string("Valid value are 'r', 'l', 'b'")); } else if (directed && !(d_side == 'r' || d_side == 'l')) { throw std::make_pair(std::string("Invalid value of 'driving side'"), - std::string("Valid values are for directed graph are: 'r', 'l'")); + std::string("Valid values for directed graph are: 'r', 'l'")); } else if (!directed && !(d_side == 'b')) { throw std::make_pair(std::string("Invalid value of 'driving side'"), - std::string("Valid value are for iundirected graph is: 'b'")); + std::string("Valid value for undirected graph is: 'b'")); } } else { /* For the moment its old signature of pgr_withPoints */ diff --git a/src/withPoints/withPoints.c b/src/withPoints/withPoints.c index 870bca34696..bf4216ebbbd 100644 --- a/src/withPoints/withPoints.c +++ b/src/withPoints/withPoints.c @@ -177,19 +177,18 @@ _pgr_withpoints(PG_FUNCTION_ARGS) { Path_rt *result_tuples = NULL; size_t result_count = 0; -#ifdef SHOWMSG - ereport(NOTICE, ( - errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), - errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), - errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), - errhint("Consider upgrade pgRouting"))); -#endif - if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), + errhint("Consider upgrade pgRouting"))); +#endif if (PG_NARGS() == 9) { /* @@ -213,7 +212,7 @@ _pgr_withpoints(PG_FUNCTION_ARGS) { text_to_cstring(PG_GETARG_TEXT_P(5)), // driving side PG_GETARG_BOOL(6), // details - 101, // which + 1, // which &result_tuples, &result_count); From 9960be4ca7f60980f66ca35d1a312caa11f90c73 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 17/39] (pgtap) pgr_withPoints: test the new signatures with unamed driving side --- .../withPoints/edge_cases/issue_1640.pg | 49 +-- .../withPoints/edge_cases/one_to_one.pg | 180 ++------- .../withPoints/edge_cases/point_in_vertex.pg | 381 ++++++------------ .../withPoints/edge_cases/undirected.pg | 212 +--------- pgtap/withPoints/withPoints/inner_query.pg | 63 +-- pgtap/withPoints/withPoints/no_crash_test.pg | 164 +------- pgtap/withPoints/withPoints/types_check.pg | 2 +- 7 files changed, 212 insertions(+), 839 deletions(-) diff --git a/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg b/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg index 096fba67527..b3ece8c6510 100644 --- a/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg +++ b/pgtap/withPoints/withPoints/edge_cases/issue_1640.pg @@ -19,51 +19,32 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN NOT min_version('3.2.0') THEN plan(1) ELSE plan(4) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(4) ELSE plan(1) END; CREATE OR REPLACE FUNCTION issue_check() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.2.0') THEN - RETURN QUERY SELECT skip(1,'Issue fixed on 3.2.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); RETURN; END IF; - IF min_version('4.0.0') THEN + PREPARE q1 AS + SELECT * FROM pgr_withPoints ( + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', + 1, -2, 'r' + ); - PREPARE q1 AS - SELECT * FROM pgr_withPoints ( - 'SELECT id, source, target, cost, reverse_cost FROM edges', - 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', - 1, -2, 'r' - ); + PREPARE q2 AS + SELECT * FROM pgr_withPoints ( + 'SELECT id, source, target, cost, reverse_cost FROM edges', + 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', + 5, 6, 'r' + ); - PREPARE q2 AS - SELECT * FROM pgr_withPoints ( - 'SELECT id, source, target, cost, reverse_cost FROM edges', - 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', - 5, 6, 'r' - ); - - ELSE - - PREPARE q1 AS - SELECT * FROM pgr_withPoints ( - 'SELECT id, source, target, cost, reverse_cost FROM edges', - 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', - 1, -2 - ); - - PREPARE q2 AS - SELECT * FROM pgr_withPoints ( - 'SELECT id, source, target, cost, reverse_cost FROM edges', - 'SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (-1)', - 5, 6 - ); - - END IF; RETURN QUERY SELECT * FROM lives_ok('q1'); RETURN QUERY SELECT * FROM is_empty('q1'); diff --git a/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg b/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg index d110decdcd9..d0efdbc733d 100644 --- a/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg +++ b/pgtap/withPoints/withPoints/edge_cases/one_to_one.pg @@ -21,202 +21,108 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; SET extra_float_digits = -3; -SELECT plan(6); +SELECT CASE WHEN min_version('4.0.0') THEN plan(6) ELSE plan(1) END; CREATE OR REPLACE FUNCTION test_cases() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -5, - 'r', - directed := true, - details := true); - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -5, - 'r', - directed := true, - details := false); - - PREPARE q21 AS - SELECT -6 AS node, 4 AS edge, round(2.1, 12) AS agg_cost; - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -5, - 'l', - directed := true, - details := true); - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -5, - 'l', - directed := true, - details := false); - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -5, - 'r', - directed := true, - details := true); - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, -5, - 'r', - directed := true, - details := true); - - PREPARE q61 AS - SELECT -6::BIGINT AS node, 4::BIGINT AS edge, 2.1 AS agg_cost; - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -3, -1, - 'r', - directed := true, - details := true) WHERE edge = -1; - - - PREPARE q8 AS - SELECT * FROM pgr_withPointsCost( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -3, -1, - 'r', - directed := true - ); - - RETURN QUERY SELECT set_has('q1', 'q2', '1: Right: from p1 to p5 pass in front of a point'); - RETURN QUERY SELECT set_has('q1', 'q21', '2: Right: from p1 to p5 pass in front of p6'); - RETURN QUERY SELECT set_has('q1', 'q2', '3: Right: from p1 to p5 pass dont pass in front of points'); - RETURN QUERY SELECT set_has('q5', 'q6', '4: both: from p1 to p5 pass in front of a point'); - RETURN QUERY SELECT set_has('q5', 'q61', '5: both: from p1 to p5 pass in front of p6'); - RETURN QUERY SELECT set_eq('q7','q8','Right, directed: Cost is the last row'); - - ELSE - -PREPARE q1 AS -SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; + END IF; + + 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 edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, - driving_side := 'r', + 'r', directed := true, details := true); -PREPARE q2 AS -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 edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, - driving_side := 'r', + 'r', directed := true, - details := true); - -PREPARE q21 AS -SELECT -6 AS node, 4 AS edge, round(2.1, 6) AS agg_cost; + details := false); -RETURN QUERY SELECT set_has('q1', 'q2', '1: Right: from p1 to p5 pass in front of a point'); -RETURN QUERY SELECT set_has('q1', 'q21', '2: Right: from p1 to p5 pass in front of p6'); + PREPARE q21 AS + SELECT -6 AS node, 4 AS edge, round(2.1, 12) AS agg_cost; -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( + 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 edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, - driving_side := 'l', + 'l', directed := true, details := true); - -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( + 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 edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, - driving_side := 'l', + 'l', directed := true, details := false); -RETURN QUERY SELECT set_has('q1', 'q2', '3: Right: from p1 to p5 pass dont pass in front of points'); - -PREPARE q5 AS -SELECT node, edge, round(agg_cost::numeric, 12) AS agg_cost FROM pgr_withPoints( + 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 edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, - driving_side := 'b', + 'r', directed := true, details := true); -PREPARE q6 AS -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 edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -1, -5, - driving_side := 'b', + 'r', directed := true, - details := false); - -PREPARE q61 AS -SELECT -6::BIGINT AS node, 4::BIGINT AS edge, 1.3 AS agg_cost; - -RETURN QUERY SELECT set_has('q5', 'q6', '4: both: from p1 to p5 pass in front of a point'); -RETURN QUERY SELECT set_has('q5', 'q61', '5: both: from p1 to p5 pass in front of p6'); + details := true); + PREPARE q61 AS + SELECT -6::BIGINT AS node, 4::BIGINT AS edge, 2.1 AS agg_cost; -PREPARE q7 AS -SELECT -3 AS start_vid, -1 AS end_vid, agg_cost FROM pgr_withPoints( + 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 edges ORDER BY id', 'SELECT pid, edge_id, fraction, side from pointsOfInterest', -3, -1, - driving_side := 'r', + 'r', directed := true, details := true) WHERE edge = -1; -PREPARE q8 AS -SELECT * FROM pgr_withPointsCost( + PREPARE q8 AS + SELECT * FROM pgr_withPointsCost( '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', + 'r', directed := true - ); - -RETURN QUERY SELECT set_eq('q7','q8','Right, directed: Cost is the last row'); - - END IF; + ); + RETURN QUERY SELECT set_has('q1', 'q2', '1: Right: from p1 to p5 pass in front of a point'); + RETURN QUERY SELECT set_has('q1', 'q21', '2: Right: from p1 to p5 pass in front of p6'); + RETURN QUERY SELECT set_has('q1', 'q2', '3: Right: from p1 to p5 pass dont pass in front of points'); + RETURN QUERY SELECT set_has('q5', 'q6', '4: both: from p1 to p5 pass in front of a point'); + RETURN QUERY SELECT set_has('q5', 'q61', '5: both: from p1 to p5 pass in front of p6'); + RETURN QUERY SELECT set_eq('q7','q8','Right, directed: Cost is the last row'); END; $BODY$ language plpgsql; SELECT test_cases(); - SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPoints/edge_cases/point_in_vertex.pg b/pgtap/withPoints/withPoints/edge_cases/point_in_vertex.pg index 025cad2bd74..f887f15385c 100644 --- a/pgtap/withPoints/withPoints/edge_cases/point_in_vertex.pg +++ b/pgtap/withPoints/withPoints/edge_cases/point_in_vertex.pg @@ -20,7 +20,7 @@ BEGIN; SET extra_float_digits=-3; -SELECT plan(38); +SELECT CASE WHEN min_version('4.0.0') THEN plan(38) ELSE plan(1) END; CREATE VIEW four_edges AS SELECT * FROM edges WHERE id IN (1,4,10,14); @@ -30,266 +30,129 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - - PREPARE dijkstra1(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_dijkstra( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $1, $2, true) WHERE edge < 0; - - -- its a straight line and one extreme are reachable - RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); - RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); - - - /* Points - midpoint of edge 1 (-1 by default) - */ - PREPARE expectedCost1(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, - -1, $1, 'r', true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost1(8)$$, ARRAY[2.5]::TEXT[] , 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost from midpoint on 1 to 9'); - - /* Points - midpoint of edge 1 (-2 assigned) - */ - PREPARE expectedCost2(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, - -2, $1, 'r', true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost2(8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - /* UNION ALL data is not sorted - source point of edge 10 (-1 by default) - midpoint of edge 1 (-2 by default) - */ - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, - $1, $2, 'r', true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - - /* UNION data is sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, - $1, $2, 'r', true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - /* VALUES data is not sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, - $1, $2, 'r', true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - /* Points - midpoint of edge 1 (-2 assigned) - source point of edge 10 (-1 assigned) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, - $1, $2, 'r', true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - ELSE - - PREPARE dijkstra1(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_dijkstra( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $1, $2, true) WHERE edge < 0; - - -- its a straight line and one extreme are reachable - RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); - RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); - - - /* Points - midpoint of edge 1 (-1 by default) - */ - PREPARE expectedCost1(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, - -1, $1, true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost1(8)$$, ARRAY[2.5]::TEXT[] , 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost from midpoint on 1 to 9'); - - /* Points - midpoint of edge 1 (-2 assigned) - */ - PREPARE expectedCost2(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, - -2, $1, true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost2(8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - /* UNION ALL data is not sorted - source point of edge 10 (-1 by default) - midpoint of edge 1 (-2 by default) - */ - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, - $1, $2, true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; - - /* UNION data is sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, - $1, $2, true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; - - /* VALUES data is not sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, - $1, $2, true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; - - /* Points - midpoint of edge 1 (-2 assigned) - source point of edge 10 (-1 assigned) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPoints( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, - $1, $2, true) WHERE edge < 0; - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; + END IF; - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; + PREPARE dijkstra1(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_dijkstra( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $1, $2, true) WHERE edge < 0; + + -- its a straight line and one extreme are reachable + RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); + RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); + + + /* Points + midpoint of edge 1 (-1 by default) + */ + PREPARE expectedCost1(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPoints( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, + -1, $1, 'r', true) WHERE edge < 0; + + RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost1(8)$$, ARRAY[2.5]::TEXT[] , 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost from midpoint on 1 to 9'); + + /* Points + midpoint of edge 1 (-2 assigned) + */ + PREPARE expectedCost2(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPoints( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, + -2, $1, 'r', true) WHERE edge < 0; + + RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost2(8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + /* UNION ALL data is not sorted + source point of edge 10 (-1 by default) + midpoint of edge 1 (-2 by default) + */ + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPoints( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, + $1, $2, 'r', true) WHERE edge < 0; + + RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); + + + /* UNION data is sorted + midpoint of edge 1 (-1 by default) + source point of edge 10 (-2 by default) + */ + DEALLOCATE PREPARE expectedCost3; + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPoints( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, + $1, $2, 'r', true) WHERE edge < 0; + + RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); + + /* VALUES data is not sorted + midpoint of edge 1 (-1 by default) + source point of edge 10 (-2 by default) + */ + DEALLOCATE PREPARE expectedCost3; + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPoints( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, + $1, $2, 'r', true) WHERE edge < 0; + + RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); + + /* Points + midpoint of edge 1 (-2 assigned) + source point of edge 10 (-1 assigned) + */ + DEALLOCATE PREPARE expectedCost3; + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPoints( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, + $1, $2, 'r', true) WHERE edge < 0; + + RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - END IF; END; $BODY$ diff --git a/pgtap/withPoints/withPoints/edge_cases/undirected.pg b/pgtap/withPoints/withPoints/edge_cases/undirected.pg index 0e70247371b..1605561268d 100644 --- a/pgtap/withPoints/withPoints/edge_cases/undirected.pg +++ b/pgtap/withPoints/withPoints/edge_cases/undirected.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -SELECT PLAN(12); +SELECT CASE WHEN min_version('4.0.0') THEN plan(12) ELSE plan(1) END; ------------------ ---- FROM -1 to 7 @@ -96,11 +96,16 @@ FROM ( -1 , -1 , 0 , 4.6) ) AS t (node, edge, cost, agg_cost); -CREATE OR REPLACE FUNCTION test_new_fn() +CREATE OR REPLACE FUNCTION test_fn() RETURNS SETOF TEXT AS $BODY$ BEGIN + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; + END IF; + --- -- UNDIRECTED GRAPH -- Because the graph is undirected no matter the driving side @@ -264,209 +269,6 @@ END; $BODY$ language plpgsql; -CREATE OR REPLACE FUNCTION test_fn() -RETURNS SETOF TEXT AS -$BODY$ -BEGIN - - IF min_version('4.0.0') THEN - - RETURN QUERY SELECT test_new_fn(); - RETURN; - - END IF; - - --- - -- UNDIRECTED GRAPH - -- Because the graph is undirected no matter the driving side - -- the results should be the same - - --------------------------- - -- No Details - --------------------------- - - -------- both driving sides - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 1, driving_side := 'b', details := false, directed:=false) - ORDER BY seq; - - RETURN QUERY 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'); - - -------- 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_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 1, driving_side := 'r', details := false, directed:=false) - ORDER BY seq; - - - RETURN QUERY SELECT set_eq('q2', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test1$$, - 'Should be aggregating individual costs: right driving side'); - - -------- 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_withPoints( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - -1, 1, driving_side := 'l', details := false, directed:=false) - ORDER BY seq; - - - RETURN QUERY SELECT set_eq('q3', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test1$$, - 'Should be aggregating individual costs: left driving side'); - - ------------------ - ---- FROM 12 to -1 - ------------------ - -------- both driving sides - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 17, -1, driving_side := 'b', details := false, directed:=false) - ORDER BY seq; - - RETURN QUERY SELECT set_eq('q4', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test2$$, - 'Should be aggregating individual costs: both driving sides'); - - -------- right driving side - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 17, -1, driving_side := 'r', details := false, directed:=false) - ORDER BY seq; - - - RETURN QUERY SELECT set_eq('q5', - $$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'); - - -------- left driving side - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 17, -1, driving_side := 'l', details := false, directed:=false) - ORDER BY seq; - - - RETURN QUERY SELECT set_eq('q6', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test2$$, - 'Should be aggregating individual costs: left driving side'); - - --------------------------- - -- With Details - --------------------------- - - ------------------ - ---- FROM 1 to 7 - ------------------ - - -------- 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 5, 1, driving_side := 'b', details := true, directed:=false); - - RETURN QUERY SELECT set_eq('q7', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, - '5, 1, driving_side := b, details := true, directed:=false'); - - - -------- right driving side - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 5, 1, driving_side := 'r', details := true, directed:=false) - ORDER BY seq; - - - RETURN QUERY SELECT set_eq('q8', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, - '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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 5, 1, driving_side := 'l', details := true, directed:=false) - ORDER BY seq; - - - RETURN QUERY SELECT set_eq('q9', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test3$$, - '5, 1, driving_side := l, details := true, directed:=false'); - - - ------------------ - ---- FROM 12 to -1 - ------------------ - -------- both driving sides - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 17, -1, driving_side := 'b', details := true, directed:=false); - - RETURN QUERY SELECT set_eq('q10', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - '17, -1, driving_side := b, details := true, directed:=false'); - - -------- right driving side - - 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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 17, -1, driving_side := 'r', details := true, directed:=false); - - - RETURN QUERY SELECT set_eq('q11', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - '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 edges ORDER BY id', - 'SELECT pid, edge_id, fraction, side from pointsOfInterest', - 17, -1, driving_side := 'l', details := true, directed:=false); - - - RETURN QUERY SELECT set_eq('q12', - $$SELECT node, edge, round(cost::numeric, 12) AS cost, round(agg_cost::numeric, 12) AS agg_cost FROM test4$$, - '17, -1, driving_side := l, details := true, directed:=false'); - -END; -$BODY$ -language plpgsql; - - SELECT test_fn(); - SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPoints/inner_query.pg b/pgtap/withPoints/withPoints/inner_query.pg index 8b615c7e5e4..4a4df47d483 100644 --- a/pgtap/withPoints/withPoints/inner_query.pg +++ b/pgtap/withPoints/withPoints/inner_query.pg @@ -20,56 +20,35 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; 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; +SELECT CASE WHEN min_version('4.0.0') THEN plan(432) ELSE plan(1) END; CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - - -- ONE TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, 3, $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, 3, $$r$$, true)'); - -- ONE TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, ARRAY[3], $$r$$, true)'); - -- MANY TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], 3, $$r$$, true)'); - -- MANY TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], $$r$$, true)'); - -- COMBINATIONS - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', $$SELECT * FROM combinations$$, $$r$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_withPoints($$SELECT * FROM edges$$, $$SELECT * from pointsOfInterest$$,',', $$r$$, true)'); - - ELSE + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; + END IF; - -- ONE TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, 3, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, 3, true)'); - -- ONE TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, ARRAY[3], true)'); - -- MANY TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], 3, true)'); - -- MANY TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], true)'); - -- COMBINATIONS - IF min_version('3.2.0') THEN - 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; + -- ONE TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, 3, $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, 3, $$r$$, true)'); + -- ONE TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', 2, ARRAY[3], $$r$$, true)'); + -- MANY TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], 3, $$r$$, true)'); + -- MANY TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], $$r$$, true)'); + -- COMBINATIONS + RETURN QUERY SELECT style_dijkstra('pgr_withPoints(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPoints($$SELECT * FROM edges$$,', ', $$SELECT * FROM combinations$$, $$r$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_withPoints($$SELECT * FROM edges$$, $$SELECT * from pointsOfInterest$$,',', $$r$$, true)'); - END IF; END $BODY$ diff --git a/pgtap/withPoints/withPoints/no_crash_test.pg b/pgtap/withPoints/withPoints/no_crash_test.pg index d36206b7d70..f16f0d75716 100644 --- a/pgtap/withPoints/withPoints/no_crash_test.pg +++ b/pgtap/withPoints/withPoints/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('4.0.0') THEN plan(122) WHEN min_version('3.2.0') THEN plan (102) ELSE plan(85) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(116) ELSE plan(1) END; PREPARE edges AS SELECT id, source, target, cost, reverse_cost FROM edges; @@ -41,7 +41,7 @@ PREPARE null_combinations AS SELECT source, target FROM combinations WHERE source IN (-1); -CREATE OR REPLACE FUNCTION test_new_function() +CREATE OR REPLACE FUNCTION test_function() RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -50,20 +50,10 @@ subs TEXT[]; BEGIN IF NOT min_version('4.0.0') THEN - RETURN QUERY - SELECT skip(1, 'Test for new function on 4.0.0'); + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); RETURN; END IF; - RETURN QUERY - SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT isnt_empty('pois', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); - RETURN QUERY - SELECT set_eq('null_ret_arr', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); - -- one to one params = ARRAY[ '$$edges$$', @@ -161,11 +151,6 @@ BEGIN RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); -- Combinations SQL - RETURN QUERY - SELECT isnt_empty('combinations', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT is_empty('null_combinations', 'Should be empty to tests be meaningful'); - params = ARRAY['$$edges$$', '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', '$$combinations$$','$$r$$::CHAR']::TEXT[]; @@ -190,149 +175,6 @@ END $BODY$ LANGUAGE plpgsql VOLATILE; -CREATE OR REPLACE FUNCTION test_function() -RETURNS SETOF TEXT AS -$BODY$ -DECLARE -params TEXT[]; -subs TEXT[]; -BEGIN - - IF min_version('4.0.0') THEN - RETURN QUERY SELECT test_new_function(); - RETURN; - END IF; - - RETURN QUERY - SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT isnt_empty('pois', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); - RETURN QUERY - SELECT set_eq('null_ret_arr', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); - - -- one to one - params = ARRAY[ - '$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '5::BIGINT', - '6::BIGINT' - ]::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT', - 'NULL::BIGINT' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); - - -- one to many - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '1', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT', - 'NULL::BIGINT[]' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); - - -- many to one - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - 'ARRAY[2,5]::BIGINT[]', '1']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT[]', - 'NULL::BIGINT' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); - - -- many to many - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - 'ARRAY[1]::BIGINT[]', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT[]', - 'NULL::BIGINT[]' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); - - -- Combinations SQL - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations functionality is new on 3.2.0'); - RETURN; - END IF; - - RETURN QUERY - SELECT isnt_empty('combinations', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT is_empty('null_combinations', 'Should be empty to tests be meaningful'); - - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '$$combinations$$']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '$$(SELECT source, target FROM combinations WHERE source IN (-1))$$' - ]::TEXT[]; - - RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::TEXT' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPoints', params, subs); - -END -$BODY$ -LANGUAGE plpgsql VOLATILE; - SELECT test_function(); SELECT finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPoints/types_check.pg b/pgtap/withPoints/withPoints/types_check.pg index 4a196b58250..3e3fa26129d 100644 --- a/pgtap/withPoints/withPoints/types_check.pg +++ b/pgtap/withPoints/withPoints/types_check.pg @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.2.0') THEN plan(12) ELSE PLAN(10) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) ELSE PLAN(2) END; SELECT single_path_types_check('pgr_withpoints', '{"",directed,details}'::TEXT[], '{bpchar,bool,bool}'::TEXT[], standard_v => '4.0.0'); From 6576ccc3eeba9824c6ebe203decd52a45c7b5487 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:52:16 -0600 Subject: [PATCH 18/39] (docqueries) pgr_withPoints: Adjusting documentation examples --- docqueries/withPoints/withPoints.pg | 2 +- docqueries/withPoints/withPoints.result | 30 ++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docqueries/withPoints/withPoints.pg b/docqueries/withPoints/withPoints.pg index eb55e86e266..2aabfd441f3 100644 --- a/docqueries/withPoints/withPoints.pg +++ b/docqueries/withPoints/withPoints.pg @@ -34,7 +34,7 @@ SELECT * FROM pgr_withPoints( ARRAY[5, -1], ARRAY[-2, -3, -6, 10, 11], 'r', details => true); /* -- q7 */ -SELECT (start_vid || ' -> ' || end_vid ||' at ' || path_seq || 'th step')::TEXT AS path_at, +SELECT (start_vid || ' -> ' || end_vid ||' at ' || path_seq || 'th step:')::TEXT AS path_at, CASE WHEN edge = -1 THEN ' visits' ELSE ' passes in front of' END as status, diff --git a/docqueries/withPoints/withPoints.result b/docqueries/withPoints/withPoints.result index b316bda4ef5..465bf25bdbe 100644 --- a/docqueries/withPoints/withPoints.result +++ b/docqueries/withPoints/withPoints.result @@ -180,7 +180,7 @@ SELECT * FROM pgr_withPoints( (63 rows) /* -- q7 */ -SELECT (start_vid || ' -> ' || end_vid ||' at ' || path_seq || 'th step')::TEXT AS path_at, +SELECT (start_vid || ' -> ' || end_vid ||' at ' || path_seq || 'th step:')::TEXT AS path_at, CASE WHEN edge = -1 THEN ' visits' ELSE ' passes in front of' END as status, @@ -193,20 +193,20 @@ FROM pgr_withPoints( 'SELECT pid, edge_id, fraction, side FROM pointsOfInterest', ARRAY[5, -1], ARRAY[-6, -3, -6, 10, 11], 'r', details => true) WHERE node IN (-6, 11); - path_at | status | is_a | id -----------------------+---------------------+--------+---- - -1 -> -6 at 4th step | visits | Point | 6 - -1 -> -3 at 4th step | passes in front of | Point | 6 - -1 -> 10 at 4th step | passes in front of | Point | 6 - -1 -> 10 at 6th step | passes in front of | Vertex | 11 - -1 -> 11 at 4th step | passes in front of | Point | 6 - -1 -> 11 at 6th step | visits | Vertex | 11 - 5 -> -6 at 3th step | visits | Point | 6 - 5 -> -3 at 3th step | passes in front of | Point | 6 - 5 -> 10 at 3th step | passes in front of | Point | 6 - 5 -> 10 at 5th step | passes in front of | Vertex | 11 - 5 -> 11 at 3th step | passes in front of | Point | 6 - 5 -> 11 at 5th step | visits | Vertex | 11 + path_at | status | is_a | id +-----------------------+---------------------+--------+---- + -1 -> -6 at 4th step: | visits | Point | 6 + -1 -> -3 at 4th step: | passes in front of | Point | 6 + -1 -> 10 at 4th step: | passes in front of | Point | 6 + -1 -> 10 at 6th step: | passes in front of | Vertex | 11 + -1 -> 11 at 4th step: | passes in front of | Point | 6 + -1 -> 11 at 6th step: | visits | Vertex | 11 + 5 -> -6 at 3th step: | visits | Point | 6 + 5 -> -3 at 3th step: | passes in front of | Point | 6 + 5 -> 10 at 3th step: | passes in front of | Point | 6 + 5 -> 10 at 5th step: | passes in front of | Vertex | 11 + 5 -> 11 at 3th step: | passes in front of | Point | 6 + 5 -> 11 at 5th step: | visits | Vertex | 11 (12 rows) /* -- q8 */ From 93c70263ba3ffc860fc22d201f39f5ffdd771ec0 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:04:00 -0600 Subject: [PATCH 19/39] (doc) pgr_withPoints: Adjusting documentation about driving side --- doc/withPoints/pgr_withPoints.rst | 64 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/doc/withPoints/pgr_withPoints.rst b/doc/withPoints/pgr_withPoints.rst index 1f4af5d161a..a9e59a99109 100644 --- a/doc/withPoints/pgr_withPoints.rst +++ b/doc/withPoints/pgr_withPoints.rst @@ -25,13 +25,22 @@ temporary vertices. .. rubric:: Version 4.0.0 -* Output columns standardized to |short-generic-result| * Function promoted to official. -* Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. +* **Driving side** parameter is positional unnamed and compulsory. + + * Valid values depend on kind of graph + +* Output columns standardized to |short-generic-result| - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` +.. Breaking change + +* Breaking change, signatures no longer available: + + * pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean) + * pgr_withpoints(text,text,anyarray,bigint,boolean,character,boolean) + * pgr_withpoints(text,text,bigint,anyarray,boolean,character,boolean) + * pgr_withpoints(text,text,bigint,bigint,boolean,character,boolean) + * pgr_withpoints(text,text,text,boolean,character,boolean) .. rubric:: Version 3.2.0 @@ -46,7 +55,7 @@ temporary vertices. Description ------------------------------------------------------------------------------- -Modify the graph to include points defined by points_sql. +Modify the graph to include points defined by `Points SQL`_. Using Dijkstra algorithm, find the shortest path. The main characteristics are: @@ -54,8 +63,8 @@ The main characteristics are: - Process is done only on edges with positive costs. - Vertices of the graph are: - - **positive** when it belongs to the edges_sql - - **negative** when it belongs to the points_sql + - **positive** when it belongs to the `Edges SQL`_ + - **negative** when it belongs to the `Points SQL`_ - Values are returned when there is a path. @@ -68,17 +77,8 @@ The main characteristics are: - The `agg_cost` in the non included values `(u, v)` is :math:`\infty` - - If the values returned are stored in a table, the unique index would be the - pair: `(start_vid, end_vid)`. - - - For **undirected** graphs, the results are **symmetric**. - - - The sequence of nodes from `u` to `v` is the reverse sequence of nodes - from `v` to `u` - - The `agg_cost` of `(u, v)` is the same as for `(v, u)`. - -- For optimization purposes, any duplicated value in the input arrays of `start vids` or - `end vids` or are ignored. +- For optimization purposes, any duplicated value in the input arrays of **start vids** or + **end vids** or are ignored. - The returned values are ordered: @@ -101,8 +101,8 @@ Signatures | pgr_withPoints(`Edges SQL`_, `Points SQL`_, **start vid**, **end vids**, **driving side** [**options**]) | pgr_withPoints(`Edges SQL`_, `Points SQL`_, **start vids**, **end vid**, **driving side** [**options**]) | pgr_withPoints(`Edges SQL`_, `Points SQL`_, **start vids**, **end vids**, **driving side** [**options**]) - | pgr_withPoints(`Edges SQL`_, `Points SQL`_, `Combinations SQL`_, [**options**]) - | **options:** ``[directed, details]`` + | pgr_withPoints(`Edges SQL`_, `Points SQL`_, `Combinations SQL`_, **driving side** [**options**]) + | **options:** ``[directed, details])`` | Returns set of |short-generic-result| | OR EMPTY SET @@ -122,7 +122,8 @@ One to One | Returns set of |short-generic-result| | OR EMPTY SET -:Example: From point :math:`1` to vertex :math:`10` with details +:Example: From point :math:`1` to vertex :math:`10` with right driving side in directed graph. + (without details) .. literalinclude:: withPoints.queries :start-after: -- q1 @@ -137,7 +138,7 @@ One to Many .. admonition:: \ \ :class: signatures - pgr_withPoints(`Edges SQL`_, `Points SQL`_, **start vid**, **end vids**, **driving side** [**options**]) + | pgr_withPoints(`Edges SQL`_, `Points SQL`_, **start vid**, **end vids**, **driving side** [**options**]) | **options:** ``[directed, details]`` | Returns set of |short-generic-result| @@ -165,7 +166,8 @@ Many to One | Returns set of |short-generic-result| | OR EMPTY SET -:Example: From point :math:`1` and vertex :math:`6` to point :math:`3` +:Example: From point :math:`1` and vertex :math:`6` to point :math:`3` with right driving side in directed graph. + (without details) .. literalinclude:: withPoints.queries :start-after: -- q3 @@ -187,7 +189,7 @@ Many to Many | OR EMPTY SET :Example: From point :math:`1` and vertex :math:`6` to point :math:`3` and - vertex :math:`1` + vertex :math:`1` with left side driving. .. literalinclude:: withPoints.queries :start-after: -- q4 @@ -211,7 +213,8 @@ Combinations :Example: Two combinations From point :math:`1` to vertex :math:`10`, and from vertex :math:`6` to point -:math:`3` with **right** side driving. +:math:`3` with right side driving. +(with details) .. literalinclude:: withPoints.queries :start-after: -- q5 @@ -234,9 +237,9 @@ Optional parameters With points optional parameters ............................................................................... -.. include:: withPoints-family.rst - :start-after: withPoints_optionals_start - :end-before: withPoints_optionals_end +.. include:: withPoints-category.rst + :start-after: withPoints_optionals_start + :end-before: withPoints_optionals_end Inner Queries ------------------------------------------------------------------------------- @@ -267,7 +270,7 @@ Result columns .. include:: pgRouting-concepts.rst :start-after: return_path_complete_start - :end-before: return_path_withPoints_end + :end-before: return_path_complete_end Additional Examples ------------------------------------------------------------------------------- @@ -303,7 +306,6 @@ Passes in front or visits with right side driving. For point :math:`6` and vertex :math:`11`. - .. literalinclude:: withPoints.queries :start-after: -- q7 :end-before: -- q8 From be559ef1703a106367600e47af5dbef144be8dc1 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:04:02 -0600 Subject: [PATCH 20/39] (sql, src) pgr_withPoints_KSP: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/ksp/_withPointsKSP.sql | 13 +++++----- src/ksp/withPoints_ksp.c | 53 ++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/sql/ksp/_withPointsKSP.sql b/sql/ksp/_withPointsKSP.sql index 201f1b0a504..55743294f7c 100644 --- a/sql/ksp/_withPointsKSP.sql +++ b/sql/ksp/_withPointsKSP.sql @@ -1,8 +1,11 @@ /*PGR-GNU***************************************************************** File: _withPointsKSP.sql +Copyright (c) 2015 pgRouting developers +Mail: project at pgrouting.org + Copyright (c) 2015 Celia Virginia Vergara Castillo -vicky_vergara@hotmail.com +Mail: vicky at erosion.dev Copyright (c) 2023 Abhinav Jain Mail: this.abhinav at gmail.com @@ -25,10 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ --------------------- --- pgr_withPointsKSP: --------------------- - --v4.0 CREATE FUNCTION _pgr_withPointsKSP_v4( TEXT, -- edges @@ -53,7 +52,7 @@ CREATE FUNCTION _pgr_withPointsKSP_v4( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE c STABLE STRICT; +LANGUAGE C VOLATILE STRICT; --v4.0 CREATE FUNCTION _pgr_withPointsKSP_v4( @@ -78,7 +77,7 @@ CREATE FUNCTION _pgr_withPointsKSP_v4( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE c STABLE STRICT; +LANGUAGE C VOLATILE STRICT; COMMENT ON FUNCTION _pgr_withPointsKSP_v4(TEXT, TEXT, ANYARRAY, ANYARRAY, INTEGER, CHAR, BOOLEAN, BOOLEAN, BOOLEAN) IS 'pgRouting internal function'; diff --git a/src/ksp/withPoints_ksp.c b/src/ksp/withPoints_ksp.c index 00ad59ba75d..29fa3a6a892 100644 --- a/src/ksp/withPoints_ksp.c +++ b/src/ksp/withPoints_ksp.c @@ -63,32 +63,24 @@ process( Path_rt **result_tuples, size_t *result_count) { - if (p_k < 0) { - /* TODO add error message */ + char d_side = estimate_drivingSide(driving_side[0]); + if (d_side == ' ') { + pgr_throw_error("Invalid value of 'driving side'", "Valid value are 'r', 'l', 'b'"); + return; + } else if (directed && !(d_side == 'r' || d_side == 'l')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for directed graph are: 'r', 'l'"); + return; + } else if (!directed && !(d_side == 'b')) { + pgr_throw_error("Invalid value of 'driving side'", "Valid values are for undirected graph is: 'b'"); return; } - size_t k = (size_t)p_k; - - if (start_vid) { - driving_side[0] = (char) tolower(driving_side[0]); - if (!((driving_side[0] == 'r') - || (driving_side[0] == 'l'))) { - driving_side[0] = 'b'; - } - } else { - driving_side[0] = (char) tolower(driving_side[0]); - if (directed) { - if (!((driving_side[0] == 'r') || (driving_side[0] == 'l'))) { - pgr_throw_error("Invalid value of 'driving side'", "Valid values are for directed graph are: 'r', 'l'"); - return; - } - } else if (!(driving_side[0] == 'b')) { - pgr_throw_error("Invalid value of 'driving side'", "Valid values are for undirected graph is: 'b'"); - return; - } + if (p_k < 0) { + pgr_throw_error("Invalid value of 'K'", "Valid value are greater than 0"); } + size_t k = (size_t)p_k; + pgr_SPI_connect(); char* log_msg = NULL; @@ -117,7 +109,7 @@ process( directed, heap_paths, - driving_side[0], + d_side, details, result_tuples, @@ -246,9 +238,12 @@ PGDLLEXPORT Datum _pgr_withpointsksp_v4(PG_FUNCTION_ARGS) { } } -/* - * TODO (v5) v5 remove deprecated code - * TODO (v4 last micro) warn about deprecated code +/* Deprecated code starts here + * This code is used on v3.8 and under + * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING + * TODO(v5) Move to legacy */ PGDLLEXPORT Datum _pgr_withpointsksp(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(_pgr_withpointsksp); @@ -265,6 +260,14 @@ PGDLLEXPORT Datum _pgr_withpointsksp(PG_FUNCTION_ARGS) { funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), + errhint("Consider upgrade pgRouting"))); +#endif + if (PG_NARGS() == 10) { process( text_to_cstring(PG_GETARG_TEXT_P(0)), From ea2a39fa75fdb9c3c06feff83c5de786579ca531 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:04:00 -0600 Subject: [PATCH 21/39] (doc) pgr_withPointsKSP: Adjusting documentation about driving side --- doc/withPoints/pgr_withPointsKSP.rst | 55 ++++++++++++++++++---------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/doc/withPoints/pgr_withPointsKSP.rst b/doc/withPoints/pgr_withPointsKSP.rst index 17efc4989df..de05c038b99 100644 --- a/doc/withPoints/pgr_withPointsKSP.rst +++ b/doc/withPoints/pgr_withPointsKSP.rst @@ -20,18 +20,24 @@ ``pgr_withPointsKSP`` — Yen's algorithm for K shortest paths using Dijkstra. +.. rubric:: Availability + .. rubric:: Version 4.0.0 * Function promoted to official. +.. Breaking change + +* Breaking change, signatures no longer available: + + * pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) + .. rubric:: Version 3.6.0 -* Standardizing output columns to |nksp-result| -* pgr_withPointsKSP(One to One) +* Output columns standardized to |nksp-result| +* **Driving side** parameter is positional unnamed and compulsory. - * Signature change: ``driving_side`` parameter changed from named optional to - unnamed compulsory **driving side**. - * Added ``start_vid`` and ``end_vid`` result columns. + * Valid values depend on kind of graph * New proposed signatures: @@ -40,9 +46,9 @@ * pgr_withPointsKSP(Many to Many) * pgr_withPointsKSP(Combinations) -* Deprecated signature +* Deprecated signatures: - * pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,char,boolean)`` + * pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) .. rubric:: Version 2.2.0 @@ -191,7 +197,7 @@ Parameters .. list-table:: :width: 81 - :widths: 17 22 44 + :widths: 14 14 44 :header-rows: 1 * - Column @@ -199,25 +205,34 @@ Parameters - Description * - `Edges SQL`_ - ``TEXT`` - - `Edges SQL`_ query as described. + - `Edges SQL`_ as described below * - `Points SQL`_ - ``TEXT`` - - `Points SQL`_ query as described. + - `Points SQL`_ as described below + * - `Combinations SQL`_ + - ``TEXT`` + - `Combinations SQL`_ as described below * - **start vid** - - **ANY-INTEGER** - - Identifier of the departure vertex. - - - Negative values represent a point + - ``BIGINT`` + - Identifier of the starting vertex of the path. Negative value is for + point’s identifier. + * - **start vids** + - ``ARRAY[BIGINT]`` + - Array of identifiers of starting vertices. Negative values are for + point’s identifiers. * - **end vid** - - **ANY-INTEGER** - - Identifier of the destination vertex. - - - Negative values represent a point + - ``BIGINT`` + - Identifier of the ending vertex of the path. Negative value is for + point’s identifier. + * - **end vids** + - ``ARRAY[BIGINT]`` + - Array of identifiers of ending vertices. Negative values are for point’s + identifiers. * - **K** - **ANY-INTEGER** - Number of required paths - * - **driving_side** - - **CHAR** + * - **driving side** + - ``CHAR`` - Value in [``r``, ``R``, ``l``, ``L``, ``b``, ``B``] indicating if the driving side is: - [``r``, ``R``] for right driving side (for directed graph only) From 88cd7ce028808c26a341a4d351bca39a2750eb55 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 22/39] (sql) pgr_withPointsCost: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/withPoints/withPointsCost.sql | 147 ++---------------------------- 1 file changed, 7 insertions(+), 140 deletions(-) diff --git a/sql/withPoints/withPointsCost.sql b/sql/withPoints/withPointsCost.sql index 636efec427e..da7a91bccdc 100644 --- a/sql/withPoints/withPointsCost.sql +++ b/sql/withPoints/withPointsCost.sql @@ -153,7 +153,7 @@ IS 'pgr_withPointsCost (One to One) - Points SQL with columns: [pid], edge_id, fraction [,side] - From vertices/point identifier - To vertex/point identifier - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - Documentation: @@ -167,7 +167,7 @@ IS 'pgr_withPointsCost (One to Many) - Points SQL with columns: [pid], edge_id, fraction [,side] - From vertices/point identifier - To ARRAY[vertices/points identifiers] - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - Documentation: @@ -181,7 +181,7 @@ IS 'pgr_withPointsCost (Many to One) - Points SQL with columns: [pid], edge_id, fraction [,side] - From ARRAY[vertices/points identifiers] - To vertex/point identifier - - driving side: directed graph [r,l], undirected graph [b] + - Driving side: directed graph [r,l], undirected graph [b] - Optional Parameters - directed => true - Documentation: @@ -191,13 +191,13 @@ IS 'pgr_withPointsCost (Many to One) COMMENT ON FUNCTION pgr_withPointsCost(TEXT, TEXT, ANYARRAY, ANYARRAY, CHAR, BOOLEAN) IS 'pgr_withPointsCost (Many to Many) - - Parameters: +- Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] - Points SQL with columns: [pid], edge_id, fraction [,side] - From ARRAY[vertices/points identifiers] - To ARRAY[vertices/points identifiers] - driving side: directed graph [r,l], undirected graph [b] -- Optional Parameters +- Optional Parameters: - directed => true - Documentation: - ${PROJECT_DOC_LINK}/pgr_withPointsCost.html @@ -205,146 +205,13 @@ IS 'pgr_withPointsCost (Many to Many) COMMENT ON FUNCTION pgr_withPointsCost(TEXT, TEXT, TEXT, CHAR, BOOLEAN) IS 'pgr_withPointsCost(Combinations) - - Parameters: +- Parameters: - Edges SQL with columns: id, source, target, cost [,reverse_cost] - Points SQL with columns: [pid], edge_id, fraction [,side] - Combinations SQL with columns: source, target - driving side: directed graph [r,l], undirected graph [b] -- Optional Parameters +- Optional Parameters: - directed => true - Documentation: - ${PROJECT_DOC_LINK}/pgr_withPointsCost.html '; - -/* TODO remove on v5.0 */ --- ONE TO ONE ---v3.0 -CREATE FUNCTION pgr_withPointsCost( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - BIGINT, -- start_vid (required) - BIGINT, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - - OUT start_pid BIGINT, - OUT end_pid BIGINT, - OUT agg_cost float) -RETURNS SETOF RECORD AS -$BODY$ - SELECT $3, $4, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, ARRAY[$3]::BIGINT[], ARRAY[$4]::BIGINT[], $5, $6, TRUE, TRUE) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- ONE TO MANY ---v3.0 -CREATE FUNCTION pgr_withPointsCost( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - BIGINT, -- start_vid (required) - ANYARRAY, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - - OUT start_pid BIGINT, - OUT end_pid BIGINT, - OUT agg_cost float) -RETURNS SETOF RECORD AS -$BODY$ - SELECT $3, a.end_pid, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, ARRAY[$3]::BIGINT[], $4::BIGINT[], $5, $6, TRUE, TRUE) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- MANY TO ONE ---v3.0 -CREATE FUNCTION pgr_withPointsCost( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - ANYARRAY, -- start_vid (required) - BIGINT, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - - OUT start_pid BIGINT, - OUT end_pid BIGINT, - OUT agg_cost float) -RETURNS SETOF RECORD AS -$BODY$ - SELECT a.start_pid, $4, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, $3::BIGINT[], ARRAY[$4]::BIGINT[], $5, $6, TRUE, TRUE) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- MANY TO MANY ---v3.0 -CREATE FUNCTION pgr_withPointsCost( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - ANYARRAY, -- start_vid (required) - ANYARRAY, -- end_vid (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - - OUT start_pid BIGINT, - OUT end_pid BIGINT, - OUT agg_cost float) -RETURNS SETOF RECORD AS -$BODY$ - SELECT a.start_pid, a.end_pid, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), $2, $3::BIGINT[], $4::BIGINT[], $5, $6, TRUE, TRUE) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - --- Combinations ---v3.2 -CREATE FUNCTION pgr_withPointsCost( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - TEXT, -- combinations_sql (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - - OUT start_pid BIGINT, - OUT end_pid BIGINT, - OUT agg_cost float) -RETURNS SETOF RECORD AS -$BODY$ - SELECT a.start_pid, a.end_pid, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), $4, $5, TRUE, TRUE) AS a; -$BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; - - - - -COMMENT ON FUNCTION pgr_withPointsCost(TEXT, TEXT, BIGINT, BIGINT, BOOLEAN, CHAR) -IS 'pgr_withPointsCost (One to One) deprecated signature on v4.0.0'; - -COMMENT ON FUNCTION pgr_withPointsCost(TEXT, TEXT, BIGINT, ANYARRAY, BOOLEAN, CHAR) -IS 'pgr_withPointsCost (One to Many) deprecated signature on v4.0.0'; - -COMMENT ON FUNCTION pgr_withPointsCost(TEXT, TEXT, ANYARRAY, BIGINT, BOOLEAN, CHAR) -IS 'pgr_withPointsCost (Many to One) deprecated signature on v4.0.0'; - -COMMENT ON FUNCTION pgr_withPointsCost(TEXT, TEXT, ANYARRAY, ANYARRAY, BOOLEAN, CHAR) -IS 'pgr_withPointsCost (Many to Many) deprecated signature on v4.0.0'; - -COMMENT ON FUNCTION pgr_withPointsCost(TEXT, TEXT, TEXT, BOOLEAN, CHAR) -IS 'pgr_withPointsCost(Combinations) deprecated signature on v4.0.0'; From d2c007b69ece58dfbd433a9f669a23a7507dd27f Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 23/39] (pgtap) pgr_withPointsCost: test the new signatures with unamed driving side --- .../edge_cases/point_in_vertex.pg | 383 ++++++------------ .../withPoints/withPointsCost/inner_query.pg | 66 +-- .../withPointsCost/no_crash_test.pg | 149 +------ .../withPoints/withPointsCost/types_check.pg | 116 ++---- 4 files changed, 176 insertions(+), 538 deletions(-) diff --git a/pgtap/withPoints/withPointsCost/edge_cases/point_in_vertex.pg b/pgtap/withPoints/withPointsCost/edge_cases/point_in_vertex.pg index 41ee5fdc47c..63c73cdd201 100644 --- a/pgtap/withPoints/withPointsCost/edge_cases/point_in_vertex.pg +++ b/pgtap/withPoints/withPointsCost/edge_cases/point_in_vertex.pg @@ -20,7 +20,7 @@ BEGIN; SET extra_float_digits=-3; -SELECT plan(38); +SELECT CASE WHEN min_version('4.0.0') THEN plan(38) ELSE plan(1) END; CREATE VIEW four_edges AS SELECT * FROM edges WHERE id IN (1,4,10,14); @@ -30,272 +30,133 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - - PREPARE dijkstra1(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_dijkstraCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $1, $2, true); - - -- its a straight line and one extreme are reachable - RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); - RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); - - - /* Points - midpoint of edge 1 (-1 by default) - */ - PREPARE expectedCost1(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, - -1, $1, 'r', true); - - RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost1(8)$$, ARRAY[2.5]::TEXT[] , 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost from midpoint on 1 to 9'); - - /* Points - midpoint of edge 1 (-2 assigned) - */ - PREPARE expectedCost2(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, - -2, $1, 'r', true); - - RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost2(8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - /* UNION ALL data is not sorted - source point of edge 10 (-1 by default) - midpoint of edge 1 (-2 by default) - */ - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, - $1, $2, 'r', true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - - /* UNION data is sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, - $1, $2, 'r', true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - /* VALUES data is not sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, - $1, $2, 'r', true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - /* Points - midpoint of edge 1 (-2 assigned) - source point of edge 10 (-1 assigned) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, - $1, $2, 'r', true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); - RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); - - ELSE - - PREPARE dijkstra1(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_dijkstraCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $1, $2, true); - - -- its a straight line and one extreme are reachable - RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); - RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); - - - /* Points - midpoint of edge 1 (-1 by default) - */ - PREPARE expectedCost1(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, - -1, $1, true); - - RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost1(8)$$, ARRAY[2.5]::TEXT[] , 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost from midpoint on 1 to 9'); - - /* Points - midpoint of edge 1 (-2 assigned) - */ - PREPARE expectedCost2(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, - -2, $1, true); - - RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost2(8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - /* UNION ALL data is not sorted - source point of edge 10 (-1 by default) - midpoint of edge 1 (-2 by default) - */ - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, - $1, $2, true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; - - /* UNION data is sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, - $1, $2, true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; - - /* VALUES data is not sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, - $1, $2, true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; - - /* Points - midpoint of edge 1 (-2 assigned) - source point of edge 10 (-1 assigned) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCost( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, - $1, $2, true); - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) - ELSE skip('Fix implemented on 3.7.1',3) END; - + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; END IF; + PREPARE dijkstra1(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_dijkstraCost( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $1, $2, true); + + -- its a straight line and one extreme are reachable + RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); + RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); + + + /* Points + midpoint of edge 1 (-1 by default) + */ + PREPARE expectedCost1(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsCost( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, + -1, $1, 'r', true); + + RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost1(8)$$, ARRAY[2.5]::TEXT[] , 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost from midpoint on 1 to 9'); + + /* Points + midpoint of edge 1 (-2 assigned) + */ + PREPARE expectedCost2(BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsCost( + $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, + -2, $1, 'r', true); + + RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost2(8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + /* UNION ALL data is not sorted + source point of edge 10 (-1 by default) + midpoint of edge 1 (-2 by default) + */ + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsCost( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, + $1, $2, 'r', true); + + RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); + + + /* UNION data is sorted + midpoint of edge 1 (-1 by default) + source point of edge 10 (-2 by default) + */ + DEALLOCATE PREPARE expectedCost3; + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsCost( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, + $1, $2, 'r', true); + + RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); + + /* VALUES data is not sorted + midpoint of edge 1 (-1 by default) + source point of edge 10 (-2 by default) + */ + DEALLOCATE PREPARE expectedCost3; + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsCost( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, + $1, $2, 'r', true); + + RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); + + /* Points + midpoint of edge 1 (-2 assigned) + source point of edge 10 (-1 assigned) + */ + DEALLOCATE PREPARE expectedCost3; + PREPARE expectedCost3(BIGINT, BIGINT) AS + SELECT agg_cost::TEXT FROM pgr_withPointsCost( + $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, + $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, + $1, $2, 'r', true); + + RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); + RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); + + RETURN QUERY SELECT set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'); + RETURN QUERY SELECT set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7'); + END; $BODY$ language plpgsql; SELECT test_cases(); - SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPointsCost/inner_query.pg b/pgtap/withPoints/withPointsCost/inner_query.pg index cf440606a97..d565d4dbb04 100644 --- a/pgtap/withPoints/withPointsCost/inner_query.pg +++ b/pgtap/withPoints/withPointsCost/inner_query.pg @@ -19,63 +19,39 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -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; - +SELECT CASE WHEN min_version('4.0.0') THEN plan(432) ELSE plan(1) END; CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - - -- ONE TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, 3, $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, 3, $$r$$, true)'); - -- ONE TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, ARRAY[3], $$r$$, true)'); - -- MANY TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], 3, $$r$$, true)'); - -- MANY TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], $$r$$, true)'); - -- COMBINATIONS - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', $$SELECT * FROM combinations$$, $$r$$, true)'); - RETURN QUERY SELECT innerquery_combinations('pgr_withPointsCost($$SELECT * FROM edges$$, $$SELECT * from pointsOfInterest$$,',', $$r$$, true)'); - - ELSE + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; + END IF; - -- ONE TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, 3, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, 3, true)'); - -- ONE TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, ARRAY[3], true)'); - -- MANY TO ONE - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], 3, true)'); - -- MANY TO MANY - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], true)'); - -- COMBINATIONS - IF min_version('3.2.0') THEN - 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; - END IF; + -- ONE TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, 3, $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, 3, $$r$$, true)'); + -- ONE TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, 2, ARRAY[3], $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', 2, ARRAY[3], $$r$$, true)'); + -- MANY TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], 3, $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], 3, $$r$$, true)'); + -- MANY TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, ARRAY[2], ARRAY[3], $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', ARRAY[2], ARRAY[3], $$r$$, true)'); + -- COMBINATIONS + RETURN QUERY SELECT style_dijkstra('pgr_withPointsCost(', ', $$SELECT * from pointsOfInterest$$, $$SELECT * FROM combinations$$, $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsCost($$SELECT * FROM edges$$,', ', $$SELECT * FROM combinations$$, $$r$$, true)'); + RETURN QUERY SELECT innerquery_combinations('pgr_withPointsCost($$SELECT * FROM edges$$, $$SELECT * from pointsOfInterest$$,',', $$r$$, true)'); END $BODY$ LANGUAGE plpgsql VOLATILE; SELECT inner_query(); - SELECT finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPointsCost/no_crash_test.pg b/pgtap/withPoints/withPointsCost/no_crash_test.pg index 1cf96d5894b..231de3c21f4 100644 --- a/pgtap/withPoints/withPointsCost/no_crash_test.pg +++ b/pgtap/withPoints/withPointsCost/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('4.0.0') THEN plan(122) WHEN min_version('3.2.0') THEN plan (102) ELSE plan(85) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(122) ELSE plan(1) END; PREPARE edges AS SELECT id, source, target, cost, reverse_cost FROM edges; @@ -41,7 +41,7 @@ PREPARE null_combinations AS SELECT source, target FROM combinations WHERE source IN (-1); -CREATE OR REPLACE FUNCTION test_new_function() +CREATE OR REPLACE FUNCTION test_function() RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -50,8 +50,7 @@ subs TEXT[]; BEGIN IF NOT min_version('4.0.0') THEN - RETURN QUERY - SELECT skip(1, 'Test for new function on 4.0.0'); + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); RETURN; END IF; @@ -190,148 +189,6 @@ END $BODY$ LANGUAGE plpgsql VOLATILE; -CREATE OR REPLACE FUNCTION test_function() -RETURNS SETOF TEXT AS -$BODY$ -DECLARE -params TEXT[]; -subs TEXT[]; -BEGIN - - IF min_version('4.0.0') THEN - RETURN QUERY SELECT test_new_function(); - RETURN; - END IF; - - RETURN QUERY - SELECT isnt_empty('edges', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT isnt_empty('pois', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); - RETURN QUERY - SELECT set_eq('null_ret_arr', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); - - -- one to one - params = ARRAY[ - '$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '5::BIGINT', - '6::BIGINT' - ]::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT', - 'NULL::BIGINT' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); - - -- one to many - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '1', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT', - 'NULL::BIGINT[]' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); - - -- many to one - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - 'ARRAY[2,5]::BIGINT[]', '1']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT[]', - 'NULL::BIGINT' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); - - -- many to many - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - 'ARRAY[1]::BIGINT[]', 'ARRAY[2,5]::BIGINT[]']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(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); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT[]', - 'NULL::BIGINT[]' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); - - -- Combinations SQL - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations functionality is new on 3.2.0'); - RETURN; - END IF; - - RETURN QUERY - SELECT isnt_empty('combinations', 'Should be not empty to tests be meaningful'); - RETURN QUERY - SELECT is_empty('null_combinations', 'Should be empty to tests be meaningful'); - - params = ARRAY['$$edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - '$$combinations$$']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '$$(SELECT source, target FROM combinations WHERE source IN (-1))$$' - ]::TEXT[]; - - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::TEXT' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCost', params, subs); - -END -$BODY$ -LANGUAGE plpgsql VOLATILE; SELECT test_function(); SELECT finish(); diff --git a/pgtap/withPoints/withPointsCost/types_check.pg b/pgtap/withPoints/withPointsCost/types_check.pg index 22c7ae2b586..d09db298674 100644 --- a/pgtap/withPoints/withPointsCost/types_check.pg +++ b/pgtap/withPoints/withPointsCost/types_check.pg @@ -19,9 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -SET client_min_messages TO WARNING; - -SELECT CASE WHEN min_version('4.0.0') THEN plan(25) ELSE plan(13) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) ELSE plan(2) END; SELECT has_function('pgr_withpointscost'); @@ -30,92 +28,38 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','bigint','bigint','character','boolean']); - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','bigint','anyarray','character','boolean']); - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','anyarray','bigint','character','boolean']); - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','anyarray','anyarray','character','boolean']); - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','text','character','boolean']); - - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','bigint','bigint','character','boolean'],'setof record'); - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','bigint','anyarray','character','boolean'],'setof record'); - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','anyarray','bigint','character','boolean'],'setof record'); - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','anyarray','anyarray','character','boolean'],'setof record'); - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','text','character','boolean'],'setof record'); - - RETURN QUERY SELECT function_args_has('pgr_withpointscost', - $$VALUES - ('{"","","","", directed,start_vid,end_vid,agg_cost}'::TEXT[]), - ('{"","","","","",directed,start_vid,end_vid,agg_cost}') - $$); - - RETURN QUERY SELECT function_types_has('pgr_withpointscost', - $$VALUES - ('{text,text,anyarray,int8, bpchar,bool,int8,int8,float8}'::TEXT[]), - ('{text,text,int8,int8, bpchar,bool,int8,int8,float8}'), - ('{text,text,int8,anyarray, bpchar,bool,int8,int8,float8}'), - ('{text,text,anyarray,anyarray,bpchar,bool,int8,int8,float8}'), - ('{text,text,text, bpchar,bool,int8,int8,float8}') - $$); - + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withpointscost: New signatures on 4.0.0'); + RETURN; END IF; - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','bigint','bigint','boolean','character']); - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','bigint','anyarray','boolean','character']); - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','anyarray','bigint','boolean','character']); - RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','anyarray','anyarray','boolean','character']); - - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','bigint','bigint','boolean','character'],'setof record'); - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','bigint','anyarray','boolean','character'],'setof record'); - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','anyarray','bigint','boolean','character'],'setof record'); - RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','anyarray','anyarray','boolean','character'],'setof record'); - - - RETURN QUERY SELECT CASE WHEN min_version('3.2.0') THEN - collect_tap( - has_function('pgr_withpointscost', ARRAY['text','text','text','boolean','character']), - function_returns('pgr_withpointscost', ARRAY['text','text','text','boolean','character'],'setof record') - ) ELSE skip(2, 'Combinations signature added on 3.1.0') END; - - RETURN QUERY SELECT - CASE WHEN min_version('3.2.0') THEN - collect_tap( - function_args_has('pgr_withpointscost', - $$VALUES - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]), - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]), - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]), - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]), - ('{"","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]) - $$), - - function_types_has('pgr_withpointscost', - $$VALUES - ('{text,text,text,bool,bpchar,int8,int8,float8}'::TEXT[]), - ('{text,text,int8,int8,bool,bpchar,int8,int8,float8}'::TEXT[]), - ('{text,text,int8,anyarray,bool,bpchar,int8,int8,float8}'::TEXT[]), - ('{text,text,anyarray,int8,bool,bpchar,int8,int8,float8}'::TEXT[]), - ('{text,text,anyarray,anyarray,bool,bpchar,int8,int8,float8}'::TEXT[]) - $$) - ) ELSE - collect_tap( - function_args_eq('pgr_withpointscost', - $$VALUES - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]), - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]), - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]), - ('{"","","","","directed","driving_side","start_pid","end_pid","agg_cost"}'::TEXT[]) - $$), + RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','bigint','bigint','character','boolean']); + RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','bigint','anyarray','character','boolean']); + RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','anyarray','bigint','character','boolean']); + RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','anyarray','anyarray','character','boolean']); + RETURN QUERY SELECT has_function('pgr_withpointscost', ARRAY['text','text','text','character','boolean']); + + RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','bigint','bigint','character','boolean'],'setof record'); + RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','bigint','anyarray','character','boolean'],'setof record'); + RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','anyarray','bigint','character','boolean'],'setof record'); + RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','anyarray','anyarray','character','boolean'],'setof record'); + RETURN QUERY SELECT function_returns('pgr_withpointscost', ARRAY['text','text','text','character','boolean'],'setof record'); + + RETURN QUERY SELECT function_args_has('pgr_withpointscost', + $$VALUES + ('{"","","","", directed,start_vid,end_vid,agg_cost}'::TEXT[]), + ('{"","","","","",directed,start_vid,end_vid,agg_cost}') + $$); + + RETURN QUERY SELECT function_types_has('pgr_withpointscost', + $$VALUES + ('{text,text,anyarray,int8, bpchar,bool,int8,int8,float8}'::TEXT[]), + ('{text,text,int8,int8, bpchar,bool,int8,int8,float8}'), + ('{text,text,int8,anyarray, bpchar,bool,int8,int8,float8}'), + ('{text,text,anyarray,anyarray,bpchar,bool,int8,int8,float8}'), + ('{text,text,text, bpchar,bool,int8,int8,float8}') + $$); - function_types_eq('pgr_withpointscost', - $$VALUES - ('{text,text,int8,int8,bool,bpchar,int8,int8,float8}'::TEXT[]), - ('{text,text,int8,anyarray,bool,bpchar,int8,int8,float8}'::TEXT[]), - ('{text,text,anyarray,int8,bool,bpchar,int8,int8,float8}'::TEXT[]), - ('{text,text,anyarray,anyarray,bool,bpchar,int8,int8,float8}'::TEXT[]) - $$) - ) END; END $BODY$ From ef5fa2369cbeef5cc3ad04c99fe750d4322ead17 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:04:00 -0600 Subject: [PATCH 24/39] (doc) pgr_withPointsCost: Adjusting documentation about driving side --- doc/withPoints/pgr_withPointsCost.rst | 47 ++++++++++++++------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/doc/withPoints/pgr_withPointsCost.rst b/doc/withPoints/pgr_withPointsCost.rst index ffe8f64a166..05ac6ff4cbe 100644 --- a/doc/withPoints/pgr_withPointsCost.rst +++ b/doc/withPoints/pgr_withPointsCost.rst @@ -27,12 +27,19 @@ given. .. rubric:: Version 4.0.0 * Function promoted to official. +* **Driving side** parameter is unnamed and compulsory. + + * Valid values depend on kind of graph + * Output columns standardized to |matrix-result| -* Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. +* Breaking change, signatures no longer available: + + * pgr_withpointscost(text,text,anyarray,anyarray,boolean,character) + * pgr_withpointscost(text,text,anyarray,bigint,boolean,character) + * pgr_withpointscost(text,text,bigint,anyarray,boolean,character) + * pgr_withpointscost(text,text,bigint,bigint,boolean,character) + * pgr_withpointscost(text,text,text,boolean,character) - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` .. rubric:: Version 3.2.0 @@ -62,8 +69,8 @@ The main characteristics are: - Vertices of the graph are: - - **positive** when it belongs to the edges sql - - **negative** when it belongs to the points sql + - **positive** when it belongs to the edges_sql + - **negative** when it belongs to the points_sql - Values are returned when there is a path. @@ -98,6 +105,8 @@ The main characteristics are: Signatures ------------------------------------------------------------------------------- +.. rubric:: Summary + .. admonition:: \ \ :class: signatures @@ -105,7 +114,7 @@ Signatures | pgr_withPointsCost(`Edges SQL`_, `Points SQL`_, **start vid**, **end vids**, **driving side** [**options**]) | pgr_withPointsCost(`Edges SQL`_, `Points SQL`_, **start vids**, **end vid**, **driving side** [**options**]) | pgr_withPointsCost(`Edges SQL`_, `Points SQL`_, **start vids**, **end vids**, **driving side** [**options**]) - | pgr_withPointsCost(`Edges SQL`_, `Points SQL`_, `Combinations SQL`_, [**options**]) + | pgr_withPointsCost(`Edges SQL`_, `Points SQL`_, `Combinations SQL`_, **driving side** [**options**]) | **options:** ``[directed]`` | Returns set of |matrix-result| @@ -129,7 +138,7 @@ One to One | Returns set of |matrix-result| | OR EMPTY SET -:Example: From point :math:`1` to vertex :math:`10` with default options. +.. rubric:: From point :math:`1` to vertex :math:`10` with right driving side in directed graph. .. literalinclude:: withPointsCost.queries :start-after: -- q1 @@ -144,14 +153,14 @@ One to Many .. admonition:: \ \ :class: signatures - pgr_withPointsCost(`Edges SQL`_, `Points SQL`_, **start vid**, **end vids**, **driving side** [**options**]) + | pgr_withPointsCost(`Edges SQL`_, `Points SQL`_, **start vid**, **end vids**, **driving side** [**options**]) | **options:** ``[directed]`` | Returns set of |matrix-result| | OR EMPTY SET -:Example: From point :math:`1` to point :math:`3` and vertex :math:`7` on an - undirected graph +.. rubric:: From point :math:`1` to point :math:`3` and vertex :math:`7` on an + undirected graph .. literalinclude:: withPointsCost.queries :start-after: -- q2 @@ -172,7 +181,7 @@ Many to One | Returns set of |matrix-result| | OR EMPTY SET -:Example: From point :math:`1` and vertex :math:`6` to point :math:`3` +:Example: From point :math:`1` and vertex :math:`6` to point :math:`3` with right driving side in directed graph. .. literalinclude:: withPointsCost.queries :start-after: -- q3 @@ -194,7 +203,7 @@ Many to Many | OR EMPTY SET :Example: From point :math:`1` and vertex :math:`6` to point :math:`3` and - vertex :math:`1` + vertex :math:`1` with left side driving. .. literalinclude:: withPointsCost.queries :start-after: -- q4 @@ -218,7 +227,7 @@ Combinations :Example: Two combinations From point :math:`1` to vertex :math:`10`, and from vertex :math:`6` to point -:math:`3` with **right** side driving. +:math:`3` with right side driving. .. literalinclude:: withPointsCost.queries :start-after: -- q5 @@ -238,13 +247,6 @@ Optional parameters :start-after: dijkstra_optionals_start :end-before: dijkstra_optionals_end -With points optional parameters -............................................................................... - -.. include:: withPoints-family.rst - :start-after: withPoints_optionals_start - :end-before: * - ``details - Inner Queries ------------------------------------------------------------------------------- @@ -326,12 +328,13 @@ Traveling from point :math:`1` and vertex :math:`5` to points :math:`\{2, 3, :start-after: -- q8 :end-before: -- q9 -:doc:`sampledata` See Also ------------------------------------------------------------------------------- * :doc:`withPoints-family` +* :doc:`cost-category` +* :doc:`sampledata` .. rubric:: Indices and tables From 92c95a9d6cadf8a94050a63f4d373aa0c7727e5b Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 25/39] (sql) pgr_withPointsCostMatrix: Driving side is compulsory unnamed - keeping old C code - Removing functions with driving_side optional named --- sql/withPoints/withPointsCostMatrix.sql | 35 ++----------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/sql/withPoints/withPointsCostMatrix.sql b/sql/withPoints/withPointsCostMatrix.sql index 3b5e7768d21..ea8f89a96f0 100644 --- a/sql/withPoints/withPointsCostMatrix.sql +++ b/sql/withPoints/withPointsCostMatrix.sql @@ -54,40 +54,9 @@ IS'pgr_withPointsCostMatrix - Edges SQL with columns: id, source, target, cost [,reverse_cost] - Points SQL with columns: [pid], edge_id, fraction [,side] - ARRAY [vertex/points identifiers], - - driving side: directed graph [r,l], undirected graph [b] -- Optional Parameters + - Driving side: directed graph [r,l], undirected graph [b] +- Optional Parameters: - directed => true - Documentation: - ${PROJECT_DOC_LINK}/pgr_withPointsCostMatrix.html '; - -/* TODO remove in v5.0 */ ---------------------------- --- pgr_withPointsCostMatrix ---------------------------- - ---v2.6 -CREATE FUNCTION pgr_withPointsCostMatrix( - TEXT, -- edges_sql (required) - TEXT, -- points_sql (required) - ANYARRAY, -- pids (required) - - directed BOOLEAN DEFAULT true, - driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL - - OUT start_vid BIGINT, - OUT end_vid BIGINT, - OUT agg_cost float) -RETURNS SETOF RECORD AS -$BODY$ - SELECT a.start_pid, a.end_pid, a.agg_cost - FROM _pgr_withPoints(_pgr_get_statement($1), _pgr_get_statement($2), $3, $3, $4, $5, TRUE, TRUE) AS a; -$BODY$ -LANGUAGE SQL VOLATILE STRICT -COST 100 -ROWS 1000; - --- COMMENTS - -COMMENT ON FUNCTION pgr_withPointsCostMatrix(TEXT, TEXT, ANYARRAY, BOOLEAN, CHAR) -IS 'pgr_withPointsCostMatrix deprecated signature on v4.0.0'; From 1f666805bce1599e542b8426669deecb9c668082 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 26/39] (pgtap) pgr_withPointsCostMatrix: test the new signatures with unamed driving side --- .../edge_cases/point_in_vertex.pg | 156 +----------------- .../withPointsCostMatrix/inner_query.pg | 14 +- .../withPointsCostMatrix/no_crash_test.pg | 71 +++----- .../withPointsCostMatrix/types_check.pg | 30 ++-- 4 files changed, 49 insertions(+), 222 deletions(-) diff --git a/pgtap/withPoints/withPointsCostMatrix/edge_cases/point_in_vertex.pg b/pgtap/withPoints/withPointsCostMatrix/edge_cases/point_in_vertex.pg index 02a5925f02c..1728af2cd80 100644 --- a/pgtap/withPoints/withPointsCostMatrix/edge_cases/point_in_vertex.pg +++ b/pgtap/withPoints/withPointsCostMatrix/edge_cases/point_in_vertex.pg @@ -20,17 +20,22 @@ BEGIN; SET extra_float_digits=-3; -SELECT plan(38); +SELECT CASE WHEN min_version('4.0.0') THEN plan(38) ELSE plan(1) END; CREATE VIEW four_edges AS SELECT * FROM edges WHERE id IN (1,4,10,14); -CREATE OR REPLACE FUNCTION test_cases_new() +CREATE OR REPLACE FUNCTION test_cases() RETURNS SETOF TEXT AS $BODY$ BEGIN + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPointsCostMatrix: New signatures on 4.0.0'); + RETURN; + END IF; + PREPARE dijkstra1(BIGINT, BIGINT) AS SELECT agg_cost::TEXT FROM pgr_dijkstraCostMatrix( $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, @@ -151,153 +156,6 @@ $BODY$ language plpgsql; -CREATE OR REPLACE FUNCTION test_cases() -RETURNS SETOF TEXT AS -$BODY$ -BEGIN - - IF min_version('4.0.0') THEN - RETURN QUERY SELECT test_cases_new(); - RETURN; - END IF; - - PREPARE dijkstra1(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_dijkstraCostMatrix( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - ARRAY[$1, $2], true) LIMIT 1; - - -- its a straight line and one extreme are reachable - RETURN QUERY SELECT results_eq($$dijkstra1(5,9)$$, ARRAY[4]::TEXT[]); - RETURN QUERY SELECT results_eq($$dijkstra1(9,5)$$, ARRAY[4]::TEXT[]); - - /* Points - midpoint of edge 1 (-1 by default) - */ - PREPARE expectedCost1(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCostMatrix( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 1 AS edge_id, 0.5::float AS fraction$$, - ARRAY[-1, $1], true) LIMIT 1; - - RETURN QUERY SELECT results_eq($$expectedCost1(6)$$, ARRAY[0.5]::TEXT[], 'Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost1(7)$$, ARRAY[1.5]::TEXT[] , 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost1(8)$$, ARRAY[2.5]::TEXT[] , 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost1(9)$$, ARRAY[3.5]::TEXT[] , 'Cost from midpoint on 1 to 9'); - - /* Points - midpoint of edge 1 (-2 assigned) - */ - PREPARE expectedCost2(BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCostMatrix( - $$ SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$ SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction$$, - ARRAY[-2, $1], true) LIMIT 1; - - RETURN QUERY SELECT results_eq($$expectedCost2(6)$$, $$expectedCost1(6)$$, 'Cost from midpoint on 1 (-2 assigned) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost2(7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost2(8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost2(9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - /* UNION ALL data is not sorted - source point of edge 10 (-1 by default) - midpoint of edge 1 (-2 by default) - */ - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCostMatrix( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION ALL SELECT 1, 0.5 $$, - ARRAY[$1, $2], true)LIMIT 1; - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(UNION ALL) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) ELSE skip('Fix implemented on 3.7.1',3) END; - - /* UNION data is sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCostMatrix( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 10 AS edge_id, 0::float AS fraction UNION SELECT 1, 0.5 $$, - ARRAY[$1, $2], true) LIMIT 1; - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(UNION) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) ELSE skip('Fix implemented on 3.7.1',3) END; - - /* VALUES data is not sorted - midpoint of edge 1 (-1 by default) - source point of edge 10 (-2 by default) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCostMatrix( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT * FROM (VALUES (1,0.5), (10, 0)) AS t (edge_id, fraction)$$, - ARRAY[$1, $2], true) LIMIT 1; - - RETURN QUERY SELECT results_eq($$expectedCost3(-1,6)$$, $$expectedCost1(6)$$, '(VALUES) Cost from midpoint on 1 (-1 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-1,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-2,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-2,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-2,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) ELSE skip('Fix implemented on 3.7.1',3) END; - - /* Points - midpoint of edge 1 (-2 assigned) - source point of edge 10 (-1 assigned) - */ - DEALLOCATE PREPARE expectedCost3; - PREPARE expectedCost3(BIGINT, BIGINT) AS - SELECT agg_cost::TEXT FROM pgr_withPointsCostMatrix( - $$SELECT id, source, target, cost, reverse_cost FROM four_edges$$, - $$SELECT 2 AS pid, 1 AS edge_id, 0.5::float AS fraction UNION SELECT 1, 10, 0 $$, - ARRAY[$1, $2], true) LIMIT 1; - - RETURN QUERY SELECT results_eq($$expectedCost3(-2,6)$$, $$expectedCost1(6)$$, '(ASSIGNED) Cost from midpoint on 1 (-2 default) to 6'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,7)$$, $$expectedCost1(7)$$, 'Cost from midpoint on 1 to 7'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,8)$$, $$expectedCost1(8)$$, 'Cost from midpoint on 1 to 8'); - RETURN QUERY SELECT results_eq($$expectedCost3(-2,9)$$, $$expectedCost1(9)$$, 'Cost from midpoint on 1 to 9'); - - RETURN QUERY SELECT CASE WHEN min_version('3.7.1') - THEN - collect_tap( - set_eq($$expectedCost3(-1,9)$$, $$dijkstra1(7,9)$$, 'Cost from target on 10 (-1 default, aka 7) to 9'), - set_eq($$expectedCost3(-1,8)$$, $$dijkstra1(7,8)$$, 'Cost from target on 10 to 8'), - set_eq($$expectedCost3(-1,7)$$, ARRAY[0]::TEXT[], 'Cost from target on 10 to 7') - ) ELSE skip('Fix implemented on 3.7.1',3) END; - -END; -$BODY$ -language plpgsql; - SELECT test_cases(); - SELECT finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPointsCostMatrix/inner_query.pg b/pgtap/withPoints/withPointsCostMatrix/inner_query.pg index 6b2db75fbbe..cf254f95e70 100644 --- a/pgtap/withPoints/withPointsCostMatrix/inner_query.pg +++ b/pgtap/withPoints/withPointsCostMatrix/inner_query.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(84); +SELECT CASE WHEN min_version('4.0.0') THEN plan(84) ELSE plan(1) END; CREATE OR REPLACE FUNCTION inner_query() @@ -28,14 +28,14 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCostMatrix(', ', $$SELECT * from pointsOfInterest$$, ARRAY[1,2,3,4], $$r$$, true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCostMatrix($$SELECT * FROM edges$$,', ', ARRAY[1,2,3,4], $$r$$, true)'); - ELSE - RETURN QUERY SELECT style_dijkstra('pgr_withPointsCostMatrix(', ', $$SELECT * from pointsOfInterest$$, ARRAY[1,2,3,4], true)'); - RETURN QUERY SELECT innerquery_points('pgr_withPointsCostMatrix($$SELECT * FROM edges$$,', ', ARRAY[1,2,3,4], true)'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; END IF; + RETURN QUERY SELECT style_dijkstra('pgr_withPointsCostMatrix(', ', $$SELECT * from pointsOfInterest$$, ARRAY[1,2,3,4], $$r$$, true)'); + RETURN QUERY SELECT innerquery_points('pgr_withPointsCostMatrix($$SELECT * FROM edges$$,', ', ARRAY[1,2,3,4], $$r$$, true)'); + END $BODY$ LANGUAGE plpgsql VOLATILE; diff --git a/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg b/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg index 69b2be607de..3c3dba14b17 100644 --- a/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg +++ b/pgtap/withPoints/withPointsCostMatrix/no_crash_test.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT CASE WHEN min_version('4.0.0') THEN plan(23) ELSE plan(19) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(20) ELSE plan(1) END; PREPARE edges AS SELECT id, source, target, cost, reverse_cost FROM edges; @@ -31,11 +31,6 @@ SELECT pid, edge_id, fraction from pointsOfInterest; PREPARE null_ret AS 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'); -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$ @@ -43,54 +38,38 @@ DECLARE params TEXT[]; subs TEXT[]; BEGIN - IF min_version('4.0.0') THEN - params = ARRAY[ - '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - 'ARRAY[5,6]','$$r$$']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', - 'NULL' - ]::TEXT[]; - - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCostMatrix', params, subs); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT[]', - 'NULL' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCostMatrix', params, subs); - ELSE - params = ARRAY[ - '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', - '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', - 'ARRAY[5,6]']::TEXT[]; - subs = ARRAY[ - 'NULL', - 'NULL', - '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCostMatrix', params, subs); - - subs = ARRAY[ - 'NULL', - 'NULL', - 'NULL::BIGINT[]' - ]::TEXT[]; - RETURN query SELECT * FROM no_crash_test('pgr_withPointsCostMatrix', params, subs); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withPoints: New signatures on 4.0.0'); + RETURN; END IF; + params = ARRAY[ + '$$SELECT id, source, target, cost, reverse_cost FROM edges$$', + '$$SELECT pid, edge_id, fraction from pointsOfInterest$$', + 'ARRAY[5,6]','$$r$$']::TEXT[]; + subs = ARRAY[ + 'NULL', + 'NULL', + '(SELECT array_agg(id) FROM vertices WHERE id IN (-1))', + 'NULL' + ]::TEXT[]; + + RETURN query SELECT * FROM no_crash_test('pgr_withPointsCostMatrix', params, subs); + + subs = ARRAY[ + 'NULL', + 'NULL', + 'NULL::BIGINT[]', + 'NULL' + ]::TEXT[]; + RETURN query SELECT * FROM no_crash_test('pgr_withPointsCostMatrix', params, subs); + END $BODY$ LANGUAGE plpgsql VOLATILE; SELECT * FROM test_function(); - SELECT finish(); ROLLBACK; diff --git a/pgtap/withPoints/withPointsCostMatrix/types_check.pg b/pgtap/withPoints/withPointsCostMatrix/types_check.pg index 12690ffbd96..5d30e86bca5 100644 --- a/pgtap/withPoints/withPointsCostMatrix/types_check.pg +++ b/pgtap/withPoints/withPointsCostMatrix/types_check.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('4.0.0') THEN plan(9) ELSE plan(5) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(5) ELSE plan(2) END; SELECT has_function('pgr_withpointscostmatrix'); @@ -28,36 +28,26 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF min_version('4.0.0') THEN - - RETURN QUERY SELECT has_function('pgr_withpointscostmatrix', ARRAY['text','text','anyarray','character','boolean']); - RETURN QUERY SELECT function_returns('pgr_withpointscostmatrix', ARRAY['text','text','anyarray','character','boolean'],'setof record'); - - RETURN QUERY SELECT function_args_has('pgr_withpointscostmatrix', - $$VALUES - ('{"","","","",directed,start_vid,end_vid,agg_cost}'::TEXT[]) - $$); - - RETURN QUERY SELECT function_types_has('pgr_withpointscostmatrix', - $$VALUES - ('{text,text,anyarray,bpchar,bool,int8,int8,float8}'::TEXT[]) - $$); - + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_withpointscostmatrix: New signatures on 4.0.0'); + RETURN; END IF; - RETURN QUERY SELECT has_function('pgr_withpointscostmatrix', ARRAY['text','text','anyarray','boolean','character']); - RETURN QUERY SELECT function_returns('pgr_withpointscostmatrix', ARRAY['text','text','anyarray','boolean','character'],'setof record'); + + RETURN QUERY SELECT has_function('pgr_withpointscostmatrix', ARRAY['text','text','anyarray','character','boolean']); + RETURN QUERY SELECT function_returns('pgr_withpointscostmatrix', ARRAY['text','text','anyarray','character','boolean'],'setof record'); RETURN QUERY SELECT function_args_has('pgr_withpointscostmatrix', $$VALUES - ('{"","","",directed,driving_side,start_vid,end_vid,agg_cost}'::TEXT[]) + ('{"","","","",directed,start_vid,end_vid,agg_cost}'::TEXT[]) $$); RETURN QUERY SELECT function_types_has('pgr_withpointscostmatrix', $$VALUES - ('{text,text,anyarray,bool,bpchar,int8,int8,float8}'::TEXT[]) + ('{text,text,anyarray,bpchar,bool,int8,int8,float8}'::TEXT[]) $$); + END $BODY$ LANGUAGE plpgsql VOLATILE; From b0a3dfc6b8b159f9e0c033fff9fc44c7c1296384 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:04:00 -0600 Subject: [PATCH 27/39] (doc) pgr_withPointsCostMatrix: Adjusting documentation about driving side --- doc/withPoints/pgr_withPointsCostMatrix.rst | 64 +++------------------ 1 file changed, 8 insertions(+), 56 deletions(-) diff --git a/doc/withPoints/pgr_withPointsCostMatrix.rst b/doc/withPoints/pgr_withPointsCostMatrix.rst index 0a07744130c..9834cfc49ee 100644 --- a/doc/withPoints/pgr_withPointsCostMatrix.rst +++ b/doc/withPoints/pgr_withPointsCostMatrix.rst @@ -26,12 +26,13 @@ .. rubric:: Version 4.0.0 * Function promoted to official. +* **Driving side** parameter is positional unnamed and compulsory. + + * Valid values depend on kind of graph * Output columns standardized to |matrix-result| -* Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. +* Breaking change, signatures no longer available: - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` + * pgr_withpointscostmatrix(text,text,anyarray,boolean,character) .. rubric:: Version 2.2.0 @@ -40,50 +41,7 @@ Description ------------------------------------------------------------------------------- -Modify the graph to include points defined by points_sql. -Using Dijkstra algorithm, return calculate and return a cost matrix. - -The main characteristics are: - -- Process is done only on edges with positive costs. -- It does not return a path. -- Returns the sum of the costs of the shortest path for pair combination of - vertices in the modified graph. - - - The returned values are in the form of a set of |matrix-result|. - -- Vertices of the graph are: - - - **positive** when it belongs to the edges sql - - **negative** when it belongs to the points sql - -- Values are returned when there is a path. - - - When the starting vertex and ending vertex are the same, there is no path. - - - The `agg_cost` in the non included values `(v, v)` is `0` - - - When the starting vertex and ending vertex are the different and there is no - path: - - - The `agg_cost` in the non included values `(u, v)` is :math:`\infty` - - - If the values returned are stored in a table, the unique index would be the - pair: `(start_vid, end_vid)`. - - - For **undirected** graphs, the results are **symmetric**. - - - The `agg_cost` of `(u, v)` is the same as for `(v, u)`. - -- For optimization purposes, any duplicated value in the input arrays of **start vids** or - **end vids** or are ignored. - -- The returned values are ordered: - - - `start_vid` ascending - - `end_vid` ascending - -- Running time: :math:`O(|start\_vids|\times(V \log V + E))` +Using Dijkstra algorithm, calculate and return a cost matrix. .. include:: dijkstra-family.rst :start-after: dijkstra_description_start @@ -101,7 +59,7 @@ Signatures .. admonition:: \ \ :class: signatures - | pgr_withPointsCostMatrix(`Edges SQL`_, `Points SQL`_, **start vids**, **driving side** [**options**]) + | pgr_withPointsCostMatrix(`Edges SQL`_, `Points SQL`_, **start vids**, **driving side** [**options**]) | **options:** ``[directed]`` | Returns set of |matrix-result| @@ -135,13 +93,6 @@ Optional parameters :start-after: dijkstra_optionals_start :end-before: dijkstra_optionals_end -With points optional parameters -............................................................................... - -.. include:: withPoints-family.rst - :start-after: withPoints_optionals_start - :end-before: * - ``details - Inner Queries ------------------------------------------------------------------------------- @@ -184,6 +135,7 @@ locations on the graph of point `(2.9, 1.8)`. * Point :math:`-1` corresponds to the closest edge from point `(2.9, 1.8)`. * Point :math:`-2` corresponds to the next close edge from point `(2.9, 1.8)`. +* Being close to the graph does not mean have a shorter route. Use with :doc:`pgr_TSP`. ............................................................................... From a9a969c485ad5aeec57d5db88463e1bdfe5293f6 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:04:02 -0600 Subject: [PATCH 28/39] (src) Using ERRCODE_WARNING_DEPRECATED_FEATURE for deprecated function - keeping old C code - Removing functions with driving_side optional named --- src/dijkstra/dijkstra.c | 16 ++++++++-------- src/driving_distance/driving_distance.c | 16 +++++++++------- src/spanningTree/kruskal.c | 15 +++++++++------ src/spanningTree/prim.c | 16 ++++++++++------ 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/dijkstra/dijkstra.c b/src/dijkstra/dijkstra.c index b3cf699f0c5..e71a6a8c4ce 100644 --- a/src/dijkstra/dijkstra.c +++ b/src/dijkstra/dijkstra.c @@ -181,20 +181,20 @@ _pgr_dijkstra(PG_FUNCTION_ARGS) { Path_rt *result_tuples = NULL; size_t result_count = 0; -#ifdef SHOWMSG - ereport(NOTICE, ( - errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), - errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), - errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), - errhint("Consider upgrade pgRouting"))); -#endif - if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); char *driving_side = " "; +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "4.0.0"), + errhint("Consider upgrade pgRouting"))); +#endif + if (PG_NARGS() == 7) { pgr_process_shortestPath( text_to_cstring(PG_GETARG_TEXT_P(0)), diff --git a/src/driving_distance/driving_distance.c b/src/driving_distance/driving_distance.c index 6a03b892465..e6bf5f0f196 100644 --- a/src/driving_distance/driving_distance.c +++ b/src/driving_distance/driving_distance.c @@ -163,6 +163,8 @@ _pgr_drivingdistancev4(PG_FUNCTION_ARGS) { /* Deprecated code starts here * This code is used on v3.5 and under * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING * TODO(v5) Move to legacy */ @@ -177,20 +179,20 @@ _pgr_drivingdistance(PG_FUNCTION_ARGS) { MST_rt *result_tuples = 0; size_t result_count = 0; - ereport(NOTICE, ( - errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), - errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.6.0"), - errhint("Consider upgrade pgRouting"))); - if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.6.0"), + errhint("Consider upgrade pgRouting"))); +#endif - PGR_DBG("Calling driving_many_to_dist_driver"); process( text_to_cstring(PG_GETARG_TEXT_P(0)), PG_GETARG_ARRAYTYPE_P(1), diff --git a/src/spanningTree/kruskal.c b/src/spanningTree/kruskal.c index aa5bb47dfa9..50e1e48236f 100644 --- a/src/spanningTree/kruskal.c +++ b/src/spanningTree/kruskal.c @@ -173,6 +173,8 @@ PGDLLEXPORT Datum _pgr_kruskalv4(PG_FUNCTION_ARGS) { /* Deprecated code starts here * This code is used on v3.6 and under * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING * TODO(v5) Move to legacy */ @@ -186,17 +188,18 @@ PGDLLEXPORT Datum _pgr_kruskal(PG_FUNCTION_ARGS) { MST_rt *result_tuples = NULL; size_t result_count = 0; - ereport(NOTICE, ( - errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), - errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.7.0"), - errhint("Consider upgrade pgRouting"))); - if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.7.0"), + errhint("Consider upgrade pgRouting"))); +#endif /* Edge sql, tree roots, fn_suffix, max_depth, distance */ process( diff --git a/src/spanningTree/prim.c b/src/spanningTree/prim.c index d8030ed9b25..9f8d79f0444 100644 --- a/src/spanningTree/prim.c +++ b/src/spanningTree/prim.c @@ -174,6 +174,8 @@ PGDLLEXPORT Datum _pgr_primv4(PG_FUNCTION_ARGS) { /* Deprecated code starts here * This code is used on v3.6 and under * + * TODO(v4.2) define SHOWMSG + * TODO(v4.3) change to WARNING * TODO(v5) Move to legacy */ @@ -187,17 +189,19 @@ PGDLLEXPORT Datum _pgr_prim(PG_FUNCTION_ARGS) { MST_rt *result_tuples = NULL; size_t result_count = 0; - ereport(NOTICE, ( - errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), - errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.7.0"), - errhint("Consider upgrade pgRouting"))); - if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); +#ifdef SHOWMSG + ereport(NOTICE, ( + errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), + errmsg("A stored procedure is using deprecated C internal function '%s'", __func__), + errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.7.0"), + errhint("Consider upgrade pgRouting"))); +#endif + process( text_to_cstring(PG_GETARG_TEXT_P(0)), PG_GETARG_ARRAYTYPE_P(1), From 07a4a9df013c9fa71b93a9eca9d8294e0290aade Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 29/39] (build) Adjusting script to build-extension-update-files - keeping old C code - Removing functions with driving_side optional named --- sql/scripts/build-extension-update-files.pl | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/sql/scripts/build-extension-update-files.pl b/sql/scripts/build-extension-update-files.pl index ef96d1e3dc3..f646e17695e 100755 --- a/sql/scripts/build-extension-update-files.pl +++ b/sql/scripts/build-extension-update-files.pl @@ -277,10 +277,6 @@ sub generate_upgrade_script { # Out parameters changed names on v4.0.0 # Experimental functions push @commands, drop_special_case_function("pgr_dagshortestpath(text,text)"); - - # Official functions - push @commands, drop_special_case_function("pgr_withpoints(text,text,text,boolean,character,boolean)"); - push @commands, drop_special_case_function("pgr_withpointscost(text,text,text,boolean,character)"); } # Row type defined by OUT parameters is different. @@ -308,19 +304,6 @@ sub generate_upgrade_script { push @commands, drop_special_case_function("pgr_bddijkstra(text,bigint,bigint,boolean)"); push @commands, drop_special_case_function("pgr_bddijkstra(text,anyarray,bigint,boolean)"); push @commands, drop_special_case_function("pgr_bddijkstra(text,bigint,anyarray,boolean)"); - - push @commands, drop_special_case_function("pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean)"); - push @commands, drop_special_case_function("pgr_withpoints(text,text,anyarray,bigint,boolean,character,boolean)"); - push @commands, drop_special_case_function("pgr_withpoints(text,text,bigint,anyarray,boolean,character,boolean)"); - push @commands, drop_special_case_function("pgr_withpoints(text,text,bigint,bigint,boolean,character,boolean)"); - - push @commands, drop_special_case_function("pgr_withpointscost(text,text,anyarray,anyarray,boolean,character)"); - push @commands, drop_special_case_function("pgr_withpointscost(text,text,anyarray,bigint,boolean,character)"); - push @commands, drop_special_case_function("pgr_withpointscost(text,text,bigint,anyarray,boolean,character)"); - push @commands, drop_special_case_function("pgr_withpointscost(text,text,bigint,bigint,boolean,character)"); - - - push @commands, drop_special_case_function("pgr_withpointscostmatrix(text,text,anyarray,boolean,character)"); } } From 18ef7a3c817e68b92d8e44236ee80f4398fea29f Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:02:06 -0600 Subject: [PATCH 30/39] (signatures) pgrouting--4.0: Adjusting for changes because of driving side compulsory - keeping old C code - Removing functions with driving_side optional named --- sql/sigs/pgrouting--4.0.sig | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/sql/sigs/pgrouting--4.0.sig b/sql/sigs/pgrouting--4.0.sig index 749b9723cd4..b8c9d53666d 100644 --- a/sql/sigs/pgrouting--4.0.sig +++ b/sql/sigs/pgrouting--4.0.sig @@ -252,15 +252,15 @@ _pgr_trspv4(text,text,anyarray,anyarray,boolean) _pgr_trspv4(text,text,text,boolean) _pgr_trspvia(text,text,anyarray,boolean,boolean,boolean) pgr_trspvia(text,text,anyarray,boolean,boolean,boolean) -_pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) -pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) -_pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) -pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) -pgr_trsp_withpoints(text,text,text,anyarray,bigint,boolean,character,boolean) -pgr_trsp_withpoints(text,text,text,bigint,anyarray,boolean,character,boolean) -pgr_trsp_withpoints(text,text,text,bigint,bigint,boolean,character,boolean) -_pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) -pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) +pgr_trspvia_withpoints(text,text,text,anyarray,character,boolean,boolean,boolean,boolean) +_pgr_trspvia_withpoints_v4(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) +pgr_trsp_withpoints(text,text,text,anyarray,anyarray,character,boolean,boolean) +pgr_trsp_withpoints(text,text,text,anyarray,bigint,character,boolean,boolean) +pgr_trsp_withpoints(text,text,text,bigint,anyarray,character,boolean,boolean) +pgr_trsp_withpoints(text,text,text,bigint,bigint,character,boolean,boolean) +pgr_trsp_withpoints(text,text,text,text,character,boolean,boolean) +_pgr_trsp_withpoints_v4(text,text,text,anyarray,anyarray,boolean,character,boolean) +_pgr_trsp_withpoints_v4(text,text,text,text,boolean,character,boolean) pgr_tspeuclidean(text,bigint,bigint) _pgr_tspeuclidean_v4(text,bigint,bigint) pgr_tsp(text,bigint,bigint) @@ -270,17 +270,11 @@ pgr_turnrestrictedpath(text,text,bigint,bigint,integer,boolean,boolean,boolean,b pgr_version() _pgr_vrponedepot(text,text,text,integer) pgr_vrponedepot(text,text,text,integer) -pgr_withpointscostmatrix(text,text,anyarray,boolean,character) pgr_withpointscostmatrix(text,text,anyarray,character,boolean) -pgr_withpointscost(text,text,anyarray,anyarray,boolean,character) pgr_withpointscost(text,text,anyarray,anyarray,character,boolean) -pgr_withpointscost(text,text,anyarray,bigint,boolean,character) pgr_withpointscost(text,text,anyarray,bigint,character,boolean) -pgr_withpointscost(text,text,bigint,anyarray,boolean,character) pgr_withpointscost(text,text,bigint,anyarray,character,boolean) -pgr_withpointscost(text,text,bigint,bigint,boolean,character) pgr_withpointscost(text,text,bigint,bigint,character,boolean) -pgr_withpointscost(text,text,text,boolean,character) pgr_withpointscost(text,text,text,character,boolean) pgr_withpointsdd(text,text,anyarray,double precision,character,boolean,boolean,boolean) pgr_withpointsdd(text,text,bigint,double precision,character,boolean,boolean) @@ -292,19 +286,14 @@ pgr_withpointsksp(text,text,bigint,bigint,integer,character,boolean,boolean,bool pgr_withpointsksp(text,text,text,integer,character,boolean,boolean,boolean) _pgr_withpointsksp_v4(text,text,anyarray,anyarray,integer,character,boolean,boolean,boolean) _pgr_withpointsksp_v4(text,text,text,integer,character,boolean,boolean,boolean) -pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean) _pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean,boolean,boolean) pgr_withpoints(text,text,anyarray,anyarray,character,boolean,boolean) -pgr_withpoints(text,text,anyarray,bigint,boolean,character,boolean) pgr_withpoints(text,text,anyarray,bigint,character,boolean,boolean) -pgr_withpoints(text,text,bigint,anyarray,boolean,character,boolean) pgr_withpoints(text,text,bigint,anyarray,character,boolean,boolean) -pgr_withpoints(text,text,bigint,bigint,boolean,character,boolean) pgr_withpoints(text,text,bigint,bigint,character,boolean,boolean) -pgr_withpoints(text,text,text,boolean,character,boolean) _pgr_withpoints(text,text,text,boolean,character,boolean,boolean) pgr_withpoints(text,text,text,character,boolean,boolean) _pgr_withpoints_v4(text,text,anyarray,anyarray,boolean,character,boolean,boolean,boolean,bigint,boolean) _pgr_withpoints_v4(text,text,text,boolean,character,boolean,boolean,bigint,boolean) -_pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) -pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) +pgr_withpointsvia(text,text,anyarray,character,boolean,boolean,boolean,boolean) +_pgr_withpointsvia_v4(text,text,anyarray,boolean,boolean,boolean,character,boolean) From b2ae39963ac21e3793585a344af4de629f8de469 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:30:58 -0600 Subject: [PATCH 31/39] (tools) Adjusting function tests because of driving side --- tools/testers/general_pgtap_tests.sql | 135 ++++++++++++++++++++++++++ tools/testers/types_check.sql | 79 ++++++++------- tools/testers/via_compare.sql | 42 ++++---- 3 files changed, 205 insertions(+), 51 deletions(-) diff --git a/tools/testers/general_pgtap_tests.sql b/tools/testers/general_pgtap_tests.sql index c329e76f1ce..298354e79e6 100644 --- a/tools/testers/general_pgtap_tests.sql +++ b/tools/testers/general_pgtap_tests.sql @@ -142,3 +142,138 @@ BEGIN $$, $1, $3); END $BODY$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION test_drivingSide(fn TEXT) +RETURNS SETOF TEXT AS +$BODY$ +DECLARE + query_sql TEXT; + data TEXT := $$ARRAY[-6, 15, -5], -3$$; +BEGIN + + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'New signatures on 4.0.0'); + RETURN; + END IF; + + query_sql := $$SELECT * FROM $$ || fn || $$('edges_sql',$$; + IF fn ilike '%trsp%' THEN + query_sql := query_sql ||$$ 'restrictions_sql', $$; + END IF; + + IF fn ilike '%matrix%' OR fn ilike '%via%' THEN + data := $$ARRAY[-6, 15, -5]$$; + END IF; + + IF fn ilike '%dd%' THEN + data := $$ARRAY[-6, 15, -5], 3$$; + END IF; + + IF fn ilike '%ksp%' THEN + data := $$ARRAY[-6, 15, -5], 3, 2$$; + END IF; + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'r')$$, + fn || ': right driving side on default directed graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'r', true)$$, + fn || ': right driving side on directed graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'R')$$, + fn || ': Right driving side on default directed graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'R', true)$$, + fn || ': Right driving side on directed graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'l')$$, + fn || ': left driving side on default directed graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'l', true)$$, + fn || ': left driving side on directed graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'L')$$, + fn || ': Left driving side on default directed graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'L', true)$$, + fn || ': Left driving side on directed graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'b')$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': both driving side not allowed on default directed graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'B')$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': Both driving side not allowed on default directed graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'w')$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': wrong driving side not allowed on default directed graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'W')$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': Wrong driving side not allowed on default directed graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, '')$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': empty driving side not allowed on undirected graph'); + + -- undirected graph + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'b', false)$$, + fn || ': both driving side on undirected graph'); + + RETURN QUERY SELECT lives_ok( + query_sql || $$'points_sql', $$ || data || $$, 'B', false)$$, + fn || ': Both driving side on undirected graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'r', false)$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': right driving side not allowed on undirected graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'R', false)$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': Right driving side not allowed on undirected graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'l', false)$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': left driving side not allowed on undirected graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'L', false)$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': Left driving side not allowed on undirected graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'w', false)$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': wrong driving side not allowed on undirected graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, 'W', false)$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': Wrong driving side not allowed on undirected graph'); + + RETURN QUERY SELECT throws_ok( + query_sql || $$'points_sql', $$ || data || $$, '', false)$$, + 'XX000', $$Invalid value of 'driving side'$$, + fn || ': empty driving side not allowed on undirected graph'); + +END; +$BODY$ +LANGUAGE plpgsql; diff --git a/tools/testers/types_check.sql b/tools/testers/types_check.sql index 6a73a5f10f3..2de0eb4a9a1 100644 --- a/tools/testers/types_check.sql +++ b/tools/testers/types_check.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE FUNCTION single_path_types_check( opt_names TEXT[] DEFAULT '{directed}'::TEXT[], opt_types TEXT[] DEFAULT '{bool}'::TEXT[], created_v TEXT DEFAULT '3.0.0', - standard_v TEXT default '4.0.0') + standard_v TEXT default '3.0.0') RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -17,6 +17,18 @@ DECLARE bounds INTEGER := array_length(opt_names, 1); BEGIN + IF NOT min_version(created_v) THEN + RETURN QUERY SELECT skip(1, fn || ': Created on version ' || created_v); + RETURN; + END IF; + + RETURN QUERY SELECT has_function(fn); + + IF NOT min_version(standard_v) THEN + RETURN QUERY SELECT skip(1, fn || ': Standardized on ' || standard_v || ', skipping non standardized signatures'); + RETURN; + END IF; + IF fn ilike '%trsp%' THEN extra_name := '{""}'::TEXT[]; extra_type := '{text}'::TEXT[]; @@ -25,11 +37,6 @@ BEGIN IF fn ilike '%withPoints%' THEN extra_name := extra_name || '{""}'::TEXT[]; extra_type := extra_type || '{text}'::TEXT[]; - - IF NOT min_version('4.0.0') THEN - opt_names := '{directed,driving_side,details}'::TEXT[]; - opt_types := '{bool,bpchar,bool}'::TEXT[]; - END IF; END IF; IF fn ilike '%near%' THEN @@ -41,13 +48,6 @@ BEGIN 'int8', 'bigint'), 'bpchar', 'character'); - IF NOT min_version(created_v) THEN - RETURN QUERY SELECT skip(1, fn || ': Created on version ' || created_v); - RETURN; - END IF; - - RETURN QUERY SELECT has_function(fn); - IF NOT fn ilike '%near%' THEN RETURN QUERY SELECT has_function(fn, extra_type || '{text,bigint,bigint}' || taptypes); END IF; @@ -66,11 +66,6 @@ BEGIN IF min_version('3.2.0') THEN RETURN QUERY SELECT function_returns(fn, extra_type || '{text,text}' || taptypes, 'setof record'); END IF; - IF NOT min_version(standard_v) THEN - RETURN QUERY SELECT skip(1, fn || ': Standardized on ' || standard_v || ', skipping non standardized signatures'); - RETURN; - END IF; - IF fn ilike '%near%' THEN args := format($$VALUES @@ -305,50 +300,66 @@ RETURNS SETOF TEXT AS $BODY$ DECLARE -- edges sql - params_types_words TEXT[] = ARRAY['text']; params_names TEXT[] = ARRAY['']; - params_numbers TEXT[] = ARRAY['text']; + params_types_words TEXT[] = ARRAY['text']; + params_types TEXT[] = ARRAY['text']; - optional_params_types_words TEXT[] = ARRAY['boolean','boolean','boolean']; optional_params_names TEXT[] = ARRAY['directed','strict','u_turn_on_edge']; - optional_params_numbers TEXT[] = '{bool,bool,bool}'::TEXT[]; + optional_params_types_words TEXT[] = ARRAY['boolean','boolean','boolean']; + optional_params_types TEXT[] = '{bool,bool,bool}'::TEXT[]; return_params_names TEXT[] = ARRAY['seq','path_id','path_seq','start_vid','end_vid','node','edge','cost','agg_cost','route_agg_cost']; - return_params_numbers TEXT[] = '{int4,int4,int4,int8,int8,int8,int8,float8,float8,float8}'::TEXT[]; + return_params_types TEXT[] = '{int4,int4,int4,int8,int8,int8,int8,float8,float8,float8}'::TEXT[]; + names TEXT; + typs TEXT; BEGIN - IF fn IN ('pgr_trspvia','pgr_trspvia_withpoints','pgr_withpointsvia') AND NOT min_version('3.4.0') THEN + + IF fn ilike '%withpoints%' AND NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, fn || ': New signatures on 4.0.0'); + RETURN; + END IF; + + IF fn IN ('pgr_trspvia') AND NOT min_version('3.4.0') THEN RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); RETURN; END IF; IF fn LIKE '%trsp%' THEN -- restrictions sql - params_types_words := params_types_words || 'text'::TEXT; params_names := params_names || ARRAY['']; - params_numbers := params_numbers || ARRAY['text']; + params_types_words := params_types_words || 'text'::TEXT; + params_types := params_types || ARRAY['text']; END IF; IF fn LIKE '%withpoints%' THEN -- points sql - params_types_words := params_types_words || 'text'::TEXT; params_names := params_names || ARRAY['']; - params_numbers := params_numbers || ARRAY['text']; + params_types_words := params_types_words || 'text'::TEXT; + params_types := params_types || ARRAY['text']; -- points optionals - optional_params_types_words := optional_params_types_words || ARRAY['character','boolean']; - optional_params_names := optional_params_names || ARRAY['driving_side','details']; - optional_params_numbers := optional_params_numbers || '{bpchar,bool}'::TEXT[]; + optional_params_names := optional_params_names || 'details'::TEXT; + optional_params_types_words := optional_params_types_words || 'boolean'::TEXT; + optional_params_types := optional_params_types || 'bool'::TEXT; END IF; -- vias - params_types_words := params_types_words || 'anyarray'::TEXT; params_names := params_names || ARRAY['']; - params_numbers := params_numbers || ARRAY['anyarray']; + params_types_words := params_types_words || 'anyarray'::TEXT; + params_types := params_types || 'anyarray'::TEXT; + + IF fn LIKE '%withpoints%' THEN + -- driving side + params_names := params_names || ARRAY['']; + params_types_words := params_types_words || 'character'::TEXT; + params_types := params_types || 'bpchar'::TEXT; + END IF; RETURN QUERY SELECT has_function(fn); RETURN QUERY SELECT has_function(fn, params_types_words || optional_params_types_words); RETURN QUERY SELECT function_returns(fn, params_types_words || optional_params_types_words,'setof record'); + RETURN QUERY SELECT function_args_eq(fn, format( $$VALUES (%1$L::TEXT[])$$, @@ -362,7 +373,7 @@ BEGIN $$VALUES (%1$L::TEXT[])$$, -- one via '{"' || array_to_string( - params_numbers || optional_params_numbers || return_params_numbers,'","') + params_types || optional_params_types || return_params_types,'","') || '"}')); diff --git a/tools/testers/via_compare.sql b/tools/testers/via_compare.sql index 2bbbd23a90f..65cce51858e 100644 --- a/tools/testers/via_compare.sql +++ b/tools/testers/via_compare.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION trspVia_VS_dijstraVia(cant INTEGER default 18, flag boolean default true ) +CREATE OR REPLACE FUNCTION trspVia_VS_dijstraVia(quantity INTEGER default 18, flag boolean default true ) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -34,8 +34,8 @@ BEGIN inc = 2; END IF; - FOR i IN 1 .. cant BY inc LOOP - FOR j IN 1 .. cant LOOP + FOR i IN 1 .. quantity BY inc LOOP + FOR j IN 1 .. quantity LOOP FOR l IN 0 .. 1 LOOP FOR m IN 0 .. 1 LOOP all_found := (l=1); @@ -76,7 +76,7 @@ END $BODY$ language plpgsql; -CREATE OR REPLACE FUNCTION withPointsVia_VS_dijstraVia(cant INTEGER default 18, flag boolean default true ) +CREATE OR REPLACE FUNCTION withPointsVia_VS_dijstraVia(quantity INTEGER default 18, flag boolean default true ) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -92,6 +92,7 @@ msg_end TEXT; all_found BOOLEAN; allow_u BOOLEAN; inc INTEGER = 1; +drv_side TEXT = '$$b$$, '; BEGIN IF NOT min_version('3.4.0') THEN RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); @@ -99,7 +100,8 @@ BEGIN END IF; directed = 'Undirected'; - IF flag THEN directed = 'Directed'; END IF; + IF flag THEN directed = 'Directed'; drv_side = '$$r$$, '; END IF; + IF NOT min_version('4.0.0') THEN drv_side = 'driving_side => ' || drv_side || ' directed => '; END IF; k := 1; with_reverse_cost = quote_literal('SELECT id, source, target, cost, reverse_cost from edges ORDER BY id'); @@ -111,8 +113,8 @@ BEGIN inc = 2; END IF; - FOR i IN 1 .. cant BY inc LOOP - FOR j IN 1 .. cant LOOP + FOR i IN 1 .. quantity BY inc LOOP + FOR j IN 1 .. quantity LOOP FOR l IN 0 .. 1 LOOP FOR m IN 0 .. 1 LOOP all_found := (l=1); @@ -125,7 +127,7 @@ BEGIN withPoints_sql := 'SELECT * FROM pgr_withPointsVia(' || with_reverse_cost || ',' || the_points - || ', ARRAY[1, ' || i || ', ' || j || '], ' || flag || ',' || all_found || ',' || allow_u || ')'; + || ', ARRAY[1, ' || i || ', ' || j || '], ' || drv_side || flag || ', strict => ' || all_found || ', U_turn_on_edge => ' || allow_u || ')'; msg := '-1- ' || directed || ', with reverse_cost: from 1 to ' || i || ' to ' || j || msg_end || withPoints_sql; RETURN query SELECT set_eq(withPoints_sql, dijkstraVia_sql, msg); @@ -137,7 +139,7 @@ BEGIN withPoints_sql := 'SELECT * FROM pgr_withPointsVia(' || no_reverse_cost || ',' || the_points - || ', ARRAY[1, ' || i || ', ' || j || '], ' || flag || ',' || all_found || ',' || allow_u || ')'; + || ', ARRAY[1, ' || i || ', ' || j || '], ' || drv_side || flag || ', strict => ' || all_found || ', U_turn_on_edge => ' || allow_u || ')'; msg := '-1- ' || directed || ', no reverse_cost: from 1 to ' || i || ' to ' || j || msg_end; RETURN query SELECT set_eq(withPoints_sql, dijkstraVia_sql, msg); @@ -153,7 +155,7 @@ END $BODY$ language plpgsql; -CREATE OR REPLACE FUNCTION trspVia_withPoints_VS_withPointsVia(cant INTEGER default 18, flag boolean default true ) +CREATE OR REPLACE FUNCTION trspVia_withPoints_VS_withPointsVia(quantity INTEGER default 18, flag boolean default true ) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -170,14 +172,20 @@ msg_end TEXT; all_found BOOLEAN; allow_u BOOLEAN; inc INTEGER = 1; +drv_side TEXT = '$$b$$::CHAR, '; BEGIN IF NOT min_version('3.4.0') THEN RETURN QUERY SELECT skip(1, 'Signature added on 3.4.0'); RETURN; END IF; + IF NOT min_version('4.0.0') AND min_lib_version('4.0.0') THEN + -- SET client_min_messages TO WARNING; + END IF; + directed = 'Undirected'; - IF flag THEN directed = 'Directed'; END IF; + IF flag THEN directed = 'Directed'; drv_side = '$$r$$::CHAR, '; END IF; + IF NOT min_version('4.0.0') THEN drv_side = 'driving_side => ' || drv_side || ' directed => '; END IF; k := 1; with_reverse_cost = quote_literal('SELECT id, source, target, cost, reverse_cost from edges ORDER BY id'); @@ -190,8 +198,8 @@ BEGIN inc = 2; END IF; - FOR i IN 1 .. cant BY inc LOOP - FOR j IN 1 .. cant LOOP + FOR i IN 1 .. quantity BY inc LOOP + FOR j IN 1 .. quantity LOOP FOR l IN 0 .. 1 LOOP FOR m IN 0 .. 1 LOOP all_found := (l=1); @@ -200,13 +208,13 @@ BEGIN dijkstraVia_sql := 'SELECT * FROM pgr_withPointsVia( ' || with_reverse_cost || ',' || the_points - || ', ARRAY[1, ' || i || ', ' || j || '], ' || flag || ',' || all_found || ',' || allow_u || ')'; + || ', ARRAY[1, ' || i || ', ' || j || '], ' || drv_side || flag || ', strict => ' || all_found || ', U_turn_on_edge => ' || allow_u || ')'; withPoints_sql := 'SELECT * FROM pgr_trspVia_withPoints(' || with_reverse_cost || ',' || empty_restrictions || ',' || the_points - || ', ARRAY[1, ' || i || ', ' || j || '], ' || flag || ',' || all_found || ',' || allow_u || ')'; + || ', ARRAY[1, ' || i || ', ' || j || '], ' || drv_side || flag || ', strict => ' || all_found || ', U_turn_on_edge => ' || allow_u || ')'; msg := '-1- ' || directed || ', with reverse_cost: from 1 to ' || i || ' to ' || j || msg_end || withPoints_sql; RETURN query SELECT set_eq(withPoints_sql, dijkstraVia_sql, msg); @@ -214,13 +222,13 @@ BEGIN dijkstraVia_sql := 'SELECT * FROM pgr_withPointsVia( ' || no_reverse_cost || ',' || the_points - || ', ARRAY[1, ' || i || ', ' || j || '], ' || flag || ',' || all_found || ',' || allow_u || ')'; + || ', ARRAY[1, ' || i || ', ' || j || '], ' || drv_side || flag || ', strict => ' || all_found || ', U_turn_on_edge => ' || allow_u || ')'; withPoints_sql := 'SELECT * FROM pgr_trspVia_withPoints(' || no_reverse_cost || ',' || empty_restrictions || ',' || the_points - || ', ARRAY[1, ' || i || ', ' || j || '], ' || flag || ',' || all_found || ',' || allow_u || ')'; + || ', ARRAY[1, ' || i || ', ' || j || '], ' || drv_side || flag || ', strict => ' || all_found || ', U_turn_on_edge => ' || allow_u || ')'; msg := '-2- ' || directed || ', no reverse_cost: from 1 to ' || i || ' to ' || j || msg_end; RETURN query SELECT set_eq(withPoints_sql, dijkstraVia_sql, msg); From a4c9af648cca73e4b2dff23b3e06f6e3c4bca7fa Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:33:25 -0600 Subject: [PATCH 32/39] (pgtap) Adjust other tests that use new signature or test function changed --- .../bellman_ford/bellman_ford/types_check.pg | 2 +- pgtap/bellman_ford/edwardMoore/types_check.pg | 2 +- pgtap/others/dagShortestPath/types_check.pg | 2 +- .../binaryBreadthFirstSearch/types_check.pg | 2 +- pgtap/tsp/tsp/edge_cases/edge_cases.pg | 45 +++++++++++++------ 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/pgtap/bellman_ford/bellman_ford/types_check.pg b/pgtap/bellman_ford/bellman_ford/types_check.pg index 9b5a5bed7e0..186a166a8f8 100644 --- a/pgtap/bellman_ford/bellman_ford/types_check.pg +++ b/pgtap/bellman_ford/bellman_ford/types_check.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.2.0') THEN plan(12) ELSE PLAN(10) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) ELSE PLAN(2) END; SELECT single_path_types_check('pgr_bellmanford', standard_v => '4.0.0'); diff --git a/pgtap/bellman_ford/edwardMoore/types_check.pg b/pgtap/bellman_ford/edwardMoore/types_check.pg index 6ad63003c86..ddcff71366e 100644 --- a/pgtap/bellman_ford/edwardMoore/types_check.pg +++ b/pgtap/bellman_ford/edwardMoore/types_check.pg @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.2.0') THEN plan(12) ELSE PLAN(10) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) ELSE PLAN(2) END; SELECT single_path_types_check('pgr_edwardmoore', standard_v => '4.0.0'); diff --git a/pgtap/others/dagShortestPath/types_check.pg b/pgtap/others/dagShortestPath/types_check.pg index aa1493e7735..337e0311f3b 100644 --- a/pgtap/others/dagShortestPath/types_check.pg +++ b/pgtap/others/dagShortestPath/types_check.pg @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BEGIN; -SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.2.0') THEN plan(12) ELSE PLAN(10) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) ELSE PLAN(2) END; SELECT single_path_types_check('pgr_dagshortestpath', '{}'::TEXT[], '{}'::TEXT[], standard_v => '4.0.0'); diff --git a/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg b/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg index d5f9e6b817a..2862e2bedfc 100644 --- a/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg +++ b/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.2.0') THEN plan(12) ELSE PLAN(10) END; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) ELSE PLAN(2) END; SELECT single_path_types_check('pgr_binarybreadthfirstsearch', standard_v => '4.0.0'); diff --git a/pgtap/tsp/tsp/edge_cases/edge_cases.pg b/pgtap/tsp/tsp/edge_cases/edge_cases.pg index 5c511f73c59..f3e59659928 100644 --- a/pgtap/tsp/tsp/edge_cases/edge_cases.pg +++ b/pgtap/tsp/tsp/edge_cases/edge_cases.pg @@ -23,28 +23,47 @@ UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(revers SELECT CASE WHEN min_lib_version('4.0.0') THEN plan(56) ELSE plan(2) END; -CREATE TEMP TABLE data AS -SELECT * FROM pgr_withPointsCostMatrix( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction from pointsOfInterest', - array[-1, 10, 7, 11, -6], directed := false); -CREATE TEMP TABLE data_directed AS -SELECT * FROM pgr_withPointsCostMatrix( - 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', - 'SELECT pid, edge_id, fraction from pointsOfInterest', - array[-1, 10, 7, 11, -6], directed := true); - - -CREATE FUNCTION tsp_edge_cases(tbl regclass) +CREATE FUNCTION tsp_edge_cases(tbl TEXT) RETURNS SETOF TEXT AS $code$ BEGIN + IF NOT min_lib_version('4.0.0') THEN RETURN QUERY SELECT skip(1, 'pgr_tsp new internal code on v4.0.0'); RETURN; END IF; + IF min_version('4.0.0') THEN + + CREATE TEMP TABLE IF NOT EXISTS data AS + SELECT * FROM pgr_withPointsCostMatrix( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction from pointsOfInterest', + array[-1, 10, 7, 11, -6], 'b', directed => false); + + CREATE TEMP TABLE IF NOT EXISTS data_directed AS + SELECT * FROM pgr_withPointsCostMatrix( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction from pointsOfInterest', + array[-1, 10, 7, 11, -6], 'r', directed => true); + + ELSE + + CREATE TEMP TABLE IF NOT EXISTS data AS + SELECT * FROM pgr_withPointsCostMatrix( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction from pointsOfInterest', + array[-1, 10, 7, 11, -6], driving_side => 'b', directed => false); + + CREATE TEMP TABLE IF NOT EXISTS data_directed AS + SELECT * FROM pgr_withPointsCostMatrix( + 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', + 'SELECT pid, edge_id, fraction from pointsOfInterest', + array[-1, 10, 7, 11, -6], driving_side => 'r', directed => true); + + END IF; + RETURN QUERY SELECT throws_ok(format($$ SELECT * FROM pgr_TSP('SELECT * FROM %1$I', start_id => 7, end_id => 8) $$, tbl), From 5817e142c6b972b965810821fee0d121e521d746 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:47:31 -0600 Subject: [PATCH 33/39] Adding test file for testing flags and driving side --- pgtap/ksp/withPointsKSP/flag_test.pg | 34 ++++++++++++++++ pgtap/trsp/trspVia_withPoints/flag_test.pg | 39 +++++++++++++++++++ pgtap/trsp/trsp_withpoints/flag_test.pg | 39 +++++++++++++++++++ pgtap/withPoints/withPoints/flag_test.pg | 34 ++++++++++++++++ pgtap/withPoints/withPointsCost/flag_test.pg | 34 ++++++++++++++++ .../withPointsCostMatrix/flag_test.pg | 34 ++++++++++++++++ pgtap/withPoints/withPointsDD/flag_test.pg | 34 ++++++++++++++++ pgtap/withPoints/withPointsVia/flag_test.pg | 34 ++++++++++++++++ 8 files changed, 282 insertions(+) create mode 100644 pgtap/ksp/withPointsKSP/flag_test.pg create mode 100644 pgtap/trsp/trspVia_withPoints/flag_test.pg create mode 100644 pgtap/trsp/trsp_withpoints/flag_test.pg create mode 100644 pgtap/withPoints/withPoints/flag_test.pg create mode 100644 pgtap/withPoints/withPointsCost/flag_test.pg create mode 100644 pgtap/withPoints/withPointsCostMatrix/flag_test.pg create mode 100644 pgtap/withPoints/withPointsDD/flag_test.pg create mode 100644 pgtap/withPoints/withPointsVia/flag_test.pg diff --git a/pgtap/ksp/withPointsKSP/flag_test.pg b/pgtap/ksp/withPointsKSP/flag_test.pg new file mode 100644 index 00000000000..b7fbd276dab --- /dev/null +++ b/pgtap/ksp/withPointsKSP/flag_test.pg @@ -0,0 +1,34 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2025 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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_withPointsKSP'); + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/trsp/trspVia_withPoints/flag_test.pg b/pgtap/trsp/trspVia_withPoints/flag_test.pg new file mode 100644 index 00000000000..8fac43a1b90 --- /dev/null +++ b/pgtap/trsp/trspVia_withPoints/flag_test.pg @@ -0,0 +1,39 @@ + +/*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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE restrictions_sql AS +SELECT path, cost FROM restrictions; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_trspVia_withPoints'); + + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/trsp/trsp_withpoints/flag_test.pg b/pgtap/trsp/trsp_withpoints/flag_test.pg new file mode 100644 index 00000000000..c49d033ad1e --- /dev/null +++ b/pgtap/trsp/trsp_withpoints/flag_test.pg @@ -0,0 +1,39 @@ + +/*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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE restrictions_sql AS +SELECT path, cost FROM restrictions; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_trsp_withPoints'); + + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/withPoints/withPoints/flag_test.pg b/pgtap/withPoints/withPoints/flag_test.pg new file mode 100644 index 00000000000..ddf393cdfd5 --- /dev/null +++ b/pgtap/withPoints/withPoints/flag_test.pg @@ -0,0 +1,34 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2025 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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_withPoints'); + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/withPoints/withPointsCost/flag_test.pg b/pgtap/withPoints/withPointsCost/flag_test.pg new file mode 100644 index 00000000000..56d14d32071 --- /dev/null +++ b/pgtap/withPoints/withPointsCost/flag_test.pg @@ -0,0 +1,34 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2025 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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_withPointsCost'); + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/withPoints/withPointsCostMatrix/flag_test.pg b/pgtap/withPoints/withPointsCostMatrix/flag_test.pg new file mode 100644 index 00000000000..189654afcfb --- /dev/null +++ b/pgtap/withPoints/withPointsCostMatrix/flag_test.pg @@ -0,0 +1,34 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2025 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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_withPointsCostMatrix'); + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/withPoints/withPointsDD/flag_test.pg b/pgtap/withPoints/withPointsDD/flag_test.pg new file mode 100644 index 00000000000..0254c044597 --- /dev/null +++ b/pgtap/withPoints/withPointsDD/flag_test.pg @@ -0,0 +1,34 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2025 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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_withPointsDD'); + +SELECT finish(); +ROLLBACK; diff --git a/pgtap/withPoints/withPointsVia/flag_test.pg b/pgtap/withPoints/withPointsVia/flag_test.pg new file mode 100644 index 00000000000..0e48dadc9c3 --- /dev/null +++ b/pgtap/withPoints/withPointsVia/flag_test.pg @@ -0,0 +1,34 @@ +/*PGR-GNU***************************************************************** + +Copyright (c) 2025 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 edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(22) ELSE plan(1) END; + +PREPARE edges_sql AS +SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id; + +PREPARE points_sql AS +SELECT pid, edge_id, side, fraction FROM pointsOfInterest; + +SELECT test_drivingSide('pgr_withPointsVia'); + +SELECT finish(); +ROLLBACK; From 3246129c8db5ffa2a889a9b1f23c5bc5e8380df1 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:52:16 -0600 Subject: [PATCH 34/39] (docqueries) migration: Adjusting documentation examples --- docqueries/src/migration.pg | 12 ++++++------ docqueries/src/migration.result | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docqueries/src/migration.pg b/docqueries/src/migration.pg index 57e64a44dfa..d7b21cd0ab1 100644 --- a/docqueries/src/migration.pg +++ b/docqueries/src/migration.pg @@ -83,7 +83,7 @@ SELECT * FROM pgr_trsp_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (4, 3)$$, -4, -3, - driving_side => 'r', details => false); + 'r', details => false); /* --edgesv6 */ SELECT seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost FROM pgr_trsp_withPoints( @@ -91,7 +91,7 @@ FROM pgr_trsp_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6)) AS t(pid, edge_id, fraction)$$, -1, -2, - driving_side => 'r', details => false) + 'r', details => false) WHERE edge != -1; /* --edgesv7 */ /* --viav2 */ @@ -131,7 +131,7 @@ SELECT * FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$, ARRAY[-4, -3, -6], - driving_side => 'r', details => false); + 'r', details => false); /* --edgesvia3 */ SELECT row_number() over(ORDER BY seq) AS seq, path_id::INTEGER AS id1, node::INTEGER AS id2, @@ -140,7 +140,7 @@ FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$, ARRAY[-4, -3, -6], - driving_side => 'r', details => false); + 'r', details => false); /* --edgesvia4 */ /* --edgesvia5 */ SELECT * FROM pgr_trspVia_withPoints( @@ -148,7 +148,7 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$, ARRAY[-4, -3, -6], - driving_side => 'r', details => false); + 'r', details => false); /* --edgesvia6 */ SELECT row_number() over(ORDER BY seq) AS seq, path_id::INTEGER AS id1, node::INTEGER AS id2, @@ -158,7 +158,7 @@ FROM pgr_trspVia_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6),(3, 4, 0.7)) AS t(pid, edge_id, fraction)$$, ARRAY[-1, -2, -3], - driving_side => 'r', details => false); + 'r', details => false); /* --edgesvia7 */ /* --maxcard2 */ diff --git a/docqueries/src/migration.result b/docqueries/src/migration.result index 0dcf166b184..26ecabff085 100644 --- a/docqueries/src/migration.result +++ b/docqueries/src/migration.result @@ -174,7 +174,7 @@ SELECT * FROM pgr_trsp_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (4, 3)$$, -4, -3, - driving_side => 'r', details => false); + 'r', details => false); seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost -----+----------+-----------+---------+------+------+------+---------- 1 | 1 | -4 | -3 | -4 | 6 | 0.7 | 0 @@ -197,7 +197,7 @@ FROM pgr_trsp_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6)) AS t(pid, edge_id, fraction)$$, -1, -2, - driving_side => 'r', details => false) + 'r', details => false) WHERE edge != -1; seq | id1 | id2 | cost -----+-----+-----+------ @@ -315,7 +315,7 @@ SELECT * FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$, ARRAY[-4, -3, -6], - driving_side => 'r', details => false); + 'r', details => false); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | -4 | -3 | -4 | 6 | 0.7 | 0 | 0 @@ -340,7 +340,7 @@ FROM pgr_withPointsVia( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$, ARRAY[-4, -3, -6], - driving_side => 'r', details => false); + 'r', details => false); seq | id1 | id2 | id3 | cost -----+-----+-----+-----+------ 1 | 1 | -4 | 6 | 0.7 @@ -364,7 +364,7 @@ SELECT * FROM pgr_trspVia_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT pid, edge_id, fraction FROM pointsOfInterest WHERE pid IN (3, 4, 6)$$, ARRAY[-4, -3, -6], - driving_side => 'r', details => false); + 'r', details => false); seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost | route_agg_cost -----+---------+----------+-----------+---------+------+------+------+----------+---------------- 1 | 1 | 1 | -4 | -3 | -4 | 6 | 0.7 | 0 | 0 @@ -391,7 +391,7 @@ FROM pgr_trspVia_withPoints( $$SELECT * FROM new_restrictions$$, $$SELECT * FROM (VALUES (1, 6, 0.3),(2, 12, 0.6),(3, 4, 0.7)) AS t(pid, edge_id, fraction)$$, ARRAY[-1, -2, -3], - driving_side => 'r', details => false); + 'r', details => false); seq | id1 | id2 | id3 | cost -----+-----+-----+-----+------ 1 | 1 | -1 | 6 | 0.7 From c33177c69c298a3299104c3e24b30dc0fb212b9e Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 13:52:16 -0600 Subject: [PATCH 35/39] (docqueries) pgr_TSP: Adjusting documentation examples --- docqueries/tsp/TSP.pg | 2 +- docqueries/tsp/TSP.result | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docqueries/tsp/TSP.pg b/docqueries/tsp/TSP.pg index 3b24b6b5025..be0a422cc0b 100644 --- a/docqueries/tsp/TSP.pg +++ b/docqueries/tsp/TSP.pg @@ -21,7 +21,7 @@ SELECT * FROM pgr_TSP( $$SELECT * FROM pgr_withPointsCostMatrix( 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction from pointsOfInterest', - array[-1, 10, 7, 11, -6], + array[-1, 10, 7, 11, -6], 'r', directed => true) $$, start_id => 7, end_id => 11); diff --git a/docqueries/tsp/TSP.result b/docqueries/tsp/TSP.result index ec9618218bd..7152ec230a5 100644 --- a/docqueries/tsp/TSP.result +++ b/docqueries/tsp/TSP.result @@ -60,7 +60,7 @@ SELECT * FROM pgr_TSP( $$SELECT * FROM pgr_withPointsCostMatrix( 'SELECT id, source, target, cost, reverse_cost FROM edges ORDER BY id', 'SELECT pid, edge_id, fraction from pointsOfInterest', - array[-1, 10, 7, 11, -6], + array[-1, 10, 7, 11, -6], 'r', directed => true) $$, start_id => 7, end_id => 11); From 924745a0ad219214154b37b818e0e08d2346f4e0 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 14:17:05 -0600 Subject: [PATCH 36/39] (doc) standardizing availability becuase of 4.0.0 --- doc/contraction/pgr_contraction.rst | 8 ++++ doc/max_flow/pgr_maxCardinalityMatch.rst | 42 ++++++++++++--------- doc/trsp/pgr_trsp.rst | 47 ++++++++++++++---------- doc/trsp/pgr_trspVia.rst | 14 +++++-- doc/tsp/pgr_TSP.rst | 8 +++- doc/tsp/pgr_TSPeuclidean.rst | 8 +++- 6 files changed, 84 insertions(+), 43 deletions(-) diff --git a/doc/contraction/pgr_contraction.rst b/doc/contraction/pgr_contraction.rst index 2f9dcdf430c..999a0122436 100644 --- a/doc/contraction/pgr_contraction.rst +++ b/doc/contraction/pgr_contraction.rst @@ -22,6 +22,14 @@ vertices and edges. .. rubric:: Availability +.. rubric:: Version 4.0.0 + +.. Breaking change + +* Breaking change, signatures no longer available: + + * pgr_contraction(text,bigint[],integer,bigint[],boolean) + .. rubric:: Version 3.8.0 * New signature: diff --git a/doc/max_flow/pgr_maxCardinalityMatch.rst b/doc/max_flow/pgr_maxCardinalityMatch.rst index 86aac8566ee..b84236964d0 100644 --- a/doc/max_flow/pgr_maxCardinalityMatch.rst +++ b/doc/max_flow/pgr_maxCardinalityMatch.rst @@ -19,35 +19,43 @@ ``pgr_maxCardinalityMatch`` — Calculates a maximum cardinality matching in a graph. -.. Rubric:: Availability +.. rubric:: Availability -* Version 3.4.0 +.. rubric:: Version 4.0.0 - * Use ``cost`` and ``reverse_cost`` on the inner query - * Results are ordered - * Works for undirected graphs. - * New signature +.. Breaking change - * pgr_maxCardinalityMatch(text) returns only ``edge`` column. +* Breaking change, signatures no longer available: - * Deprecated signature + * pgr_maxCardinalityMatch(text,boolean) - * pgr_maxCardinalityMatch(text,boolean) +.. rubric:: Version 3.4.0 - * directed => ``false`` when used. +* Use ``cost`` and ``reverse_cost`` on the inner query +* Results are ordered +* Works for undirected graphs. +* New signature -* Version 3.0.0 + * pgr_maxCardinalityMatch(text) returns only ``edge`` column. - * Function promoted to official. +* Deprecated signature -* Version 2.5.0 + * pgr_maxCardinalityMatch(text,boolean) - * Renamed from ``pgr_maximumCardinalityMatching`` - * Function promoted to proposed. + * directed => ``false`` when used. -* Version 2.3.0 +.. rubric:: Version 3.0.0 - * New experimental function. +* Function promoted to official. + +.. rubric:: Version 2.5.0 + +* Renamed from ``pgr_maximumCardinalityMatching`` +* Function promoted to proposed. + +.. rubric:: Version 2.3.0 + +* New experimental function. Description diff --git a/doc/trsp/pgr_trsp.rst b/doc/trsp/pgr_trsp.rst index d63fb626561..20d32508598 100644 --- a/doc/trsp/pgr_trsp.rst +++ b/doc/trsp/pgr_trsp.rst @@ -22,37 +22,44 @@ .. rubric:: Availability -* Version 4.0.0 +.. rubric:: Version 4.0.0 - * Function promoted to official. +* Function promoted to official. -* Version 3.4.0 +.. Breaking change - * New proposed signatures: +* Breaking change, signatures no longer available: - * pgr_trsp(One to One) - * pgr_trsp(One to Many) - * pgr_trsp(Many to One) - * pgr_trsp(Many to Many) - * pgr_trsp(Combinations) + * pgr_trsp(text,integer,integer,boolean,boolean,text) + * pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) - * Deprecated signatures +.. rubric:: Version 3.4.0 - * pgr_trsp(text,integer,integer,boolean,boolean,text) - * pgr_trsp(text,integer,float,integer,float,boolean,boolean,text) - * pgr_trspViaVertices(text,anyarray,boolean,boolean,text) - * pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) +* New proposed signatures: -* Version 2.1.0 + * pgr_trsp(One to One) + * pgr_trsp(One to Many) + * pgr_trsp(Many to One) + * pgr_trsp(Many to Many) + * pgr_trsp(Combinations) - * New prototypes +* Deprecated signatures - * pgr_trspViaVertices - * pgr_trspViaEdges + * pgr_trsp(text,integer,integer,boolean,boolean,text) + * pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) + * pgr_trspViaVertices(text,anyarray,boolean,boolean,text) + * pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) -* Version 2.0.0 +.. rubric:: Version 2.1.0 - * Official function. +* New prototypes + + * pgr_trspViaVertices + * pgr_trspViaEdges + +.. rubric:: Version 2.0.0 + +* Official function. Description ------------------------------------------------------------------------------- diff --git a/doc/trsp/pgr_trspVia.rst b/doc/trsp/pgr_trspVia.rst index 4afd7435564..2a41c09c6b2 100644 --- a/doc/trsp/pgr_trspVia.rst +++ b/doc/trsp/pgr_trspVia.rst @@ -22,13 +22,19 @@ .. rubric:: Availability -* Version 4.0.0 +.. rubric:: Version 4.0.0 - * Function promoted to official. +* Function promoted to official. +* Breaking change, signatures no longer available: -* Version 3.4.0 + * pgr_trspviavertices(text,anyarray,boolean,boolean,text) - * New proposed function. +.. rubric:: Version 3.4.0 + +* New proposed function. +* Deprecated signatures + + * pgr_trspviavertices(text,anyarray,boolean,boolean,text) Description ------------------------------------------------------------------------------- diff --git a/doc/tsp/pgr_TSP.rst b/doc/tsp/pgr_TSP.rst index 32a1bd71292..67543d6f18a 100644 --- a/doc/tsp/pgr_TSP.rst +++ b/doc/tsp/pgr_TSP.rst @@ -22,10 +22,16 @@ .. rubric:: Version 4.0.0 -* Simulated Annealing signature removed * Results change depending on input order * Only for undirected graphs +.. Breaking change + +* Breaking change, signatures no longer available: + + * pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double + precision,double precision,double precision,boolean) + .. rubric:: Version 3.2.1 * Metric Algorithm from `Boost library diff --git a/doc/tsp/pgr_TSPeuclidean.rst b/doc/tsp/pgr_TSPeuclidean.rst index 901fd1fb932..d4807869055 100644 --- a/doc/tsp/pgr_TSPeuclidean.rst +++ b/doc/tsp/pgr_TSPeuclidean.rst @@ -22,9 +22,15 @@ .. rubric:: Version 4.0.0 -* Simulated Annealing signature removed * Results change depending on input order +.. Breaking change + +* Breaking change, signatures no longer available: + + * pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer, + integer,double precision,double precision,double precision,boolean) + .. rubric:: Version 3.2.1 * Using `Boost: metric TSP approx From 90bdc4ca5d6e83f89e9c209e89b547fd0e7cb292 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 15:04:48 -0600 Subject: [PATCH 37/39] (doc) Adusting to consider recent offical functions --- doc/categories/KSP-category.rst | 12 +---- doc/categories/cost-category.rst | 4 +- doc/categories/costMatrix-category.rst | 12 +---- doc/categories/drivingDistance-category.rst | 11 +---- doc/categories/via-category.rst | 29 ++++++++---- doc/categories/withPoints-category.rst | 27 +++++------ doc/src/proposed.rst | 52 ++------------------- doc/src/routingFunctions.rst | 17 ++++++- doc/traversal/traversal-family.rst | 4 +- doc/utilities/utilities-family.rst | 4 +- doc/withPoints/withPoints-family.rst | 52 +++++---------------- 11 files changed, 71 insertions(+), 153 deletions(-) diff --git a/doc/categories/KSP-category.rst b/doc/categories/KSP-category.rst index 8416fcb0b83..5b96d59240f 100644 --- a/doc/categories/KSP-category.rst +++ b/doc/categories/KSP-category.rst @@ -17,19 +17,9 @@ K shortest paths - Category .. official-start * :doc:`pgr_KSP` - Yen's algorithm based on pgr_dijkstra - -.. official-end - -.. include:: proposed.rst - :start-after: warning-begin - :end-before: end-warning - -.. proposed-start - * :doc:`pgr_withPointsKSP` - Yen's algorithm based on pgr_withPoints -.. proposed-end - +.. official-end .. rubric:: Indices and tables diff --git a/doc/categories/cost-category.rst b/doc/categories/cost-category.rst index 305cda32776..3f775a3a688 100644 --- a/doc/categories/cost-category.rst +++ b/doc/categories/cost-category.rst @@ -22,7 +22,7 @@ Cost - Category * :doc:`pgr_bdAstarCost` * :doc:`pgr_dijkstraCost` * :doc:`pgr_bdDijkstraCost` -* :doc:`pgr_dijkstraNearCost` +* :doc:`pgr_withPointsCost` .. official-end @@ -32,7 +32,7 @@ Cost - Category .. proposed-start -* :doc:`pgr_withPointsCost` +* :doc:`pgr_dijkstraNearCost` .. proposed-end diff --git a/doc/categories/costMatrix-category.rst b/doc/categories/costMatrix-category.rst index 1ea0a043803..6a934ccb351 100644 --- a/doc/categories/costMatrix-category.rst +++ b/doc/categories/costMatrix-category.rst @@ -20,19 +20,9 @@ Cost Matrix - Category * :doc:`pgr_dijkstraCostMatrix` * :doc:`pgr_bdAstarCostMatrix` * :doc:`pgr_bdDijkstraCostMatrix` - -.. official-end - - -.. include:: proposed.rst - :start-after: warning-begin - :end-before: end-warning - -.. proposed-start - * :doc:`pgr_withPointsCostMatrix` -.. proposed-end +.. official-end General Information ------------------------------------------------------------------------------- diff --git a/doc/categories/drivingDistance-category.rst b/doc/categories/drivingDistance-category.rst index 7f103e1f832..22e0151e94c 100644 --- a/doc/categories/drivingDistance-category.rst +++ b/doc/categories/drivingDistance-category.rst @@ -19,18 +19,9 @@ Driving Distance - Category * :doc:`pgr_drivingDistance` - Driving Distance based on Dijkstra's algorithm * :doc:`pgr_primDD` - Driving Distance based on Prim's algorithm * :doc:`pgr_kruskalDD` - Driving Distance based on Kruskal's algorithm - -.. official-end - -.. include:: proposed.rst - :start-after: warning-begin - :end-before: end-warning - -.. proposed-start - * :doc:`pgr_withPointsDD` - Driving Distance based on pgr_withPoints -.. proposed-end +.. official-end Calculate nodes that are within a distance. diff --git a/doc/categories/via-category.rst b/doc/categories/via-category.rst index 6fec87e3d83..deb5e6ca77f 100644 --- a/doc/categories/via-category.rst +++ b/doc/categories/via-category.rst @@ -14,18 +14,23 @@ Via - Category =============================================================================== +.. official-start + +* :doc:`pgr_withPointsVia` +* :doc:`pgr_trspVia` +* :doc:`pgr_trspVia_withPoints` + +.. official-end + .. include:: proposed.rst :start-after: warning-begin :end-before: end-warning -.. proposed start +.. proposed-start * :doc:`pgr_dijkstraVia` -* :doc:`pgr_withPointsVia` -* :doc:`pgr_trspVia` -* :doc:`pgr_trspVia_withPoints` -.. proposed end +.. proposed-end General Information ------------------------------------------------------------------------------- @@ -84,28 +89,32 @@ Where: .. list-table:: :width: 81 - :widths: 14 20 7 40 + :widths: auto :header-rows: 1 * - Parameter - Type - - Default - Description * - `Edges SQL`_ - ``TEXT`` - - - SQL query as described. * - `Points SQL`_ - ``TEXT`` - - - SQL query as described. * - **via vertices** - ``ARRAY`` [ **ANY-INTEGER** ] - - - Array of ordered vertices identifiers that are going to be visited. * When positive it is considered a vertex identifier * When negative it is considered a point identifier + * - **driving side** + - ``CHAR`` + - Value in [``r``, ``R``, ``l``, ``L``, ``b``, ``B``] indicating if the driving side is: + + - [``r``, ``R``] for right driving side (for directed graph only) + - [``l``, ``L``] for left driving side (for directed graph only) + - [``b``, ``B``] for both (only for undirected graph) + Where: diff --git a/doc/categories/withPoints-category.rst b/doc/categories/withPoints-category.rst index 2ed13d18b01..0daf52273db 100644 --- a/doc/categories/withPoints-category.rst +++ b/doc/categories/withPoints-category.rst @@ -16,11 +16,7 @@ withPoints - Category When points are added to the graph. -.. include:: proposed.rst - :start-after: warning-begin - :end-before: end-warning - -.. proposed start +.. official-start - :doc:`withPoints-family` - Functions based on Dijkstra algorithm. - From the :doc:`TRSP-family`: @@ -28,7 +24,7 @@ When points are added to the graph. - :doc:`pgr_trsp_withPoints` - Vertex/Point routing with restrictions. - :doc:`pgr_trspVia_withPoints` - Via Vertex/point routing with restrictions. -.. proposed end +.. official-end Introduction ------------------------------------------------------------------------------- @@ -126,6 +122,13 @@ Parameters - ``ARRAY[BIGINT]`` - Array of identifiers of ending vertices. Negative values are for point’s identifiers. + * - **driving side** + - ``CHAR`` + - Value in [``r``, ``R``, ``l``, ``L``, ``b``, ``B``] indicating if the driving side is: + + - [``r``, ``R``] for right driving side (for directed graph only) + - [``l``, ``L``] for left driving side (for directed graph only) + - [``b``, ``B``] for both (only for undirected graph) .. withPoints_parameters_end @@ -143,18 +146,12 @@ Optional parameters - Type - Default - Description - * - ``driving_side`` - - ``CHAR`` - - ``r`` - - Value in [``r``, ``l``] indicating if the driving side is: - - - ``r`` for right driving side - - ``l`` for left driving side - - Any other value will be considered as ``r`` * - ``details`` - ``BOOLEAN`` - ``false`` - - - When ``true`` the results will include the points that are in the path. + - For showing points stops. + + - When ``true`` the results will include the points that are in the path. - When ``false`` the results will not include the points that are in the path. diff --git a/doc/src/proposed.rst b/doc/src/proposed.rst index 65198aa74a3..8b6952a235a 100644 --- a/doc/src/proposed.rst +++ b/doc/src/proposed.rst @@ -39,12 +39,6 @@ Proposed Functions :start-after: proposed-start :end-before: proposed-end -:doc:`withPoints-family` - -.. include:: withPoints-family.rst - :start-after: proposed-start - :end-before: proposed-end - :doc:`transformation-family` .. include:: transformation-family.rst @@ -66,14 +60,8 @@ Proposed Functions :doc:`traversal-family` .. include:: traversal-family.rst - :start-after: official-start - :end-before: official-end - -.. toctree:: - :hidden: - - traversal-family - coloring-family + :start-after: proposed-start + :end-before: proposed-end .. rubric:: categories @@ -83,43 +71,11 @@ Proposed Functions :start-after: proposed-start :end-before: proposed-end -:doc:`costMatrix-category` - -.. include:: costMatrix-category.rst - :start-after: proposed-start - :end-before: proposed-end - -:doc:`drivingDistance-category` - -.. include:: drivingDistance-category.rst - :start-after: proposed-start - :end-before: proposed-end - -:doc:`KSP-category` - -.. include:: KSP-category.rst - :start-after: proposed-start - :end-before: proposed-end - :doc:`via-category` .. include:: via-category.rst - :start-after: proposed start - :end-before: proposed end - -:doc:`withPoints-category` - -.. include:: withPoints-category.rst - :start-after: proposed start - :end-before: proposed end - -.. toctree:: - :hidden: - - withPoints-family - KSP-category - via-category - withPoints-category + :start-after: proposed-start + :end-before: proposed-end See Also ------------------------------------------------------------------------------- diff --git a/doc/src/routingFunctions.rst b/doc/src/routingFunctions.rst index 3f187c89f5e..17c1856f353 100644 --- a/doc/src/routingFunctions.rst +++ b/doc/src/routingFunctions.rst @@ -104,8 +104,14 @@ Function Families :doc:`utilities-family` .. include:: utilities-family.rst - :start-after: utility_official-start - :end-before: utility_official-end + :start-after: official-start + :end-before: official-end + +:doc:`withPoints-family` + +.. include:: withPoints-family.rst + :start-after: official-start + :end-before: official-end Functions by categories =============================================================================== @@ -153,6 +159,12 @@ Functions by categories :start-after: official-start :end-before: official-end +:doc:`withPoints-category` + +.. include:: withPoints-category.rst + :start-after: official-start + :end-before: official-end + .. to-here .. toctree:: @@ -173,6 +185,7 @@ Functions by categories TRSP-family TSP-family utilities-family + withPoints-family .. toctree:: :hidden: diff --git a/doc/traversal/traversal-family.rst b/doc/traversal/traversal-family.rst index ec3be222f37..331a51bf06a 100644 --- a/doc/traversal/traversal-family.rst +++ b/doc/traversal/traversal-family.rst @@ -18,11 +18,11 @@ Traversal - Family of functions :start-after: warning-begin :end-before: end-warning -.. official-start +.. proposed-start * :doc:`pgr_depthFirstSearch` - Depth first search traversal of the graph. -.. official-end +.. proposed-end .. include:: experimental.rst :start-after: warning-begin diff --git a/doc/utilities/utilities-family.rst b/doc/utilities/utilities-family.rst index ad7e01da699..1290e95645a 100644 --- a/doc/utilities/utilities-family.rst +++ b/doc/utilities/utilities-family.rst @@ -14,7 +14,7 @@ Utility functions =============================================================================== -.. utility_official-start +.. official-start - :doc:`pgr_extractVertices` - Extracts vertex information based on the edge table information. @@ -22,7 +22,7 @@ Utility functions - :doc:`pgr_separateCrossing` - Breaks geometries that cross each other. - :doc:`pgr_separateTouching` - Breaks geometries that (almost) touch each other. -.. utility_official-end +.. official-end .. toctree:: :hidden: diff --git a/doc/withPoints/withPoints-family.rst b/doc/withPoints/withPoints-family.rst index 83e47ee8413..1db757138b5 100644 --- a/doc/withPoints/withPoints-family.rst +++ b/doc/withPoints/withPoints-family.rst @@ -16,11 +16,7 @@ withPoints - Family of functions When points are also given as input: -.. include:: proposed.rst - :start-after: warning-begin - :end-before: end-warning - -.. proposed-start +.. official-start - :doc:`pgr_withPoints` - Route from/to points anywhere on the graph. - :doc:`pgr_withPointsCost` - Costs of the shortest paths. @@ -29,7 +25,7 @@ When points are also given as input: - :doc:`pgr_withPointsDD` - Driving distance. - :doc:`pgr_withPointsVia` - Via routing -.. proposed-end +.. official-end .. toctree:: :hidden: @@ -73,33 +69,9 @@ Optional parameters With points optional parameters ............................................................................... -.. withPoints_optionals_start - -.. list-table:: - :width: 81 - :widths: 14 7 7 60 - :header-rows: 1 - - * - Parameter - - Type - - Default - - Description - * - ``driving_side`` - - ``CHAR`` - - ``b`` - - Value in [``r``, ``l``, ``b``] indicating if the driving side is: - - - ``r`` for right driving side. - - ``l`` for left driving side. - - ``b`` for both. - * - ``details`` - - ``BOOLEAN`` - - ``false`` - - - When ``true`` the results will include the points that are in the path. - - When ``false`` the results will not include the points that are in the - path. - -.. withPoints_optionals_end +.. include:: withPoints-category.rst + :start-after: withPoints_optionals_start + :end-before: withPoints_optionals_end Inner Queries ------------------------------------------------------------------------------- @@ -111,13 +83,6 @@ Edges SQL :start-after: basic_edges_sql_start :end-before: basic_edges_sql_end -Points SQL -............................................................................... - -.. include:: withPoints-category.rst - :start-after: points_sql_start - :end-before: points_sql_end - Combinations SQL ............................................................................... @@ -125,6 +90,13 @@ Combinations SQL :start-after: basic_combinations_sql_start :end-before: basic_combinations_sql_end +Points SQL +............................................................................... + +.. include:: withPoints-category.rst + :start-after: points_sql_start + :end-before: points_sql_end + Advanced Documentation ------------------------------------------------------------------------------- From 6d0286dabf2c13208114e488dffbdcf9632c9547 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 15:06:42 -0600 Subject: [PATCH 38/39] Adjusting NEWS about driving side changes --- NEWS.md | 451 ++++++++++++++++++++++++++------------ doc/src/release_notes.rst | 427 +++++++++++++++++++++++++----------- 2 files changed, 602 insertions(+), 276 deletions(-) diff --git a/NEWS.md b/NEWS.md index 42f8c0f3787..99a917abff6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,108 +13,213 @@ To see all issues & pull requests closed by this release see the [Git closed milestone for 4.0.0 ](https://github.com/pgRouting/pgrouting/issues?utf8=%E2%9C%93&q=milestone%3A%22Release%204.0.0%22) -Functions promoted to official + +Summary of changes by function ............................................................................... +* pgr_contraction + + .. Breaking change + * Breaking change, signatures no longer available: + * pgr_contraction(text,bigint[],integer,bigint[],boolean) + +* pgr_bdDijkstra + + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + * Combinations signature promoted to official. + +* pgr_bellmanFord + + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + +* pgr_binaryBreadthFirstSearch + + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + +* pgr_edwardMoore + + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + +* pgr_DAGshortestPath + + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + * pgr_trsp + + * Function promoted to official. + .. Breaking change + * Breaking change, signatures no longer available: + * pgr_trsp(text,integer,integer,boolean,boolean,text) + * pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) + * pgr_trspVia + + * Function promoted to official. + * Breaking change, signatures no longer available: + * pgr_trspviavertices(text,anyarray,boolean,boolean,text) + * pgr_trspVia_withPoints + + * Function promoted to official. + * **Driving side** parameter is positional unnamed and compulsory. + * Valid values depend on kind of graph + * Breaking change, signatures no longer available: + * pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) + * pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) + * pgr_trsp_withPoints -* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) pgr_withPoints - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` * Function promoted to official. - * Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` + * **Driving side** parameter is positional unnamed and compulsory. + * Valid values depend on kind of graph + * Breaking change, signatures no longer available: + * pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,anyarray,bigint,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,bigint,anyarray,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,bigint,bigint,boolean,character,boolean) + * pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) -* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) pgr_withPointsCost +* pgr_withPoints * Function promoted to official. + * **Driving side** parameter is positional unnamed and compulsory. + * Valid values depend on kind of graph + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + .. Breaking change + * Breaking change, signatures no longer available: + * pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean) + * pgr_withpoints(text,text,anyarray,bigint,boolean,character,boolean) + * pgr_withpoints(text,text,bigint,anyarray,boolean,character,boolean) + * pgr_withpoints(text,text,bigint,bigint,boolean,character,boolean) + * pgr_withpoints(text,text,text,boolean,character,boolean) + +* pgr_withPointsCost + + * Function promoted to official. + * **Driving side** parameter is unnamed and compulsory. + * Valid values depend on kind of graph * Output columns standardized to ``(start_vid, end_vid, agg_cost)`` - * Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` + * Breaking change, signatures no longer available: + * pgr_withpointscost(text,text,anyarray,anyarray,boolean,character) + * pgr_withpointscost(text,text,anyarray,bigint,boolean,character) + * pgr_withpointscost(text,text,bigint,anyarray,boolean,character) + * pgr_withpointscost(text,text,bigint,bigint,boolean,character) + * pgr_withpointscost(text,text,text,boolean,character) -* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) - pgr_withPointsCostMatrix +* pgr_withPointsCostMatrix * Function promoted to official. + * **Driving side** parameter is positional unnamed and compulsory. + * Valid values depend on kind of graph * Output columns standardized to ``(start_vid, end_vid, agg_cost)`` - * Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` + * Breaking change, signatures no longer available: + * pgr_withpointscostmatrix(text,text,anyarray,boolean,character) * pgr_withPointsDD + + * Function promoted to official. + .. Breaking change + * Breaking change, signatures no longer available: + * pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) + * pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) + * pgr_withPointsKSP + + * Function promoted to official. + .. Breaking change + * Breaking change, signatures no longer available: + * pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) + * pgr_withPointsVia -**Signatures promoted to official** - -[#2718](https://github.com/pgRouting/pgrouting/issues/2918) - Make official the Combinations signature on the official functions - -* pgr_aStar(Combinations) -* pgr_aStarCost(Combinations) -* pgr_bdAstar(Combinations) -* pgr_bdAstarCost(Combinations) -* pgr_bdDijkstra(Combinations) -* pgr_bdDijkstraCost(Combinations) -* pgr_dijkstra(Combinations) -* pgr_dijkstraCost(Combinations) -* pgr_KSP(All signatures) -* pgr_boykovKolmogorov(Combinations) -* pgr_edmondsKarp(Combinations) -* pgr_maxFlow(Combinations) -* pgr_pushRelabel(Combinations) + * Function promoted to official. + * **Driving side** parameter is positional unnamed and compulsory. + * Valid values depend on kind of graph + .. Breaking change + * Breaking change, signatures no longer available: + * pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) -SQL signatures and output standardization +Functions promoted to official ............................................................................... -[#2904](https://github.com/pgRouting/pgrouting/issues/2904) -Standardize output columns of functions with different output columns within overloads +* [#2701](https://github.com/pgRouting/pgrouting/issues/2701) + pgr_trsp +* [#2701](https://github.com/pgRouting/pgrouting/issues/2701) + pgr_trspVia +* [#2701](https://github.com/pgRouting/pgrouting/issues/2701) + pgr_trspVia_withPoints +* [#2701](https://github.com/pgRouting/pgrouting/issues/2701) + pgr_trsp_withPoints +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPoints +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPointsCost +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPointsCostMatrix +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPointsDD +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPointsKSP +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPointsVia -**Official functions** +Signatures promoted to official +............................................................................... -* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) - pgr_withPoints +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_aStar(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_aStarCost(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_bdAstar(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_bdAstarCost(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_bdDijkstra(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_bdDijkstraCost(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_dijkstra(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_dijkstraCost(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_KSP(All signatures) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_boykovKolmogorov(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_edmondsKarp(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_maxFlow(Combinations) +* [#2718](https://github.com/pgRouting/pgrouting/issues/2918) + pgr_pushRelabel(Combinations) - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` - * Function promoted to official. - * Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` - -* [#2906](https://github.com/pgRouting/pgrouting/issues/2906) pgr_bdDijkstra +SQL signatures and output standardization +............................................................................... - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` - * Combinations signature promoted to official. +[#2904](https://github.com/pgRouting/pgrouting/issues/2904) +Standardize output columns of functions with different output columns within overloads -**Experimental functions** +**Standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``** +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPoints +* [#2906](https://github.com/pgRouting/pgrouting/issues/2906) + pgr_bdDijkstra * [#2907](https://github.com/pgRouting/pgrouting/issues/2907) pgr_bellmanFord - - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` - * [#2908](https://github.com/pgRouting/pgrouting/issues/2908) pgr_binaryBreadthFirstSearch - - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` - * [#2910](https://github.com/pgRouting/pgrouting/issues/2910) pgr_edwardMoore - - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` - * [#2913](https://github.com/pgRouting/pgrouting/issues/2913) pgr_DAGshortestPath - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` +**Standardized to ``(start_vid, end_vid, agg_cost)``** + +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPointsCost +* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) + pgr_withPointsCostMatrix Removal of SQL deprecated signatures ............................................................................... @@ -122,12 +227,17 @@ Removal of SQL deprecated signatures * [#2798](https://github.com/pgRouting/pgrouting/issues/2798): pgr_contraction - * pgr_contraction(text,bigint[],integer,bigint[],boolean) + * pgr_contraction(text,bigint[],integer,bigint[],boolean) * [#2683](https://github.com/pgRouting/pgrouting/issues/2683): pgr_trsp - * pgr_trsp(text,integer,integer,boolean,boolean,text) - * pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) + * pgr_trsp(text,integer,integer,boolean,boolean,text) + * pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) + +* [#2700](https://github.com/pgRouting/pgrouting/issues/2700): + pgr_withPointsVia + + * pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) * [#2888](https://github.com/pgRouting/pgrouting/issues/2888): pgr_findCloseEdges @@ -138,23 +248,31 @@ Removal of SQL deprecated signatures * [#2890](https://github.com/pgRouting/pgrouting/issues/2890): pgr_withPointsDD - * pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) - * pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) + * pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) + * pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) * [#2895](https://github.com/pgRouting/pgrouting/issues/2895): pgr_withPointsKSP - * pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) + * pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) * [#2899](https://github.com/pgRouting/pgrouting/issues/2899): pgr_maxCardinalityMatch - * pgr_maxcardinalitymatch(text,boolean) + * pgr_maxCardinalityMatch(text,boolean) + +* [#2901](https://github.com/pgRouting/pgrouting/issues/2901): + pgr_TSP + + * pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double + precision,double precision,double precision,boolean) -* [#2901](https://github.com/pgRouting/pgrouting/issues/2901): TSP family +* [#2901](https://github.com/pgRouting/pgrouting/issues/2901): + pgr_TSPeuclidean + + * pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer, + integer,double precision,double precision,double precision,boolean) - * pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) - * pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) Removal of SQL deprecated functions ............................................................................... @@ -176,90 +294,139 @@ Removal of SQL deprecated functions * [#2886](https://github.com/pgRouting/pgrouting/issues/2886): pgr_nodeNetwork -rubric:: Removal of SQL deprecated internal functions +Removal of SQL deprecated internal functions ............................................................................... -Related issues: [#2897](https://github.com/pgRouting/pgrouting/issues/2897) - -* _pgr_dijkstranear(text,anyarray,anyarray,bigint,boolean) -* _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean) -* _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean) -* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint) -* _pgr_dijkstra(text,text,boolean,boolean,boolean) -* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) -* _pgr_ksp(text,anyarray,anyarray,integer,boolean,boolean,boolean) -* _pgr_ksp(text,bigint,bigint,integer,boolean,boolean) -* _pgr_ksp(text,text,integer,boolean,boolean) -* _pgr_kruskal(text,anyarray,text,bigint,double precision) -* _pgr_maxcardinalitymatch(text,boolean) -* _pgr_prim(text,anyarray,text,bigint,double precision) -* _pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) -* _pgr_trsp(text,text,anyarray,anyarray,boolean) -* _pgr_trsp(text,text,anyarray,bigint,boolean) -* _pgr_trsp(text,text,bigint,anyarray,boolean) -* _pgr_trsp(text,text,bigint,bigint,boolean) -* _pgr_trspviavertices(text,integer[],boolean,boolean,text) -* _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) -* _pgr_withpointsksp(text,text,anyarray,anyarray,integer,character,boolean,boolean,boolean,boolean) -* _pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) -* _pgr_withpointsksp(text,text,text,integer,character,boolean,boolean,boolean) -* _pgr_withpointsvia(text,bigint[],double precision[],boolean) -* _trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,text,boolean) -* _pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) -* _pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) -* [#2913](https://github.com/pgRouting/pgrouting/issues/2913) - _pgr_dagshortestpath(text,text,boolean,boolean) -* [#2913](https://github.com/pgRouting/pgrouting/issues/2913) - _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) - - -* [#2861](https://github.com/pgRouting/pgrouting/issues/2861): - Remove unused internal functions - - - _pgr_checkverttab(text,text[],integer,text) - - _pgr_createindex(text,text,text,integer,text) - - _pgr_createindex(text,text,text,text,integer,text) - - _pgr_endpoint(geometry) - - _pgr_getcolumnname(text,text,integer,text) - - _pgr_getcolumnname(text,text,text,integer,text) - - _pgr_getcolumntype(text,text,integer,text) - - _pgr_getcolumntype(text,text,text,integer,text) - - _pgr_gettablename(text,integer,text) - - _pgr_iscolumnindexed(text,text,integer,text) - - _pgr_iscolumnindexed(text,text,text,integer,text) - - _pgr_iscolumnintable(text,text) - - _pgr_msg(integer,text,text) - - _pgr_onerror(boolean,integer,text,text,text,text) - - _pgr_pointtoid(geometry,double precision,text,integer) - - _pgr_quote_ident(text) - - _pgr_startpoint(geometry) - - _pgr_versionless(text,text) +* #2748 _pgr_alphashape(text,double precision) +* #2861 _pgr_checkverttab(text,text[],integer,text) +* #2861 _pgr_createindex(text,text,text,integer,text) +* #2861 _pgr_createindex(text,text,text,text,integer,text) +* #2913 _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) +* #2913 _pgr_dagshortestpath(text,text,boolean,boolean) +* #2730 _pgr_dijkstranear(text,anyarray,anyarray,bigint,boolean) +* #2730 _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean) +* #2730 _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean) +* #2730 _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint) +* #2730 _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean) +* #2730 _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean) +* #2730 _pgr_dijkstra(text,text,boolean,boolean,boolean) +* #2735 _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) +* #2861 _pgr_endpoint(geometry) +* #2861 _pgr_getcolumnname(text,text,integer,text) +* #2861 _pgr_getcolumnname(text,text,text,integer,text) +* #2861 _pgr_getcolumntype(text,text,integer,text) +* #2861 _pgr_getcolumntype(text,text,text,integer,text) +* #2861 _pgr_gettablename(text,integer,text) +* #2861 _pgr_iscolumnindexed(text,text,integer,text) +* #2861 _pgr_iscolumnindexed(text,text,text,integer,text) +* #2861 _pgr_iscolumnintable(text,text) +* #2745 _pgr_kruskal(text,anyarray,text,bigint,double precision) +* #2897 _pgr_ksp(text,anyarray,anyarray,integer,boolean,boolean,boolean) +* #2897 _pgr_ksp(text,bigint,bigint,integer,boolean,boolean) +* #2897 _pgr_ksp(text,text,integer,boolean,boolean) +* #2899 _pgr_maxcardinalitymatch(text,boolean) +* #2861 _pgr_msg(integer,text,text) +* #2861 _pgr_onerror(boolean,integer,text,text,text,text) +* #2861 _pgr_pointtoid(geometry,double precision,text,integer) +* #2743 _pgr_prim(text,anyarray,text,bigint,double precision) +* #2861 _pgr_quote_ident(text) +* #2861 _pgr_startpoint(geometry) +* #2683 _pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) +* #2683 _pgr_trsp(text,text,anyarray,anyarray,boolean) +* #2683 _pgr_trsp(text,text,anyarray,bigint,boolean) +* #2683 _pgr_trsp(text,text,bigint,anyarray,boolean) +* #2683 _pgr_trsp(text,text,bigint,bigint,boolean) +* #2682 _pgr_trspviavertices(text,integer[],boolean,boolean,text) +* #2919 _pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) +* #2919 _pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) +* #2919 _pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) +* #2901 _pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2901 _pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2861 _pgr_versionless(text,text) +* #2890 _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) +* #2895 _pgr_withpointsksp(text,text,anyarray,anyarray,integer,character,boolean,boolean,boolean,boolean) +* #2895 _pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) +* #2895 _pgr_withpointsksp(text,text,text,integer,character,boolean,boolean,boolean) +* #2741 _pgr_withpointsvia(text,bigint[],double precision[],boolean) +* #2741 _pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) +* #2683 _trsp(text,text,anyarray,anyarray,boolean) +* #2683 _v4trsp(text,text,anyarray,anyarray,boolean) +* #2683 _v4trsp(text,text,text,boolean) + +Summary of functions and signatures no longer on pgrouting +............................................................................... + +* #2748 pgr_alphashape(geometry,double precision) +* #2752 pgr_analyzegraph(text,double precision,text,text,text,text,text) +* #2755 pgr_analyzeoneway(text,text[],text[],text[],text[],boolean,text,text,text) +* #2798 pgr_contraction(text,bigint[],integer,bigint[],boolean) +* #2751 pgr_createtopology(text,double precision,text,text,text,text,text,boolean) +* #2827 pgr_createverticestable(text,text,text,text,text) +* #2888 pgr_findcloseedges(text,geometry,double precision,integer,boolean,boolean) +* #2888 pgr_findcloseedges(text,geometry[],double precision,integer,boolean,boolean) +* #2899 pgr_maxcardinalitymatch(text,boolean) +* #2886 pgr_nodenetwork(text,double precision,text,text,text,text,boolean) +* #2683 pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) +* #2683 pgr_trsp(text,integer,integer,boolean,boolean,text) +* #2681 pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) +* #2682 pgr_trspviavertices(text,anyarray,boolean,boolean,text) +* #2919 pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,anyarray,bigint,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,bigint,anyarray,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,bigint,bigint,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) +* #2901 pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2901 pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2919 pgr_withpointscostmatrix(text,text,anyarray,boolean,character) +* #2919 pgr_withpointscost(text,text,anyarray,anyarray,boolean,character) +* #2919 pgr_withpointscost(text,text,anyarray,bigint,boolean,character) +* #2919 pgr_withpointscost(text,text,bigint,anyarray,boolean,character) +* #2919 pgr_withpointscost(text,text,bigint,bigint,boolean,character) +* #2919 pgr_withpointscost(text,text,text,boolean,character) +* #2890 pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) +* #2890 pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) +* #2895 pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,anyarray,bigint,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,bigint,anyarray,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,bigint,bigint,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,text,boolean,character,boolean) +* #2919 pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) + +**Internal functions** + Code enhancements ............................................................................... * Removal of unused C/C++ code * Refactor the Script to build the update PostgreSQL file. -* One driver for: +* One process & driver for: - * allpairs: johnson and Flowy-Warshall + * allpairs: johnson and Floyd-Warshall * Shortest path: Dijkstra and withPoints using Dijkstra **Deprecation of internal C/C++ functions** -* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) -* _pgr_kruskal(text,anyarray,text,bigint,double precision) -* _pgr_prim(text,anyarray,text,bigint,double precision) +Deprecated functions are substitued by new function. + +* _pgr_drivingdistance => _pgr_drivingdistancev4 +* _pgr_withpointsdd => _pgr_withpointsddv4 +* _pgr_kruskal => _pgr_kruskalv4 +* _pgr_prim => _pgr_primv4 +* _pgr_dijkstra => _pgr_dijkstra_v4 +* _pgr_withpointsksp => _pgr_withpointsksp_v4 +* _pgr_trspvia_withpoints => _pgr_trspvia_withpoints_v4 +* _pgr_trsp_withpoints => _pgr_trsp_withpoints_v4 +* _pgr_withpointsvia => _pgr_withpointsvia_v4 **Internal C/C++ functions in legacy** -* _trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,text,boolean) -* _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) -* [#2913](https://github.com/pgRouting/pgrouting/issues/2913) - _pgr_dagshortestpath +* #2683 _trsp +* #2683 _v4trsp +* #2683 _v4trsp +* #2748 _pgr_alphashape +* #2913 _pgr_dagshortestpath diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 97bd782143b..e8f84458ff7 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -43,105 +43,190 @@ To see all issues & pull requests closed by this release see the `Git closed milestone for 4.0.0 `__ -Functions promoted to official +.. contents:: Contents + :local: + :depth: 1 + +Summary of changes by function ............................................................................... -* pgr_trsp -* pgr_trspVia -* pgr_trspVia_withPoints -* pgr_trsp_withPoints -* `#2905 `__ pgr_withPoints +* pgr_contraction - .. include:: pgr_withPoints.rst + .. include:: pgr_contraction.rst :start-after: Version 4.0.0 :end-before: .. rubric -* `#2905 `__ pgr_withPointsCost +* pgr_bdDijkstra - .. include:: pgr_withPointsCost.rst + .. include:: pgr_bdDijkstra.rst :start-after: Version 4.0.0 :end-before: .. rubric -* `#2905 `__ - pgr_withPointsCostMatrix +* pgr_bellmanFord - .. include:: pgr_withPointsCostMatrix.rst + .. include:: pgr_bellmanFord.rst :start-after: Version 4.0.0 :end-before: .. rubric -* pgr_withPointsDD -* pgr_withPointsKSP -* pgr_withPointsVia +* pgr_binaryBreadthFirstSearch -.. rubric:: Signatures promoted to official - -`#2718 `__ - Make official the Combinations signature on the official functions - -* pgr_aStar(Combinations) -* pgr_aStarCost(Combinations) -* pgr_bdAstar(Combinations) -* pgr_bdAstarCost(Combinations) -* pgr_bdDijkstra(Combinations) -* pgr_bdDijkstraCost(Combinations) -* pgr_dijkstra(Combinations) -* pgr_dijkstraCost(Combinations) -* pgr_KSP(All signatures) -* pgr_boykovKolmogorov(Combinations) -* pgr_edmondsKarp(Combinations) -* pgr_maxFlow(Combinations) -* pgr_pushRelabel(Combinations) + .. include:: pgr_binaryBreadthFirstSearch.rst + :start-after: Version 4.0.0 + :end-before: .. rubric -SQL signatures and output standardization -............................................................................... +* pgr_edwardMoore -`#2904 `__ -Standardize output columns of functions with different output columns within overloads + .. include:: pgr_edwardMoore.rst + :start-after: Version 4.0.0 + :end-before: .. rubric -.. rubric:: Official functions +* pgr_DAGshortestPath -* `#2905 `__ - pgr_withPoints + .. include:: pgr_dagShortestPath.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + +* pgr_trsp + + .. include:: pgr_trsp.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + +* pgr_trspVia + + .. include:: pgr_trspVia.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + +* pgr_trspVia_withPoints + + .. include:: pgr_trspVia_withPoints.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + +* pgr_trsp_withPoints + + .. include:: pgr_trsp_withPoints.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + +* pgr_withPoints .. include:: pgr_withPoints.rst :start-after: Version 4.0.0 :end-before: .. rubric -* `#2906 `__ pgr_bdDijkstra +* pgr_withPointsCost - .. include:: pgr_bdDijkstra.rst + .. include:: pgr_withPointsCost.rst :start-after: Version 4.0.0 :end-before: .. rubric -.. rubric:: Experimental functions +* pgr_withPointsCostMatrix -* `#2907 `__ - pgr_bellmanFord + .. include:: pgr_withPointsCostMatrix.rst + :start-after: Version 4.0.0 + :end-before: .. rubric - .. include:: pgr_bellmanFord.rst +* pgr_withPointsDD + + .. include:: pgr_withPointsDD.rst :start-after: Version 4.0.0 :end-before: .. rubric -* `#2908 `__ - pgr_binaryBreadthFirstSearch +* pgr_withPointsKSP - .. include:: pgr_binaryBreadthFirstSearch.rst + .. include:: pgr_withPointsKSP.rst :start-after: Version 4.0.0 :end-before: .. rubric -* `#2910 `__ - pgr_edwardMoore +* pgr_withPointsVia - .. include:: pgr_edwardMoore.rst + .. include:: pgr_withPointsVia.rst :start-after: Version 4.0.0 :end-before: .. rubric +Functions promoted to official +............................................................................... + +* `#2701 `__ + pgr_trsp +* `#2701 `__ + pgr_trspVia +* `#2701 `__ + pgr_trspVia_withPoints +* `#2701 `__ + pgr_trsp_withPoints +* `#2905 `__ + pgr_withPoints +* `#2905 `__ + pgr_withPointsCost +* `#2905 `__ + pgr_withPointsCostMatrix +* `#2905 `__ + pgr_withPointsDD +* `#2905 `__ + pgr_withPointsKSP +* `#2905 `__ + pgr_withPointsVia + +Signatures promoted to official +............................................................................... + +* `#2718 `__ + pgr_aStar(Combinations) +* `#2718 `__ + pgr_aStarCost(Combinations) +* `#2718 `__ + pgr_bdAstar(Combinations) +* `#2718 `__ + pgr_bdAstarCost(Combinations) +* `#2718 `__ + pgr_bdDijkstra(Combinations) +* `#2718 `__ + pgr_bdDijkstraCost(Combinations) +* `#2718 `__ + pgr_dijkstra(Combinations) +* `#2718 `__ + pgr_dijkstraCost(Combinations) +* `#2718 `__ + pgr_KSP(All signatures) +* `#2718 `__ + pgr_boykovKolmogorov(Combinations) +* `#2718 `__ + pgr_edmondsKarp(Combinations) +* `#2718 `__ + pgr_maxFlow(Combinations) +* `#2718 `__ + pgr_pushRelabel(Combinations) + +SQL signatures and output standardization +............................................................................... + +`#2904 `__ +Standardize output columns of functions with different output columns within overloads + +.. rubric:: Standardized to |short-generic-result| + +* `#2905 `__ + pgr_withPoints +* `#2906 `__ + pgr_bdDijkstra +* `#2907 `__ + pgr_bellmanFord +* `#2908 `__ + pgr_binaryBreadthFirstSearch +* `#2910 `__ + pgr_edwardMoore * `#2913 `__ pgr_DAGshortestPath - .. include:: pgr_dagShortestPath.rst - :start-after: Version 4.0.0 - :end-before: .. rubric +.. rubric:: Standardized to |matrix-result| + +* `#2905 `__ + pgr_withPointsCost +* `#2905 `__ + pgr_withPointsCostMatrix Removal of SQL deprecated signatures ............................................................................... @@ -149,12 +234,22 @@ Removal of SQL deprecated signatures * `#2798 `__: pgr_contraction - * pgr_contraction(text,bigint[],integer,bigint[],boolean) + .. include:: pgr_contraction.rst + :start-after: Breaking change + :end-before: .. rubric * `#2683 `__: pgr_trsp - * pgr_trsp(text,integer,integer,boolean,boolean,text) - * pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) + .. include:: pgr_trsp.rst + :start-after: Breaking change + :end-before: .. rubric + +* `#2700 `__: + pgr_withPointsVia + + .. include:: pgr_withPointsVia.rst + :start-after: Breaking change + :end-before: .. rubric * `#2888 `__: pgr_findCloseEdges @@ -165,23 +260,38 @@ Removal of SQL deprecated signatures * `#2890 `__: pgr_withPointsDD - * pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) - * pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) + .. include:: pgr_withPointsDD.rst + :start-after: Breaking change + :end-before: .. rubric * `#2895 `__: pgr_withPointsKSP - * pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) + .. include:: pgr_withPointsKSP.rst + :start-after: Breaking change + :end-before: .. rubric * `#2899 `__: pgr_maxCardinalityMatch - * pgr_maxcardinalitymatch(text,boolean) + .. include:: pgr_maxCardinalityMatch.rst + :start-after: Breaking change + :end-before: .. rubric -* `#2901 `__: TSP family +* `#2901 `__: + pgr_TSP + + .. include:: pgr_TSP.rst + :start-after: Breaking change + :end-before: .. rubric + +* `#2901 `__: + pgr_TSPeuclidean + + .. include:: pgr_TSPeuclidean.rst + :start-after: Breaking change + :end-before: .. rubric - * pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) - * pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) Removal of SQL deprecated functions ............................................................................... @@ -203,91 +313,140 @@ Removal of SQL deprecated functions * `#2886 `__: pgr_nodeNetwork -rubric:: Removal of SQL deprecated internal functions +Removal of SQL deprecated internal functions ............................................................................... -Related issues: `#2897 `__ - -* _pgr_dijkstranear(text,anyarray,anyarray,bigint,boolean) -* _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean) -* _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean) -* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint) -* _pgr_dijkstra(text,text,boolean,boolean,boolean) -* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) -* _pgr_ksp(text,anyarray,anyarray,integer,boolean,boolean,boolean) -* _pgr_ksp(text,bigint,bigint,integer,boolean,boolean) -* _pgr_ksp(text,text,integer,boolean,boolean) -* _pgr_kruskal(text,anyarray,text,bigint,double precision) -* _pgr_maxcardinalitymatch(text,boolean) -* _pgr_prim(text,anyarray,text,bigint,double precision) -* _pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) -* _pgr_trsp(text,text,anyarray,anyarray,boolean) -* _pgr_trsp(text,text,anyarray,bigint,boolean) -* _pgr_trsp(text,text,bigint,anyarray,boolean) -* _pgr_trsp(text,text,bigint,bigint,boolean) -* _pgr_trspviavertices(text,integer[],boolean,boolean,text) -* _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) -* _pgr_withpointsksp(text,text,anyarray,anyarray,integer,character,boolean,boolean,boolean,boolean) -* _pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) -* _pgr_withpointsksp(text,text,text,integer,character,boolean,boolean,boolean) -* _pgr_withpointsvia(text,bigint[],double precision[],boolean) -* _trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,text,boolean) -* _pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) -* _pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) -* `#2913 `__ - _pgr_dagshortestpath(text,text,boolean,boolean) -* `#2913 `__ - _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) - - -* `#2861 `__: - Remove unused internal functions - - - _pgr_checkverttab(text,text[],integer,text) - - _pgr_createindex(text,text,text,integer,text) - - _pgr_createindex(text,text,text,text,integer,text) - - _pgr_endpoint(geometry) - - _pgr_getcolumnname(text,text,integer,text) - - _pgr_getcolumnname(text,text,text,integer,text) - - _pgr_getcolumntype(text,text,integer,text) - - _pgr_getcolumntype(text,text,text,integer,text) - - _pgr_gettablename(text,integer,text) - - _pgr_iscolumnindexed(text,text,integer,text) - - _pgr_iscolumnindexed(text,text,text,integer,text) - - _pgr_iscolumnintable(text,text) - - _pgr_msg(integer,text,text) - - _pgr_onerror(boolean,integer,text,text,text,text) - - _pgr_pointtoid(geometry,double precision,text,integer) - - _pgr_quote_ident(text) - - _pgr_startpoint(geometry) - - _pgr_versionless(text,text) +* #2748 _pgr_alphashape(text,double precision) +* #2861 _pgr_checkverttab(text,text[],integer,text) +* #2861 _pgr_createindex(text,text,text,integer,text) +* #2861 _pgr_createindex(text,text,text,text,integer,text) +* #2913 _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) +* #2913 _pgr_dagshortestpath(text,text,boolean,boolean) +* #2730 _pgr_dijkstranear(text,anyarray,anyarray,bigint,boolean) +* #2730 _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean) +* #2730 _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean) +* #2730 _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint) +* #2730 _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean) +* #2730 _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean) +* #2730 _pgr_dijkstra(text,text,boolean,boolean,boolean) +* #2735 _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) +* #2861 _pgr_endpoint(geometry) +* #2861 _pgr_getcolumnname(text,text,integer,text) +* #2861 _pgr_getcolumnname(text,text,text,integer,text) +* #2861 _pgr_getcolumntype(text,text,integer,text) +* #2861 _pgr_getcolumntype(text,text,text,integer,text) +* #2861 _pgr_gettablename(text,integer,text) +* #2861 _pgr_iscolumnindexed(text,text,integer,text) +* #2861 _pgr_iscolumnindexed(text,text,text,integer,text) +* #2861 _pgr_iscolumnintable(text,text) +* #2745 _pgr_kruskal(text,anyarray,text,bigint,double precision) +* #2897 _pgr_ksp(text,anyarray,anyarray,integer,boolean,boolean,boolean) +* #2897 _pgr_ksp(text,bigint,bigint,integer,boolean,boolean) +* #2897 _pgr_ksp(text,text,integer,boolean,boolean) +* #2899 _pgr_maxcardinalitymatch(text,boolean) +* #2861 _pgr_msg(integer,text,text) +* #2861 _pgr_onerror(boolean,integer,text,text,text,text) +* #2861 _pgr_pointtoid(geometry,double precision,text,integer) +* #2743 _pgr_prim(text,anyarray,text,bigint,double precision) +* #2861 _pgr_quote_ident(text) +* #2861 _pgr_startpoint(geometry) +* #2683 _pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) +* #2683 _pgr_trsp(text,text,anyarray,anyarray,boolean) +* #2683 _pgr_trsp(text,text,anyarray,bigint,boolean) +* #2683 _pgr_trsp(text,text,bigint,anyarray,boolean) +* #2683 _pgr_trsp(text,text,bigint,bigint,boolean) +* #2682 _pgr_trspviavertices(text,integer[],boolean,boolean,text) +* #2919 _pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) +* #2919 _pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) +* #2919 _pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) +* #2901 _pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2901 _pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2861 _pgr_versionless(text,text) +* #2890 _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) +* #2895 _pgr_withpointsksp(text,text,anyarray,anyarray,integer,character,boolean,boolean,boolean,boolean) +* #2895 _pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) +* #2895 _pgr_withpointsksp(text,text,text,integer,character,boolean,boolean,boolean) +* #2741 _pgr_withpointsvia(text,bigint[],double precision[],boolean) +* #2741 _pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) +* #2683 _trsp(text,text,anyarray,anyarray,boolean) +* #2683 _v4trsp(text,text,anyarray,anyarray,boolean) +* #2683 _v4trsp(text,text,text,boolean) + +Summary of functions and signatures no longer on pgrouting +............................................................................... + +* #2748 pgr_alphashape(geometry,double precision) +* #2752 pgr_analyzegraph(text,double precision,text,text,text,text,text) +* #2755 pgr_analyzeoneway(text,text[],text[],text[],text[],boolean,text,text,text) +* #2798 pgr_contraction(text,bigint[],integer,bigint[],boolean) +* #2751 pgr_createtopology(text,double precision,text,text,text,text,text,boolean) +* #2827 pgr_createverticestable(text,text,text,text,text) +* #2888 pgr_findcloseedges(text,geometry,double precision,integer,boolean,boolean) +* #2888 pgr_findcloseedges(text,geometry[],double precision,integer,boolean,boolean) +* #2899 pgr_maxcardinalitymatch(text,boolean) +* #2886 pgr_nodenetwork(text,double precision,text,text,text,text,boolean) +* #2683 pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text) +* #2683 pgr_trsp(text,integer,integer,boolean,boolean,text) +* #2681 pgr_trspviaedges(text,integer[],double precision[],boolean,boolean,text) +* #2682 pgr_trspviavertices(text,anyarray,boolean,boolean,text) +* #2919 pgr_trspvia_withpoints(text,text,text,anyarray,boolean,boolean,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,anyarray,anyarray,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,anyarray,bigint,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,bigint,anyarray,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,bigint,bigint,boolean,character,boolean) +* #2919 pgr_trsp_withpoints(text,text,text,text,boolean,character,boolean) +* #2901 pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2901 pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* #2919 pgr_withpointscostmatrix(text,text,anyarray,boolean,character) +* #2919 pgr_withpointscost(text,text,anyarray,anyarray,boolean,character) +* #2919 pgr_withpointscost(text,text,anyarray,bigint,boolean,character) +* #2919 pgr_withpointscost(text,text,bigint,anyarray,boolean,character) +* #2919 pgr_withpointscost(text,text,bigint,bigint,boolean,character) +* #2919 pgr_withpointscost(text,text,text,boolean,character) +* #2890 pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) +* #2890 pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean) +* #2895 pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,anyarray,bigint,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,bigint,anyarray,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,bigint,bigint,boolean,character,boolean) +* #2919 pgr_withpoints(text,text,text,boolean,character,boolean) +* #2919 pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) + +.. rubric:: Internal functions + Code enhancements ............................................................................... * Removal of unused C/C++ code * Refactor the Script to build the update PostgreSQL file. -* One driver for: +* One process & driver for: - * allpairs: johnson and Flowy-Warshall + * allpairs: johnson and Floyd-Warshall * Shortest path: Dijkstra and withPoints using Dijkstra .. rubric:: Deprecation of internal C/C++ functions -* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean) -* _pgr_kruskal(text,anyarray,text,bigint,double precision) -* _pgr_prim(text,anyarray,text,bigint,double precision) +Deprecated functions are substitued by new function. + +* _pgr_drivingdistance => _pgr_drivingdistancev4 +* _pgr_withpointsdd => _pgr_withpointsddv4 +* _pgr_kruskal => _pgr_kruskalv4 +* _pgr_prim => _pgr_primv4 +* _pgr_dijkstra => _pgr_dijkstra_v4 +* _pgr_withpointsksp => _pgr_withpointsksp_v4 +* _pgr_trspvia_withpoints => _pgr_trspvia_withpoints_v4 +* _pgr_trsp_withpoints => _pgr_trsp_withpoints_v4 +* _pgr_withpointsvia => _pgr_withpointsvia_v4 .. rubric:: Internal C/C++ functions in legacy -* _trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,anyarray,anyarray,boolean) -* _v4trsp(text,text,text,boolean) -* _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) -* `#2913 `__ - _pgr_dagshortestpath +* #2683 _trsp +* #2683 _v4trsp +* #2683 _v4trsp +* #2748 _pgr_alphashape +* #2913 _pgr_dagshortestpath pgRouting 3 ******************************************************************************* From 63bd7cab6b4ef030ce6007d499f196be2f7830a6 Mon Sep 17 00:00:00 2001 From: cvvergara Date: Sun, 22 Jun 2025 15:18:17 -0600 Subject: [PATCH 39/39] fixing NEWS --- NEWS.md | 10 ---------- doc/contraction/pgr_contraction.rst | 2 -- tools/release-scripts/notes2news.pl | 2 +- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/NEWS.md b/NEWS.md index 99a917abff6..bc8e66321f4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,11 +15,9 @@ milestone for 4.0.0 Summary of changes by function -............................................................................... * pgr_contraction - .. Breaking change * Breaking change, signatures no longer available: * pgr_contraction(text,bigint[],integer,bigint[],boolean) @@ -140,7 +138,6 @@ Summary of changes by function * pgr_withpointsvia(text,text,anyarray,boolean,boolean,boolean,character,boolean) Functions promoted to official -............................................................................... * [#2701](https://github.com/pgRouting/pgrouting/issues/2701) pgr_trsp @@ -164,7 +161,6 @@ Functions promoted to official pgr_withPointsVia Signatures promoted to official -............................................................................... * [#2718](https://github.com/pgRouting/pgrouting/issues/2918) pgr_aStar(Combinations) @@ -194,7 +190,6 @@ Signatures promoted to official pgr_pushRelabel(Combinations) SQL signatures and output standardization -............................................................................... [#2904](https://github.com/pgRouting/pgrouting/issues/2904) Standardize output columns of functions with different output columns within overloads @@ -222,7 +217,6 @@ Standardize output columns of functions with different output columns within ove pgr_withPointsCostMatrix Removal of SQL deprecated signatures -............................................................................... * [#2798](https://github.com/pgRouting/pgrouting/issues/2798): pgr_contraction @@ -275,7 +269,6 @@ Removal of SQL deprecated signatures Removal of SQL deprecated functions -............................................................................... * [#2681](https://github.com/pgRouting/pgrouting/issues/2681): pgr_trspviaedges @@ -295,7 +288,6 @@ Removal of SQL deprecated functions pgr_nodeNetwork Removal of SQL deprecated internal functions -............................................................................... * #2748 _pgr_alphashape(text,double precision) * #2861 _pgr_checkverttab(text,text[],integer,text) @@ -354,7 +346,6 @@ Removal of SQL deprecated internal functions * #2683 _v4trsp(text,text,text,boolean) Summary of functions and signatures no longer on pgrouting -............................................................................... * #2748 pgr_alphashape(geometry,double precision) * #2752 pgr_analyzegraph(text,double precision,text,text,text,text,text) @@ -398,7 +389,6 @@ Summary of functions and signatures no longer on pgrouting Code enhancements -............................................................................... * Removal of unused C/C++ code * Refactor the Script to build the update PostgreSQL file. diff --git a/doc/contraction/pgr_contraction.rst b/doc/contraction/pgr_contraction.rst index 999a0122436..4265fc50c35 100644 --- a/doc/contraction/pgr_contraction.rst +++ b/doc/contraction/pgr_contraction.rst @@ -24,8 +24,6 @@ vertices and edges. .. rubric:: Version 4.0.0 -.. Breaking change - * Breaking change, signatures no longer available: * pgr_contraction(text,bigint[],integer,bigint[],boolean) diff --git a/tools/release-scripts/notes2news.pl b/tools/release-scripts/notes2news.pl index 13ffd228afb..4348fdc59b0 100755 --- a/tools/release-scripts/notes2news.pl +++ b/tools/release-scripts/notes2news.pl @@ -57,7 +57,7 @@ sub Usage { next if $skipping and $line !~ /^pgRouting/; $skipping = 0; - next if $line =~ /current|contents|:local:|:depth:|\*\*\*\*\*\*\*|\=\=\=\=\=\=\=|\-\-\-\-\-\-\-|\+\+\+\+\+\+\+\+/; + next if $line =~ /current|contents|:local:|:depth:|\*\*\*\*\*\*\*|\=\=\=\=\=\=\=|\-\-\-\-\-\-\-|\+\+\+\+\+\+\+\+|\.\.\.\.\.\.\.\.\./; $line =~ s/[\|]+//g; $line =~ s/($check)/$conversions{$1}/go;