Heikki Linnakangas <heikki@enterprisedb.com> writes:
> Tom Lane wrote:
>> Jeff Davis <pgsql@j-davis.com> writes:
>>> Just to be sure: a backwards-started scan is currently unreachable code,
>>> correct?
>>
>> [ yawn... ] I think so, but I wouldn't swear to it right at the moment.
>> In any case it doesn't seem like a path that we need to optimize.
> Agreed, let's just disable the reporting when moving backwards.
Now that I'm awake, it is reachable code, per this comment:
* Note: when we fall off the end of the scan in either direction, we
* reset rs_inited. This means that a further request with the same
* scan direction will restart the scan, which is a bit odd, but a
* request with the opposite scan direction will start a fresh scan
* in the proper direction. The latter is required behavior for cursors,
* while the former case is generally undefined behavior in Postgres
* so we don't care too much.
That is, if you run a cursor to the end and then back up, you'll go
through the init-in-the-backwards-direction code.
But we're agreed that we don't want to report when moving backwards,
so this is just an interesting note...
regards, tom lane