@@ -30,59 +30,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3030
3131#include <stdbool.h>
3232#include "c_common/postgres_connection.h"
33-
3433#include "c_types/path_rt.h"
35- #include "c_common/debug_macro.h"
36- #include "c_common/e_report.h"
37- #include "c_common/time_msg.h"
38- #include "drivers/dagShortestPath/dagShortestPath_driver.h"
34+ #include "process/shortestPath_process.h"
3935
4036PGDLLEXPORT Datum _pgr_dagshortestpath_v4 (PG_FUNCTION_ARGS );
4137PG_FUNCTION_INFO_V1 (_pgr_dagshortestpath_v4 );
4238
43-
44- static
45- void
46- process (
47- char * edges_sql ,
48- char * combinations_sql ,
49- ArrayType * starts ,
50- ArrayType * ends ,
51- bool only_cost ,
52- bool normal ,
53- Path_rt * * result_tuples ,
54- size_t * result_count ) {
55- pgr_SPI_connect ();
56- char * log_msg = NULL ;
57- char * notice_msg = NULL ;
58- char * err_msg = NULL ;
59- (* result_tuples ) = NULL ;
60- (* result_count ) = 0 ;
61-
62- clock_t start_t = clock ();
63- pgr_do_dagShortestPath (
64- edges_sql ,
65- combinations_sql ,
66- starts , ends ,
67-
68- only_cost ,
69- normal ,
70-
71- result_tuples ,
72- result_count ,
73- & log_msg ,
74- & notice_msg ,
75- & err_msg );
76- time_msg (" processing pgr_dagShortestPath" , start_t , clock ());
77-
78- if (err_msg ) {
79- if (* result_tuples ) pfree (* result_tuples );
80- }
81- pgr_global_report (& log_msg , & notice_msg , & err_msg );
82-
83- pgr_SPI_finish ();
84- }
85-
8639PGDLLEXPORT Datum _pgr_dagshortestpath_v4 (PG_FUNCTION_ARGS ) {
8740 FuncCallContext * funcctx ;
8841 TupleDesc tuple_desc ;
@@ -99,26 +52,48 @@ PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS) {
9952 /*
10053 * many to many
10154 */
102- process (
55+ pgr_process_shortestPath (
10356 text_to_cstring (PG_GETARG_TEXT_P (0 )),
10457 NULL ,
58+ NULL ,
59+
10560 PG_GETARG_ARRAYTYPE_P (1 ),
10661 PG_GETARG_ARRAYTYPE_P (2 ),
62+
63+ true,
10764 PG_GETARG_BOOL (3 ),
10865 PG_GETARG_BOOL (4 ),
66+
67+ 0 ,
68+ true,
69+ ' ' ,
70+ true,
71+
72+ DAGSP ,
10973 & result_tuples ,
11074 & result_count );
11175
11276 } else if (PG_NARGS () == 3 ) {
11377 /*
11478 * combinations
11579 */
116- process (
80+ pgr_process_shortestPath (
11781 text_to_cstring (PG_GETARG_TEXT_P (0 )),
82+ NULL ,
11883 text_to_cstring (PG_GETARG_TEXT_P (1 )),
84+
11985 NULL , NULL ,
86+
87+ true,
12088 PG_GETARG_BOOL (2 ),
12189 true,
90+
91+ 0 ,
92+ true,
93+ ' ' ,
94+ true,
95+
96+ DAGSP ,
12297 & result_tuples ,
12398 & result_count );
12499 }
@@ -129,7 +104,8 @@ PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS) {
129104 != TYPEFUNC_COMPOSITE ) {
130105 ereport (ERROR ,
131106 (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
132- errmsg ("function returning record called in context that cannot accept type record" )));
107+ errmsg ("function returning record called in context "
108+ "that cannot accept type record" )));
133109 }
134110
135111 funcctx -> tuple_desc = tuple_desc ;
0 commit comments