aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/sqlite3/events_table.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-08-19 13:24:54 +0100
committerGitHub <noreply@github.com>2020-08-19 13:24:54 +0100
commit775b04d776ddc06fdee5ece6a407008f00edb7f2 (patch)
treebedb0c9b077aa1ceb43d6e110a90bc98a41c654b /roomserver/storage/sqlite3/events_table.go
parent3d58417555ef6a1308fec8b83e752016765b72f2 (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.go14
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
}