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:
Till 2023-11-09 08:42:33 +01:00 committed by GitHub
parent ee73a90aea
commit 699f5ca8c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 101 additions and 61 deletions

View file

@ -151,7 +151,7 @@ func (s *notaryServerKeysMetadataStatements) SelectKeys(ctx context.Context, txn
}
results = append(results, sk)
}
return results, nil
return results, rows.Err()
}
func (s *notaryServerKeysMetadataStatements) DeleteOldJSONResponses(ctx context.Context, txn *sql.Tx) error {

View file

@ -109,5 +109,5 @@ func (s *queueJSONStatements) SelectQueueJSON(
}
blobs[nid] = blob
}
return blobs, err
return blobs, rows.Err()
}

View file

@ -110,7 +110,7 @@ func (s *relayServersStatements) SelectRelayServers(
}
result = append(result, spec.ServerName(relayServer))
}
return result, nil
return result, rows.Err()
}
func (s *relayServersStatements) DeleteRelayServers(

View file

@ -216,5 +216,5 @@ func joinedHostsFromStmt(
})
}
return result, nil
return result, rows.Err()
}

View file

@ -154,7 +154,7 @@ func (s *notaryServerKeysMetadataStatements) SelectKeys(ctx context.Context, txn
}
results = append(results, sk)
}
return results, nil
return results, rows.Err()
}
func (s *notaryServerKeysMetadataStatements) DeleteOldJSONResponses(ctx context.Context, txn *sql.Tx) error {

View file

@ -135,5 +135,5 @@ func (s *queueJSONStatements) SelectQueueJSON(
}
blobs[nid] = blob
}
return blobs, err
return blobs, rows.Err()
}

View file

@ -109,7 +109,7 @@ func (s *relayServersStatements) SelectRelayServers(
}
result = append(result, spec.ServerName(relayServer))
}
return result, nil
return result, rows.Err()
}
func (s *relayServersStatements) DeleteRelayServers(

View file

@ -109,5 +109,5 @@ func (s *relayQueueJSONStatements) SelectQueueJSON(
}
blobs[nid] = blob
}
return blobs, err
return blobs, rows.Err()
}

View file

@ -133,5 +133,5 @@ func (s *relayQueueJSONStatements) SelectQueueJSON(
}
blobs[nid] = blob
}
return blobs, err
return blobs, rows.Err()
}

View file

@ -249,6 +249,7 @@ func (s *eventStatements) BulkSelectSnapshotsFromEventIDs(
if err != nil {
return nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "BulkSelectSnapshotsFromEventIDs: rows.close() failed")
var eventID string
var stateNID types.StateSnapshotNID
@ -563,7 +564,7 @@ func (s *eventStatements) SelectRoomNIDsForEventNIDs(
}
result[eventNID] = roomNID
}
return result, nil
return result, rows.Err()
}
func eventNIDsAsArray(eventNIDs []types.EventNID) pq.Int64Array {

View file

@ -363,7 +363,7 @@ func (s *membershipStatements) SelectRoomsWithMembership(
}
roomNIDs = append(roomNIDs, roomNID)
}
return roomNIDs, nil
return roomNIDs, rows.Err()
}
func (s *membershipStatements) SelectJoinedUsersSetForRooms(

View file

@ -137,7 +137,7 @@ func (s *roomStatements) SelectRoomIDsWithEvents(ctx context.Context, txn *sql.T
}
roomIDs = append(roomIDs, roomID)
}
return roomIDs, nil
return roomIDs, rows.Err()
}
func (s *roomStatements) InsertRoomNID(
ctx context.Context, txn *sql.Tx,
@ -255,7 +255,7 @@ func (s *roomStatements) SelectRoomVersionsForRoomNIDs(
}
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) {
@ -277,7 +277,7 @@ func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roo
}
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) {
@ -299,7 +299,7 @@ func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, ro
}
roomNIDs = append(roomNIDs, roomNID)
}
return roomNIDs, nil
return roomNIDs, rows.Err()
}
func roomNIDsAsArray(roomNIDs []types.RoomNID) pq.Int64Array {

View file

@ -162,6 +162,7 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")
resultMap := make(map[types.RoomNID]ed25519.PublicKey)
@ -173,5 +174,5 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
}
resultMap[roomNID] = pubkey
}
return resultMap, err
return resultMap, rows.Err()
}

View file

@ -109,5 +109,5 @@ func (s *eventJSONStatements) BulkSelectEventJSON(
}
result.EventNID = types.EventNID(eventNID)
}
return results[:i], nil
return results[:i], rows.Err()
}

View file

@ -136,7 +136,7 @@ func (s *eventStateKeyStatements) BulkSelectEventStateKeyNID(
}
result[stateKey] = types.EventStateKeyNID(stateKeyNID)
}
return result, nil
return result, rows.Err()
}
func (s *eventStateKeyStatements) BulkSelectEventStateKey(
@ -167,5 +167,5 @@ func (s *eventStateKeyStatements) BulkSelectEventStateKey(
}
result[types.EventStateKeyNID(stateKeyNID)] = stateKey
}
return result, nil
return result, rows.Err()
}

View file

@ -147,5 +147,5 @@ func (s *eventTypeStatements) BulkSelectEventTypeNID(
}
result[eventType] = types.EventTypeNID(eventTypeNID)
}
return result, nil
return result, rows.Err()
}

View file

@ -310,6 +310,9 @@ func (s *eventStatements) BulkSelectStateEventByID(
}
results = append(results, result)
}
if err = rows.Err(); err != nil {
return nil, err
}
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.
// 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 results[:i], err
return results[:i], rows.Err()
}
// 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) {
return nil, types.MissingEventError(
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.EventID = eventID
}
if err = rows.Err(); err != nil {
return nil, err
}
if 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
}
if err = rows.Err(); err != nil {
return nil, err
}
if 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),
}
}
return results, nil
return results, rows.Err()
}
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
}
return result, nil
return result, rows.Err()
}
func eventNIDsAsArray(eventNIDs []types.EventNID) string {

View file

@ -126,6 +126,9 @@ func (s *inviteStatements) UpdateInviteRetired(
}
eventIDs = append(eventIDs, inviteEventID)
}
if err = rows.Err(); err != nil {
return
}
// now retire the invites
stmt = sqlutil.TxStmt(txn, s.updateInviteRetiredStmt)
_, err = stmt.ExecContext(ctx, roomNID, targetUserNID)
@ -157,5 +160,5 @@ func (s *inviteStatements) SelectInviteActiveForUserInRoom(
result = append(result, types.EventStateKeyNID(senderUserNID))
eventIDs = append(eventIDs, eventID)
}
return result, eventIDs, eventJSON, nil
return result, eventIDs, eventJSON, rows.Err()
}

View file

@ -250,6 +250,7 @@ func (s *membershipStatements) SelectMembershipsFromRoom(
}
eventNIDs = append(eventNIDs, eNID)
}
err = rows.Err()
return
}
@ -277,6 +278,7 @@ func (s *membershipStatements) SelectMembershipsFromRoomAndMembership(
}
eventNIDs = append(eventNIDs, eNID)
}
err = rows.Err()
return
}
@ -313,7 +315,7 @@ func (s *membershipStatements) SelectRoomsWithMembership(
}
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) {

View file

@ -121,7 +121,7 @@ func (s *roomAliasesStatements) SelectAliasesFromRoomID(
aliases = append(aliases, alias)
}
err = rows.Err()
return
}

View file

@ -128,7 +128,7 @@ func (s *roomStatements) SelectRoomIDsWithEvents(ctx context.Context, txn *sql.T
}
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) {
@ -265,7 +265,7 @@ func (s *roomStatements) SelectRoomVersionsForRoomNIDs(
}
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) {
@ -293,7 +293,7 @@ func (s *roomStatements) BulkSelectRoomIDs(ctx context.Context, txn *sql.Tx, roo
}
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) {
@ -321,5 +321,5 @@ func (s *roomStatements) BulkSelectRoomNIDs(ctx context.Context, txn *sql.Tx, ro
}
roomNIDs = append(roomNIDs, roomNID)
}
return roomNIDs, nil
return roomNIDs, rows.Err()
}

View file

@ -133,13 +133,16 @@ func (s *stateSnapshotStatements) BulkSelectStateBlockNIDs(
var stateBlockNIDsJSON string
for ; rows.Next(); 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
}
if err := json.Unmarshal([]byte(stateBlockNIDsJSON), &result.StateBlockNIDs); err != nil {
if err = json.Unmarshal([]byte(stateBlockNIDsJSON), &result.StateBlockNIDs); err != nil {
return nil, err
}
}
if err = rows.Err(); err != nil {
return nil, err
}
if i != len(stateNIDs) {
return nil, types.MissingStateError(fmt.Sprintf("storage: state NIDs missing from the database (%d != %d)", i, len(stateNIDs)))
}

View file

@ -177,6 +177,7 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")
resultMap := make(map[types.RoomNID]ed25519.PublicKey)
@ -188,5 +189,5 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
}
resultMap[roomNID] = pubkey
}
return resultMap, err
return resultMap, rows.Err()
}

View file

@ -301,7 +301,7 @@ func (p *DB) ChildrenForParent(ctx context.Context, eventID, relType string, rec
}
children = append(children, evInfo)
}
return children, nil
return children, rows.Err()
}
func (p *DB) ParentForChild(ctx context.Context, eventID, relType string) (*eventInfo, error) {

View file

@ -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) {

View file

@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
rstypes "github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
@ -160,6 +161,7 @@ func (s *membershipsStatements) SelectMemberships(
if err != nil {
return
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectMemberships: failed to close rows")
var (
eventID string
)

View file

@ -164,7 +164,7 @@ func (s *peekStatements) SelectPeekingDevices(
devices = append(devices, types.PeekingDevice{UserID: userID, DeviceID: deviceID})
result[roomID] = devices
}
return result, nil
return result, rows.Err()
}
func (s *peekStatements) SelectMaxPeekID(

View file

@ -144,7 +144,7 @@ func (p *presenceStatements) GetPresenceForUsers(
presence.ClientFields.Presence = presence.Presence.String()
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) {

View file

@ -177,7 +177,7 @@ func (s *currentRoomStateStatements) SelectJoinedUsers(
users = append(users, userID)
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.
@ -236,7 +236,7 @@ func (s *currentRoomStateStatements) SelectRoomIDsWithMembership(
}
result = append(result, roomID)
}
return result, nil
return result, rows.Err()
}
// 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) {

View file

@ -176,7 +176,7 @@ func (s *inviteEventsStatements) SelectInviteEventsInRange(
if lastPos == 0 {
lastPos = r.To
}
return result, retired, lastPos, nil
return result, retired, lastPos, rows.Err()
}
func (s *inviteEventsStatements) SelectMaxInviteID(

View file

@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
rstypes "github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
@ -163,6 +164,7 @@ func (s *membershipsStatements) SelectMemberships(
if err != nil {
return
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectMemberships: failed to close rows")
var eventID string
for rows.Next() {
if err = rows.Scan(&eventID); err != nil {

View file

@ -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,
@ -520,7 +520,7 @@ func rowsToStreamEvents(rows *sql.Rows) ([]types.StreamEvent, error) {
ExcludeFromSync: excludeFromSync,
})
}
return result, nil
return result, rows.Err()
}
func (s *outputRoomEventsStatements) SelectContextEvent(
ctx context.Context, txn *sql.Tx, roomID, eventID string,

View file

@ -18,6 +18,7 @@ import (
"context"
"database/sql"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
rstypes "github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
@ -137,6 +138,7 @@ func (s *outputRoomEventsTopologyStatements) SelectEventIDsInRange(
} else if err != nil {
return
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectEventIDsInRange: failed to close rows")
// Return the IDs.
var eventID string
@ -155,7 +157,7 @@ func (s *outputRoomEventsTopologyStatements) SelectEventIDsInRange(
start = tokens[0]
end = tokens[len(tokens)-1]
}
err = rows.Err()
return
}

View file

@ -184,7 +184,7 @@ func (s *peekStatements) SelectPeekingDevices(
devices = append(devices, types.PeekingDevice{UserID: userID, DeviceID: deviceID})
result[roomID] = devices
}
return result, nil
return result, rows.Err()
}
func (s *peekStatements) SelectMaxPeekID(

View file

@ -169,7 +169,7 @@ func (p *presenceStatements) GetPresenceForUsers(
presence.ClientFields.Presence = presence.Presence.String()
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) {

View file

@ -77,7 +77,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
for rows.Next() {
var keyTypeInt int16
var keyData spec.Base64Bytes
if err := rows.Scan(&keyTypeInt, &keyData); err != nil {
if err = rows.Scan(&keyTypeInt, &keyData); err != nil {
return nil, err
}
keyType, ok := types.KeyTypeIntToPurpose[keyTypeInt]
@ -86,6 +86,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
}
r[keyType] = keyData
}
err = rows.Err()
return
}

View file

@ -98,7 +98,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
var userID string
var keyID gomatrixserverlib.KeyID
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
}
if _, ok := r[userID]; !ok {
@ -106,6 +106,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
}
r[userID][keyID] = signature
}
err = rows.Err()
return
}

View file

@ -162,5 +162,5 @@ func unpackKeys(ctx context.Context, rows *sql.Rows) (map[string]map[string]api.
roomData[key.SessionID] = key.KeyBackupSession
result[key.RoomID] = roomData
}
return result, nil
return result, rows.Err()
}

View file

@ -115,7 +115,7 @@ func (s *keyChangesStatements) SelectKeyChanges(
for rows.Next() {
var userID string
var offset int64
if err := rows.Scan(&userID, &offset); err != nil {
if err = rows.Scan(&userID, &offset); err != nil {
return nil, 0, err
}
if offset > latestOffset {
@ -123,5 +123,6 @@ func (s *keyChangesStatements) SelectKeyChanges(
}
userIDs = append(userIDs, userID)
}
err = rows.Err()
return
}

View file

@ -134,7 +134,7 @@ func (s *oneTimeKeysStatements) CountOneTimeKeys(ctx context.Context, userID, de
}
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) {

View file

@ -165,5 +165,5 @@ func (s *profilesStatements) SelectProfilesBySearch(
profiles = append(profiles, profile)
}
}
return profiles, nil
return profiles, rows.Err()
}

View file

@ -18,6 +18,7 @@ import (
"context"
"database/sql"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/userapi/storage/tables"
"github.com/matrix-org/gomatrixserverlib/spec"
@ -94,6 +95,7 @@ func (s *threepidStatements) SelectThreePIDsForLocalpart(
if err != nil {
return
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectThreePIDsForLocalpart: failed to close rows")
threepids = []authtypes.ThreePID{}
for rows.Next() {
@ -107,7 +109,7 @@ func (s *threepidStatements) SelectThreePIDsForLocalpart(
Medium: medium,
})
}
err = rows.Err()
return
}

View file

@ -19,6 +19,7 @@ import (
"database/sql"
"encoding/json"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/userapi/storage/tables"
"github.com/matrix-org/gomatrixserverlib/spec"
@ -95,6 +96,7 @@ func (s *accountDataStatements) SelectAccountData(
if err != nil {
return nil, nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAccountData: failed to close rows")
global := 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(

View file

@ -76,7 +76,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
for rows.Next() {
var keyTypeInt int16
var keyData spec.Base64Bytes
if err := rows.Scan(&keyTypeInt, &keyData); err != nil {
if err = rows.Scan(&keyTypeInt, &keyData); err != nil {
return nil, err
}
keyType, ok := types.KeyTypeIntToPurpose[keyTypeInt]
@ -85,6 +85,7 @@ func (s *crossSigningKeysStatements) SelectCrossSigningKeysForUser(
}
r[keyType] = keyData
}
err = rows.Err()
return
}

View file

@ -96,7 +96,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
var userID string
var keyID gomatrixserverlib.KeyID
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
}
if _, ok := r[userID]; !ok {
@ -104,6 +104,7 @@ func (s *crossSigningSigsStatements) SelectCrossSigningSigsForTarget(
}
r[userID][keyID] = signature
}
err = rows.Err()
return
}

View file

@ -296,6 +296,7 @@ func (s *devicesStatements) SelectDevicesByLocalpart(
if err != nil {
return devices, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectDevicesByLocalpart: failed to close rows")
var dev api.Device
var lastseents sql.NullInt64
@ -325,7 +326,7 @@ func (s *devicesStatements) SelectDevicesByLocalpart(
devices = append(devices, dev)
}
return devices, nil
return devices, rows.Err()
}
func (s *devicesStatements) SelectDevicesByID(ctx context.Context, deviceIDs []string) ([]api.Device, error) {

View file

@ -162,5 +162,5 @@ func unpackKeys(ctx context.Context, rows *sql.Rows) (map[string]map[string]api.
roomData[key.SessionID] = key.KeyBackupSession
result[key.RoomID] = roomData
}
return result, nil
return result, rows.Err()
}

View file

@ -113,7 +113,7 @@ func (s *keyChangesStatements) SelectKeyChanges(
for rows.Next() {
var userID string
var offset int64
if err := rows.Scan(&userID, &offset); err != nil {
if err = rows.Scan(&userID, &offset); err != nil {
return nil, 0, err
}
if offset > latestOffset {
@ -121,5 +121,6 @@ func (s *keyChangesStatements) SelectKeyChanges(
}
userIDs = append(userIDs, userID)
}
err = rows.Err()
return
}

View file

@ -140,7 +140,7 @@ func (s *oneTimeKeysStatements) CountOneTimeKeys(ctx context.Context, userID, de
}
counts.KeyCount[algorithm] = count
}
return counts, nil
return counts, rows.Err()
}
func (s *oneTimeKeysStatements) InsertOneTimeKeys(

View file

@ -173,5 +173,5 @@ func (s *profilesStatements) SelectProfilesBySearch(
profiles = append(profiles, profile)
}
}
return profiles, nil
return profiles, rows.Err()
}