Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

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

Closed
openstreetmap-trac opened this issue Jul 23, 2021 · 5 comments
Closed

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

openstreetmap-trac opened this issue Jul 23, 2021 · 5 comments

Comments

@openstreetmap-trac
Copy link

Reporter: aubreyholland[at]gmail.com
[Submitted to the original trac issue database at 9.04am, Wednesday, 21st October 2009]

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.

@openstreetmap-trac
Copy link
Author

Author: TomH
[Added to the original trac issue at 8.16pm, Wednesday, 21st October 2009]

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,

@openstreetmap-trac
Copy link
Author

Author: aubreyholland[at]gmail.com
[Added to the original trac issue at 8.20pm, Wednesday, 21st October 2009]

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

@openstreetmap-trac
Copy link
Author

Author: jburgess777[at]googlemail.com
[Added to the original trac issue at 8.58pm, Wednesday, 21st October 2009]

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.

@openstreetmap-trac
Copy link
Author

Author: aubreyholland[at]gmail.com
[Added to the original trac issue at 9.34pm, Wednesday, 21st October 2009]

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.

@openstreetmap-trac
Copy link
Author

Author: jburgess777[at]googlemail.com
[Added to the original trac issue at 10.30pm, Wednesday, 28th October 2009]

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant