[postgis-tickets] r15005 - Use "DROP TABLE IF EXISTS" on shp2pgsql -d

Sandro Santilli strk at kbt.io
Thu Jul 21 02:46:21 PDT 2016


Author: strk
Date: 2016-07-21 02:46:20 -0700 (Thu, 21 Jul 2016)
New Revision: 15005

Modified:
   trunk/NEWS
   trunk/loader/shp2pgsql-core.c
Log:
Use "DROP TABLE IF EXISTS" on shp2pgsql -d

Patch by Eugene Antimirov
Closes #2236

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2016-07-19 22:52:09 UTC (rev 15004)
+++ trunk/NEWS	2016-07-21 09:46:20 UTC (rev 15005)
@@ -19,6 +19,7 @@
   - populate_topology_layer (Sandro Santilli)
   - #454,  ST_WrapX and lwgeom_wrapx (Sandro Santilli)
   - #1758, ST_Normalize (Sandro Santilli)
+  - #2236, shp2pgsql -d now emits "DROP TABLE IF EXISTS"
   - #2259, ST_Voronoi (Dan Baston)
   - #2991, Enable ST_Transform to use PROJ.4 text (Mike Toews)
   - #3059, Allow passing per-dimension parameters in ST_Expand (Dan Baston)

Modified: trunk/loader/shp2pgsql-core.c
===================================================================
--- trunk/loader/shp2pgsql-core.c	2016-07-19 22:52:09 UTC (rev 15004)
+++ trunk/loader/shp2pgsql-core.c	2016-07-21 09:46:20 UTC (rev 15005)
@@ -1299,7 +1299,7 @@
 				                     state->config->schema, state->config->table, state->geo_col);
 			}
 
-			stringbuffer_aprintf(sb, "DROP TABLE \"%s\".\"%s\";\n", state->config->schema,
+			stringbuffer_aprintf(sb, "DROP TABLE IF EXISTS \"%s\".\"%s\";\n", state->config->schema,
 			                     state->config->table);
 		}
 		else
@@ -1310,7 +1310,7 @@
 				                     state->config->table, state->geo_col);
 			}
 
-			stringbuffer_aprintf(sb, "DROP TABLE \"%s\";\n", state->config->table);
+			stringbuffer_aprintf(sb, "DROP TABLE IF EXISTS \"%s\";\n", state->config->table);
 		}
 	}
 



More information about the postgis-tickets mailing list