Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not use wildcards on sql #2561

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Changes on the documentation to the following:

* using bootstrap_version 2 because 3+ does not do dropdowns

**SQL enhancements**

* [#2561](https://github.com/pgRouting/pgrouting/issues/2561) Not use
wildcards on SQL

**pgtap tests**

* [#2559](https://github.com/pgRouting/pgrouting/issues/2559) pgtap test using sampledata
Expand Down
5 changes: 5 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Changes on the documentation to the following:

* using bootstrap_version 2 because 3+ does not do dropdowns

.. rubric:: SQL enhancements

* `#2561 <https://github.com/pgRouting/pgrouting/issues/2561>`__ Not use
wildcards on SQL

.. rubric:: pgtap tests

* `#2559 <https://github.com/pgRouting/pgrouting/issues/2559>`__ pgtap test using sampledata
Expand Down
2 changes: 1 addition & 1 deletion docqueries/src/migration.result
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ SELECT * FROM pgr_maxCardinalityMatch(
$$SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edges$$,
directed => true
);
WARNING: pgr_maxCardinalityMatch(text,boolean) deprecated on v3.4.0
WARNING: pgr_maxCardinalityMatch(text,boolean) deprecated signature on v3.4.0
seq | edge | source | target
-----+------+--------+--------
1 | 1 | 5 | 6
Expand Down
2 changes: 1 addition & 1 deletion sql/allpairs/floydWarshall.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CREATE FUNCTION pgr_floydWarshall(
RETURNS SETOF RECORD AS
$BODY$

SELECT *
SELECT start_vid, end_vid, agg_cost
FROM _pgr_floydWarshall(_pgr_get_statement($1), $2);

$BODY$
Expand Down
2 changes: 1 addition & 1 deletion sql/allpairs/johnson.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CREATE FUNCTION pgr_johnson(
RETURNS SETOF RECORD AS
$BODY$

SELECT *
SELECT start_vid, end_vid, agg_cost
FROM _pgr_johnson(_pgr_get_statement($1), $2);

$BODY$
Expand Down
8 changes: 4 additions & 4 deletions sql/astar/astar.sql
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ CREATE FUNCTION pgr_aStar(

RETURNS SETOF RECORD AS
$BODY$
SELECT *
FROM _pgr_aStar(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT) AS a;
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_aStar(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down Expand Up @@ -169,8 +169,8 @@ CREATE FUNCTION pgr_aStar(

RETURNS SETOF RECORD AS
$BODY$
SELECT *
FROM _pgr_aStar(_pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5::FLOAT, $6::FLOAT) AS a;
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_aStar(_pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5::FLOAT, $6::FLOAT);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down
16 changes: 8 additions & 8 deletions sql/bdAstar/bdAstar.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ CREATE FUNCTION pgr_bdAstar(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT, false) AS a;
SELECT seq, path_seq, node, edge, cost, agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -76,8 +76,8 @@ CREATE FUNCTION pgr_bdAstar(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT a.seq, a.path_seq, a.end_vid, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT, false) AS a;
SELECT seq, path_seq, end_vid, node, edge, cost, agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -104,8 +104,8 @@ CREATE FUNCTION pgr_bdAstar(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT a.seq, a.path_seq, a.start_vid, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT, false) AS a;
SELECT seq, path_seq, start_vid, node, edge, cost, agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down Expand Up @@ -133,7 +133,7 @@ CREATE FUNCTION pgr_bdAstar(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], $4, $5, $6::FLOAT, $7::FLOAT, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
Expand Down Expand Up @@ -161,7 +161,7 @@ CREATE FUNCTION pgr_bdAstar(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_bdAstar(_pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5::FLOAT, $6::FLOAT, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
Expand Down
20 changes: 10 additions & 10 deletions sql/bdDijkstra/bdDijkstra.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ CREATE FUNCTION pgr_bdDijkstra(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, false) AS a;
SELECT seq, path_seq, node, edge, cost, agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -73,8 +73,8 @@ CREATE FUNCTION pgr_bdDijkstra(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT a.seq, a.path_seq, a.end_vid, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, false) as a;
SELECT seq, path_seq, end_vid, node, edge, cost, agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -99,8 +99,8 @@ CREATE FUNCTION pgr_bdDijkstra(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT a.seq, a.path_seq, a.start_vid, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, false) as a;
SELECT seq, path_seq, start_vid, node, edge, cost, agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -127,8 +127,8 @@ CREATE FUNCTION pgr_bdDijkstra(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
FROM _pgr_bdDijkstra(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], directed, false) as a;
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], directed, false);
$BODY$
LANGUAGE SQL VOLATILE STRICT
COST 100
Expand All @@ -153,8 +153,8 @@ CREATE FUNCTION pgr_bdDijkstra(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
FROM _pgr_bdDijkstra(_pgr_get_statement($1), _pgr_get_statement($2), directed, false) as a;
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_bdDijkstra(_pgr_get_statement($1), _pgr_get_statement($2), directed, false);
$BODY$
LANGUAGE SQL VOLATILE STRICT
COST 100
Expand Down
8 changes: 4 additions & 4 deletions sql/breadthFirstSearch/breadthFirstSearch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ BEGIN


RETURN QUERY
SELECT *
SELECT a.seq, a.depth, a.start_vid, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_breadthFirstSearch(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], max_depth, directed) AS a;
END;
$BODY$
Expand Down Expand Up @@ -92,7 +92,7 @@ BEGIN


RETURN QUERY
SELECT *
SELECT a.seq, a.depth, a.start_vid, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_breadthFirstSearch(_pgr_get_statement($1), $2::BIGINT[], max_depth, directed) AS a;
END;
$BODY$
Expand All @@ -107,7 +107,7 @@ IS 'pgr_breadthFirstSearch(One to Depth)
- Parameters:
- edges SQL with columns: id, source, target, cost [,reverse_cost]
- From vertex identifier
- Optional Parameters:
- Optional Parameters:
- Maximum Depth := 9223372036854775807
- directed := true
- Documentation:
Expand All @@ -125,4 +125,4 @@ IS 'pgr_breadthFirstSearch(Many to Depth)
- directed := true
- Documentation:
- ${PROJECT_DOC_LINK}/pgr_breadthFirstSearch.html
';
';
2 changes: 1 addition & 1 deletion sql/chinese/pgr_chinesePostman.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CREATE FUNCTION pgr_chinesePostman(

RETURNS SETOF RECORD AS
$BODY$
SELECT *
SELECT seq, node, edge, cost, agg_cost
FROM _pgr_chinesePostman(_pgr_get_statement($1), only_cost := false);
$BODY$
LANGUAGE SQL VOLATILE STRICT;
Expand Down
4 changes: 2 additions & 2 deletions sql/circuits/hawickCircuits.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ RETURNS SETOF RECORD AS
$BODY$
BEGIN
RETURN QUERY
SELECT *
FROM _pgr_hawickCircuits(_pgr_get_statement($1));
SELECT a.seq, a.path_id, a.path_seq, a.start_vid, a.end_vid, a.node, a.edge, a.cost, a.agg_cost
FROM _pgr_hawickCircuits(_pgr_get_statement($1)) AS a;
END;
$BODY$
LANGUAGE plpgsql VOLATILE STRICT;
Expand Down
2 changes: 1 addition & 1 deletion sql/coloring/bipartite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RETURNS SETOF RECORD AS
$BODY$
BEGIN
RETURN QUERY
SELECT *
SELECT node, color
FROM _pgr_bipartite(_pgr_get_statement($1));
END;
$BODY$
Expand Down
4 changes: 2 additions & 2 deletions sql/coloring/edgeColoring.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ RETURNS SETOF RECORD AS
$BODY$
BEGIN
RETURN QUERY
SELECT *
FROM _pgr_edgeColoring(_pgr_get_statement($1));
SELECT a.edge_id, a.color_id
FROM _pgr_edgeColoring(_pgr_get_statement($1)) AS a;
END;
$BODY$
LANGUAGE plpgsql VOLATILE STRICT;
Expand Down
4 changes: 2 additions & 2 deletions sql/coloring/sequentialVertexColoring.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ RETURNS SETOF RECORD AS
$BODY$
BEGIN
RETURN QUERY
SELECT *
FROM _pgr_sequentialVertexColoring(_pgr_get_statement($1));
SELECT a.vertex_id, a.color_id
FROM _pgr_sequentialVertexColoring(_pgr_get_statement($1)) AS a;
END;
$BODY$
LANGUAGE plpgsql VOLATILE STRICT;
Expand Down
2 changes: 1 addition & 1 deletion sql/common/_checkcolumn.sql
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ LANGUAGE plpgsql VOLATILE STRICT;

-- COMMENTS
COMMENT ON FUNCTION _pgr_checkColumn(TEXT, TEXT, TEXT, BOOLEAN, BOOLEAN)
IS '_pgr_checkColumn is an internal function';
IS 'pgRouting internal function';
2 changes: 1 addition & 1 deletion sql/common/_checkquery.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ LANGUAGE plpgsql VOLATILE STRICT;

-- COMMENTS
COMMENT ON FUNCTION _pgr_checkquery(TEXT)
IS '_pgr_checkquery is an internal function';
IS 'pgrouting internal function';
12 changes: 6 additions & 6 deletions sql/common/pgrouting_utilities.sql
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ DECLARE
naming record;
err boolean;
BEGIN
select * into naming from _pgr_getTableName(tab,reportErrs, fnName) ;
select a.sname, a.tname into naming from _pgr_getTableName(tab,reportErrs, fnName) AS a;
sname=naming.sname;
tname=naming.tname;

select * into cname from _pgr_getColumnName(sname,tname,col,reportErrs, fnName);
select _pgr_getColumnName into cname from _pgr_getColumnName(sname,tname,col,reportErrs, fnName);
RETURN cname;
END;

Expand Down Expand Up @@ -239,7 +239,7 @@ $BODY$
DECLARE
cname text;
BEGIN
select * from _pgr_getColumnName(tab,col,0, '_pgr_isColumnInTable') into cname;
select _pgr_getColumnName from _pgr_getColumnName(tab,col,0, '_pgr_isColumnInTable') into cname;
return cname is not null;
END;
$BODY$
Expand Down Expand Up @@ -342,17 +342,17 @@ DECLARE
pkey text;
value boolean;
BEGIN
SELECT * into naming FROM _pgr_getTableName(tab, 0, fnName);
SELECT a.sname, a.tname into naming FROM _pgr_getTableName(tab, 0, fnName) AS a;
sname=naming.sname;
tname=naming.tname;
IF sname IS NULL OR tname IS NULL THEN
RETURN FALSE;
END IF;
SELECT * into cname from _pgr_getColumnName(sname, tname, col, 0, fnName) ;
SELECT _pgr_getColumnName into cname from _pgr_getColumnName(sname, tname, col, 0, fnName) ;
IF cname IS NULL THEN
RETURN FALSE;
END IF;
select * into value from _pgr_isColumnIndexed(sname, tname, cname, reportErrs, fnName);
select _pgr_isColumnIndexed into value from _pgr_isColumnIndexed(sname, tname, cname, reportErrs, fnName);
return value;
END
$BODY$
Expand Down
4 changes: 2 additions & 2 deletions sql/common/utilities_pgr.sql
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ BEGIN
select * into naming from _pgr_getTableName(tab,reportErrs, fnName) ;
sname=naming.sname;
tname=naming.tname;
select * into cname from _pgr_getColumnName(tab,col,reportErrs, fnName) ;
select * into ctype from _pgr_getColumnType(sname,tname,cname,reportErrs, fnName);
select _pgr_getColumnName into cname from _pgr_getColumnName(tab,col,reportErrs, fnName) ;
select _pgr_getColumnType into ctype from _pgr_getColumnType(sname,tname,cname,reportErrs, fnName);
RETURN ctype;
END;

Expand Down
4 changes: 2 additions & 2 deletions sql/components/biconnectedComponents.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ CREATE FUNCTION pgr_biconnectedComponents(
OUT edge BIGINT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
FROM _pgr_biconnectedComponents(_pgr_get_statement($1));
SELECT seq, component, edge
FROM _pgr_biconnectedComponents(_pgr_get_statement($1)) ;
$BODY$
LANGUAGE SQL VOLATILE STRICT;

Expand Down
2 changes: 1 addition & 1 deletion sql/components/connectedComponents.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CREATE FUNCTION pgr_connectedComponents(
OUT node BIGINT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
SELECT seq, component, node
FROM _pgr_connectedComponents(_pgr_get_statement($1));
$BODY$
LANGUAGE SQL VOLATILE STRICT;
Expand Down
4 changes: 2 additions & 2 deletions sql/components/makeConnected.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ CREATE FUNCTION pgr_makeConnected(

RETURNS SETOF RECORD AS
$BODY$
SELECT *
FROM _pgr_makeConnected(_pgr_get_statement($1)) AS a;
SELECT seq, start_vid, end_vid
FROM _pgr_makeConnected(_pgr_get_statement($1));
$BODY$
LANGUAGE SQL VOLATILE STRICT;

Expand Down
2 changes: 1 addition & 1 deletion sql/components/strongComponents.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CREATE FUNCTION pgr_strongComponents(
OUT node BIGINT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
SELECT seq, component, node
FROM _pgr_strongComponents(_pgr_get_statement($1));
$BODY$
LANGUAGE SQL VOLATILE STRICT;
Expand Down
2 changes: 1 addition & 1 deletion sql/contraction/contraction.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CREATE FUNCTION pgr_contraction(
OUT cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT *
SELECT type, id, contracted_vertices, source, target, cost
FROM _pgr_contraction(_pgr_get_statement($1), $2::BIGINT[], $3, $4, $5);
$BODY$
LANGUAGE SQL VOLATILE STRICT;
Expand Down
Loading