Comments (6)
Not targeting the issue but the fact... yuck 👎
Did you write a test to check what it does in practice?
from go-database-sql-tutorial.
Not yet - I intend to. If you want to, go ahead :)
from go-database-sql-tutorial.
That honor shall be yours...
Maybe it's time for a Go issue to create something sessiony in database/sql - db.Session()
with Close()
or End()
which has a subset of the functions of sql.DB
: Query, QueryRow, Exec, Prepare, Begin, Close.
That would also be practical with SET @var := ...
for variables that have to be kept for multiple queries.
from go-database-sql-tutorial.
Do you still think this could be a problem? I haven't heard of it, and I wonder if we do something sensible in the driver (you know the code, I don't) to set the autocommit flag on when creating statements that are not part of a transaction. Or is this just left up to the winds of fate?
from go-database-sql-tutorial.
We do not check any server flags except max_packet_size and what the protocol delivers in the headers. I'd have to check and do some reading, but I don't intend to do that for now.
Intuitively, I'd say it is a problem but either everyone with that setting knows what causes the error and writes code accordingly or - more probable - nobody uses that setting. I can't think of a sensible reason to use that mode, it probably breaks a lot of tools and libraries and enforcing usage of transactions for every query - the only value it delivers - will be damaging in at least some cases for most real world systems.
from go-database-sql-tutorial.
I believe, but I'm not sure, that most libraries want to assume autocommit
is set on by default, and that you'll set it off if you want -- during
opening a connection most likely. I am pretty sure this is how Perl's DBI
wants it to be... yep. https://metacpan.org/pod/DBI#AutoCommit "Drivers
should always default to AutoCommit mode (an unfortunate choice largely
forced on the DBI by ODBC and JDBC conventions.)"
I remember once early in my career we configured the server with
autocommit=0 but we figured out our mistake pretty fast.
from go-database-sql-tutorial.
Related Issues (20)
- go-sql-driver/mysql does provide error identifiers HOT 1
- 404 when using link
- question: are connections pooled per prepared statement? HOT 1
- question: are connections pooled per prepared statement?
- "Go doesn't support multiple result sets" statement is incorrect.
- Transaction + lock tables
- Explain idiomatic checking of error codes
- Error-handling unclear
- The type settings make this website generally hard to read HOT 6
- retrieving.md: description of rows.Close() handling doesn't match with the code HOT 4
- Adding a section that describes the table creation HOT 1
- Complete Example?
- License HOT 19
- Working with Unknown Columns witch has time with oracle HOT 2
- consider using sqlite3 as your example scenario?
- Stop using log.Fatal
- Consider teaching readers to insert data before fetching it HOT 1
- Mention variations with Context
- empty "leftnav" ? HOT 1
- Something broken after add translate. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-database-sql-tutorial.