Re: problem with PQsendQuery/PQgetResult and COPY FROM statement

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: problem with PQsendQuery/PQgetResult and COPY FROM statement
Дата
Msg-id 731.1148497597@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: problem with PQsendQuery/PQgetResult and COPY FROM statement  (max.poletto@gmail.com)
Ответы Re: problem with PQsendQuery/PQgetResult and COPY FROM statement
Список pgsql-hackers
max.poletto@gmail.com writes:
> I do not expect PQgetResult to return millions of non-null PGresult
> objects after a PQsendQuery("COPY test FROM STDIN").  I expect exactly
> one non-null result, with a result status of PGRES_COPY_IN.

If you call it exactly once, it'll say that exactly once.  If you keep
calling it "millions of times", it'll keep saying that.

> Moreover, the manual says:

>    If a COPY command is issued via PQexec in a string that could
> contain
>    additional commands, the application must continue fetching results
>    via PQgetResult after completing the COPY sequence. Only when
>    PQgetResult returns NULL is it certain that the PQexec command
> string
>    is done and it is safe to issue more commands.

Indeed.  You forgot to "complete the COPY sequence" before returning
to the PQgetResult loop.  As long as the thing is in COPY mode,
PQgetResult will return a result saying PGRES_COPY_IN.  The point
of this paragraph is that you might want to consider doing more
PQgetResults *after* you've ended COPY mode.
        regards, tom lane


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

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Why is CVS server so slow?
Следующее
От: "Dave Page"
Дата:
Сообщение: Re: Why is CVS server so slow?