• Daniel Theophanes's avatar
    database/sql: allow using a single connection from the database · d234f9a7
    Daniel Theophanes authored
    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/40694Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    d234f9a7
Name
Last commit
Last update
..
driver Loading commit data...
convert.go Loading commit data...
convert_test.go Loading commit data...
ctxutil.go Loading commit data...
doc.txt Loading commit data...
example_test.go Loading commit data...
fakedb_test.go Loading commit data...
sql.go Loading commit data...
sql_test.go Loading commit data...