diff --git a/roomserver/storage/postgres/membership_table.go b/roomserver/storage/postgres/membership_table.go index 0688c7c19..b790dac79 100644 --- a/roomserver/storage/postgres/membership_table.go +++ b/roomserver/storage/postgres/membership_table.go @@ -115,9 +115,6 @@ const updateMembershipForgetRoom = "" + const selectRoomsWithMembershipSQL = "" + "SELECT room_nid FROM roomserver_membership WHERE membership_nid = $1 AND target_nid = $2 and forgotten = false" -const selectRoomsForUserSQL = "" + - "SELECT room_nid FROM roomserver_membership WHERE target_nid = $1 and forgotten = false" - // selectKnownUsersSQL uses a sub-select statement here to find rooms that the user is // joined to. Since this information is used to populate the user directory, we will // only return users that the user would ordinarily be able to see anyway. @@ -161,7 +158,6 @@ type membershipStatements struct { updateMembershipForgetRoomStmt *sql.Stmt selectLocalServerInRoomStmt *sql.Stmt selectServerInRoomStmt *sql.Stmt - selectRoomsForUserStmt *sql.Stmt } func createMembershipTable(db *sql.DB) error { @@ -187,7 +183,6 @@ func prepareMembershipTable(db *sql.DB) (tables.Membership, error) { {&s.updateMembershipForgetRoomStmt, updateMembershipForgetRoom}, {&s.selectLocalServerInRoomStmt, selectLocalServerInRoomSQL}, {&s.selectServerInRoomStmt, selectServerInRoomSQL}, - {&s.selectRoomsForUserStmt, selectRoomsForUserSQL}, }.Prepare(db) } @@ -296,12 +291,8 @@ func (s *membershipStatements) SelectRoomsWithMembership( ctx context.Context, txn *sql.Tx, userID types.EventStateKeyNID, membershipState tables.MembershipState, ) ([]types.RoomNID, error) { - var ( - rows *sql.Rows - err error - ) stmt := sqlutil.TxStmt(txn, s.selectRoomsWithMembershipStmt) - rows, err = stmt.QueryContext(ctx, membershipState, userID) + rows, err := stmt.QueryContext(ctx, membershipState, userID) if err != nil { return nil, err diff --git a/roomserver/storage/sqlite3/membership_table.go b/roomserver/storage/sqlite3/membership_table.go index d1d59f85f..1a111087d 100644 --- a/roomserver/storage/sqlite3/membership_table.go +++ b/roomserver/storage/sqlite3/membership_table.go @@ -91,9 +91,6 @@ const updateMembershipForgetRoom = "" + const selectRoomsWithMembershipSQL = "" + "SELECT room_nid FROM roomserver_membership WHERE membership_nid = $1 AND target_nid = $2 and forgotten = false" -const selectRoomsForUserSQL = "" + - "SELECT room_nid FROM roomserver_membership WHERE target_nid = $1 and forgotten = false" - // selectKnownUsersSQL uses a sub-select statement here to find rooms that the user is // joined to. Since this information is used to populate the user directory, we will // only return users that the user would ordinarily be able to see anyway. @@ -137,7 +134,6 @@ type membershipStatements struct { updateMembershipForgetRoomStmt *sql.Stmt selectLocalServerInRoomStmt *sql.Stmt selectServerInRoomStmt *sql.Stmt - selectRoomsForUserStmt *sql.Stmt } func createMembershipTable(db *sql.DB) error { @@ -164,7 +160,6 @@ func prepareMembershipTable(db *sql.DB) (tables.Membership, error) { {&s.updateMembershipForgetRoomStmt, updateMembershipForgetRoom}, {&s.selectLocalServerInRoomStmt, selectLocalServerInRoomSQL}, {&s.selectServerInRoomStmt, selectServerInRoomSQL}, - {&s.selectRoomsForUserStmt, selectRoomsForUserSQL}, }.Prepare(db) } @@ -273,13 +268,8 @@ func (s *membershipStatements) UpdateMembership( func (s *membershipStatements) SelectRoomsWithMembership( ctx context.Context, txn *sql.Tx, userID types.EventStateKeyNID, membershipState tables.MembershipState, ) ([]types.RoomNID, error) { - var ( - rows *sql.Rows - err error - ) - stmt := sqlutil.TxStmt(txn, s.selectRoomsWithMembershipStmt) - rows, err = stmt.QueryContext(ctx, membershipState, userID) + rows, err := stmt.QueryContext(ctx, membershipState, userID) if err != nil { return nil, err