From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Alexander Lakhin" <exclusion(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, 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-04-08 20:03:21 |
Message-ID: | 470c8529-260a-4ccf-a7d2-d52cc357d95f@manitou-mail.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Alexander Lakhin wrote:
> >> Now that ExecQueryUsingCursor() is gone, it's not clear, what does
> >> the following comment mean:?
> >> * We must turn off gexec_flag to avoid infinite recursion. Note that
> >> * this allows ExecQueryUsingCursor to be applied to the individual query
> >> * results.
> > Hmm, the point about recursion is still valid isn't it? I agree the
> > reference to ExecQueryUsingCursor is obsolete, but I think we need to
> > reconstruct what this comment is actually talking about. It's
> > certainly pretty obscure ...
>
> Sorry, I wasn't clear enough, I meant to remove only that reference, not
> the quoted comment altogether.
The comment might want to stress the fact that psql honors
FETCH_COUNT "on top of" \gset, so if the user issues for instance:
select 'select ' || i from generate_series(1,<N>) as i \gexec
what's going to be sent to the server is a series of:
BEGIN
DECLARE _psql_cursor NO SCROLL CURSOR FOR
select <i>
FETCH FORWARD <FETCH_COUNT> FROM _psql_cursor (possibly repeated)
CLOSE _psql_cursor
COMMIT
Another choice would be to ignore FETCH_COUNT and send exactly the
queries that \gset produces, with the assumption that it better
matches the user's expectation. Maybe that alternative was considered
and the comment reflects the decision.
Since the new implementation doesn't rewrite the user-supplied queries,
the point is moot, and this part should be removed:
"Note that this allows ExecQueryUsingCursor to be applied to the
individual query results"
I'll wait a bit for other comments and submit a patch.
Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-04-08 20:04:50 | Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs |
Previous Message | Robert Haas | 2024-04-08 19:49:51 | Re: PostgreSQL 17 Release Management Team & Feature Freeze |