sql,pg,engine: rework sql interfaces #601
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reduce sql interfaces, and clean up pg methods.
This change does:
rework all of the interfaces in
common/sql/sql.go
for clarity and versatility. See updated type docs there. Types and interfaces are generally defined from lowest to highest level of composition for easy of understanding.With a
*pg.DB
, it was previously required to callPrecommit
beforeCommit
, but made the type less able to effectively satisfy the simpler sql interfaces, and it was technically of no need if a commit ID (or 2pc) was not required. Now it is optional, simplifying it's use in contexts where these features are not relevant (only commit or rollback needed).Remove
AccessMode
from theDB
(and thusTx
) interfaces, making it an optional type assertion required by the engine for mutable actions. This wasn't totally necessary to change, but it was an awkward method for all other systems and their tests.Remove many obsolete types and methods from
internal/sql/pg/conn.go
, mostly from when we had implicit sessions rather than transaction-scoped Executors.The
OuterTxMaker
interface no longer collides withTxMaker
, allowing*pg.DB
to satisfy both.Fix
(*Pool).BeginReadTx
beginning a RW txn instead of a RO txn.Globally narrow the interfaces on function input arguments to what is actually required. This improves semantics and testability.
Many other less notable changes...
Some significant ugliness in the event store test setup (events_tests.go) is eliminated.