[OSM-dev] [OSM-talk] Potlatch data

Richard Fairhurst richard at systemeD.net
Wed May 30 14:13:33 BST 2007


Francisco R. Santos wrote:

> Can this be fixed in database directly? It just happened to me, but I don't
> know which and how many ways are affected by this bug. Unless I know that a
> way is missing, I can't fix it!

(copied to dev, may be better to have further discussion there)

Essentially the issue was that Potlatch, at first, did not update the  
timestamp and user ID in the current_ways table whenever it updated  
that way. It did update the timestamp/uid in the ways table, and in  
any nodes or segments.

The Rails port appeared to object to this. I'm not sure whether this  
was because there was a mismatch between the timestamp/uid in ways and  
current_ways, or because the timestamp/uid in current_ways was earlier  
than that of the constituent nodes and segments.

The Potlatch code was changed here:

http://trac.openstreetmap.org/changeset?new=sites%2Frails_port%2Fapp%2Fcontrollers%2Famf_controller.rb%402976&old=sites%2Frails_port%2Fapp%2Fcontrollers%2Famf_controller.rb%402968

So the solution in the database would be to update the timestamp/uid  
on the ways. I guess the SQL would be something like:

UPDATE current_ways,ways,way_tags
    SET current_ways.timestamp=ways.timestamp,
        current_ways.user_id  =ways.user_id
  WHERE current_ways.id=way_tags.id
    AND current_ways.id=ways.id
    AND way_tags.k='created_by'
    AND way_tags.v='Potlatch alpha'

but you'd need to restrict this to only the row in 'ways' with the  
highest value of 'version', and I'm unsure how to do that in SQL...  
any suggestions? (MAX?)

cheers
Richard





More information about the dev mailing list