0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-12-14 06:53:49 +01:00
dendrite/roomserver/storage/postgres
Kiril Vladimiroff d5dbe546e4
Always defer *sql.Rows.Close and consult with Err (#844)
* Always defer *sql.Rows.Close and consult with Err

database/sql.Rows.Next() makes sure to call Close only after exhausting
result rows which would NOT happen when returning early from a bad Scan.
Close being idempotent makes it a great candidate to get always deferred
regardless of what happens later on the result set.

This change also makes sure call Err() after exhausting Next() and
propagate non-nil results from it as the documentation advises.

Closes #764

Signed-off-by: Kiril Vladimiroff <kiril@vladimiroff.org>

* Override named result parameters in last returns

Signed-off-by: Kiril Vladimiroff <kiril@vladimiroff.org>

* Do the same over new changes that got merged

Signed-off-by: Kiril Vladimiroff <kiril@vladimiroff.org>

Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2020-02-11 14:12:21 +00:00
..
event_json_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
event_state_keys_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
event_types_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
events_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
invite_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
membership_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
prepare.go Implement storage interfaces (#841) 2020-01-03 14:07:05 +00:00
previous_events_table.go Implement storage interfaces (#841) 2020-01-03 14:07:05 +00:00
room_aliases_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
rooms_table.go Room version abstractions (#865) 2020-02-05 16:25:58 +00:00
sql.go Implement storage interfaces (#841) 2020-01-03 14:07:05 +00:00
state_block_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
state_block_table_test.go Implement storage interfaces (#841) 2020-01-03 14:07:05 +00:00
state_snapshot_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
storage.go Room version abstractions (#865) 2020-02-05 16:25:58 +00:00
transactions_table.go Implement storage interfaces (#841) 2020-01-03 14:07:05 +00:00