Re: Two small patches to improve dbf2pg

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martin Pitt <martin(at)piware(dot)de>
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Two small patches to improve dbf2pg
Date: 2005-10-06 23:07:05
Message-ID: 26690.1128640025@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Martin Pitt <martin(at)piware(dot)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));

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bernard Simmons 2005-10-07 14:11:39 BUG #1945: pgAdmin Crash when adding user
Previous Message Martin Pitt 2005-10-06 18:38:37 Re: Two small patches to improve dbf2pg - attachments