<p>This is a well known issue and one that is likely not going to be addressed any time soon.</p>

<p>While the rendering tables allow multiple geometries per osm feature / id and therefore don't have a unique constraint on osm_id, the slim tables are used for update processing and thus need to do lookups based on osm_id, for which it has to be unique.</p>

<p>For performance reasons osm2pgsql uses the COPY command, that batches up inserts into a single command. As such, if there is a unique constraint (or duplicate Key) violation, the whole batch fails. As osm2pgsql does stream based processing, it does not have the ability to go back and reprocess that batch of nodes / ways / relations to properly deal with the duplicate entry. Therefore, it cannot recover from such a duplicate key failure and terminates.</p>

<p>Osm2pgsql therefore doesn't support importing multiple files into one database in slim mode if there are duplicate osm features. Instead, I would recommend merging the two files prior to importing with osm2pgsql. For example with osmosis that supports de-duplication on merge.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href='https://github.com/openstreetmap/osm2pgsql/issues/16#issuecomment-16060115'>view it on GitHub</a>.<img src='https://github.com/notifications/beacon/g8smGCFOcVLF28Q-xX3zcfG0AQ2JBHDVUt4HvL823Z6-BWTRonhYlF3JMIEjOpp7.gif' height='1' width='1'></p>