Ticket #156 (closed bug report: invalid)

Opened 19 months ago

Last modified 19 months ago

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));

values[0] = call_cntr; nulls[0] = ' ';

The problem is that you should probably be casting it using the Int32GetDatum, such as:

values[3] = Int32GetDatum(call_cntr); nulls[3] = ' ';

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.

Change History

Changed 19 months ago by anton

  • status changed from new to closed
  • resolution set to invalid

You are using core function (shortest_path_astar). Please look at core/sql/routing_core_wrappers.sql file to find more sophisticated wrappers - all of them return sequence numbers.

Note: See TracTickets for help on using tickets.