dendrite/common
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
..
basecomponent Store our own keys in the keydb (#853) 2020-01-25 14:12:52 +00:00
config patch dendrite microservices with bind config (#795) 2019-10-02 10:29:27 +01:00
http use go module for dependencies (#594) 2019-05-21 21:56:55 +01:00
keydb Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
test Fix AppService bind addrs in test (#805) 2020-02-11 13:53:54 +00:00
transactions Replace deprecated prometheus.InstrumentHandler and unsafe time.Ticker 2019-12-17 16:47:45 +00:00
consumers.go use go module for dependencies (#594) 2019-05-21 21:56:55 +01:00
eventcontent.go Replace event content types with ones in gomatrixserverlib (#785) 2019-08-16 01:45:11 +08:00
events.go Pass cfg by reference around the codebase (#819) 2020-02-11 11:18:12 +00:00
httpapi.go Replace deprecated prometheus.InstrumentHandler and unsafe time.Ticker 2019-12-17 16:47:45 +00:00
log.go Add filepath and function name to log output (#755) 2019-07-24 12:44:05 +08:00
partition_offset_table.go Always defer *sql.Rows.Close and consult with Err (#844) 2020-02-11 14:12:21 +00:00
routing.go Encode URLs properly (#728) 2019-07-03 16:38:50 +01:00
sql.go use go module for dependencies (#594) 2019-05-21 21:56:55 +01:00
types.go Implement profile retrieval over federation (#726) 2019-08-07 00:02:12 +08:00