On 14.04.2011 10:15, Pavel Stehule wrote:

I have a problem with PQputCopyData function. It doesn't signal some error.

                while ((row = mysql_fetch_row(res)) != NULL)
                        snprintf(buffer, sizeof(buffer), "%s%s\n", row[0], 
                        copy_result = PQputCopyData(pconn, buffer, 
                        printf(">>%s<<\n", PQerrorMessage(pconn));
                        printf("%d\n", copy_result);
                        if (copy_result != 1)
                                fprintf(stderr, "Copy to target table failed: 

it returns 1 for broken values too :(

Is necessary some special check?

The way COPY works is that PQputCopyData just sends the data to the server, and the server will buffer it in its internal buffer and processes it when it feels like it. The PQputCopyData() calls don't even need to match line boundaries.

I think you'll need to send all the data and finish the COPY until you get an error. If you have a lot of data to send, you might want to slice it into multiple COPY statements of say 50MB each, so that you can catch errors in between.

  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to