Opened 10 years ago

Closed 10 years ago

#2379 closed defect (fixed)

osm2pgsql: Don't try to drop tables that don't exist

Reported by: aubreyholland@… Owned by: jburgess777@…
Priority: minor Milestone:
Component: utils Version:
Keywords: osm2pgsql Cc:

Description

There are several places where osm2pgsql drops tables without checking to see if they exist first. We have a monitoring service that is being alerted when this happens if the tables don't exist and causing problems.

I'm attaching a patch that will check to see if tables exist before dropping them. It does this by doing a select against pg_tables to see if the table is in the list before attempting to drop it.

Attachments (2)

osm2pgsql.patch (4.1 KB) - added by aubreyholland@… 10 years ago.
osm2pgsql_new.patch (4.3 KB) - added by aubreyholland@… 10 years ago.

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by aubreyholland@…

Attachment: osm2pgsql.patch added

comment:1 Changed 10 years ago by Tom Hughes

Owner: changed from Tom Hughes to jburgess777@…

One for you, though personally I'd probably just change to "DROP TABLE IF EXISTS" now that the tile server is running a version of postgres which supports that,

comment:2 Changed 10 years ago by aubreyholland@…

Funny, I did all of that because I thought it needed to maintain backward compatibility. IF EXISTS would be a lot easier.

comment:3 Changed 10 years ago by jburgess777@…

I have been wanting to get rid of those error messages in the logs too.

Backwards compatibility would be nice to have but postgresql-8.2 has been around for nearly 3 years so it seems reasonable to require that as a minimum version. I could be persuaded to go with either solution.

comment:4 Changed 10 years ago by aubreyholland@…

Sorry, I made a major screwup in my patch there, and it would delete the main tables instead of the tmp ones. Found out the hard way. I'm attaching another patch. I'm in favor of the IF EXISTS solution rather than this one, for what it's worth.

Changed 10 years ago by aubreyholland@…

Attachment: osm2pgsql_new.patch added

comment:5 Changed 10 years ago by jburgess777@…

Resolution: fixed
Status: newclosed

Fixed in r18353 by using "DROP TABLE IF EXISTS". Thanks for reporting the problem and providing the patches.

Note: See TracTickets for help on using tickets.