Hi again,

Martin Pitt [2005-10-06 20:34 +0200]:
> A long time ago some Debian user sent me two patches to improve the
> dbf2pg conversion tool (in contrib). These are applied in the Debian
> packages for quite a while now without any problems. I forwarded them
> here some time ago already, but just let's try again. :-)

*cough* I forgot the attachments, as usual. Sorry.

Martin


-- 
Martin Pitt        http://www.piware.de
Ubuntu Developer   http://www.ubuntu.com
Debian Developer   http://www.debian.org

In a world without walls and fences, who needs Windows and Gates?
diff -ruN postgresql-8.1.1-old/contrib/dbase/dbf2pg.c 
postgresql-8.1.1/contrib/dbase/dbf2pg.c
--- postgresql-8.1.1-old/contrib/dbase/dbf2pg.c 2004-09-14 05:28:28.100000000 
+0200
+++ postgresql-8.1.1/contrib/dbase/dbf2pg.c     2005-02-11 17:06:24.193256800 
+0100
@@ -335,7 +335,10 @@
                printf("%s\n", query);
        }
 
-       if ((res = PQexec(conn, query)) == NULL)
+       if ((res = PQexec(conn, query)) == NULL ||
+           PQresultStatus(res) == PGRES_BAD_RESPONSE ||
+           PQresultStatus(res) == PGRES_NONFATAL_ERROR ||
+           PQresultStatus(res) == PGRES_FATAL_ERROR)
        {
                fprintf(stderr, "Error creating table!\n");
                fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn));
@@ -429,7 +432,10 @@
                        }
                        sprintf(query, "COPY %s FROM stdin", table);
                        res = PQexec(conn, query);
-                       if (res == NULL)
+                       if (res == NULL ||
+                           PQresultStatus(res)==PGRES_BAD_RESPONSE ||
+                           PQresultStatus(res)==PGRES_NONFATAL_ERROR ||
+                           PQresultStatus(res)==PGRES_FATAL_ERROR)
                        {
                                fprintf(stderr, "Error starting COPY!\n");
                                fprintf(stderr, "Detailed report: %s\n", 
PQerrorMessage(conn));
diff -ruN postgresql-8.1.1-old/contrib/dbase/dbf2pg.c 
postgresql-8.1.1/contrib/dbase/dbf2pg.c
--- postgresql-8.1.1-old/contrib/dbase/dbf2pg.c 2005-02-11 17:07:17.928087000 
+0100
+++ postgresql-8.1.1/contrib/dbase/dbf2pg.c     2005-02-11 17:07:35.127473160 
+0100
@@ -324,6 +324,10 @@
                        case 'L':
                                strcat(query, " char");
                                break;
+
+                       case 'M':
+                               strcat(query, " text");
+                               break;
                }
        }
 

Attachment: signature.asc
Description: Digital signature

Reply via email to