Re: BUG #17889: Invalid cursor direction for a foreign scan that reached the fetch_size (MOVE BACKWARD ALL IN cX)

Etsuro Fujita <etsuro.fujita@gmail.com>

From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: eric.cyr@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-04-07T09:16:03Z
Lists: pgsql-bugs
On Fri, Apr 7, 2023 at 5:21 AM PG Bug reporting form
<noreply@postgresql.org> wrote:
> The scenario is the following:
> On DB 1 have
> 3 tables, a view using a where clause on table 1 and a view using a inner
> join on table 1 and 2.
>
> On DB 2 have
> A fdw server(with use_remote_estimate set to true), 3 foreign tables, one
> for each view and one for table 3 and a view on the foreign table of view of
> table 1 (with a cte using a function and used in where clause)
>
> On DB 2 execute a SELECT on view of foreign table 1 with a join on foreign
> table 2 with a where clause using a subquery on foreign table 3.
>
> If the SELECT would return an amount of rows equal or greater than the fetch
> size of foreign table of view of table 1 the error will occur.

> The same scenario was tested on Postgres 10 and 14, both worked without
> error.

> The error is the following:
>
> ERROR: cursor can only scan forward Hint:
> Declare it with SCROLL option to enable backward scan.
> Where: remote SQL command: MOVE BACKWARD ALL IN c3

Will look into this.  Thanks for the report!

Best regards,
Etsuro Fujita



Commits

  1. postgres_fdw: Avoid "cursor can only scan forward" error.

  2. Fix some anomalies with NO SCROLL cursors.