List:MySQL++« Previous MessageNext Message »
From:Tony Whyman Date:April 3 2014 9:26am
Subject:Start Transaction fails with error in your SQL syntax near READSERIALIZABLE
View as plain text  
I have been using MySQL++ for several years but only just decided to
take advantage of the new capability to use transactions with other than
default isolation modes. I requested repeatable read and immediately the
program failed with a MySQL syntax error not liking a command containing
"READSERIALIZABLE". Odd.

Checking through mysql++ transaction.cpp reveals the following code:

Transaction::Transaction(Connection& conn, IsolationLevel level,
        IsolationScope scope, bool consistent) :
conn_(conn),
finished_(true)        // don't bother rolling it back if ctor fails
{
    // Set the transaction isolation level and scope as the user wishes
    Query q(conn_.query("SET "));
    if (scope == session) q << "SESSION ";
    if (scope == global)  q << "GLOBAL ";
    q << "TRANSACTION ISOLATION LEVEL ";
    switch (level) {
        case read_uncommitted:    q << "READ UNCOMMITTED";
        case read_committed:    q << "READ COMMITTED";
        case repeatable_read:    q << "REPEATABLE READ";
        case serializable:        q << "SERIALIZABLE";
    }
...

I stared at it for some  time before the obvious came to mind - there
are no "break;" statements between the "cases". Thus when I asked for
repeatable read, the SQL actually contained "REPEATABLE READSERIALIZABLE"!

I guess not many others have tried to use this code.

Tony Whyman
MWA

Thread
Start Transaction fails with error in your SQL syntax near READSERIALIZABLETony Whyman3 Apr 2014
  • Re: Start Transaction fails with error in your SQL syntax near READSERIALIZABLEWarren Young3 Apr 2014