aboutsummaryrefslogtreecommitdiff
path: root/syncapi/storage/postgres/output_room_events_topology_table.go
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-05-15 16:27:34 +0100
committerGitHub <noreply@github.com>2020-05-15 16:27:34 +0100
commit8db60c90bbe064ffe3f85b79a433172d30ab3b5f (patch)
tree12fe0b2f97757b27361d00c993a46425c297bb87 /syncapi/storage/postgres/output_room_events_topology_table.go
parent5f6f8adaa5f44bc8c38d0f55e3f5d2dda58baf2b (diff)
Fix a bug whereby backfilling could leak events across rooms (#1043)
* Fix a bug whereby backfilling could leak events across rooms Caused by a faulty SQL query. With tests now. * comment
Diffstat (limited to 'syncapi/storage/postgres/output_room_events_topology_table.go')
-rw-r--r--syncapi/storage/postgres/output_room_events_topology_table.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/syncapi/storage/postgres/output_room_events_topology_table.go b/syncapi/storage/postgres/output_room_events_topology_table.go
index 8a9cc49c..9fc5f519 100644
--- a/syncapi/storage/postgres/output_room_events_topology_table.go
+++ b/syncapi/storage/postgres/output_room_events_topology_table.go
@@ -48,17 +48,17 @@ const insertEventInTopologySQL = "" +
const selectEventIDsInRangeASCSQL = "" +
"SELECT event_id FROM syncapi_output_room_events_topology" +
- " WHERE room_id = $1 AND" +
+ " WHERE room_id = $1 AND (" +
"(topological_position > $2 AND topological_position < $3) OR" +
"(topological_position = $4 AND stream_position <= $5)" +
- " ORDER BY topological_position ASC, stream_position ASC LIMIT $6"
+ ") ORDER BY topological_position ASC, stream_position ASC LIMIT $6"
const selectEventIDsInRangeDESCSQL = "" +
"SELECT event_id FROM syncapi_output_room_events_topology" +
- " WHERE room_id = $1 AND" +
+ " WHERE room_id = $1 AND (" +
"(topological_position > $2 AND topological_position < $3) OR" +
"(topological_position = $4 AND stream_position <= $5)" +
- " ORDER BY topological_position DESC, stream_position DESC LIMIT $6"
+ ") ORDER BY topological_position DESC, stream_position DESC LIMIT $6"
const selectPositionInTopologySQL = "" +
"SELECT topological_position, stream_position FROM syncapi_output_room_events_topology" +