Skip to content

PostgreSQL read_stream_backwards is incorrect for backwards reads #446

@nmummau

Description

@nmummau

The issue fixed here for SQL Server also has the same bug in Postgres: 73c56ce

Should be a simple fix but needs tested by someone with a Postgres setup, so I didn't want to fix it alongside all of my SQL Server fixes in PR #431

postgresql code function __schema__.read_stream_backwards:

if _current_version < _from_position + _count then
    return;
end if;

This guard is incorrect for backwards reads. It mixes the page size (_count) with the valid start position check. Example: if _current_version = 10, _from_position = 10, and _count = 3, there are clearly events at positions 10, 9, 8. Yet 10 < 10 + 3 is true, so the procedure returns nothing even though valid data exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions