Giter VIP home page Giter VIP logo

Comments (6)

arnehormann avatar arnehormann commented on June 3, 2024

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.

xaprb avatar xaprb commented on June 3, 2024

Not yet - I intend to. If you want to, go ahead :)

from go-database-sql-tutorial.

arnehormann avatar arnehormann commented on June 3, 2024

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.

xaprb avatar xaprb commented on June 3, 2024

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.

arnehormann avatar arnehormann commented on June 3, 2024

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.

xaprb avatar xaprb commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.