diff --git a/NEWS.md b/NEWS.md index 5a2d28dd93e..c5b895d3584 100644 --- a/NEWS.md +++ b/NEWS.md @@ -54,6 +54,9 @@ Functions promoted to official **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) @@ -74,14 +77,8 @@ SQL signatures and output standardization [#2904](https://github.com/pgRouting/pgrouting/issues/2904) Standardize output columns of functions with different output columns within overloads - **Official functions** -* [#2906](https://github.com/pgRouting/pgrouting/issues/2906) pgr_bdDijkstra - - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` - * Combinations signature promoted to official. - * [#2905](https://github.com/pgRouting/pgrouting/issues/2905) pgr_withPoints @@ -92,15 +89,10 @@ Standardize output columns of functions with different output columns within ove - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - Undirected graph valid values: ``b`` or ``B`` -* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) - pgr_withPointsCost +* [#2906](https://github.com/pgRouting/pgrouting/issues/2906) pgr_bdDijkstra - * Function promoted to official. - * 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`` + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + * Combinations signature promoted to official. **Experimental functions** @@ -114,6 +106,11 @@ Standardize output columns of functions with different output columns within ove * 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)`` + Removal of SQL deprecated signatures ............................................................................... @@ -207,6 +204,10 @@ Related issues: [#2897](https://github.com/pgRouting/pgrouting/issues/2897) * _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): @@ -253,5 +254,7 @@ Code enhancements * _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 diff --git a/doc/dagShortestPath/pgr_dagShortestPath.rst b/doc/dagShortestPath/pgr_dagShortestPath.rst index 005799c942a..c380b282a75 100644 --- a/doc/dagShortestPath/pgr_dagShortestPath.rst +++ b/doc/dagShortestPath/pgr_dagShortestPath.rst @@ -27,15 +27,19 @@ In particular, the DAG shortest paths algorithm implemented by Boost.Graph. .. rubric:: Availability -* Version 3.2.0 +.. rubric:: Version 4.0.0 - * New experimental function. +* Output columns standardized to |short-generic-result| - * pgr_dagShortestPath(Combinations) +.. rubric:: Version 3.2.0 -* Version 3.0.0 +* New experimental function. - * New experimental function. + * pgr_dagShortestPath(Combinations) + +..rubric:: Version 3.0.0 + +* New experimental function. Description @@ -93,7 +97,7 @@ Signatures | pgr_dagShortestPath(`Edges SQL`_, **start vids**, **end vids**) | pgr_dagShortestPath(`Edges SQL`_, `Combinations SQL`_) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET @@ -108,7 +112,7 @@ One to One | pgr_dagShortestPath(`Edges SQL`_, **start vid**, **end vid**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertex :math:`5` to vertex :math:`11` on a **directed** graph @@ -128,7 +132,7 @@ One to Many | pgr_dagShortestPath(`Edges SQL`_, **start vid**, **end vids**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertex :math:`5` to vertices :math:`\{7, 11\}` @@ -148,7 +152,7 @@ Many to One | pgr_dagShortestPath(`Edges SQL`_, **start vids**, **end vid**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertices :math:`\{5, 10\}` to vertex :math:`11` @@ -168,7 +172,7 @@ Many to Many | pgr_dagShortestPath(`Edges SQL`_, **start vids**, **end vids**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertices :math:`\{5, 15\}` to vertices :math:`\{11, 17\}` on an @@ -189,7 +193,7 @@ Combinations | pgr_dagShortestPath(`Edges SQL`_, `Combinations SQL`_) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: Using a combinations table on an **undirected** graph @@ -234,8 +238,8 @@ Return columns ------------------------------------------------------------------------------- .. include:: pgRouting-concepts.rst - :start-after: return_path_short_start - :end-before: return_path_short_end + :start-after: return_path_complete_start + :end-before: return_path_complete_end Additional Examples ------------------------------------------------------------------------------- diff --git a/doc/src/migration.rst b/doc/src/migration.rst index c1ba077b391..749b4549d3f 100644 --- a/doc/src/migration.rst +++ b/doc/src/migration.rst @@ -81,6 +81,8 @@ types. - `Migration of single path functions`_ * - .. versionchanged:: 4.0.0 :doc:`pgr_bellmanFord` [3]_ - `Migration of single path functions`_ + * - .. versionchanged:: 4.0.0 :doc:`pgr_dagShortestPath` [3]_ + - `Migration of single path functions`_ * - .. versionchanged:: 4.0.0 :doc:`pgr_edwardMoore` [3]_ - `Migration of single path functions`_ * - .. versionchanged:: 4.0.0 :doc:`pgr_withPoints` [2]_ @@ -313,6 +315,9 @@ application. * - ``pgr_bellmanFord`` - v < 4.0 - |old-generic-result| + * - ``pgr_dagShortestPath`` + - v < 4.0 + - |result-1-1| * - ``pgr_edwardMoore`` - v < 4.0 - |old-generic-result| @@ -410,6 +415,24 @@ Before updating pgRouting enumerate the columns: |result-1-1| :start-after: --bdDijkstra-1-to-1-filter :end-before: --bdDijkstra-1-to-m +.. rubric:: Using ``pgr_DAGshortestPath`` + +Migrating `this v3.8 +`__ +example. + +.. literalinclude:: migration.queries + :start-after: --DAGshortestPath-1-to-1 + :end-before: --DAGshortestPath-1-to-1-filter + +Before updating pgRouting enumerate the columns: |result-1-1| + +.. literalinclude:: migration.queries + :start-after: --DAGshortestPath-1-to-1-filter + :end-before: --DAGshortestPath-END + +.. note:: This applies to all signatures of ``pgr_DAGshortestPath`` + Examples for One to Many with one route result ............................................................................... diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 0900f1d4524..8cef4c61d75 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -75,6 +75,9 @@ Functions promoted to official .. rubric:: Signatures promoted to official +`#2718 `__ + Make official the Combinations signature on the official functions + * pgr_aStar(Combinations) * pgr_aStarCost(Combinations) * pgr_bdAstar(Combinations) @@ -95,15 +98,8 @@ SQL signatures and output standardization `#2904 `__ Standardize output columns of functions with different output columns within overloads - .. rubric:: Official functions -* `#2906 `__ pgr_bdDijkstra - - .. include:: pgr_bdDijkstra.rst - :start-after: Version 4.0.0 - :end-before: .. rubric - * `#2905 `__ pgr_withPoints @@ -111,10 +107,9 @@ Standardize output columns of functions with different output columns within ove :start-after: Version 4.0.0 :end-before: .. rubric -* `#2905 `__ - pgr_withPointsCost +* `#2906 `__ pgr_bdDijkstra - .. include:: pgr_withPointsCost.rst + .. include:: pgr_bdDijkstra.rst :start-after: Version 4.0.0 :end-before: .. rubric @@ -134,6 +129,13 @@ Standardize output columns of functions with different output columns within ove :start-after: Version 4.0.0 :end-before: .. rubric +* `#2913 `__ + pgr_DAGshortestPath + + .. include:: pgr_dagShortestPath.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + Removal of SQL deprecated signatures ............................................................................... @@ -227,6 +229,10 @@ Related issues: `#2897 `__ * _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 `__: @@ -273,6 +279,8 @@ Code enhancements * _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 pgRouting 3 ******************************************************************************* diff --git a/docqueries/dagShortestPath/dagShortestPath.result b/docqueries/dagShortestPath/dagShortestPath.result index ff51c630547..efc8f85ff2c 100644 --- a/docqueries/dagShortestPath/dagShortestPath.result +++ b/docqueries/dagShortestPath/dagShortestPath.result @@ -6,62 +6,62 @@ SET SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 5, 11); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 (4 rows) /* -- q3 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 5, ARRAY[7, 11]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | -1 | 0 | 2 - 4 | 1 | 5 | 1 | 1 | 0 - 5 | 2 | 6 | 4 | 1 | 1 - 6 | 3 | 7 | 8 | 1 | 2 - 7 | 4 | 11 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 7 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 7 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 7 | 7 | -1 | 0 | 2 + 4 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 5 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 6 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 7 | 4 | 5 | 11 | 11 | -1 | 0 | 3 (7 rows) /* -- q4 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 10], 11); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 10 | 5 | 1 | 0 - 6 | 2 | 11 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 10 | 11 | 10 | 5 | 1 | 0 + 6 | 2 | 10 | 11 | 11 | -1 | 0 | 1 (6 rows) /* -- q5 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 15], ARRAY[11, 17]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 5 | 1 | 1 | 0 - 6 | 2 | 6 | 4 | 1 | 1 - 7 | 3 | 7 | 8 | 1 | 2 - 8 | 4 | 11 | 9 | 1 | 3 - 9 | 5 | 16 | 15 | 1 | 4 - 10 | 6 | 17 | -1 | 0 | 5 - 11 | 1 | 15 | 16 | 1 | 0 - 12 | 2 | 16 | 15 | 1 | 1 - 13 | 3 | 17 | -1 | 0 | 2 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 5 | 17 | 5 | 1 | 1 | 0 + 6 | 2 | 5 | 17 | 6 | 4 | 1 | 1 + 7 | 3 | 5 | 17 | 7 | 8 | 1 | 2 + 8 | 4 | 5 | 17 | 11 | 9 | 1 | 3 + 9 | 5 | 5 | 17 | 16 | 15 | 1 | 4 + 10 | 6 | 5 | 17 | 17 | -1 | 0 | 5 + 11 | 1 | 15 | 17 | 15 | 16 | 1 | 0 + 12 | 2 | 15 | 17 | 16 | 15 | 1 | 1 + 13 | 3 | 15 | 17 | 17 | -1 | 0 | 2 (13 rows) /* -- q51 */ @@ -79,58 +79,58 @@ SELECT source, target FROM combinations; SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 'SELECT source, target FROM combinations'); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 6 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 6 | 6 | -1 | 0 | 1 (2 rows) /* -- q6 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 10, 5, 10, 10, 5], ARRAY[11, 17, 17, 11]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 5 | 1 | 1 | 0 - 6 | 2 | 6 | 4 | 1 | 1 - 7 | 3 | 7 | 8 | 1 | 2 - 8 | 4 | 11 | 9 | 1 | 3 - 9 | 5 | 16 | 15 | 1 | 4 - 10 | 6 | 17 | -1 | 0 | 5 - 11 | 1 | 10 | 5 | 1 | 0 - 12 | 2 | 11 | -1 | 0 | 1 - 13 | 1 | 10 | 5 | 1 | 0 - 14 | 2 | 11 | 9 | 1 | 1 - 15 | 3 | 16 | 15 | 1 | 2 - 16 | 4 | 17 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 5 | 17 | 5 | 1 | 1 | 0 + 6 | 2 | 5 | 17 | 6 | 4 | 1 | 1 + 7 | 3 | 5 | 17 | 7 | 8 | 1 | 2 + 8 | 4 | 5 | 17 | 11 | 9 | 1 | 3 + 9 | 5 | 5 | 17 | 16 | 15 | 1 | 4 + 10 | 6 | 5 | 17 | 17 | -1 | 0 | 5 + 11 | 1 | 10 | 11 | 10 | 5 | 1 | 0 + 12 | 2 | 10 | 11 | 11 | -1 | 0 | 1 + 13 | 1 | 10 | 17 | 10 | 5 | 1 | 0 + 14 | 2 | 10 | 17 | 11 | 9 | 1 | 1 + 15 | 3 | 10 | 17 | 16 | 15 | 1 | 2 + 16 | 4 | 10 | 17 | 17 | -1 | 0 | 3 (16 rows) /* -- q7 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 10, 11], ARRAY[5, 10, 11]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 10 | 5 | 1 | 0 - 6 | 2 | 11 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 10 | 11 | 10 | 5 | 1 | 0 + 6 | 2 | 10 | 11 | 11 | -1 | 0 | 1 (6 rows) /* -- q8 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 'SELECT * FROM (VALUES (6, 10), (6, 7), (12, 10)) AS combinations (source, target)'); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 6 | 4 | 1 | 0 - 2 | 2 | 7 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 6 | 7 | 6 | 4 | 1 | 0 + 2 | 2 | 6 | 7 | 7 | -1 | 0 | 1 (2 rows) /* -- q9 */ diff --git a/docqueries/src/migration.result b/docqueries/src/migration.result index f7abbc293fb..0dcf166b184 100644 --- a/docqueries/src/migration.result +++ b/docqueries/src/migration.result @@ -1593,12 +1593,12 @@ FROM pgr_bdDijkstra( SELECT * FROM pgr_DAGshortestPath( 'select id, source, target, cost from edges', 5, 11); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 (4 rows) /* --DAGshortestPath-1-to-1-filter */ diff --git a/locale/en/LC_MESSAGES/pgrouting_doc_strings.po b/locale/en/LC_MESSAGES/pgrouting_doc_strings.po index 01df7de5da2..0f793d7000d 100644 --- a/locale/en/LC_MESSAGES/pgrouting_doc_strings.po +++ b/locale/en/LC_MESSAGES/pgrouting_doc_strings.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: pgRouting v3.8\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-12 15:41+0000\n" +"POT-Creation-Date: 2025-06-14 12:05+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3968,6 +3968,12 @@ msgstr "" msgid "Signatures promoted to official" msgstr "" +msgid "`#2718 `__" +msgstr "" + +msgid "Make official the Combinations signature on the official functions" +msgstr "" + msgid "pgr_aStar(Combinations)" msgstr "" @@ -4019,18 +4025,18 @@ msgstr "" msgid "Official functions" msgstr "" -msgid "" -"`#2906 `__ " -"pgr_bdDijkstra" +msgid "`#2905 `__" msgstr "" -msgid "Combinations signature promoted to official." +msgid "pgr_withPoints" msgstr "" -msgid "`#2905 `__" +msgid "" +"`#2906 `__ " +"pgr_bdDijkstra" msgstr "" -msgid "pgr_withPoints" +msgid "Combinations signature promoted to official." msgstr "" msgid "" @@ -4043,6 +4049,11 @@ msgid "" "pgr_edwardMoore" msgstr "" +msgid "" +"`#2913 `__ " +"pgr_DAGshortestPath" +msgstr "" + msgid "Removal of SQL deprecated signatures" msgstr "" @@ -4269,6 +4280,16 @@ msgid "" "precision,double precision,boolean)" msgstr "" +msgid "" +"`#2913 `__ " +"_pgr_dagshortestpath(text,text,boolean,boolean)" +msgstr "" + +msgid "" +"`#2913 `__ " +"_pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean)" +msgstr "" + msgid "" "`#2861 `__: Remove " "unused internal functions" @@ -4352,6 +4373,11 @@ msgstr "" msgid "Internal C/C++ functions in legacy" msgstr "" +msgid "" +"`#2913 `__ " +"_pgr_dagshortestpath" +msgstr "" + msgid "All releases" msgstr "" @@ -4464,6 +4490,9 @@ msgstr "" msgid ":doc:`pgr_bellmanFord` [3]_" msgstr "" +msgid ":doc:`pgr_dagShortestPath` [3]_" +msgstr "" + msgid ":doc:`pgr_edwardMoore` [3]_" msgstr "" @@ -4645,6 +4674,12 @@ msgstr "" msgid "``pgr_bellmanFord``" msgstr "" +msgid "``pgr_dagShortestPath``" +msgstr "" + +msgid "|result-1-1|" +msgstr "" + msgid "``pgr_edwardMoore``" msgstr "" @@ -4723,6 +4758,18 @@ msgid "" "example." msgstr "" +msgid "Using ``pgr_DAGshortestPath``" +msgstr "" + +msgid "" +"Migrating `this v3.8 " +"`__ example." +msgstr "" + +msgid "This applies to all signatures of ``pgr_DAGshortestPath``" +msgstr "" + msgid "Examples for One to Many with one route result" msgstr "" @@ -10422,6 +10469,9 @@ msgstr "" msgid "pgr_dagShortestPath(Combinations)" msgstr "" +msgid "..rubric:: Version 3.0.0" +msgstr "" + msgid "" "Shortest Path for Directed Acyclic Graph(DAG) is a graph search algorithm" " that solves the shortest path problem for weighted directed acyclic " diff --git a/locale/pot/pgrouting_doc_strings.pot b/locale/pot/pgrouting_doc_strings.pot index 06cc7d8a61e..e2de53d4a39 100644 --- a/locale/pot/pgrouting_doc_strings.pot +++ b/locale/pot/pgrouting_doc_strings.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: pgRouting v4.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-12 15:41+0000\n" +"POT-Creation-Date: 2025-06-14 12:05+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3559,6 +3559,12 @@ msgstr "" msgid "Signatures promoted to official" msgstr "" +msgid "`#2718 `__" +msgstr "" + +msgid "Make official the Combinations signature on the official functions" +msgstr "" + msgid "pgr_aStar(Combinations)" msgstr "" @@ -3607,16 +3613,16 @@ msgstr "" msgid "Official functions" msgstr "" -msgid "`#2906 `__ pgr_bdDijkstra" +msgid "`#2905 `__" msgstr "" -msgid "Combinations signature promoted to official." +msgid "pgr_withPoints" msgstr "" -msgid "`#2905 `__" +msgid "`#2906 `__ pgr_bdDijkstra" msgstr "" -msgid "pgr_withPoints" +msgid "Combinations signature promoted to official." msgstr "" msgid "`#2907 `__ pgr_bellmanFord" @@ -3625,6 +3631,9 @@ msgstr "" msgid "`#2910 `__ pgr_edwardMoore" msgstr "" +msgid "`#2913 `__ pgr_DAGshortestPath" +msgstr "" + msgid "Removal of SQL deprecated signatures" msgstr "" @@ -3799,6 +3808,12 @@ msgstr "" msgid "_pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean)" msgstr "" +msgid "`#2913 `__ _pgr_dagshortestpath(text,text,boolean,boolean)" +msgstr "" + +msgid "`#2913 `__ _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean)" +msgstr "" + msgid "`#2861 `__: Remove unused internal functions" msgstr "" @@ -3880,6 +3895,9 @@ msgstr "" msgid "Internal C/C++ functions in legacy" msgstr "" +msgid "`#2913 `__ _pgr_dagshortestpath" +msgstr "" + msgid "All releases" msgstr "" @@ -3985,6 +4003,9 @@ msgstr "" msgid ":doc:`pgr_bellmanFord` [3]_" msgstr "" +msgid ":doc:`pgr_dagShortestPath` [3]_" +msgstr "" + msgid ":doc:`pgr_edwardMoore` [3]_" msgstr "" @@ -4141,6 +4162,12 @@ msgstr "" msgid "``pgr_bellmanFord``" msgstr "" +msgid "``pgr_dagShortestPath``" +msgstr "" + +msgid "|result-1-1|" +msgstr "" + msgid "``pgr_edwardMoore``" msgstr "" @@ -4210,6 +4237,15 @@ msgstr "" msgid "Migrating `this v3.8 `__ example." msgstr "" +msgid "Using ``pgr_DAGshortestPath``" +msgstr "" + +msgid "Migrating `this v3.8 `__ example." +msgstr "" + +msgid "This applies to all signatures of ``pgr_DAGshortestPath``" +msgstr "" + msgid "Examples for One to Many with one route result" msgstr "" @@ -8920,6 +8956,9 @@ msgstr "" msgid "pgr_dagShortestPath(Combinations)" msgstr "" +msgid "..rubric:: Version 3.0.0" +msgstr "" + msgid "Shortest Path for Directed Acyclic Graph(DAG) is a graph search algorithm that solves the shortest path problem for weighted directed acyclic graph, producing a shortest path from a starting vertex (``start_vid``) to an ending vertex (``end_vid``)." msgstr "" diff --git a/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg b/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg index 38ec79a8059..65acdb17c1d 100644 --- a/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg +++ b/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; +UPDATE edges SET cost = sign(cost), reverse_cost = -1 * sign(cost); SELECT plan(1); CREATE OR REPLACE FUNCTION empty_combinations() @@ -26,18 +27,19 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations signature is new on 3.2.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); RETURN; END IF; - RETURN query SELECT is_empty( - 'SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_dagShortestPath( - ''SELECT id, source, target, cost FROM edges'', - ''SELECT * FROM combinations WHERE source IN (-1)'' ) ' - ); - RETURN; + RETURN query SELECT is_empty( + $$ + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_dagShortestPath( + 'SELECT id, source, target, cost FROM edges', + 'SELECT * FROM combinations WHERE source IN (-1)') + $$ + ); + END $BODY$ language plpgsql; diff --git a/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg b/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg index 8f0c4bad8f3..7454b242529 100644 --- a/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg +++ b/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg @@ -21,6 +21,7 @@ BEGIN; SELECT plan(1); +UPDATE edges SET cost = sign(cost), reverse_cost = -1 * sign(cost); UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE OR REPLACE FUNCTION eq_many( sql_TestFunction TEXT, cant INTEGER default 18 ) @@ -30,13 +31,12 @@ DECLARE sql_Combinations TEXT; sql_Many TEXT; BEGIN - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations signature is new on 3.2.0'); + + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); RETURN; END IF; - sql_Combinations := ''; sql_Many := ''; FOR i IN 1.. cant LOOP @@ -69,8 +69,7 @@ END $BODY$ language plpgsql; -SELECT * FROM eq_many('SELECT path_seq, node, edge, cost, agg_cost FROM pgr_dagShortestPath'); +SELECT eq_many('SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_dagShortestPath'); --- Finish the tests and clean up. SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/others/dagShortestPath/inner_query.pg b/pgtap/others/dagShortestPath/inner_query.pg index 9cb16839c62..22d997005fb 100644 --- a/pgtap/others/dagShortestPath/inner_query.pg +++ b/pgtap/others/dagShortestPath/inner_query.pg @@ -19,31 +19,33 @@ 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(132) ELSE plan(98) END; - --- TODO the column has to be dropped because it creates a cycle when cost and reverse cost both have positive values -ALTER TABLE edges DROP COLUMN reverse_cost; - --- ONE TO ONE -SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, 3)'); --- ONE TO MANY -SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, ARRAY[3])'); --- MANY TO ONE -SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], 3)'); --- MANY TO MANY -SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], ARRAY[3])'); - --- COMBINATIONS +UPDATE edges SET cost = sign(cost), reverse_cost = -1 * sign(cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(132) ELSE plan(1) END; + CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ +DECLARE +params TEXT[]; +subs TEXT[]; BEGIN - IF min_version('3.2.0') THEN - RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', $$SELECT * FROM combinations$$)'); - RETURN QUERY SELECT innerquery_combinations('pgr_dagshortestpath($$SELECT * FROM edges$$,',')'); - ELSE - RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.2.0'); + + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); + RETURN; END IF; + + -- ONE TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, 3)'); + -- ONE TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, ARRAY[3])'); + -- MANY TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], 3)'); + -- MANY TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], ARRAY[3])'); + + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', $$SELECT * FROM combinations$$)'); + RETURN QUERY SELECT innerquery_combinations('pgr_dagshortestpath($$SELECT * FROM edges$$,',')'); + END $BODY$ LANGUAGE plpgsql VOLATILE; diff --git a/pgtap/others/dagShortestPath/no_crash_test.pg b/pgtap/others/dagShortestPath/no_crash_test.pg index d869863d1a6..ce2901a643d 100644 --- a/pgtap/others/dagShortestPath/no_crash_test.pg +++ b/pgtap/others/dagShortestPath/no_crash_test.pg @@ -19,8 +19,8 @@ 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(81) ELSE plan(68) END; +UPDATE edges SET cost = sign(cost), reverse_cost = -sign(cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(81) ELSE plan(1) END; CREATE OR REPLACE FUNCTION no_crash() RETURNS SETOF TEXT AS @@ -29,6 +29,12 @@ DECLARE params TEXT[]; subs TEXT[]; BEGIN + + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); + RETURN; + END IF; + PREPARE edges AS SELECT id, source, target, cost FROM edges; @@ -118,12 +124,6 @@ BEGIN ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_dagShortestPath', params, subs); - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations signature is new on 3.2.0'); - RETURN; - END IF; - PREPARE combinations AS SELECT source, target FROM combinations; diff --git a/pgtap/others/dagShortestPath/types_check.pg b/pgtap/others/dagShortestPath/types_check.pg index 469f474e06d..aa1493e7735 100644 --- a/pgtap/others/dagShortestPath/types_check.pg +++ b/pgtap/others/dagShortestPath/types_check.pg @@ -17,91 +17,12 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ -BEGIN; - -SELECT plan(13); - -CREATE OR REPLACE FUNCTION types_check() -RETURNS SETOF TEXT AS -$BODY$ -BEGIN - - RETURN QUERY SELECT has_function('pgr_dagshortestpath'); - - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'bigint' ]); - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'bigint' ]); - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'anyarray' ]); - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'anyarray' ]); - - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'bigint' ], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'bigint' ], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'anyarray' ], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'anyarray' ], 'setof record'); - RETURN QUERY - SELECT CASE - WHEN min_version('3.2.0') THEN - collect_tap( - has_function('pgr_dagshortestpath', ARRAY['text','text']), - function_returns('pgr_dagshortestpath', ARRAY['text','text'], 'setof record') - ) - ELSE - skip(2, 'Combinations functiontionality new on 3.2.0') - END; - - RETURN QUERY - SELECT CASE - WHEN min_version('3.2.0') THEN - collect_tap( - - function_args_eq('pgr_dagshortestpath', - $$VALUES - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","",seq,path_seq,node,edge,cost,agg_cost}'::TEXT[]) - $$ - ), - function_types_eq('pgr_dagshortestpath', - $$VALUES - ('{text,int8,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,int8,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,text,int4,int4,int8,int8,float8,float8}') - $$ - ) - ) - - ELSE - - collect_tap( - - function_args_eq('pgr_dagshortestpath', - $$VALUES - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]) - $$ - ), - function_types_eq('pgr_dagshortestpath', - $$VALUES - ('{text,int8,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,int8,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]) - $$ - ) - ) - END; +BEGIN; -END; -$BODY$ -LANGUAGE plpgsql; +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 types_check(); +SELECT single_path_types_check('pgr_dagshortestpath', '{}'::TEXT[], '{}'::TEXT[], standard_v => '4.0.0'); SELECT finish(); ROLLBACK; diff --git a/sql/dagShortestPath/CMakeLists.txt b/sql/dagShortestPath/CMakeLists.txt index 7e0811123e1..981d638104b 100644 --- a/sql/dagShortestPath/CMakeLists.txt +++ b/sql/dagShortestPath/CMakeLists.txt @@ -1,6 +1,6 @@ SET(LOCAL_FILES - _dagShortestPath.sql + _dagShortestPath.sql dagShortestPath.sql ) diff --git a/sql/dagShortestPath/_dagShortestPath.sql b/sql/dagShortestPath/_dagShortestPath.sql index 9b4756edf40..d2584db4c05 100644 --- a/sql/dagShortestPath/_dagShortestPath.sql +++ b/sql/dagShortestPath/_dagShortestPath.sql @@ -27,57 +27,51 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ---------------------- ---------------------- --- dagShortestPath ---------------------- ---------------------- - ---------------------------- ---_pgr_dagShortestPath ---------------------------- - ---v3.0 -CREATE FUNCTION _pgr_dagShortestPath( - TEXT, - ANYARRAY, - ANYARRAY, - directed BOOLEAN DEFAULT true, - only_cost BOOLEAN DEFAULT false, +--v4.0 +CREATE FUNCTION _pgr_dagShortestPath_v4( + TEXT, -- edges + + ANYARRAY, -- departures + ANYARRAY, -- arrivals + + BOOLEAN, -- only_cost + BOOLEAN, -- normal OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, OUT agg_cost FLOAT) - RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE c IMMUTABLE STRICT; +LANGUAGE C VOLATILE STRICT; ---v3.2 -CREATE FUNCTION _pgr_dagShortestPath( - TEXT, - TEXT, - directed BOOLEAN DEFAULT true, - only_cost BOOLEAN DEFAULT false, +--v4.0 +CREATE FUNCTION _pgr_dagShortestPath_v4( + TEXT, -- edges + TEXT, -- combinations + + BOOLEAN, -- only_cost OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, OUT agg_cost FLOAT) - RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE C IMMUTABLE STRICT; +LANGUAGE C VOLATILE STRICT; -- COMMENTS -COMMENT ON FUNCTION _pgr_dagShortestPath(TEXT, ANYARRAY, ANYARRAY, BOOLEAN, BOOLEAN) +COMMENT ON FUNCTION _pgr_dagShortestPath_v4(TEXT, ANYARRAY, ANYARRAY, BOOLEAN, BOOLEAN) IS 'pgRouting internal function'; -COMMENT ON FUNCTION _pgr_dagShortestPath(TEXT, TEXT, BOOLEAN, BOOLEAN) +COMMENT ON FUNCTION _pgr_dagShortestPath_v4(TEXT, TEXT, BOOLEAN) IS 'pgRouting internal function'; diff --git a/sql/dagShortestPath/dagShortestPath.sql b/sql/dagShortestPath/dagShortestPath.sql index 404d30e008a..8ce3531c4d9 100644 --- a/sql/dagShortestPath/dagShortestPath.sql +++ b/sql/dagShortestPath/dagShortestPath.sql @@ -7,7 +7,7 @@ Mail: project@pgrouting.org Function's developer: Copyright (c) 2018 Sourabh Garg -Mail: sourabh.garg.mat@gmail.com +Mail: sourabh.garg.mat at gmail.com ------ @@ -27,12 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ----------------------- --- pgr_dagShortestPath ----------------------- - -- ONE to ONE ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) BIGINT, -- from_vid (required) @@ -40,6 +36,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -47,16 +45,14 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- ONE to MANY ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) BIGINT, -- from_vid (required) @@ -64,6 +60,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -71,16 +69,14 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- MANY to ONE ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) ANYARRAY, -- from_vids (required) @@ -88,6 +84,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -95,16 +93,14 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- MANY to MANY ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) ANYARRAY, -- from_vids (required) @@ -112,6 +108,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -119,12 +117,10 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- COMBINATIONS @@ -135,6 +131,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -142,24 +140,23 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), _pgr_get_statement($2), true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), _pgr_get_statement($2), false); $BODY$ LANGUAGE sql VOLATILE STRICT COST 100 ROWS 1000; --- COMMENTS COMMENT ON FUNCTION pgr_dagShortestPath(TEXT, BIGINT, BIGINT) IS 'pgr_dagShortestPath(One to One) - EXPERIMENTAL - Parameters: - - Edges SQL with columns: id, source, target, cost [,reverse_cost] - - From vertex identifier - - To vertex identifier + - Edges SQL with columns: id, source, target, cost [,reverse_cost] + - From vertex identifier + - To vertex identifier - Documentation: - - ${PROJECT_DOC_LINK}/pgr_dagShortestPath.html + - ${PROJECT_DOC_LINK}/pgr_dagShortestPath.html '; COMMENT ON FUNCTION pgr_dagShortestPath(TEXT, BIGINT, ANYARRAY) diff --git a/sql/scripts/build-extension-update-files.pl b/sql/scripts/build-extension-update-files.pl index 27656d99d3b..26012aee3b4 100755 --- a/sql/scripts/build-extension-update-files.pl +++ b/sql/scripts/build-extension-update-files.pl @@ -275,6 +275,9 @@ sub generate_upgrade_script { if ($old_minor >= "3.2") { # 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)"); @@ -288,6 +291,11 @@ sub generate_upgrade_script { push @commands, drop_special_case_function("pgr_bellmanford(text,anyarray,bigint,boolean)"); push @commands, drop_special_case_function("pgr_bellmanford(text,bigint,anyarray,boolean)"); + push @commands, drop_special_case_function("pgr_dagshortestpath(text,bigint,bigint)"); + push @commands, drop_special_case_function("pgr_dagshortestpath(text,bigint,anyarray)"); + push @commands, drop_special_case_function("pgr_dagshortestpath(text,anyarray,bigint)"); + push @commands, drop_special_case_function("pgr_dagshortestpath(text,anyarray,anyarray)"); + push @commands, drop_special_case_function("pgr_edwardmoore(text,bigint,bigint,boolean)"); push @commands, drop_special_case_function("pgr_edwardmoore(text,anyarray,bigint,boolean)"); push @commands, drop_special_case_function("pgr_edwardmoore(text,bigint,anyarray,boolean)"); diff --git a/sql/sigs/pgrouting--4.0.sig b/sql/sigs/pgrouting--4.0.sig index 4a6fd80505e..749b9723cd4 100644 --- a/sql/sigs/pgrouting--4.0.sig +++ b/sql/sigs/pgrouting--4.0.sig @@ -90,12 +90,12 @@ pgr_contraction(text,boolean,integer[],integer,bigint[]) _pgr_cuthillmckeeordering(text) pgr_cuthillmckeeordering(text) pgr_dagshortestpath(text,anyarray,anyarray) -_pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) pgr_dagshortestpath(text,anyarray,bigint) pgr_dagshortestpath(text,bigint,anyarray) pgr_dagshortestpath(text,bigint,bigint) pgr_dagshortestpath(text,text) -_pgr_dagshortestpath(text,text,boolean,boolean) +_pgr_dagshortestpath_v4(text,anyarray,anyarray,boolean,boolean) +_pgr_dagshortestpath_v4(text,text,boolean) pgr_degree(text,boolean) pgr_degree(text,text,boolean) _pgr_depthfirstsearch(text,anyarray,boolean,bigint) diff --git a/src/dagShortestPath/dagShortestPath.c b/src/dagShortestPath/dagShortestPath.c index 74295b2a905..55de4edd6f4 100644 --- a/src/dagShortestPath/dagShortestPath.c +++ b/src/dagShortestPath/dagShortestPath.c @@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "c_common/time_msg.h" #include "drivers/dagShortestPath/dagShortestPath_driver.h" -PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS); -PG_FUNCTION_INFO_V1(_pgr_dagshortestpath); +PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_dagshortestpath_v4); static @@ -48,8 +48,8 @@ process( char* combinations_sql, ArrayType *starts, ArrayType *ends, - bool directed, bool only_cost, + bool normal, Path_rt **result_tuples, size_t *result_count) { pgr_SPI_connect(); @@ -65,8 +65,9 @@ process( combinations_sql, starts, ends, - directed, only_cost, + normal, + result_tuples, result_count, &log_msg, @@ -82,9 +83,9 @@ process( pgr_SPI_finish(); } -PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { +PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; - TupleDesc tuple_desc; + TupleDesc tuple_desc; Path_rt *result_tuples = NULL; size_t result_count = 0; @@ -94,8 +95,6 @@ PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); - - PGR_DBG("Calling process"); if (PG_NARGS() == 5) { /* * many to many @@ -110,33 +109,27 @@ PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { &result_tuples, &result_count); - } else if (PG_NARGS() == 4) { + } else if (PG_NARGS() == 3) { /* * combinations */ process( text_to_cstring(PG_GETARG_TEXT_P(0)), text_to_cstring(PG_GETARG_TEXT_P(1)), - NULL, - NULL, + NULL, NULL, PG_GETARG_BOOL(2), - PG_GETARG_BOOL(3), + true, &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"))); + errmsg("function returning record called in context that cannot accept type record"))); } funcctx->tuple_desc = tuple_desc; @@ -152,33 +145,34 @@ PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { Datum result; Datum *values; bool* nulls; + size_t call_cntr = funcctx->call_cntr; - - values = palloc(6 * sizeof(Datum)); - nulls = palloc(6 * sizeof(bool)); - + size_t numb = 8; + values = palloc(numb * sizeof(Datum)); + nulls = palloc(numb * sizeof(bool)); size_t i; - for (i = 0; i < 6; ++i) { + for (i = 0; i < numb; ++i) { nulls[i] = false; } - int64_t seq = funcctx->call_cntr == 0? 1 : result_tuples[funcctx->call_cntr - 1].start_id; + int64_t seq = call_cntr == 0? 1 : result_tuples[call_cntr - 1].start_id; - values[0] = Int32GetDatum((int32_t)funcctx->call_cntr + 1); + values[0] = Int32GetDatum((int32_t)call_cntr + 1); values[1] = Int32GetDatum((int32_t)seq); - 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); + 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[funcctx->call_cntr].start_id = result_tuples[funcctx->call_cntr].edge < 0? 1 : seq + 1; + 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 { - PGR_DBG("Clean up code"); SRF_RETURN_DONE(funcctx); } } diff --git a/src/dagShortestPath/dagShortestPath_driver.cpp b/src/dagShortestPath/dagShortestPath_driver.cpp index f595ec001df..e82da570f8f 100644 --- a/src/dagShortestPath/dagShortestPath_driver.cpp +++ b/src/dagShortestPath/dagShortestPath_driver.cpp @@ -67,11 +67,10 @@ pgr_do_dagShortestPath( ArrayType *starts, ArrayType *ends, - bool directed, bool only_cost, + bool normal, - Path_rt **return_tuples, - size_t *return_count, + Path_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg) { @@ -84,8 +83,8 @@ pgr_do_dagShortestPath( std::ostringstream log; - std::ostringstream err; std::ostringstream notice; + std::ostringstream err; const char *hint = nullptr; try { @@ -96,7 +95,7 @@ pgr_do_dagShortestPath( pgassert(*return_count == 0); hint = combinations_sql; - auto combinations = get_combinations(combinations_sql, starts, ends, true); + auto combinations = get_combinations(combinations_sql, starts, ends, normal); hint = nullptr; if (combinations.empty() && combinations_sql) { @@ -108,7 +107,7 @@ pgr_do_dagShortestPath( hint = edges_sql; - auto edges = get_edges(std::string(edges_sql), true, false); + auto edges = get_edges(std::string(edges_sql), normal, false); if (edges.empty()) { *notice_msg = to_pg_msg("No edges found"); @@ -118,23 +117,16 @@ pgr_do_dagShortestPath( hint = nullptr; std::deque paths; - if (directed) { - pgrouting::DirectedGraph graph; - graph.insert_edges(edges); - paths = pgr_dagShortestPath(graph, combinations, only_cost); - } else { - pgrouting::UndirectedGraph graph; - graph.insert_edges(edges); - paths = pgr_dagShortestPath(graph, combinations, only_cost); - } + pgrouting::DirectedGraph graph; + graph.insert_edges(edges); + paths = pgr_dagShortestPath(graph, combinations, only_cost); auto count = count_tuples(paths); if (count == 0) { (*return_tuples) = NULL; (*return_count) = 0; - notice << "No paths found"; - *log_msg = to_pg_msg(notice); + *log_msg = to_pg_msg("No paths found"); return; } diff --git a/src/legacy/legacy.c b/src/legacy/legacy.c index 7c31558f740..6fb6f76894d 100644 --- a/src/legacy/legacy.c +++ b/src/legacy/legacy.c @@ -56,3 +56,4 @@ 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)