]> granicus.if.org Git - postgresql/commitdiff
Minor dbf2pg fixes from Martin Pitt: check for failure when issuing
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Oct 2005 23:05:22 +0000 (23:05 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Oct 2005 23:05:22 +0000 (23:05 +0000)
CREATE TABLE command, and translate dBase's 'M' field type to 'text'.

contrib/dbase/dbf2pg.c

index 8acb65c557a735897e3a53826167c5accb5e9724..c3e50dc4ac23bb4fc410bcb2ccb7717e1f3cbeda 100644 (file)
@@ -301,6 +301,9 @@ do_create(PGconn *conn, char *table, dbhead * dbh)
                        case 'L':
                                strcat(query, " char");
                                break;
+                       case 'M':
+                               strcat(query, " text");
+                               break;
                }
        }
 
@@ -312,7 +315,8 @@ do_create(PGconn *conn, char *table, dbhead * dbh)
                printf("%s\n", query);
        }
 
-       if ((res = PQexec(conn, query)) == NULL)
+       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));