Ticket #156 (closed bug report: invalid)
Return sequence number with shortest_path_astar
Reported by: | curtis.paris@… | Owned by: | somebody |
---|---|---|---|
Priority: | minor | Milestone: | Version 1.1 |
Component: | A* | Version: | 1.03 |
Keywords: | Cc: |
Description
When using shortest_path_astar, there is no sequence number returned.
If you use the results to joint to another table, the sequence is not guaranteed and is often invalid for calculating a route. It requires that the consumer must resort and rejoin edges together from start to finish.
Postgres 8.4 will have a row number function, but 8.3 does not. The ways of generating a row number are gross when using functions today. It would be best if the function could return a row number.
My implementation has changed to do this by: routing_core.sql: CREATE TYPE path_result AS (vertex_id integer, edge_id integer, cost float8, sequence integer);
This was already attemped in the C files:
/* This will work for some compilers. If it crashes with segfault, try to change the following block with this one
values = palloc(4 * sizeof(Datum)); nulls = palloc(4 * sizeof(char));
The problem is that you should probably be casting it using the Int32GetDatum, such as:
In my own wrapper I put the value at the END of the list. This is for backward compatability. If the tuple returns data that the function prototype does not consume, there is no harm. But, if the user updates their function definitions, they can get the sequence.