Thread: Two small patches to improve dbf2pg

Two small patches to improve dbf2pg

From
Martin Pitt
Date:
Hi PostgreSQL developers!

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.

They are not Debian specific in any way and probably useful for all
other users, too. Can you please consider applying them upstream?

Thanks in advance!

Martin

--=20
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?

Re: Two small patches to improve dbf2pg - attachments

From
Martin Pitt
Date:
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?

Attachment

Re: Two small patches to improve dbf2pg

From
Tom Lane
Date:
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));