<literal>PGRES_TUPLES_OK</literal> is returned; this is the signal that no
more rows will arrive. (But note that it is still necessary to continue
calling <xref linkend="libpq-PQgetResult"/> until it returns null.) All of
these <structname>PGresult</structname> objects will contain the same row
description data (column names, types, etc.) that an ordinary
<structname>PGresult</structname> object for the query would have.
Each object should be freed with <xref linkend="libpq-PQclear"/> as usual.
</para>
<para>
When using pipeline mode, single-row or chunked mode needs to be
activated for each query in the pipeline before retrieving results for
that query with <function>PQgetResult</function>.
See <xref linkend="libpq-pipeline-mode"/> for more information.
</para>
<para>
<variablelist>
<varlistentry id="libpq-PQsetSingleRowMode">
<term><function>PQsetSingleRowMode</function><indexterm><primary>PQsetSingleRowMode</primary></indexterm></term>
<listitem>
<para>
Select single-row mode for the currently-executing query.
<synopsis>
int PQsetSingleRowMode(PGconn *conn);
</synopsis>
</para>
<para>
This function can only be called immediately after
<xref linkend="libpq-PQsendQuery"/> or one of its sibling functions,
before any other operation on the connection such as
<xref linkend="libpq-PQconsumeInput"/> or
<xref linkend="libpq-PQgetResult"/>. If called at the correct time,
the function activates single-row mode for the current query and
returns 1. Otherwise the mode stays unchanged and the function
returns 0. In any case, the mode reverts to normal after
completion of the current query.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-PQsetChunkedRowsMode">
<term><function>PQsetChunkedRowsMode</function><indexterm><primary>PQsetChunkedRowsMode</primary></indexterm></term>
<listitem>
<para>
Select chunked mode for the currently-executing query.
<synopsis>
int PQsetChunkedRowsMode(PGconn *conn, int chunkSize);
</synopsis>
</para>
<para>
This function is similar to
<xref linkend="libpq-PQsetSingleRowMode"/>, except that it
specifies retrieval of up to <replaceable>chunkSize</replaceable> rows
per <structname>PGresult</structname>, not necessarily just one row.
This function can only be called immediately after
<xref linkend="libpq-PQsendQuery"/> or one of its sibling functions,
before any other operation on the connection such as
<xref linkend="libpq-PQconsumeInput"/> or
<xref linkend="libpq-PQgetResult"/>. If called at the correct time,
the function activates chunked mode for the current query and
returns 1. Otherwise the mode stays unchanged and the function
returns 0. In any case, the mode reverts to normal after
completion of the current query.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<caution>
<para>
While processing a query, the server may return some rows and then
encounter an error, causing the query to be aborted. Ordinarily,
<application>libpq</application> discards any such rows and reports only the
error. But in single-row or chunked mode, some rows may have already
been returned to the application. Hence, the application will see some
<literal>PGRES_SINGLE_TUPLE</literal> or <literal>PGRES_TUPLES_CHUNK</literal>
<structname>PGresult</structname>
objects followed by a <literal>PGRES_FATAL_ERROR</literal> object. For
proper transactional behavior, the application must be designed to
discard or undo whatever has been done with the previously-processed
rows, if the query ultimately fails.
</para>
</caution>
</sect1>
<sect1 id="libpq-cancel">
<title>Canceling Queries in Progress</title>
<indexterm zone="libpq-cancel">