Skip to content

Commit fdab289

Browse files
committed
(sql,pgtap,docqueries) pgr_turnRestrictedPath: Standardizing output
1 parent 0fbbd1e commit fdab289

3 files changed

Lines changed: 137 additions & 154 deletions

File tree

docqueries/max_flow/edgeDisjointPaths.result

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,60 @@ SELECT * FROM pgr_edgeDisjointPaths(
77
'SELECT id, source, target, cost, reverse_cost
88
FROM edges',
99
11, 12);
10-
seq | path_id | path_seq | node | edge | cost | agg_cost
11-
-----+---------+----------+------+------+------+----------
12-
1 | 1 | 1 | 11 | 8 | 1 | 0
13-
2 | 1 | 2 | 7 | 10 | 1 | 1
14-
3 | 1 | 3 | 8 | 12 | 1 | 2
15-
4 | 1 | 4 | 12 | -1 | 0 | 3
16-
5 | 2 | 1 | 11 | 11 | 1 | 0
17-
6 | 2 | 2 | 12 | -1 | 0 | 1
10+
seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
11+
-----+---------+----------+-----------+---------+------+------+------+----------
12+
1 | 1 | 1 | 11 | 12 | 11 | 8 | 1 | 0
13+
2 | 1 | 2 | 11 | 12 | 7 | 10 | 1 | 1
14+
3 | 1 | 3 | 11 | 12 | 8 | 12 | 1 | 2
15+
4 | 1 | 4 | 11 | 12 | 12 | -1 | 0 | 3
16+
5 | 2 | 1 | 11 | 12 | 11 | 11 | 1 | 0
17+
6 | 2 | 2 | 11 | 12 | 12 | -1 | 0 | 1
1818
(6 rows)
1919

2020
/* -- q2 */
2121
SELECT * FROM pgr_edgeDisjointPaths(
2222
'SELECT id, source, target, cost, reverse_cost
2323
FROM edges',
2424
11, ARRAY[5, 10, 12]);
25-
seq | path_id | path_seq | end_vid | node | edge | cost | agg_cost
26-
-----+---------+----------+---------+------+------+------+----------
27-
1 | 1 | 1 | 5 | 11 | 8 | 1 | 0
28-
2 | 1 | 2 | 5 | 7 | 4 | 1 | 1
29-
3 | 1 | 3 | 5 | 6 | 1 | 1 | 2
30-
4 | 1 | 4 | 5 | 5 | -1 | 0 | 3
31-
5 | 2 | 1 | 10 | 11 | 9 | 1 | 0
32-
6 | 2 | 2 | 10 | 16 | 16 | 1 | 1
33-
7 | 2 | 3 | 10 | 15 | 3 | 1 | 2
34-
8 | 2 | 4 | 10 | 10 | -1 | 0 | 3
35-
9 | 3 | 1 | 12 | 11 | 8 | 1 | 0
36-
10 | 3 | 2 | 12 | 7 | 10 | 1 | 1
37-
11 | 3 | 3 | 12 | 8 | 12 | 1 | 2
38-
12 | 3 | 4 | 12 | 12 | -1 | 0 | 3
39-
13 | 4 | 1 | 12 | 11 | 11 | 1 | 0
40-
14 | 4 | 2 | 12 | 12 | -1 | 0 | 1
25+
seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
26+
-----+---------+----------+-----------+---------+------+------+------+----------
27+
1 | 1 | 1 | 11 | 5 | 11 | 8 | 1 | 0
28+
2 | 1 | 2 | 11 | 5 | 7 | 4 | 1 | 1
29+
3 | 1 | 3 | 11 | 5 | 6 | 1 | 1 | 2
30+
4 | 1 | 4 | 11 | 5 | 5 | -1 | 0 | 3
31+
5 | 2 | 1 | 11 | 10 | 11 | 9 | 1 | 0
32+
6 | 2 | 2 | 11 | 10 | 16 | 16 | 1 | 1
33+
7 | 2 | 3 | 11 | 10 | 15 | 3 | 1 | 2
34+
8 | 2 | 4 | 11 | 10 | 10 | -1 | 0 | 3
35+
9 | 3 | 1 | 11 | 12 | 11 | 8 | 1 | 0
36+
10 | 3 | 2 | 11 | 12 | 7 | 10 | 1 | 1
37+
11 | 3 | 3 | 11 | 12 | 8 | 12 | 1 | 2
38+
12 | 3 | 4 | 11 | 12 | 12 | -1 | 0 | 3
39+
13 | 4 | 1 | 11 | 12 | 11 | 11 | 1 | 0
40+
14 | 4 | 2 | 11 | 12 | 12 | -1 | 0 | 1
4141
(14 rows)
4242

4343
/* -- q3 */
4444
SELECT * FROM pgr_edgeDisjointPaths(
4545
'SELECT id, source, target, cost, reverse_cost
4646
FROM edges',
4747
ARRAY[11, 3, 17], 12);
48-
seq | path_id | path_seq | start_vid | node | edge | cost | agg_cost
49-
-----+---------+----------+-----------+------+------+------+----------
50-
1 | 1 | 1 | 3 | 3 | 7 | 1 | 0
51-
2 | 1 | 2 | 3 | 7 | 8 | 1 | 1
52-
3 | 1 | 3 | 3 | 11 | 11 | 1 | 2
53-
4 | 1 | 4 | 3 | 12 | -1 | 0 | 3
54-
5 | 2 | 1 | 11 | 11 | 8 | 1 | 0
55-
6 | 2 | 2 | 11 | 7 | 10 | 1 | 1
56-
7 | 2 | 3 | 11 | 8 | 12 | 1 | 2
57-
8 | 2 | 4 | 11 | 12 | -1 | 0 | 3
58-
9 | 3 | 1 | 11 | 11 | 11 | 1 | 0
59-
10 | 3 | 2 | 11 | 12 | -1 | 0 | 1
60-
11 | 4 | 1 | 17 | 17 | 15 | 1 | 0
61-
12 | 4 | 2 | 17 | 16 | 9 | 1 | 1
62-
13 | 4 | 3 | 17 | 11 | 11 | 1 | 2
63-
14 | 4 | 4 | 17 | 12 | -1 | 0 | 3
48+
seq | path_id | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
49+
-----+---------+----------+-----------+---------+------+------+------+----------
50+
1 | 1 | 1 | 12 | 3 | 3 | 7 | 1 | 0
51+
2 | 1 | 2 | 12 | 3 | 7 | 8 | 1 | 1
52+
3 | 1 | 3 | 12 | 3 | 11 | 11 | 1 | 2
53+
4 | 1 | 4 | 12 | 3 | 12 | -1 | 0 | 3
54+
5 | 2 | 1 | 12 | 11 | 11 | 8 | 1 | 0
55+
6 | 2 | 2 | 12 | 11 | 7 | 10 | 1 | 1
56+
7 | 2 | 3 | 12 | 11 | 8 | 12 | 1 | 2
57+
8 | 2 | 4 | 12 | 11 | 12 | -1 | 0 | 3
58+
9 | 3 | 1 | 12 | 11 | 11 | 11 | 1 | 0
59+
10 | 3 | 2 | 12 | 11 | 12 | -1 | 0 | 1
60+
11 | 4 | 1 | 12 | 17 | 17 | 15 | 1 | 0
61+
12 | 4 | 2 | 12 | 17 | 16 | 9 | 1 | 1
62+
13 | 4 | 3 | 12 | 17 | 11 | 11 | 1 | 2
63+
14 | 4 | 4 | 12 | 17 | 12 | -1 | 0 | 3
6464
(14 rows)
6565

6666
/* -- q4 */

pgtap/max_flow/edgedisjointpaths/types_check.pg

Lines changed: 40 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,73 +19,56 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1919
********************************************************************PGR-GNU*/
2020
BEGIN;
2121

22-
SELECT plan(13);
22+
SELECT CASE WHEN min_version('4.0.0') THEN plan(13) ELSE plan(12) END;
2323

24-
SELECT has_function('pgr_edgedisjointpaths');
24+
CREATE or REPLACE FUNCTION types_check()
25+
RETURNS SETOF TEXT AS
26+
$BODY$
27+
BEGIN
2528

29+
RETURN QUERY SELECT has_function('pgr_edgedisjointpaths');
2630

27-
SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','bigint','bigint','boolean']);
28-
SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','bigint','anyarray','boolean']);
29-
SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','anyarray','bigint','boolean']);
30-
SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','anyarray','anyarray','boolean']);
31+
RETURN QUERY SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','bigint','bigint','boolean']);
32+
RETURN QUERY SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','bigint','anyarray','boolean']);
33+
RETURN QUERY SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','anyarray','bigint','boolean']);
34+
RETURN QUERY SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','anyarray','anyarray','boolean']);
3135

32-
SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','bigint','bigint','boolean'],'setof record');
33-
SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','bigint','anyarray','boolean'],'setof record');
34-
SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','anyarray','bigint','boolean'],'setof record');
35-
SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','anyarray','anyarray','boolean'],'setof record');
36+
RETURN QUERY SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','bigint','bigint','boolean'],'setof record');
37+
RETURN QUERY SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','bigint','anyarray','boolean'],'setof record');
38+
RETURN QUERY SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','anyarray','bigint','boolean'],'setof record');
39+
RETURN QUERY SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','anyarray','anyarray','boolean'],'setof record');
3640

37-
SELECT CASE
38-
WHEN min_version('3.2.0') THEN
39-
collect_tap(
40-
has_function('pgr_edgedisjointpaths', ARRAY['text','text','boolean']),
41-
function_returns('pgr_edgedisjointpaths', ARRAY['text','text','boolean'],'setof record')
42-
)
43-
ELSE
44-
skip(2, 'Combinations signature added on 3.2.0')
45-
END;
46-
47-
SELECT CASE
48-
WHEN min_version('3.2.0') THEN
49-
collect_tap(
41+
IF min_version('3.2.0') THEN
42+
RETURN QUERY SELECT has_function('pgr_edgedisjointpaths', ARRAY['text','text','boolean']);
43+
RETURN QUERY SELECT function_returns('pgr_edgedisjointpaths', ARRAY['text','text','boolean'],'setof record');
44+
ELSE
45+
RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.2.0');
46+
END IF;
5047

51-
function_args_eq('pgr_edgedisjointpaths',
52-
$$VALUES
53-
('{"","","","directed","seq","path_id","path_seq","node","edge","cost","agg_cost"}'::TEXT[]),
54-
('{"","","","directed","seq","path_id","path_seq","end_vid","node","edge","cost","agg_cost"}'::TEXT[]),
55-
('{"","","","directed","seq","path_id","path_seq","start_vid","node","edge","cost","agg_cost"}'::TEXT[]),
56-
('{"","","","directed","seq","path_id","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[]),
57-
('{"","","directed","seq","path_id","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[])
58-
$$),
48+
IF NOT min_version('4.0.0') THEN
49+
RETURN QUERY SELECT skip(1, 'pgr_edgedisjointpaths: testing only signatures standardaized in v4.0.0.');
50+
RETURN;
51+
END IF;
5952

60-
function_types_eq('pgr_edgedisjointpaths',
61-
$$VALUES
62-
('{text,int8,int8,bool,int4,int4,int4,int8,int8,float8,float8}'::TEXT[]),
63-
('{text,int8,anyarray,bool,int4,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]),
64-
('{text,anyarray,int8,bool,int4,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]),
65-
('{text,anyarray,anyarray,bool,int4,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]),
66-
('{text,text,bool,int4,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[])
67-
$$)
68-
)
69-
ELSE
70-
collect_tap(
53+
RETURN QUERY SELECT function_args_eq('pgr_edgedisjointpaths',
54+
$$VALUES
55+
('{"","","",directed,seq,path_id,path_seq,start_vid,end_vid,node,edge,cost,agg_cost}'::TEXT[]),
56+
('{"","", directed,seq,path_id,path_seq,start_vid,end_vid,node,edge,cost,agg_cost}'::TEXT[])
57+
$$);
7158

72-
function_args_eq('pgr_edgedisjointpaths',
73-
$$VALUES
74-
('{"","","","directed","seq","path_id","path_seq","node","edge","cost","agg_cost"}'::TEXT[]),
75-
('{"","","","directed","seq","path_id","path_seq","end_vid","node","edge","cost","agg_cost"}'::TEXT[]),
76-
('{"","","","directed","seq","path_id","path_seq","start_vid","node","edge","cost","agg_cost"}'::TEXT[]),
77-
('{"","","","directed","seq","path_id","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[])
78-
$$),
79-
80-
function_types_eq('pgr_edgedisjointpaths',
81-
$$VALUES
82-
('{text,int8,int8,bool,int4,int4,int4,int8,int8,float8,float8}'::TEXT[]),
83-
('{text,int8,anyarray,bool,int4,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]),
84-
('{text,anyarray,int8,bool,int4,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]),
59+
RETURN QUERY SELECT function_types_eq('pgr_edgedisjointpaths',
60+
$$VALUES
61+
('{text,text, bool,int4,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]),
62+
('{text,int8,int8, bool,int4,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]),
63+
('{text,int8,anyarray, bool,int4,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]),
64+
('{text,anyarray,int8, bool,int4,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]),
8565
('{text,anyarray,anyarray,bool,int4,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[])
86-
$$)
87-
)
66+
$$);
67+
8868
END;
69+
$BODY$
70+
language plpgsql;
8971

72+
SELECT types_check();
9073
SELECT finish();
9174
ROLLBACK;

0 commit comments

Comments
 (0)