mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-26 00:01:55 -06:00
More rows.Close()
and rows.Err()
(#3262)
Looks like we missed some `rows.Close()` Even though `rows.Err()` is mostly not necessary, we should be more consistent in the DB layer. [skip ci]
This commit is contained in:
parent
ee73a90aea
commit
699f5ca8c1
|
@ -151,7 +151,7 @@ func (s *notaryServerKeysMetadataStatements) SelectKeys(ctx context.Context, txn
|
||||||
}
|
}
|
||||||
results = append(results, sk)
|
results = append(results, sk)
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *notaryServerKeysMetadataStatements) DeleteOldJSONResponses(ctx context.Context, txn *sql.Tx) error {
|
func (s *notaryServerKeysMetadataStatements) DeleteOldJSONResponses(ctx context.Context, txn *sql.Tx) error {
|
||||||
|
|
|
@ -109,5 +109,5 @@ func (s *queueJSONStatements) SelectQueueJSON(
|
||||||
}
|
}
|
||||||
blobs[nid] = blob
|
blobs[nid] = blob
|
||||||
}
|
}
|
||||||
return blobs, err
|
return blobs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (s *relayServersStatements) SelectRelayServers(
|
||||||
}
|
}
|
||||||
result = append(result, spec.ServerName(relayServer))
|
result = append(result, spec.ServerName(relayServer))
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *relayServersStatements) DeleteRelayServers(
|
func (s *relayServersStatements) DeleteRelayServers(
|
||||||
|
|
|
@ -216,5 +216,5 @@ func joinedHostsFromStmt(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ func (s *notaryServerKeysMetadataStatements) SelectKeys(ctx context.Context, txn
|
||||||
}
|
}
|
||||||
results = append(results, sk)
|
results = append(results, sk)
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *notaryServerKeysMetadataStatements) DeleteOldJSONResponses(ctx context.Context, txn *sql.Tx) error {
|
func (s *notaryServerKeysMetadataStatements) DeleteOldJSONResponses(ctx context.Context, txn *sql.Tx) error {
|
||||||
|
|
|
@ -135,5 +135,5 @@ func (s *queueJSONStatements) SelectQueueJSON(
|
||||||
}
|
}
|
||||||
blobs[nid] = blob
|
blobs[nid] = blob
|
||||||
}
|
}
|
||||||
return blobs, err
|
return blobs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ func (s *relayServersStatements) SelectRelayServers(
|
||||||
}
|
}
|
||||||
result = append(result, spec.ServerName(relayServer))
|
result = append(result, spec.ServerName(relayServer))
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *relayServersStatements) DeleteRelayServers(
|
func (s *relayServersStatements) DeleteRelayServers(
|
||||||
|
|
|
@ -109,5 +109,5 @@ func (s *relayQueueJSONStatements) SelectQueueJSON(
|
||||||
}
|
}
|
||||||
blobs[nid] = blob
|
blobs[nid] = blob
|
||||||
}
|
}
|
||||||
return blobs, err
|
return blobs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,5 +133,5 @@ func (s *relayQueueJSONStatements) SelectQueueJSON(
|
||||||
}
|
}
|
||||||
blobs[nid] = blob
|
blobs[nid] = blob
|
||||||
}
|
}
|
||||||
return blobs, err
|
return blobs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,6 +249,7 @@ func (s *eventStatements) BulkSelectSnapshotsFromEventIDs(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "BulkSelectSnapshotsFromEventIDs: rows.close() failed")
|
||||||
|
|
||||||
var eventID string
|
var eventID string
|
||||||
var stateNID types.StateSnapshotNID
|
var stateNID types.StateSnapshotNID
|
||||||
|
@ -563,7 +564,7 @@ func (s *eventStatements) SelectRoomNIDsForEventNIDs(
|
||||||
}
|
}
|
||||||
result[eventNID] = roomNID
|
result[eventNID] = roomNID
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func eventNIDsAsArray(eventNIDs []types.EventNID) pq.Int64Array {
|
func eventNIDsAsArray(eventNIDs []types.EventNID) pq.Int64Array {
|
||||||
|
|
|
@ -363,7 +363,7 @@ func (s *membershipStatements) SelectRoomsWithMembership(
|
||||||
}
|
}
|
||||||
roomNIDs = append(roomNIDs, roomNID)
|
roomNIDs = append(roomNIDs, roomNID)
|
||||||
}
|
}
|
||||||
return roomNIDs, nil
|
return roomNIDs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *membershipStatements) SelectJoinedUsersSetForRooms(
|
func (s *membershipStatements) SelectJoinedUsersSetForRooms(
|
||||||
|
|
|
@ -137,7 +137,7 @@ func (s *roomStatements) SelectRoomIDsWithEvents(ctx context.Context, txn *sql.T
|
||||||
}
|
}
|
||||||
roomIDs = append(roomIDs, roomID)
|
roomIDs = append(roomIDs, roomID)
|
||||||
}
|
}
|
||||||
return roomIDs, nil
|
return roomIDs, rows.Err()
|
||||||
}
|
}
|
||||||
func (s *roomStatements) InsertRoomNID(
|
func (s *roomStatements) InsertRoomNID(
|
||||||
ctx context.Context, txn *sql.Tx,
|
ctx context.Context, txn *sql.Tx,
|
||||||
|
@ -255,7 +255,7 @@ func (s *roomStatements) SelectRoomVersionsForRoomNIDs(
|
||||||
}
|
}
|
||||||
result[roomNID] = roomVersion
|
result[roomNID] = roomVersion
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roomNIDs []types.RoomNID) ([]string, error) {
|
func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roomNIDs []types.RoomNID) ([]string, error) {
|
||||||
|
@ -277,7 +277,7 @@ func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roo
|
||||||
}
|
}
|
||||||
roomIDs = append(roomIDs, roomID)
|
roomIDs = append(roomIDs, roomID)
|
||||||
}
|
}
|
||||||
return roomIDs, nil
|
return roomIDs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, roomIDs []string) ([]types.RoomNID, error) {
|
func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, roomIDs []string) ([]types.RoomNID, error) {
|
||||||
|
@ -299,7 +299,7 @@ func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, ro
|
||||||
}
|
}
|
||||||
roomNIDs = append(roomNIDs, roomNID)
|
roomNIDs = append(roomNIDs, roomNID)
|
||||||
}
|
}
|
||||||
return roomNIDs, nil
|
return roomNIDs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func roomNIDsAsArray(roomNIDs []types.RoomNID) pq.Int64Array {
|
func roomNIDsAsArray(roomNIDs []types.RoomNID) pq.Int64Array {
|
||||||
|
|
|
@ -162,6 +162,7 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")
|
||||||
|
|
||||||
resultMap := make(map[types.RoomNID]ed25519.PublicKey)
|
resultMap := make(map[types.RoomNID]ed25519.PublicKey)
|
||||||
|
|
||||||
|
@ -173,5 +174,5 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
|
||||||
}
|
}
|
||||||
resultMap[roomNID] = pubkey
|
resultMap[roomNID] = pubkey
|
||||||
}
|
}
|
||||||
return resultMap, err
|
return resultMap, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,5 +109,5 @@ func (s *eventJSONStatements) BulkSelectEventJSON(
|
||||||
}
|
}
|
||||||
result.EventNID = types.EventNID(eventNID)
|
result.EventNID = types.EventNID(eventNID)
|
||||||
}
|
}
|
||||||
return results[:i], nil
|
return results[:i], rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ func (s *eventStateKeyStatements) BulkSelectEventStateKeyNID(
|
||||||
}
|
}
|
||||||
result[stateKey] = types.EventStateKeyNID(stateKeyNID)
|
result[stateKey] = types.EventStateKeyNID(stateKeyNID)
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *eventStateKeyStatements) BulkSelectEventStateKey(
|
func (s *eventStateKeyStatements) BulkSelectEventStateKey(
|
||||||
|
@ -167,5 +167,5 @@ func (s *eventStateKeyStatements) BulkSelectEventStateKey(
|
||||||
}
|
}
|
||||||
result[types.EventStateKeyNID(stateKeyNID)] = stateKey
|
result[types.EventStateKeyNID(stateKeyNID)] = stateKey
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,5 +147,5 @@ func (s *eventTypeStatements) BulkSelectEventTypeNID(
|
||||||
}
|
}
|
||||||
result[eventType] = types.EventTypeNID(eventTypeNID)
|
result[eventType] = types.EventTypeNID(eventTypeNID)
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,6 +310,9 @@ func (s *eventStatements) BulkSelectStateEventByID(
|
||||||
}
|
}
|
||||||
results = append(results, result)
|
results = append(results, result)
|
||||||
}
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if !excludeRejected && i != len(eventIDs) {
|
if !excludeRejected && i != len(eventIDs) {
|
||||||
// If there are fewer rows returned than IDs then we were asked to lookup event IDs we don't have.
|
// If there are fewer rows returned than IDs then we were asked to lookup event IDs we don't have.
|
||||||
// We don't know which ones were missing because we don't return the string IDs in the query.
|
// We don't know which ones were missing because we don't return the string IDs in the query.
|
||||||
|
@ -377,7 +380,7 @@ func (s *eventStatements) BulkSelectStateEventByNID(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results[:i], err
|
return results[:i], rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// bulkSelectStateAtEventByID lookups the state at a list of events by event ID.
|
// bulkSelectStateAtEventByID lookups the state at a list of events by event ID.
|
||||||
|
@ -425,6 +428,9 @@ func (s *eventStatements) BulkSelectStateAtEventByID(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if i != len(eventIDs) {
|
if i != len(eventIDs) {
|
||||||
return nil, types.MissingEventError(
|
return nil, types.MissingEventError(
|
||||||
fmt.Sprintf("storage: event IDs missing from the database (%d != %d)", i, len(eventIDs)),
|
fmt.Sprintf("storage: event IDs missing from the database (%d != %d)", i, len(eventIDs)),
|
||||||
|
@ -507,6 +513,9 @@ func (s *eventStatements) BulkSelectStateAtEventAndReference(
|
||||||
result.BeforeStateSnapshotNID = types.StateSnapshotNID(stateSnapshotNID)
|
result.BeforeStateSnapshotNID = types.StateSnapshotNID(stateSnapshotNID)
|
||||||
result.EventID = eventID
|
result.EventID = eventID
|
||||||
}
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if i != len(eventNIDs) {
|
if i != len(eventNIDs) {
|
||||||
return nil, fmt.Errorf("storage: event NIDs missing from the database (%d != %d)", i, len(eventNIDs))
|
return nil, fmt.Errorf("storage: event NIDs missing from the database (%d != %d)", i, len(eventNIDs))
|
||||||
}
|
}
|
||||||
|
@ -544,6 +553,9 @@ func (s *eventStatements) BulkSelectEventID(ctx context.Context, txn *sql.Tx, ev
|
||||||
}
|
}
|
||||||
results[types.EventNID(eventNID)] = eventID
|
results[types.EventNID(eventNID)] = eventID
|
||||||
}
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if i != len(eventNIDs) {
|
if i != len(eventNIDs) {
|
||||||
return nil, fmt.Errorf("storage: event NIDs missing from the database (%d != %d)", i, len(eventNIDs))
|
return nil, fmt.Errorf("storage: event NIDs missing from the database (%d != %d)", i, len(eventNIDs))
|
||||||
}
|
}
|
||||||
|
@ -602,7 +614,7 @@ func (s *eventStatements) bulkSelectEventNID(ctx context.Context, txn *sql.Tx, e
|
||||||
RoomNID: types.RoomNID(roomNID),
|
RoomNID: types.RoomNID(roomNID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *eventStatements) SelectMaxEventDepth(ctx context.Context, txn *sql.Tx, eventNIDs []types.EventNID) (int64, error) {
|
func (s *eventStatements) SelectMaxEventDepth(ctx context.Context, txn *sql.Tx, eventNIDs []types.EventNID) (int64, error) {
|
||||||
|
@ -652,7 +664,7 @@ func (s *eventStatements) SelectRoomNIDsForEventNIDs(
|
||||||
}
|
}
|
||||||
result[eventNID] = roomNID
|
result[eventNID] = roomNID
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func eventNIDsAsArray(eventNIDs []types.EventNID) string {
|
func eventNIDsAsArray(eventNIDs []types.EventNID) string {
|
||||||
|
|
|
@ -126,6 +126,9 @@ func (s *inviteStatements) UpdateInviteRetired(
|
||||||
}
|
}
|
||||||
eventIDs = append(eventIDs, inviteEventID)
|
eventIDs = append(eventIDs, inviteEventID)
|
||||||
}
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
// now retire the invites
|
// now retire the invites
|
||||||
stmt = sqlutil.TxStmt(txn, s.updateInviteRetiredStmt)
|
stmt = sqlutil.TxStmt(txn, s.updateInviteRetiredStmt)
|
||||||
_, err = stmt.ExecContext(ctx, roomNID, targetUserNID)
|
_, err = stmt.ExecContext(ctx, roomNID, targetUserNID)
|
||||||
|
@ -157,5 +160,5 @@ func (s *inviteStatements) SelectInviteActiveForUserInRoom(
|
||||||
result = append(result, types.EventStateKeyNID(senderUserNID))
|
result = append(result, types.EventStateKeyNID(senderUserNID))
|
||||||
eventIDs = append(eventIDs, eventID)
|
eventIDs = append(eventIDs, eventID)
|
||||||
}
|
}
|
||||||
return result, eventIDs, eventJSON, nil
|
return result, eventIDs, eventJSON, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,6 +250,7 @@ func (s *membershipStatements) SelectMembershipsFromRoom(
|
||||||
}
|
}
|
||||||
eventNIDs = append(eventNIDs, eNID)
|
eventNIDs = append(eventNIDs, eNID)
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +278,7 @@ func (s *membershipStatements) SelectMembershipsFromRoomAndMembership(
|
||||||
}
|
}
|
||||||
eventNIDs = append(eventNIDs, eNID)
|
eventNIDs = append(eventNIDs, eNID)
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +315,7 @@ func (s *membershipStatements) SelectRoomsWithMembership(
|
||||||
}
|
}
|
||||||
roomNIDs = append(roomNIDs, roomNID)
|
roomNIDs = append(roomNIDs, roomNID)
|
||||||
}
|
}
|
||||||
return roomNIDs, nil
|
return roomNIDs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *membershipStatements) SelectJoinedUsersSetForRooms(ctx context.Context, txn *sql.Tx, roomNIDs []types.RoomNID, userNIDs []types.EventStateKeyNID, localOnly bool) (map[types.EventStateKeyNID]int, error) {
|
func (s *membershipStatements) SelectJoinedUsersSetForRooms(ctx context.Context, txn *sql.Tx, roomNIDs []types.RoomNID, userNIDs []types.EventStateKeyNID, localOnly bool) (map[types.EventStateKeyNID]int, error) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ func (s *roomAliasesStatements) SelectAliasesFromRoomID(
|
||||||
|
|
||||||
aliases = append(aliases, alias)
|
aliases = append(aliases, alias)
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (s *roomStatements) SelectRoomIDsWithEvents(ctx context.Context, txn *sql.T
|
||||||
}
|
}
|
||||||
roomIDs = append(roomIDs, roomID)
|
roomIDs = append(roomIDs, roomID)
|
||||||
}
|
}
|
||||||
return roomIDs, nil
|
return roomIDs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *roomStatements) SelectRoomInfo(ctx context.Context, txn *sql.Tx, roomID string) (*types.RoomInfo, error) {
|
func (s *roomStatements) SelectRoomInfo(ctx context.Context, txn *sql.Tx, roomID string) (*types.RoomInfo, error) {
|
||||||
|
@ -265,7 +265,7 @@ func (s *roomStatements) SelectRoomVersionsForRoomNIDs(
|
||||||
}
|
}
|
||||||
result[roomNID] = roomVersion
|
result[roomNID] = roomVersion
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roomNIDs []types.RoomNID) ([]string, error) {
|
func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roomNIDs []types.RoomNID) ([]string, error) {
|
||||||
|
@ -293,7 +293,7 @@ func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roo
|
||||||
}
|
}
|
||||||
roomIDs = append(roomIDs, roomID)
|
roomIDs = append(roomIDs, roomID)
|
||||||
}
|
}
|
||||||
return roomIDs, nil
|
return roomIDs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, roomIDs []string) ([]types.RoomNID, error) {
|
func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, roomIDs []string) ([]types.RoomNID, error) {
|
||||||
|
@ -321,5 +321,5 @@ func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, ro
|
||||||
}
|
}
|
||||||
roomNIDs = append(roomNIDs, roomNID)
|
roomNIDs = append(roomNIDs, roomNID)
|
||||||
}
|
}
|
||||||
return roomNIDs, nil
|
return roomNIDs, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,13 +133,16 @@ func (s *stateSnapshotStatements) BulkSelectStateBlockNIDs(
|
||||||
var stateBlockNIDsJSON string
|
var stateBlockNIDsJSON string
|
||||||
for ; rows.Next(); i++ {
|
for ; rows.Next(); i++ {
|
||||||
result := &results[i]
|
result := &results[i]
|
||||||
if err := rows.Scan(&result.StateSnapshotNID, &stateBlockNIDsJSON); err != nil {
|
if err = rows.Scan(&result.StateSnapshotNID, &stateBlockNIDsJSON); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal([]byte(stateBlockNIDsJSON), &result.StateBlockNIDs); err != nil {
|
if err = json.Unmarshal([]byte(stateBlockNIDsJSON), &result.StateBlockNIDs); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if i != len(stateNIDs) {
|
if i != len(stateNIDs) {
|
||||||
return nil, types.MissingStateError(fmt.Sprintf("storage: state NIDs missing from the database (%d != %d)", i, len(stateNIDs)))
|
return nil, types.MissingStateError(fmt.Sprintf("storage: state NIDs missing from the database (%d != %d)", i, len(stateNIDs)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,7 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")
|
||||||
|
|
||||||
resultMap := make(map[types.RoomNID]ed25519.PublicKey)
|
resultMap := make(map[types.RoomNID]ed25519.PublicKey)
|
||||||
|
|
||||||
|
@ -188,5 +189,5 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
|
||||||
}
|
}
|
||||||
resultMap[roomNID] = pubkey
|
resultMap[roomNID] = pubkey
|
||||||
}
|
}
|
||||||
return resultMap, err
|
return resultMap, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ func (p *DB) ChildrenForParent(ctx context.Context, eventID, relType string, rec
|
||||||
}
|
}
|
||||||
children = append(children, evInfo)
|
children = append(children, evInfo)
|
||||||
}
|
}
|
||||||
return children, nil
|
return children, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *DB) ParentForChild(ctx context.Context, eventID, relType string) (*eventInfo, error) {
|
func (p *DB) ParentForChild(ctx context.Context, eventID, relType string) (*eventInfo, error) {
|
||||||
|
|
|
@ -392,7 +392,7 @@ func currentRoomStateRowsToStreamEvents(rows *sql.Rows) ([]types.StreamEvent, er
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return events, nil
|
return events, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func rowsToEvents(rows *sql.Rows) ([]*rstypes.HeaderedEvent, error) {
|
func rowsToEvents(rows *sql.Rows) ([]*rstypes.HeaderedEvent, error) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
rstypes "github.com/matrix-org/dendrite/roomserver/types"
|
rstypes "github.com/matrix-org/dendrite/roomserver/types"
|
||||||
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
||||||
|
@ -160,6 +161,7 @@ func (s *membershipsStatements) SelectMemberships(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectMemberships: failed to close rows")
|
||||||
var (
|
var (
|
||||||
eventID string
|
eventID string
|
||||||
)
|
)
|
||||||
|
|
|
@ -164,7 +164,7 @@ func (s *peekStatements) SelectPeekingDevices(
|
||||||
devices = append(devices, types.PeekingDevice{UserID: userID, DeviceID: deviceID})
|
devices = append(devices, types.PeekingDevice{UserID: userID, DeviceID: deviceID})
|
||||||
result[roomID] = devices
|
result[roomID] = devices
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *peekStatements) SelectMaxPeekID(
|
func (s *peekStatements) SelectMaxPeekID(
|
||||||
|
|
|
@ -144,7 +144,7 @@ func (p *presenceStatements) GetPresenceForUsers(
|
||||||
presence.ClientFields.Presence = presence.Presence.String()
|
presence.ClientFields.Presence = presence.Presence.String()
|
||||||
result = append(result, presence)
|
result = append(result, presence)
|
||||||
}
|
}
|
||||||
return result, err
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *presenceStatements) GetMaxPresenceID(ctx context.Context, txn *sql.Tx) (pos types.StreamPosition, err error) {
|
func (p *presenceStatements) GetMaxPresenceID(ctx context.Context, txn *sql.Tx) (pos types.StreamPosition, err error) {
|
||||||
|
|
|
@ -177,7 +177,7 @@ func (s *currentRoomStateStatements) SelectJoinedUsers(
|
||||||
users = append(users, userID)
|
users = append(users, userID)
|
||||||
result[roomID] = users
|
result[roomID] = users
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectJoinedUsersInRoom returns a map of room ID to a list of joined user IDs for a given room.
|
// SelectJoinedUsersInRoom returns a map of room ID to a list of joined user IDs for a given room.
|
||||||
|
@ -236,7 +236,7 @@ func (s *currentRoomStateStatements) SelectRoomIDsWithMembership(
|
||||||
}
|
}
|
||||||
result = append(result, roomID)
|
result = append(result, roomID)
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectRoomIDsWithAnyMembership returns a map of all memberships for the given user.
|
// SelectRoomIDsWithAnyMembership returns a map of all memberships for the given user.
|
||||||
|
@ -419,7 +419,7 @@ func currentRoomStateRowsToStreamEvents(rows *sql.Rows) ([]types.StreamEvent, er
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return events, nil
|
return events, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func rowsToEvents(rows *sql.Rows) ([]*rstypes.HeaderedEvent, error) {
|
func rowsToEvents(rows *sql.Rows) ([]*rstypes.HeaderedEvent, error) {
|
||||||
|
|
|
@ -176,7 +176,7 @@ func (s *inviteEventsStatements) SelectInviteEventsInRange(
|
||||||
if lastPos == 0 {
|
if lastPos == 0 {
|
||||||
lastPos = r.To
|
lastPos = r.To
|
||||||
}
|
}
|
||||||
return result, retired, lastPos, nil
|
return result, retired, lastPos, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *inviteEventsStatements) SelectMaxInviteID(
|
func (s *inviteEventsStatements) SelectMaxInviteID(
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
rstypes "github.com/matrix-org/dendrite/roomserver/types"
|
rstypes "github.com/matrix-org/dendrite/roomserver/types"
|
||||||
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
||||||
|
@ -163,6 +164,7 @@ func (s *membershipsStatements) SelectMemberships(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectMemberships: failed to close rows")
|
||||||
var eventID string
|
var eventID string
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
if err = rows.Scan(&eventID); err != nil {
|
if err = rows.Scan(&eventID); err != nil {
|
||||||
|
|
|
@ -274,7 +274,7 @@ func (s *outputRoomEventsStatements) SelectStateInRange(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stateNeeded, eventIDToEvent, nil
|
return stateNeeded, eventIDToEvent, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxID returns the ID of the last inserted event in this table. 'txn' is optional. If it is not supplied,
|
// MaxID returns the ID of the last inserted event in this table. 'txn' is optional. If it is not supplied,
|
||||||
|
@ -520,7 +520,7 @@ func rowsToStreamEvents(rows *sql.Rows) ([]types.StreamEvent, error) {
|
||||||
ExcludeFromSync: excludeFromSync,
|
ExcludeFromSync: excludeFromSync,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
func (s *outputRoomEventsStatements) SelectContextEvent(
|
func (s *outputRoomEventsStatements) SelectContextEvent(
|
||||||
ctx context.Context, txn *sql.Tx, roomID, eventID string,
|
ctx context.Context, txn *sql.Tx, roomID, eventID string,
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
rstypes "github.com/matrix-org/dendrite/roomserver/types"
|
rstypes "github.com/matrix-org/dendrite/roomserver/types"
|
||||||
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
||||||
|
@ -137,6 +138,7 @@ func (s *outputRoomEventsTopologyStatements) SelectEventIDsInRange(
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectEventIDsInRange: failed to close rows")
|
||||||
|
|
||||||
// Return the IDs.
|
// Return the IDs.
|
||||||
var eventID string
|
var eventID string
|
||||||
|
@ -155,7 +157,7 @@ func (s *outputRoomEventsTopologyStatements) SelectEventIDsInRange(
|
||||||
start = tokens[0]
|
start = tokens[0]
|
||||||
end = tokens[len(tokens)-1]
|
end = tokens[len(tokens)-1]
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ func (s *peekStatements) SelectPeekingDevices(
|
||||||
devices = append(devices, types.PeekingDevice{UserID: userID, DeviceID: deviceID})
|
devices = append(devices, types.PeekingDevice{UserID: userID, DeviceID: deviceID})
|
||||||
result[roomID] = devices
|
result[roomID] = devices
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *peekStatements) SelectMaxPeekID(
|
func (s *peekStatements) SelectMaxPeekID(
|
||||||
|
|
|
@ -169,7 +169,7 @@ func (p *presenceStatements) GetPresenceForUsers(
|
||||||
presence.ClientFields.Presence = presence.Presence.String()
|
presence.ClientFields.Presence = presence.Presence.String()
|
||||||
result = append(result, presence)
|
result = append(result, presence)
|
||||||
}
|
}
|
||||||
return result, err
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *presenceStatements) GetMaxPresenceID(ctx context.Context, txn *sql.Tx) (pos types.StreamPosition, err error) {
|
func (p *presenceStatements) GetMaxPresenceID(ctx context.Context, txn *sql.Tx) (pos types.StreamPosition, err error) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var keyTypeInt int16
|
var keyTypeInt int16
|
||||||
var keyData spec.Base64Bytes
|
var keyData spec.Base64Bytes
|
||||||
if err := rows.Scan(&keyTypeInt, &keyData); err != nil {
|
if err = rows.Scan(&keyTypeInt, &keyData); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
keyType, ok := types.KeyTypeIntToPurpose[keyTypeInt]
|
keyType, ok := types.KeyTypeIntToPurpose[keyTypeInt]
|
||||||
|
@ -86,6 +86,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
|
||||||
}
|
}
|
||||||
r[keyType] = keyData
|
r[keyType] = keyData
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
|
||||||
var userID string
|
var userID string
|
||||||
var keyID gomatrixserverlib.KeyID
|
var keyID gomatrixserverlib.KeyID
|
||||||
var signature spec.Base64Bytes
|
var signature spec.Base64Bytes
|
||||||
if err := rows.Scan(&userID, &keyID, &signature); err != nil {
|
if err = rows.Scan(&userID, &keyID, &signature); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if _, ok := r[userID]; !ok {
|
if _, ok := r[userID]; !ok {
|
||||||
|
@ -106,6 +106,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
|
||||||
}
|
}
|
||||||
r[userID][keyID] = signature
|
r[userID][keyID] = signature
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,5 +162,5 @@ func unpackKeys(ctx context.Context, rows *sql.Rows) (map[string]map[string]api.
|
||||||
roomData[key.SessionID] = key.KeyBackupSession
|
roomData[key.SessionID] = key.KeyBackupSession
|
||||||
result[key.RoomID] = roomData
|
result[key.RoomID] = roomData
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (s *keyChangesStatements) SelectKeyChanges(
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var userID string
|
var userID string
|
||||||
var offset int64
|
var offset int64
|
||||||
if err := rows.Scan(&userID, &offset); err != nil {
|
if err = rows.Scan(&userID, &offset); err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
if offset > latestOffset {
|
if offset > latestOffset {
|
||||||
|
@ -123,5 +123,6 @@ func (s *keyChangesStatements) SelectKeyChanges(
|
||||||
}
|
}
|
||||||
userIDs = append(userIDs, userID)
|
userIDs = append(userIDs, userID)
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ func (s *oneTimeKeysStatements) CountOneTimeKeys(ctx context.Context, userID, de
|
||||||
}
|
}
|
||||||
counts.KeyCount[algorithm] = count
|
counts.KeyCount[algorithm] = count
|
||||||
}
|
}
|
||||||
return counts, nil
|
return counts, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *oneTimeKeysStatements) InsertOneTimeKeys(ctx context.Context, txn *sql.Tx, keys api.OneTimeKeys) (*api.OneTimeKeysCount, error) {
|
func (s *oneTimeKeysStatements) InsertOneTimeKeys(ctx context.Context, txn *sql.Tx, keys api.OneTimeKeys) (*api.OneTimeKeysCount, error) {
|
||||||
|
|
|
@ -165,5 +165,5 @@ func (s *profilesStatements) SelectProfilesBySearch(
|
||||||
profiles = append(profiles, profile)
|
profiles = append(profiles, profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return profiles, nil
|
return profiles, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/userapi/storage/tables"
|
"github.com/matrix-org/dendrite/userapi/storage/tables"
|
||||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||||
|
@ -94,6 +95,7 @@ func (s *threepidStatements) SelectThreePIDsForLocalpart(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectThreePIDsForLocalpart: failed to close rows")
|
||||||
|
|
||||||
threepids = []authtypes.ThreePID{}
|
threepids = []authtypes.ThreePID{}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
@ -107,7 +109,7 @@ func (s *threepidStatements) SelectThreePIDsForLocalpart(
|
||||||
Medium: medium,
|
Medium: medium,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/userapi/storage/tables"
|
"github.com/matrix-org/dendrite/userapi/storage/tables"
|
||||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||||
|
@ -95,6 +96,7 @@ func (s *accountDataStatements) SelectAccountData(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectAccountData: failed to close rows")
|
||||||
|
|
||||||
global := map[string]json.RawMessage{}
|
global := map[string]json.RawMessage{}
|
||||||
rooms := map[string]map[string]json.RawMessage{}
|
rooms := map[string]map[string]json.RawMessage{}
|
||||||
|
@ -118,7 +120,7 @@ func (s *accountDataStatements) SelectAccountData(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return global, rooms, nil
|
return global, rooms, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *accountDataStatements) SelectAccountDataByType(
|
func (s *accountDataStatements) SelectAccountDataByType(
|
||||||
|
|
|
@ -76,7 +76,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var keyTypeInt int16
|
var keyTypeInt int16
|
||||||
var keyData spec.Base64Bytes
|
var keyData spec.Base64Bytes
|
||||||
if err := rows.Scan(&keyTypeInt, &keyData); err != nil {
|
if err = rows.Scan(&keyTypeInt, &keyData); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
keyType, ok := types.KeyTypeIntToPurpose[keyTypeInt]
|
keyType, ok := types.KeyTypeIntToPurpose[keyTypeInt]
|
||||||
|
@ -85,6 +85,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
|
||||||
}
|
}
|
||||||
r[keyType] = keyData
|
r[keyType] = keyData
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
|
||||||
var userID string
|
var userID string
|
||||||
var keyID gomatrixserverlib.KeyID
|
var keyID gomatrixserverlib.KeyID
|
||||||
var signature spec.Base64Bytes
|
var signature spec.Base64Bytes
|
||||||
if err := rows.Scan(&userID, &keyID, &signature); err != nil {
|
if err = rows.Scan(&userID, &keyID, &signature); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if _, ok := r[userID]; !ok {
|
if _, ok := r[userID]; !ok {
|
||||||
|
@ -104,6 +104,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
|
||||||
}
|
}
|
||||||
r[userID][keyID] = signature
|
r[userID][keyID] = signature
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,7 @@ func (s *devicesStatements) SelectDevicesByLocalpart(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, err
|
return devices, err
|
||||||
}
|
}
|
||||||
|
defer internal.CloseAndLogIfError(ctx, rows, "SelectDevicesByLocalpart: failed to close rows")
|
||||||
|
|
||||||
var dev api.Device
|
var dev api.Device
|
||||||
var lastseents sql.NullInt64
|
var lastseents sql.NullInt64
|
||||||
|
@ -325,7 +326,7 @@ func (s *devicesStatements) SelectDevicesByLocalpart(
|
||||||
devices = append(devices, dev)
|
devices = append(devices, dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
return devices, nil
|
return devices, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *devicesStatements) SelectDevicesByID(ctx context.Context, deviceIDs []string) ([]api.Device, error) {
|
func (s *devicesStatements) SelectDevicesByID(ctx context.Context, deviceIDs []string) ([]api.Device, error) {
|
||||||
|
|
|
@ -162,5 +162,5 @@ func unpackKeys(ctx context.Context, rows *sql.Rows) (map[string]map[string]api.
|
||||||
roomData[key.SessionID] = key.KeyBackupSession
|
roomData[key.SessionID] = key.KeyBackupSession
|
||||||
result[key.RoomID] = roomData
|
result[key.RoomID] = roomData
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ func (s *keyChangesStatements) SelectKeyChanges(
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var userID string
|
var userID string
|
||||||
var offset int64
|
var offset int64
|
||||||
if err := rows.Scan(&userID, &offset); err != nil {
|
if err = rows.Scan(&userID, &offset); err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
if offset > latestOffset {
|
if offset > latestOffset {
|
||||||
|
@ -121,5 +121,6 @@ func (s *keyChangesStatements) SelectKeyChanges(
|
||||||
}
|
}
|
||||||
userIDs = append(userIDs, userID)
|
userIDs = append(userIDs, userID)
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ func (s *oneTimeKeysStatements) CountOneTimeKeys(ctx context.Context, userID, de
|
||||||
}
|
}
|
||||||
counts.KeyCount[algorithm] = count
|
counts.KeyCount[algorithm] = count
|
||||||
}
|
}
|
||||||
return counts, nil
|
return counts, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *oneTimeKeysStatements) InsertOneTimeKeys(
|
func (s *oneTimeKeysStatements) InsertOneTimeKeys(
|
||||||
|
|
|
@ -173,5 +173,5 @@ func (s *profilesStatements) SelectProfilesBySearch(
|
||||||
profiles = append(profiles, profile)
|
profiles = append(profiles, profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return profiles, nil
|
return profiles, rows.Err()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue