From 06bfc299ad1cf51897b147648579eed641e8a577 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 5 Jul 2018 13:41:52 +0100 Subject: [PATCH] Change invalid_txn_id to global (for efficiency) --- .../dendrite/appservice/storage/appservice_events_table.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go b/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go index 5b47dc60d..e7322c283 100644 --- a/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go +++ b/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go @@ -57,6 +57,12 @@ const updateTxnIDForEventsSQL = "" + const deleteEventsBeforeAndIncludingIDSQL = "" + "DELETE FROM appservice_events WHERE as_id = $1 AND id <= $2" +const ( + // A transaction ID number that no transaction should ever have. Used for + // checking again the default value. + invalidTxnID = -2 +) + type eventsStatements struct { selectEventsByApplicationServiceIDStmt *sql.Stmt countEventsByApplicationServiceIDStmt *sql.Stmt @@ -131,7 +137,6 @@ func retrieveEvents(eventRows *sql.Rows, limit int) (events []gomatrixserverlib. // Iterate through each row and store event contents // If txn_id changes dramatically, we've switched from collecting old events to // new ones. Send back those events first. - invalidTxnID := -2 lastTxnID := invalidTxnID for eventsProcessed := 0; eventRows.Next(); { var event gomatrixserverlib.Event