[OSM-dev] How to clean up Negative IDs

Matt Amos zerebubuth at gmail.com
Tue Aug 3 19:47:05 BST 2010

On Tue, Aug 3, 2010 at 7:28 PM, Eric Wolf <ebwolf at gmail.com> wrote:
> I assume there is something in the API that says "negative IDs == BAD". I've
> been trying to test that theory but keep hitting stumbling blocks. Postgres
> doesn't seem to want to let me defer integrity constraints, so my efforts to
> change a few IDs to positive values keeps failing. Maybe I've lost my SQL
> chops (or maybe I just can't do that as the "openstreetmap" database user).
> Am I barking up the right tree? Should I just go ahead and destroy the
> database and repopulate it using bulk_upload.py instead of osmosis?

all IDs in the database should be positive - negative IDs are only
used on the client side to indicate elements which need to be created
by the server (so that they can be referenced by other elements in the
file). if you have negative IDs then you should use an uploader
against an API, rather than directly inserting the data into the
database with osmosis.

a further complication is that postgres allocates new IDs from a
"sequence", which is separate from the table and needs to be kept
up-to-date after any direct-to-database import (not sure if osmosis
does this?), otherwise postgres may attempt to allocate duplicate
primary key IDs...

uploading using bulk_upload.py is probably safer, but much slower,



More information about the dev mailing list