]> granicus.if.org Git - postgis/commitdiff
Alter shp2pgsql-gui so that we use one connection per file; this makes tracking error...
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Tue, 10 Jan 2012 12:28:23 +0000 (12:28 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Tue, 10 Jan 2012 12:28:23 +0000 (12:28 +0000)
on the server considerably easier, since upon abort we just disconnect from the server rather
than trying to figure out what state we are in and handle it appropriately.

git-svn-id: http://svn.osgeo.org/postgis/trunk@8743 b70326c6-7e19-0410-871a-916f4a2858ee

loader/shp2pgsql-gui.c

index 6e699bddc1789df2224bce5853c38cade804e751..2d9a9093f5824c427824d68c32f9eb3ae3598de7 100644 (file)
@@ -979,8 +979,6 @@ pgui_action_import(GtkWidget *widget, gpointer data)
 
        
        /* Once we've done the validation pass, now let's load the shapefile */
-       pg_connection = PQconnectdb(connection_string);
-       
        is_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter);
        while (is_valid)
        {
@@ -997,6 +995,9 @@ pgui_action_import(GtkWidget *widget, gpointer data)
                import_running = TRUE;
                success = FALSE;
                
+               /* One connection per file, otherwise error handling becomes tricky... */
+               pg_connection = PQconnectdb(connection_string);
+
                /* Disable the button to prevent multiple imports running at the same time */
                gtk_widget_set_sensitive(widget, FALSE);
 
@@ -1188,9 +1189,9 @@ import_cleanup:
                /* Import has definitely stopped running */
                import_running = FALSE;
 
-               /* Make sure we abort any existing transaction */
-               if (!success)
-                       pgui_exec("ABORT");
+               /* Close the existing connection */
+               PQfinish(pg_connection);
+               pg_connection = NULL;
                
                /* If we didn't finish inserting all of the items (and we expected to), an error occurred */
                if ((state->config->opt != 'p' && i != ShpLoaderGetRecordCount(state)) || !ret)
@@ -1229,10 +1230,6 @@ import_cleanup:
        while (gtk_events_pending())
                gtk_main_iteration();
 
-       /* Disconnect from the database */
-       PQfinish(pg_connection);
-       pg_connection = NULL;
-
        /* Tidy up */
        free(connection_string);