-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
database/sql: allow using a single connection from the database
Databases have the following concepts: Statement, Batch, and Session. A statement is often a single line like: SELECT Amount from Account where ID = 50; A batch is one or more statements submitted together for the query to process. It may be a DELETE, INSERT, two UPDATES and a SELECT in a single query text. A session is usually represented by a single database connection. This often is an issue when dealing with scopes in databases. Temporary tables and variables can have batch, session, or global scope depending on the syntax, database, and use. Furthermore, some databases (sybase and derivatives in perticular) that prevent certain statements from being in the same batch and may necessitate being in the same session. By allowing users to extract a Conn from the database they can manage session on their own without hacking around it by making connection pools of single connections (a real workaround presented in issue). It is tempting to just use a transaction, but this isn't always desirable or an option if running an interactive session or alter script set that itself starts transactions. Fixes #18081 Change-Id: I9bdf0796632c48d4bcaef3624c629641984ffaf2 Reviewed-on: https://go-review.googlesource.com/40694 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
- Loading branch information
Showing
2 changed files
with
283 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters