~drizzle-developers/drizzle/elliott-release

« back to all changes in this revision

Viewing changes to drizzled/statement/rollback_to_savepoint.cc

  • Committer: Patrick Crews
  • Date: 2011-02-01 20:33:06 UTC
  • mfrom: (1845.2.288 drizzle)
  • Revision ID: gleebix@gmail.com-20110201203306-mwq2rk0it81tlwxh
Merged Trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
   * starts the transaction. Table affecting statements do this work in
42
42
   * lockTables() by calling startStatement().
43
43
   */
44
 
  if ( (session->options & OPTION_NOT_AUTOCOMMIT) &&
45
 
       (session->transaction.all.getResourceContexts().empty() == true) )
 
44
  if ( (getSession()->options & OPTION_NOT_AUTOCOMMIT) &&
 
45
       (getSession()->transaction.all.getResourceContexts().empty() == true) )
46
46
  {
47
 
    if (session->startTransaction() == false)
 
47
    if (getSession()->startTransaction() == false)
48
48
    {
49
49
      return false;
50
50
    }
64
64
   * find it, we must restructure the deque by removing
65
65
   * all savepoints "above" the one we find.
66
66
   */
67
 
  deque<NamedSavepoint> &savepoints= session->transaction.savepoints;
 
67
  deque<NamedSavepoint> &savepoints= getSession()->transaction.savepoints;
68
68
  TransactionServices &transaction_services= TransactionServices::singleton();
69
69
 
70
70
  /* Short-circuit for no savepoints */
73
73
    my_error(ER_SP_DOES_NOT_EXIST, 
74
74
             MYF(0), 
75
75
             "SAVEPOINT", 
76
 
             session->lex->ident.str);
 
76
             getSession()->lex->ident.str);
77
77
    return false;
78
78
  }
79
79
 
82
82
    NamedSavepoint &first_savepoint= savepoints.front();
83
83
    const string &first_savepoint_name= first_savepoint.getName();
84
84
    if (my_strnncoll(system_charset_info,
85
 
                     (unsigned char *) session->lex->ident.str, 
86
 
                     session->lex->ident.length,
 
85
                     (unsigned char *) getSession()->lex->ident.str, 
 
86
                     getSession()->lex->ident.length,
87
87
                     (unsigned char *) first_savepoint_name.c_str(), 
88
88
                     first_savepoint_name.size()) == 0)
89
89
    {
90
90
      /* Found the named savepoint we want to rollback to */
91
 
      (void) transaction_services.rollbackToSavepoint(session, first_savepoint);
 
91
      (void) transaction_services.rollbackToSavepoint(*getSession(), first_savepoint);
92
92
 
93
 
      if (session->transaction.all.hasModifiedNonTransData())
 
93
      if (getSession()->transaction.all.hasModifiedNonTransData())
94
94
      {
95
 
        push_warning(session, 
 
95
        push_warning(getSession(), 
96
96
                     DRIZZLE_ERROR::WARN_LEVEL_WARN,
97
97
                     ER_WARNING_NOT_COMPLETE_ROLLBACK,
98
98
                     ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
99
99
      }
100
 
      session->my_ok();
 
100
      getSession()->my_ok();
101
101
      return false;
102
102
    }
103
103
  }
118
118
    const string &sv_name= sv.getName();
119
119
    if (! found && 
120
120
        my_strnncoll(system_charset_info,
121
 
                     (unsigned char *) session->lex->ident.str, 
122
 
                     session->lex->ident.length,
 
121
                     (unsigned char *) getSession()->lex->ident.str, 
 
122
                     getSession()->lex->ident.length,
123
123
                     (unsigned char *) sv_name.c_str(), 
124
124
                     sv_name.size()) == 0)
125
125
    {
126
126
      /* Found the named savepoint we want to rollback to */
127
127
      found= true;
128
128
 
129
 
      (void) transaction_services.rollbackToSavepoint(session, sv);
 
129
      (void) transaction_services.rollbackToSavepoint(*getSession(), sv);
130
130
    }
131
131
    if (found)
132
132
    {
141
141
  }
142
142
  if (found)
143
143
  {
144
 
    if (session->transaction.all.hasModifiedNonTransData())
 
144
    if (getSession()->transaction.all.hasModifiedNonTransData())
145
145
    {
146
 
      push_warning(session, 
 
146
      push_warning(getSession(), 
147
147
                   DRIZZLE_ERROR::WARN_LEVEL_WARN,
148
148
                   ER_WARNING_NOT_COMPLETE_ROLLBACK,
149
149
                   ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
150
150
    }
151
151
    /* Store new savepoints list */
152
 
    session->transaction.savepoints= new_savepoints;
153
 
    session->my_ok();
 
152
    getSession()->transaction.savepoints= new_savepoints;
 
153
    getSession()->my_ok();
154
154
  }
155
155
  else
156
156
  {
157
157
    /* restore the original savepoint list */
158
 
    session->transaction.savepoints= copy_savepoints;
 
158
    getSession()->transaction.savepoints= copy_savepoints;
159
159
    my_error(ER_SP_DOES_NOT_EXIST, 
160
160
             MYF(0), 
161
161
             "SAVEPOINT", 
162
 
             session->lex->ident.str);
 
162
             getSession()->lex->ident.str);
163
163
  }
164
164
  return false;
165
165
}