public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tim Fors <[email protected]>
To: [email protected]
Subject: Client-server communication for FETCH
Date: Wed, 3 Dec 2025 13:02:40 -0500
Message-ID: <CAOjiQ0C7NEV9ZBFxbM6KgXnzquaUY3MrN1x8vz_tv7uXac0UwQ@mail.gmail.com> (raw)
Hello community,
I have a simple C program using libpq V18 to FETCH one row at a time (see
below). Does the server send multiple rows to the client where they are
cached for satisfying the FETCH statements, or does it just send one row at
a time since that's all that each FETCH statement is asking for? If it's
sending multiple rows at a time, is there some way that I can observe this
e.g. some kind of trace info that would show it? Or where in the libpq
source would I look to see how the client is retrieving rows from the
server?
I have done extensive searching to try and find the definitive answer to
this. The searches indicate that libpq supports the concept of a
client-side cursor, where it has a cache of rows sent by the server and
uses that cache to perform each FETCH, but I'd like to be able to verify
whether this is true or not.
Thanks,
Tim
res = PQexec(conn, "DECLARE cur CURSOR FOR select * from table1");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
printf("DECLARE CURSOR failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
PQclear(res);
res = PQexec(conn, "FETCH in cur");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
printf("FETCH failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
PQclear(res);
res = PQexec(conn, "FETCH in cur");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
printf("FETCH failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Client-server communication for FETCH
In-Reply-To: <CAOjiQ0C7NEV9ZBFxbM6KgXnzquaUY3MrN1x8vz_tv7uXac0UwQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox