boulder/db
Daniel McCarney 1c9ece3f44
SA: use wrapped database maps/transactions. (#4585)
New types and related infrastructure are added to the `db` package to allow
wrapping gorp DbMaps and Transactions.

The wrapped versions return a special `db.ErrDatabaseOp` error type when errors
occur. The new error type includes additional information such as the operation
that failed and the related table.

Where possible we determine the table based on the types of the gorp function
arguments. Where that isn't possible (e.g. with raw SQL queries) we try to use
a simple regexp approach to find the table name. This isn't great for general
SQL but works well enough for Boulder's existing SQL queries.

To get additional confidence my regexps work for all of Boulder's queries
I temporarily changed the `db` package's `tableFromQuery` function to panic if
the table couldn't be determined. I re-ran the full unit and integration test
suites with this configuration and saw no panics.

Resolves https://github.com/letsencrypt/boulder/issues/4559
2019-12-04 13:03:09 -05:00
..
map.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00
map_test.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00
mocks.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00
rollback.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00
rollback_test.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00
transaction.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00