Ensure portdb selects _all_ rows with negative rowids (#13226)

pull/13175/head
David Robertson 2022-07-11 10:36:18 +01:00 committed by GitHub
parent 739adf1551
commit 28d96cb2b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

1
changelog.d/13226.bugfix Normal file
View File

@ -0,0 +1 @@
Fix a long-standing bug where the `synapse_port_db` script could fail to copy rows with negative row ids.

View File

@ -418,12 +418,15 @@ class Porter:
self.progress.update(table, table_size) # Mark table as done
return
# We sweep over rowids in two directions: one forwards (rowids 1, 2, 3, ...)
# and another backwards (rowids 0, -1, -2, ...).
forward_select = (
"SELECT rowid, * FROM %s WHERE rowid >= ? ORDER BY rowid LIMIT ?" % (table,)
)
backward_select = (
"SELECT rowid, * FROM %s WHERE rowid <= ? ORDER BY rowid LIMIT ?" % (table,)
"SELECT rowid, * FROM %s WHERE rowid <= ? ORDER BY rowid DESC LIMIT ?"
% (table,)
)
do_forward = [True]