Skip to content

Commit 2e263e2

Browse files
committed
[depthFirstSearch] Returning empty rows in case of empty edges_sql query
1 parent 87a2bd4 commit 2e263e2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/depthFirstSearch/depthFirstSearch.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ process(
7171
pgr_get_edges(edges_sql, &edges, &total_edges);
7272
PGR_DBG("Total edges in query %ld", total_edges);
7373

74+
if (total_edges == 0) {
75+
if (rootsArr) pfree(rootsArr);
76+
pgr_SPI_finish();
77+
return;
78+
}
79+
7480
PGR_DBG("Starting processing");
7581
clock_t start_t = clock();
7682
char *log_msg = NULL;

src/depthFirstSearch/depthFirstSearch_driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ do_pgr_depthFirstSearch(
6767
pgassert(!(*err_msg));
6868
pgassert(!(*return_tuples));
6969
pgassert(*return_count == 0);
70+
pgassert(total_edges != 0);
7071

7172
std::vector<int64_t> roots(rootsArr, rootsArr + size_rootsArr);
7273

0 commit comments

Comments
 (0)