~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/savepoint.cc

  • Committer: Brian Aker
  • Date: 2011-01-22 18:52:16 UTC
  • mfrom: (2098.4.1 catalogs)
  • Revision ID: brian@tangent.org-20110122185216-18and6vncipd7x72
Session encapsulation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
bool statement::Savepoint::execute()
37
37
{
38
 
  if (! (session->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
 
38
  if (! (getSession()->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
39
39
  {
40
40
    /* AUTOCOMMIT is on and not in a BEGIN */
41
 
    session->my_ok();
 
41
    getSession()->my_ok();
42
42
  }
43
43
  else
44
44
  {
48
48
     * transaction. Table affecting statements do this work in lockTables()
49
49
     * by calling startStatement().
50
50
     */
51
 
    if ( (session->options & OPTION_NOT_AUTOCOMMIT) &&
52
 
         (session->transaction.all.getResourceContexts().empty() == true) )
 
51
    if ( (getSession()->options & OPTION_NOT_AUTOCOMMIT) &&
 
52
         (getSession()->transaction.all.getResourceContexts().empty() == true) )
53
53
    {
54
 
      if (session->startTransaction() == false)
 
54
      if (getSession()->startTransaction() == false)
55
55
      {
56
56
        return false;
57
57
      }
62
62
     * the same name, delete it.
63
63
     */
64
64
    TransactionServices &transaction_services= TransactionServices::singleton();
65
 
    deque<NamedSavepoint> &savepoints= session->transaction.savepoints;
 
65
    deque<NamedSavepoint> &savepoints= getSession()->transaction.savepoints;
66
66
    deque<NamedSavepoint>::iterator iter;
67
67
 
68
68
    for (iter= savepoints.begin();
72
72
      NamedSavepoint &sv= *iter;
73
73
      const string &sv_name= sv.getName();
74
74
      if (my_strnncoll(system_charset_info,
75
 
                       (unsigned char *) session->lex->ident.str,
76
 
                       session->lex->ident.length,
 
75
                       (unsigned char *) getSession()->lex->ident.str,
 
76
                       getSession()->lex->ident.length,
77
77
                       (unsigned char *) sv_name.c_str(),
78
78
                       sv_name.size()) == 0)
79
79
        break;
81
81
    if (iter != savepoints.end())
82
82
    {
83
83
      NamedSavepoint &sv= *iter;
84
 
      (void) transaction_services.releaseSavepoint(session, sv);
 
84
      (void) transaction_services.releaseSavepoint(getSession(), sv);
85
85
      savepoints.erase(iter);
86
86
    }
87
87
    
88
 
    NamedSavepoint newsv(session->lex->ident.str, session->lex->ident.length);
 
88
    NamedSavepoint newsv(getSession()->lex->ident.str, getSession()->lex->ident.length);
89
89
 
90
 
    if (transaction_services.setSavepoint(session, newsv))
 
90
    if (transaction_services.setSavepoint(getSession(), newsv))
91
91
    {
92
92
      return true;
93
93
    }
94
94
    else
95
95
    {
96
96
      savepoints.push_front(newsv);
97
 
      session->my_ok();
 
97
      getSession()->my_ok();
98
98
    }
99
99
  }
100
100
  return false;