Re: PQputCopyData dont signal error

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: PQputCopyData dont signal error
Дата
Msg-id 4DA6A738.1050907@enterprisedb.com
обсуждение исходный текст
Ответ на PQputCopyData dont signal error  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: PQputCopyData dont signal error  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-hackers
On 14.04.2011 10:15, Pavel Stehule wrote:
> Hello
>
> 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], row[1]);
>             copy_result = PQputCopyData(pconn, buffer, strlen(buffer));
>             printf(">>%s<<\n", PQerrorMessage(pconn));
>             printf("%d\n", copy_result);
>             if (copy_result != 1)
>             {
>                 fprintf(stderr, "Copy to target table failed: %s",
>                         PQerrorMessage(pconn));
>                 EXIT;
>             }
>         }
>
> 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: PQputCopyData dont signal error
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Itanium HP-UX build failure, register stack