All four functions below use the same minimal inline graph, so each block can be run standalone, in order, to reproduce the behaviours.
-- pgr_primDD: already standardized
SELECT * FROM pgr_primDD(
'SELECT * FROM (VALUES (100,1,2,1,1),(101,2,3,1,1),(102,3,4,1,1))
AS e(id,source,target,cost,reverse_cost)',
1, -3.5
);
-- ERROR: Negative value found on 'distance'
-- Must be non negative
-- pgr_kruskalDD: already standardized
SELECT * FROM pgr_kruskalDD(
'SELECT * FROM (VALUES (100,1,2,1,1),(101,2,3,1,1),(102,3,4,1,1))
AS e(id,source,target,cost,reverse_cost)',
1, -3.5
);
-- ERROR: Negative value found on 'distance'
-- Must be non negative
-- pgr_drivingDistance: already standardized
SELECT * FROM pgr_drivingDistance(
'SELECT * FROM (VALUES (100,1,2,1,1),(101,2,3,1,1),(102,3,4,1,1))
AS e(id,source,target,cost,reverse_cost)',
1, -3.5
);
-- ERROR: Negative value found on 'distance'
-- Must be positive
-- pgr_withPointsDD: NOT standardized, different message, unchanged from main
SELECT * FROM pgr_withPointsDD(
'SELECT * FROM (VALUES (100,1,2,1,1),(101,2,3,1,1),(102,3,4,1,1))
AS e(id,source,target,cost,reverse_cost)',
'SELECT * FROM (VALUES (1,100,0.5,''b'')) AS p(pid,edge_id,fraction,side)',
1, -3.5, 'b'
);
-- ERROR: Invalid value of 'distance'
-- Valid values are greater than 0
-- pgr_withPointsDD: also wrongly rejects distance = 0
SELECT * FROM pgr_withPointsDD(
'SELECT * FROM (VALUES (100,1,2,1,1),(101,2,3,1,1),(102,3,4,1,1))
AS e(id,source,target,cost,reverse_cost)',
'SELECT * FROM (VALUES (1,100,0.5,''b'')) AS p(pid,edge_id,fraction,side)',
1, 0, 'b'
);
-- ERROR: Invalid value of 'distance'
-- Valid values are greater than 0
Problem
Follow up of #3091, same tests but on
develop(4.1.0-dev), tested on PostgreSQL 17.9 / Ubuntu 24.04.Three of the four catchment functions are already fixed on
develop, butpgr_withPointsDDstill has the exact same problem it has onmain: unchanged code, wrong message, and it wrongly rejectsdistance = 0.pgr_primDD/pgr_kruskalDD/pgr_drivingDistancealready throw a standardized error for negative distance.pgr_withPointsDDstill throws a different, non-standard message, and still rejectsdistance = 0, which every other catchment function accepts.pgr_primDD/pgr_kruskalDDuse the hintMust be non negative, whilepgr_drivingDistanceusesMust be positivesame situation (negative rejected, zero accepted) described with two different hints.All four functions below use the same minimal inline graph, so each block can be run standalone, in order, to reproduce the behaviours.
Reproduction
Summary
distance < 0distance = 0pgr_primDDNegative value found on 'distance'/Must be non negativepgr_kruskalDDNegative value found on 'distance'/Must be non negativepgr_drivingDistanceNegative value found on 'distance'/Must be positivepgr_withPointsDDInvalid value of 'distance'/Valid values are greater than 0Expected
pgr_withPointsDDshould be brought in line with the other three: throwNegative value found on 'distance'fordistance < 0, and acceptdistance = 0.mix of
Must be positiveandMust be non negative).