Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>
Subject: Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs
Date: 2024-03-29 13:07:06
Message-ID: 7a3a478be2a16465ac93ba01b13e1081568cbbd9.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2024-01-30 at 15:29 +0100, Daniel Verite wrote:
> PFA a rebased version.

I had a look at patch 0001 (0002 will follow).

> - <sect1 id="libpq-single-row-mode">
> - <title>Retrieving Query Results Row-by-Row</title>
> + <sect1 id="libpq-chunked-results-modes">
> + <title>Retrieving Query Results by chunks</title>

That should be "in chunks".

> + <para>
> + <variablelist>
> + <varlistentry id="libpq-PQsetChunkedRowsMode">
> + <term><function>PQsetChunkedRowsMode</function>
> + <indexterm><primary>PQsetChunkedRowsMode</primary></indexterm></term>
> + <listitem>
> + <para>
> + Select the mode retrieving results in chunks for the currently-executing query.

That is questionable English. How about

Select to receive the results for the currently-executing query in chunks.

> + This function is similar to <xref linkend="libpq-PQsetSingleRowMode"/>,
> + except that it can retrieve a user-specified number of rows
> + per call to <xref linkend="libpq-PQgetResult"/>, instead of a single row.

The "user-specified number" is "maxRows". So a better wording would be:

... except that it can retrieve <replaceable>maxRows</replaceable> rows
per call to <xref linkend="libpq-PQgetResult"/> instead of a single row.

> - error. But in single-row mode, those rows will have already been
> + error. But in single-row or chunked modes, those rows will have already been

I'd say it should be "in *the* single-row or chunk modes".

> --- a/src/interfaces/libpq/fe-exec.c
> +++ b/src/interfaces/libpq/fe-exec.c
> @@ -41,7 +41,8 @@ char *const pgresStatus[] = {
> "PGRES_COPY_BOTH",
> "PGRES_SINGLE_TUPLE",
> "PGRES_PIPELINE_SYNC",
> - "PGRES_PIPELINE_ABORTED"
> + "PGRES_PIPELINE_ABORTED",
> + "PGRES_TUPLES_CHUNK"
> };

I think that PGRES_SINGLE_TUPLE and PGRES_TUPLES_CHUNK should be next to each
other, but that's no big thing.
The same applies to the change in src/interfaces/libpq/libpq-fe.h

I understand that we need to keep the single-row mode for compatibility
reasons. But I think that under the hood, "single-row mode" should be the
same as "chunk mode with chunk size one".
That should save some code repetition.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Borisov 2024-03-29 13:21:23 Re: [HACKERS] make async slave to wait for lsn to be replayed
Previous Message Bertrand Drouvot 2024-03-29 12:47:51 Re: Introduce XID age and inactive timeout based replication slot invalidation