diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-08-19 13:24:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 13:24:54 +0100 |
commit | 775b04d776ddc06fdee5ece6a407008f00edb7f2 (patch) | |
tree | bedb0c9b077aa1ceb43d6e110a90bc98a41c654b /roomserver/storage/sqlite3/events_table.go | |
parent | 3d58417555ef6a1308fec8b83e752016765b72f2 (diff) |
Roomserver updater changes (#1283)
* Take input transaction when setting up updaters
* Fix nil pointer exceptions
* Rename room recent events updater to latest events updater
* Contd rename room recent events updater to latest events updater
* Remove unnecessary interfaces for latest events and membership updaters
Diffstat (limited to 'roomserver/storage/sqlite3/events_table.go')
-rw-r--r-- | roomserver/storage/sqlite3/events_table.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/roomserver/storage/sqlite3/events_table.go b/roomserver/storage/sqlite3/events_table.go index 3ac30ca3..0e39755c 100644 --- a/roomserver/storage/sqlite3/events_table.go +++ b/roomserver/storage/sqlite3/events_table.go @@ -326,9 +326,13 @@ func (s *eventStatements) BulkSelectStateAtEventAndReference( iEventNIDs[k] = v } selectOrig := strings.Replace(bulkSelectStateAtEventAndReferenceSQL, "($1)", sqlutil.QueryVariadic(len(iEventNIDs)), 1) + selectPrep, err := s.db.Prepare(selectOrig) + if err != nil { + return nil, err + } ////////////// - rows, err := txn.QueryContext(ctx, selectOrig, iEventNIDs...) + rows, err := sqlutil.TxStmt(txn, selectPrep).QueryContext(ctx, iEventNIDs...) if err != nil { return nil, err } @@ -372,7 +376,7 @@ func (s *eventStatements) BulkSelectEventReference( iEventNIDs[k] = v } selectOrig := strings.Replace(bulkSelectEventReferenceSQL, "($1)", sqlutil.QueryVariadic(len(iEventNIDs)), 1) - selectPrep, err := txn.Prepare(selectOrig) + selectPrep, err := s.db.Prepare(selectOrig) if err != nil { return nil, err } @@ -471,7 +475,11 @@ func (s *eventStatements) SelectMaxEventDepth(ctx context.Context, txn *sql.Tx, iEventIDs[i] = v } sqlStr := strings.Replace(selectMaxEventDepthSQL, "($1)", sqlutil.QueryVariadic(len(iEventIDs)), 1) - err := txn.QueryRowContext(ctx, sqlStr, iEventIDs...).Scan(&result) + sqlPrep, err := s.db.Prepare(sqlStr) + if err != nil { + return 0, err + } + err = sqlutil.TxStmt(txn, sqlPrep).QueryRowContext(ctx, iEventIDs...).Scan(&result) if err != nil { return 0, err } |