aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/sqlite3
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-09-02 10:02:48 +0100
committerGitHub <noreply@github.com>2020-09-02 10:02:48 +0100
commit02a73f29f861c637f30df4a2bb1fce400e481a3c (patch)
tree6923a7c4db81321e7286cda410fc94f986f9cde8 /roomserver/storage/sqlite3
parent82a96176599aad737e5052a501442b29a5be5c69 (diff)
Expand RoomInfo to cover more DB storage functions (#1377)
* Factor more things to RoomInfo * Factor out remaining bits for RoomInfo * Linting for now
Diffstat (limited to 'roomserver/storage/sqlite3')
-rw-r--r--roomserver/storage/sqlite3/rooms_table.go17
-rw-r--r--roomserver/storage/sqlite3/storage.go4
2 files changed, 2 insertions, 19 deletions
diff --git a/roomserver/storage/sqlite3/rooms_table.go b/roomserver/storage/sqlite3/rooms_table.go
index fc1bcf22..4c1699d0 100644
--- a/roomserver/storage/sqlite3/rooms_table.go
+++ b/roomserver/storage/sqlite3/rooms_table.go
@@ -58,9 +58,6 @@ const selectLatestEventNIDsForUpdateSQL = "" +
const updateLatestEventNIDsSQL = "" +
"UPDATE roomserver_rooms SET latest_event_nids = $1, last_event_sent_nid = $2, state_snapshot_nid = $3 WHERE room_nid = $4"
-const selectRoomVersionForRoomIDSQL = "" +
- "SELECT room_version FROM roomserver_rooms WHERE room_id = $1"
-
const selectRoomVersionForRoomNIDSQL = "" +
"SELECT room_version FROM roomserver_rooms WHERE room_nid = $1"
@@ -74,7 +71,6 @@ type roomStatements struct {
selectLatestEventNIDsStmt *sql.Stmt
selectLatestEventNIDsForUpdateStmt *sql.Stmt
updateLatestEventNIDsStmt *sql.Stmt
- selectRoomVersionForRoomIDStmt *sql.Stmt
selectRoomVersionForRoomNIDStmt *sql.Stmt
selectRoomInfoStmt *sql.Stmt
}
@@ -93,7 +89,6 @@ func NewSqliteRoomsTable(db *sql.DB) (tables.Rooms, error) {
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
{&s.selectLatestEventNIDsForUpdateStmt, selectLatestEventNIDsForUpdateSQL},
{&s.updateLatestEventNIDsStmt, updateLatestEventNIDsSQL},
- {&s.selectRoomVersionForRoomIDStmt, selectRoomVersionForRoomIDSQL},
{&s.selectRoomVersionForRoomNIDStmt, selectRoomVersionForRoomNIDSQL},
{&s.selectRoomInfoStmt, selectRoomInfoSQL},
}.Prepare(db)
@@ -198,18 +193,6 @@ func (s *roomStatements) UpdateLatestEventNIDs(
return err
}
-func (s *roomStatements) SelectRoomVersionForRoomID(
- ctx context.Context, txn *sql.Tx, roomID string,
-) (gomatrixserverlib.RoomVersion, error) {
- var roomVersion gomatrixserverlib.RoomVersion
- stmt := sqlutil.TxStmt(txn, s.selectRoomVersionForRoomIDStmt)
- err := stmt.QueryRowContext(ctx, roomID).Scan(&roomVersion)
- if err == sql.ErrNoRows {
- return roomVersion, errors.New("room not found")
- }
- return roomVersion, err
-}
-
func (s *roomStatements) SelectRoomVersionForRoomNID(
ctx context.Context, roomNID types.RoomNID,
) (gomatrixserverlib.RoomVersion, error) {
diff --git a/roomserver/storage/sqlite3/storage.go b/roomserver/storage/sqlite3/storage.go
index 33782171..4a74bf73 100644
--- a/roomserver/storage/sqlite3/storage.go
+++ b/roomserver/storage/sqlite3/storage.go
@@ -150,7 +150,7 @@ func (d *Database) SupportsConcurrentRoomInputs() bool {
}
func (d *Database) GetLatestEventsForUpdate(
- ctx context.Context, roomNID types.RoomNID,
+ ctx context.Context, roomInfo types.RoomInfo,
) (*shared.LatestEventsUpdater, error) {
// TODO: Do not use transactions. We should be holding open this transaction but we cannot have
// multiple write transactions on sqlite. The code will perform additional
@@ -158,7 +158,7 @@ func (d *Database) GetLatestEventsForUpdate(
// 'database is locked' errors. As sqlite doesn't support multi-process on the
// same DB anyway, and we only execute updates sequentially, the only worries
// are for rolling back when things go wrong. (atomicity)
- return shared.NewLatestEventsUpdater(ctx, &d.Database, nil, roomNID)
+ return shared.NewLatestEventsUpdater(ctx, &d.Database, nil, roomInfo)
}
func (d *Database) MembershipUpdater(