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

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs
Дата
Msg-id 470c8529-260a-4ccf-a7d2-d52cc357d95f@manitou-mail.org
обсуждение исходный текст
Ответ на Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs  (Alexander Lakhin <exclusion@gmail.com>)
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: PostgreSQL 17 Release Management Team & Feature Freeze
Следующее
От: Tom Lane
Дата:
Сообщение: Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs