~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sys_var.cc

  • Committer: Stewart Smith
  • Date: 2010-12-29 02:06:26 UTC
  • mto: (2099.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2100.
  • Revision ID: stewart@flamingspork.com-20101229020626-r44r6wa51ycygcaa
SET AUTOCOMMIT=1 was not completely performing a COMMIT
  
at least some status variables (session->server_status) weren't being reset correctly, leaving the next statement to incorrectly get a inTransaction()==true

Also update documentation about SET AUTOCOMMIT behaviour (i.e. it commits active txn... which is relatively hinted at in the MySQL manual as the correct behaviour). Of course any mention of what happens when a commit fails is omitted. My guess is there are bugs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1395
1395
 
1396
1396
static bool set_option_autocommit(Session *session, set_var *var)
1397
1397
{
 
1398
  bool success= true;
1398
1399
  /* The test is negative as the flag we use is NOT autocommit */
1399
1400
 
1400
1401
  uint64_t org_options= session->options;
 
1402
  uint64_t new_options= session->options;
1401
1403
 
1402
1404
  if (var->save_result.uint32_t_value != 0)
1403
 
    session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
 
1405
    new_options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1404
1406
  else
1405
 
    session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
 
1407
    new_options|= ((sys_var_session_bit*) var->var)->bit_flag;
1406
1408
 
1407
 
  if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
 
1409
  if ((org_options ^ new_options) & OPTION_NOT_AUTOCOMMIT)
1408
1410
  {
1409
1411
    if ((org_options & OPTION_NOT_AUTOCOMMIT))
1410
1412
    {
 
1413
      success= session->endActiveTransaction();
1411
1414
      /* We changed to auto_commit mode */
1412
1415
      session->options&= ~(uint64_t) (OPTION_BEGIN);
1413
1416
      session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1414
 
      TransactionServices &transaction_services= TransactionServices::singleton();
1415
 
      if (transaction_services.commitTransaction(session, true))
1416
 
        return 1;
1417
1417
    }
1418
1418
    else
1419
1419
    {
1420
1420
      session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
1421
1421
    }
1422
1422
  }
 
1423
 
 
1424
  if (var->save_result.uint32_t_value != 0)
 
1425
    session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
 
1426
  else
 
1427
    session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
 
1428
 
 
1429
  if (not success)
 
1430
    return true;
 
1431
 
1423
1432
  return 0;
1424
1433
}
1425
1434