]> granicus.if.org Git - postgis/commitdiff
- BUGFIX in pgsql2shp successful return code.
authorSandro Santilli <strk@keybit.net>
Fri, 16 Jun 2006 14:12:17 +0000 (14:12 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 16 Jun 2006 14:12:17 +0000 (14:12 +0000)
        - BUGFIX in shp2pgsql handling of MultiLine WKT.

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

loader/pgsql2shp.c
loader/shp2pgsql.c

index f9708b44ce4bdd38c2460b2d410ef1f7a4562e57..ecba3dc5ea7f853aafd2f08b254460c4bc7eb4f5 100644 (file)
@@ -153,9 +153,10 @@ byte * HexDecode(const char *hex);
 #define ZMFLAG(x) (((x)&((WKBZOFFSET)+(WKBMOFFSET)))>>30)
 
 
-static void exit_nicely(PGconn *conn){
+static void exit_nicely(PGconn *conn, int code)
+{
        PQfinish(conn);
-       exit(1);
+       exit(code);
 }
 
 int
@@ -214,7 +215,7 @@ main(int ARGC, char **ARGV)
        conn = PQconnectdb("");
        if (PQstatus(conn) == CONNECTION_BAD) {
                printf( "%s", PQerrorMessage(conn));
-               exit_nicely(conn);
+               exit_nicely(conn, 1);
        }
 
        /* Create temporary table for user query */
@@ -232,7 +233,7 @@ main(int ARGC, char **ARGV)
 
        /* Initialize shapefile and database infos */
        fprintf(stdout, "Initializing... "); fflush(stdout);
-       if ( ! initialize() ) exit_nicely(conn);
+       if ( ! initialize() ) exit_nicely(conn, 1);
        fprintf(stdout, "Done (postgis major version: %d).\n",
                pgis_major_version); 
 
@@ -252,7 +253,7 @@ main(int ARGC, char **ARGV)
        res=PQexec(conn, "BEGIN");
        if ( ! res || PQresultStatus(res) != PGRES_COMMAND_OK ) {
                printf( "%s", PQerrorMessage(conn));
-               exit_nicely(conn);
+               exit_nicely(conn, 1);
        }
        PQclear(res);
 
@@ -275,7 +276,7 @@ main(int ARGC, char **ARGV)
        free(query);
        if ( ! res || PQresultStatus(res) != PGRES_COMMAND_OK ) {
                printf( "MainScanQuery: %s", PQerrorMessage(conn));
-               exit_nicely(conn);
+               exit_nicely(conn, 1);
        }
        PQclear(res);
 
@@ -299,7 +300,7 @@ main(int ARGC, char **ARGV)
                if ( ! res || PQresultStatus(res) != PGRES_TUPLES_OK ) {
                        printf( "RecordFetch: %s",
                                PQerrorMessage(conn));
-                       exit_nicely(conn);
+                       exit_nicely(conn, 1);
                }
 
                /* No more rows, break the loop */
@@ -311,7 +312,7 @@ main(int ARGC, char **ARGV)
                for(i=0; i<PQntuples(res); i++)
                {
                        /* Add record in all output files */
-                       if ( ! addRecord(res, i, row) ) exit_nicely(conn);
+                       if ( ! addRecord(res, i, row) ) exit_nicely(conn, 1);
                        row++; 
                }
 
@@ -327,13 +328,13 @@ main(int ARGC, char **ARGV)
 
        if (dbf) DBFClose(dbf);
        if (shp) SHPClose(shp);
-       exit_nicely(conn);
 
 
 #ifdef DEBUG
        fclose(debug);
 #endif  /* DEBUG */
 
+       exit_nicely(conn, 0);
        return 0;
 }
 
@@ -2095,7 +2096,7 @@ getTableOID(char *schema, char *table)
        free(query);
        if ( ! res3 || PQresultStatus(res3) != PGRES_TUPLES_OK ) {
                printf( "TableOID: %s", PQerrorMessage(conn));
-               exit_nicely(conn);
+               exit_nicely(conn, 1);
        }
        if(PQntuples(res3) == 1 ){
                ret = strdup(PQgetvalue(res3, 0, 0));
@@ -3341,6 +3342,10 @@ goodDBFValue(const char *in, char fieldType)
 
 /**********************************************************************
  * $Log$
+ * Revision 1.85  2006/06/16 14:12:16  strk
+ *         - BUGFIX in pgsql2shp successful return code.
+ *         - BUGFIX in shp2pgsql handling of MultiLine WKT.
+ *
  * Revision 1.84  2006/04/18 14:09:28  strk
  * Limited text field size to 255 (bug #84)  [will eventually provide a switch to support wider fields ]
  *
index de39a7e067956d175b76a14e3c4e39a163e2f2c4..7e05043cf97238fcd5747c21824e4e7bdc71a4e4 100644 (file)
@@ -862,7 +862,7 @@ InsertLineStringWKT(int id)
 
                for ( vi=vs; vi<ve; vi++)
                {
-                       if ( vi ) printf(",");
+                       if ( vi > vs ) printf(",");
                        printf("%.15g %.15g",
                                obj->padfX[vi],
                                obj->padfY[vi]);
@@ -1698,6 +1698,10 @@ utf8 (const char *fromcode, char *inputbuf)
 
 /**********************************************************************
  * $Log$
+ * Revision 1.108  2006/06/16 14:12:17  strk
+ *         - BUGFIX in pgsql2shp successful return code.
+ *         - BUGFIX in shp2pgsql handling of MultiLine WKT.
+ *
  * Revision 1.107  2006/04/18 09:16:26  strk
  * Substituted bzero() use with memset()
  *