From 8db60c90bbe064ffe3f85b79a433172d30ab3b5f Mon Sep 17 00:00:00 2001 From: Kegsay Date: Fri, 15 May 2020 16:27:34 +0100 Subject: 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 --- syncapi/storage/postgres/output_room_events_topology_table.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'syncapi/storage/postgres') 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" + -- cgit v1.2.3