Re: Two small patches to improve dbf2pg - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Two small patches to improve dbf2pg
Date
Msg-id 26690.1128640025@sss.pgh.pa.us
Whole thread Raw
In response to Two small patches to improve dbf2pg  (Martin Pitt <martin@piware.de>)
List pgsql-bugs
Martin Pitt <martin@piware.de> writes:
> 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. :-)

> The first patch (52-contrib-dbf2pg-errorcheck.patch) improves error
> checking. It checks the result status of PQexec() for the cases that
> it returns a reply (i.  e. not NULL) which indicates an error.

> The second patch (53-contrib-dbf2pg-textfield.patch) adds support for
> dBase's "M" field which translates to PostgreSQL's "text" data type.

Applied with minor editorialization.

            regards, tom lane

Index: dbf2pg.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/dbase/dbf2pg.c,v
retrieving revision 1.23
diff -c -r1.23 dbf2pg.c
*** dbf2pg.c    24 Sep 2005 19:14:03 -0000    1.23
--- dbf2pg.c    6 Oct 2005 23:03:34 -0000
***************
*** 301,306 ****
--- 301,309 ----
              case 'L':
                  strcat(query, " char");
                  break;
+             case 'M':
+                 strcat(query, " text");
+                 break;
          }
      }

***************
*** 312,318 ****
          printf("%s\n", query);
      }

!     if ((res = PQexec(conn, query)) == NULL)
      {
          fprintf(stderr, "Error creating table!\n");
          fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn));
--- 315,322 ----
          printf("%s\n", query);
      }

!     if ((res = PQexec(conn, query)) == NULL ||
!         PQresultStatus(res) != PGRES_COMMAND_OK)
      {
          fprintf(stderr, "Error creating table!\n");
          fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn));

pgsql-bugs by date:

Previous
From: Martin Pitt
Date:
Subject: Re: Two small patches to improve dbf2pg - attachments
Next
From: "Jean-Pierre Pelletier"
Date:
Subject: Re: Possibly corrupted shared memory, PostgreSQL 8.1 beta2, Windows 2000