Skip to content

bugfix: rowcount doesn't work with select statements#2631

Merged
ulope merged 1 commit intoraiden-network:masterfrom
hackaugusto:bugfix_wal_replay
Sep 28, 2018
Merged

bugfix: rowcount doesn't work with select statements#2631
ulope merged 1 commit intoraiden-network:masterfrom
hackaugusto:bugfix_wal_replay

Conversation

@hackaugusto
Copy link
Copy Markdown
Contributor

From the python3's sqlite3 docs:

As required by the Python DB API Spec, the rowcount attribute “is -1 in
case no executeXX() has been performed on the cursor or the rowcount of
the last operation is not determinable by the interface”. This includes
SELECT statements because we cannot determine the number of rows a query
produced until all rows were fetched.

rowcount always returned -1, and the code to load the latest snapshot
assumed there was never a snapshot available, as a consequence all the
state changes where replaied on restarts

From the python3's sqlite3 docs:

> As required by the Python DB API Spec, the rowcount attribute “is -1 in
> case no executeXX() has been performed on the cursor or the rowcount of
> the last operation is not determinable by the interface”. This includes
> SELECT statements because we cannot determine the number of rows a query
> produced until all rows were fetched.

rowcount always returned -1, and the code to load the latest snapshot
assumed there was never a snapshot available, as a consequence all the
state changes where replaied on restarts
@ulope
Copy link
Copy Markdown
Collaborator

ulope commented Sep 28, 2018

Nice catch, that should probably make #2632 less of an issue.

Copy link
Copy Markdown
Contributor

@palango palango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Should fix #2632

@ulope ulope merged commit 111c68e into raiden-network:master Sep 28, 2018
@hackaugusto hackaugusto deleted the bugfix_wal_replay branch September 28, 2018 14:35
ulope added a commit to ulope/raiden that referenced this pull request Sep 28, 2018
ulope added a commit that referenced this pull request Sep 28, 2018
@LefterisJP
Copy link
Copy Markdown
Contributor

Very nice catch. This explains a lot. But still from the way it's phrased it does not make sense why it would return -1?

The rowcount comes right after a cursor.execute(), no?

hackaugusto pushed a commit to hackaugusto/raiden that referenced this pull request Oct 5, 2018
hackaugusto pushed a commit to hackaugusto/raiden that referenced this pull request Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants