PQconsumeInput() usage in PQgetCopyData() - Mailing list pgsql-novice

From Volkan YAZICI
Subject PQconsumeInput() usage in PQgetCopyData()
Date
Msg-id 7104a7370506060145364590e5@mail.gmail.com
Whole thread Raw
Responses Re: PQconsumeInput() usage in PQgetCopyData()
List pgsql-novice
Hi,

[Excuse me, if here's the wrong list to ask this question.]

From PQgetCopyData() documentation, it says that:

  «When async is true (not zero), PQgetCopyData will not block waiting for
  input; it will return zero if the COPY is still in progress but no complete
  row is available. (In this case wait for read-ready before trying again; it
  does not matter whether you call PQconsumeInput.)»

But in my opinion, a PQconsumeInput() call would matter in here. When
I look at pqGetCopyData3() in src/interfaces/libpq/fe-protocol3.c from
CVS:

974 nodata:
975         /* Don't block if async read requested */
976         if (async)
977             return 0;
978         /* Need to load more data */
979         if (pqWait(TRUE, FALSE, conn) ||
980             pqReadData(conn) < 0)
981             return -2;

If there's no data in sync. mode, pqGetCopyData3() is calling
pqReadData() - just like PQconsumeInput() does. Thus, in my opinion,
user should call PQconsumeInput() in the program flow while using
PQgetCopyData() in async. mode.

Moreover, when I look at pqWait further:

[src/interfaces/libpq/fe-misc.c]
pqWait() -> pqWaitTimed() -> pqSocketCheck():

/*
 * Checks a socket, using poll or select, for data to be read, written,
 * or both.
 * ...
 */
static int
pqSocketCheck(...

To summarize, despite documentation, (as I understand) user should
call PQconsumeInput() while using PQgetCopyData() in async. mode too.
Any comments will be appreciated.

Regards.

pgsql-novice by date:

Previous
From: Volkan YAZICI
Date:
Subject: Re: phppgadmin
Next
From: John DeSoi
Date:
Subject: Re: phppgadmin