Skip to content
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
6 changes: 0 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ milestone for 4.0.0
* _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean)
* _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean)
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)
* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)
* _pgr_dijkstra(text,text,boolean,boolean,boolean)
* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean)
* _pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text)
Expand All @@ -77,10 +75,6 @@ milestone for 4.0.0
**Deprecation of internal C/C++ functions**

* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean)
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)``
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)``
* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)``
* _pgr_dijkstra(text,text,boolean,boolean,boolean)``

**Internal C/C++ functions in legacy**

Expand Down
6 changes: 0 additions & 6 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ milestone for 4.0.0
* _pgr_dijkstranear(text,anyarray,bigint,bigint,boolean)
* _pgr_dijkstranear(text,bigint,anyarray,bigint,boolean)
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)
* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)
* _pgr_dijkstra(text,text,boolean,boolean,boolean)
* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean)
* _pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text)
Expand All @@ -108,10 +106,6 @@ milestone for 4.0.0
.. rubric:: Deprecation of internal C/C++ functions

* _pgr_drivingdistance(text,anyarray,double precision,boolean,boolean)
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)``
* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)``
* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)``
* _pgr_dijkstra(text,text,boolean,boolean,boolean)``

.. rubric:: Internal C/C++ functions in legacy

Expand Down
35 changes: 31 additions & 4 deletions sql/dijkstra/_dijkstra.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

--v4.0
CREATE FUNCTION _pgr_dijkstrav4(
--v3.2
CREATE FUNCTION _pgr_dijkstra(
edges_sql TEXT,
combinations_sql TEXT,
start_vids ANYARRAY,
end_vids ANYARRAY,
directed BOOLEAN,
Expand All @@ -50,6 +49,34 @@ CREATE FUNCTION _pgr_dijkstrav4(
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
'MODULE_PATHNAME'
LANGUAGE C VOLATILE;
LANGUAGE C VOLATILE STRICT;


--v3.2
CREATE FUNCTION _pgr_dijkstra(
edges_sql TEXT,
combinations_sql TEXT,
directed BOOLEAN,
only_cost BOOLEAN,
n_goals BIGINT,
global BOOLEAN,

OUT seq INTEGER,
OUT path_seq INTEGER,
OUT start_vid BIGINT,
OUT end_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;

-- COMMENTS

COMMENT ON FUNCTION _pgr_dijkstra(TEXT, ANYARRAY, ANYARRAY, BOOLEAN, BOOLEAN, BOOLEAN, BIGINT, BOOLEAN)
IS 'pgRouting internal function';

COMMENT ON FUNCTION _pgr_dijkstra(TEXT, TEXT, BOOLEAN, BOOLEAN, BIGINT, BOOLEAN)
IS 'pgRouting internal function';
10 changes: 5 additions & 5 deletions sql/dijkstra/dijkstra.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CREATE FUNCTION pgr_dijkstra(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, false, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, false, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -79,7 +79,7 @@ CREATE FUNCTION pgr_dijkstra(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, false, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, false, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -105,7 +105,7 @@ CREATE FUNCTION pgr_dijkstra(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, false, false, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, false, false, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -131,7 +131,7 @@ CREATE FUNCTION pgr_dijkstra(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], $3::BIGINT[], $4, false, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], $4, false, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -156,7 +156,7 @@ CREATE FUNCTION pgr_dijkstra(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), _pgr_get_statement($2), NULL::BIGINT[], NULL::BIGINT[], $3, false, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), _pgr_get_statement($2), $3, false, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down
10 changes: 5 additions & 5 deletions sql/dijkstra/dijkstraCost.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CREATE FUNCTION pgr_dijkstraCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, true, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4, true, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -66,7 +66,7 @@ CREATE FUNCTION pgr_dijkstraCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, true, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4, true, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -90,7 +90,7 @@ CREATE FUNCTION pgr_dijkstraCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, true, false, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4, true, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -114,7 +114,7 @@ CREATE FUNCTION pgr_dijkstraCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], $3::BIGINT[], $4, true, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], $4, true, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -134,7 +134,7 @@ CREATE FUNCTION pgr_dijkstraCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), _pgr_get_statement($2), NULL::BIGINT[], NULL::BIGINT[], $3, true, true, 0, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), _pgr_get_statement($2), $3, true, 0, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down
2 changes: 1 addition & 1 deletion sql/dijkstra/dijkstraCostMatrix.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CREATE FUNCTION pgr_dijkstraCostMatrix(
RETURNS SETOF RECORD AS
$BODY$
SELECT a.start_vid, a.end_vid, a.agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2, $2, $3, true, true, 0, false) a;
FROM _pgr_dijkstra(_pgr_get_statement($1), $2, $2, $3, true, true, 0, false) a;
$BODY$
LANGUAGE SQL VOLATILE STRICT
COST 100
Expand Down
8 changes: 4 additions & 4 deletions sql/dijkstra/dijkstraNear.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CREATE FUNCTION pgr_dijkstraNear(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, ARRAY[$2]::BIGINT[], $3::BIGINT[], directed, false, true, cap, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], directed, false, true, cap, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -76,7 +76,7 @@ CREATE FUNCTION pgr_dijkstraNear(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], ARRAY[$3]::BIGINT[], directed, false, false, cap, false);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], directed, false, false, cap, false);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down Expand Up @@ -104,7 +104,7 @@ CREATE FUNCTION pgr_dijkstraNear(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], $3::BIGINT[], directed, false, true, cap, global);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], directed, false, true, cap, global);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -131,7 +131,7 @@ CREATE FUNCTION pgr_dijkstraNear(
RETURNS SETOF RECORD AS
$BODY$
SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), _pgr_get_statement($2), NULL::BIGINT[], NULL::BIGINT[], directed, false, true, cap, global);
FROM _pgr_dijkstra(_pgr_get_statement($1), _pgr_get_statement($2), directed, false, cap, global);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down
8 changes: 4 additions & 4 deletions sql/dijkstra/dijkstraNearCost.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CREATE FUNCTION pgr_dijkstraNearCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, ARRAY[$2]::BIGINT[], $3::BIGINT[], directed, true, true, cap, true);
FROM _pgr_dijkstra(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], directed, true, true, cap, true);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -66,7 +66,7 @@ CREATE FUNCTION pgr_dijkstraNearCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], ARRAY[$3]::BIGINT[], directed, true, false, cap, true);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], directed, true, false, cap, true);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -89,7 +89,7 @@ CREATE FUNCTION pgr_dijkstraNearCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), NULL::TEXT, $2::BIGINT[], $3::BIGINT[], directed, true, true, cap, global);
FROM _pgr_dijkstra(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], directed, true, true, cap, global);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand All @@ -111,7 +111,7 @@ CREATE FUNCTION pgr_dijkstraNearCost(
RETURNS SETOF RECORD AS
$BODY$
SELECT start_vid, end_vid, agg_cost
FROM _pgr_dijkstrav4(_pgr_get_statement($1), _pgr_get_statement($2), NULL::BIGINT[], NULL::BIGINT[], directed, true, true, cap, global);
FROM _pgr_dijkstra(_pgr_get_statement($1), _pgr_get_statement($2), directed, true, cap, global);
$BODY$
LANGUAGE sql VOLATILE STRICT
COST 100
Expand Down
3 changes: 2 additions & 1 deletion sql/sigs/pgrouting--4.0.sig
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ pgr_dijkstranear(text,anyarray,bigint,boolean,bigint)
pgr_dijkstranear(text,bigint,anyarray,boolean,bigint)
pgr_dijkstranear(text,text,boolean,bigint,boolean)
pgr_dijkstra(text,anyarray,anyarray,boolean)
_pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)
pgr_dijkstra(text,anyarray,bigint,boolean)
pgr_dijkstra(text,bigint,anyarray,boolean)
pgr_dijkstra(text,bigint,bigint,boolean)
pgr_dijkstra(text,text,boolean)
_pgr_dijkstrav4(text,text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)
_pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)
_pgr_dijkstravia(text,anyarray,boolean,boolean,boolean)
pgr_dijkstravia(text,anyarray,boolean,boolean,boolean)
pgr_drivingdistance(text,anyarray,double precision,boolean,boolean)
Expand Down
88 changes: 0 additions & 88 deletions src/dijkstra/dijkstra.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

PG_MODULE_MAGIC;

PGDLLEXPORT Datum _pgr_dijkstrav4(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(_pgr_dijkstrav4);

PGDLLEXPORT Datum _pgr_dijkstra(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(_pgr_dijkstra);

Expand Down Expand Up @@ -115,91 +112,6 @@ process(
pgr_SPI_finish();
}

PGDLLEXPORT Datum
_pgr_dijkstrav4(PG_FUNCTION_ARGS) {
FuncCallContext *funcctx;
TupleDesc tuple_desc;

Path_rt *result_tuples = NULL;
size_t result_count = 0;

if (SRF_IS_FIRSTCALL()) {
MemoryContext oldcontext;
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);

if (PG_ARGISNULL(1)) PGR_DBG("is null");
process(
text_to_cstring(PG_GETARG_TEXT_P(0)),
PG_ARGISNULL(1)? NULL : text_to_cstring(PG_GETARG_TEXT_P(1)),
PG_ARGISNULL(2)? NULL : PG_GETARG_ARRAYTYPE_P(2),
PG_ARGISNULL(3)? NULL : PG_GETARG_ARRAYTYPE_P(3),
PG_GETARG_BOOL(4),
PG_GETARG_BOOL(5),
PG_GETARG_BOOL(6),
PG_GETARG_INT64(7),
PG_GETARG_BOOL(8),
&result_tuples,
&result_count);

funcctx->max_calls = result_count;
funcctx->user_fctx = result_tuples;
if (get_call_result_type(fcinfo, NULL, &tuple_desc)
!= TYPEFUNC_COMPOSITE) {
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("function returning record called in context "
"that cannot accept type record")));
}

funcctx->tuple_desc = tuple_desc;
MemoryContextSwitchTo(oldcontext);
}

funcctx = SRF_PERCALL_SETUP();
tuple_desc = funcctx->tuple_desc;
result_tuples = (Path_rt*) funcctx->user_fctx;

if (funcctx->call_cntr < funcctx->max_calls) {
HeapTuple tuple;
Datum result;
Datum *values;
bool* nulls;
size_t call_cntr = funcctx->call_cntr;

size_t numb = 8;
values = palloc(numb * sizeof(Datum));
nulls = palloc(numb * sizeof(bool));

size_t i;
for (i = 0; i < numb; ++i) {
nulls[i] = false;
}

int64_t seq = call_cntr == 0? 1 : result_tuples[call_cntr - 1].start_id;

values[0] = Int32GetDatum((int32_t)call_cntr + 1);
values[1] = Int32GetDatum((int32_t)seq);
values[2] = Int64GetDatum(result_tuples[call_cntr].start_id);
values[3] = Int64GetDatum(result_tuples[call_cntr].end_id);
values[4] = Int64GetDatum(result_tuples[call_cntr].node);
values[5] = Int64GetDatum(result_tuples[call_cntr].edge);
values[6] = Float8GetDatum(result_tuples[call_cntr].cost);
values[7] = Float8GetDatum(result_tuples[call_cntr].agg_cost);

result_tuples[call_cntr].start_id = result_tuples[call_cntr].edge < 0? 1 : seq + 1;

tuple = heap_form_tuple(tuple_desc, values, nulls);
result = HeapTupleGetDatum(tuple);
SRF_RETURN_NEXT(funcctx, result);
} else {
SRF_RETURN_DONE(funcctx);
}
}


/* kept for backwards compatibility
* TODO remove on 5.0.0 */
PGDLLEXPORT Datum
_pgr_dijkstra(PG_FUNCTION_ARGS) {
FuncCallContext *funcctx;
Expand Down
Loading