~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/rollback_to_savepoint.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
RemoveĀ unusedĀ Name_resolution_context::error_reporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
22
 
#include "drizzled/show.h"
23
 
#include "drizzled/session.h"
24
 
#include "drizzled/statement/rollback_to_savepoint.h"
25
 
#include "drizzled/transaction_services.h"
26
 
#include "drizzled/named_savepoint.h"
27
 
#include "drizzled/util/functors.h"
 
21
#include <config.h>
 
22
#include <drizzled/show.h>
 
23
#include <drizzled/session.h>
 
24
#include <drizzled/statement/rollback_to_savepoint.h>
 
25
#include <drizzled/transaction_services.h>
 
26
#include <drizzled/named_savepoint.h>
 
27
#include <drizzled/util/functors.h>
 
28
#include <drizzled/session/transactions.h>
28
29
 
29
30
#include <string>
30
31
 
31
32
using namespace std;
32
33
 
33
 
namespace drizzled
34
 
{
 
34
namespace drizzled {
35
35
 
36
36
bool statement::RollbackToSavepoint::execute()
37
37
{
41
41
   * starts the transaction. Table affecting statements do this work in
42
42
   * lockTables() by calling startStatement().
43
43
   */
44
 
  if ( (getSession()->options & OPTION_NOT_AUTOCOMMIT) &&
45
 
       (getSession()->transaction.all.getResourceContexts().empty() == true) )
 
44
  if ( (session().options & OPTION_NOT_AUTOCOMMIT) &&
 
45
       (transaction().all.getResourceContexts().empty() == true) )
46
46
  {
47
 
    if (getSession()->startTransaction() == false)
 
47
    if (session().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= getSession()->transaction.savepoints;
68
 
  TransactionServices &transaction_services= TransactionServices::singleton();
 
67
  deque<NamedSavepoint> &savepoints= transaction().savepoints;
69
68
 
70
69
  /* Short-circuit for no savepoints */
71
70
  if (savepoints.empty())
73
72
    my_error(ER_SP_DOES_NOT_EXIST, 
74
73
             MYF(0), 
75
74
             "SAVEPOINT", 
76
 
             getSession()->lex->ident.str);
 
75
             lex().ident.str);
77
76
    return false;
78
77
  }
79
78
 
82
81
    NamedSavepoint &first_savepoint= savepoints.front();
83
82
    const string &first_savepoint_name= first_savepoint.getName();
84
83
    if (my_strnncoll(system_charset_info,
85
 
                     (unsigned char *) getSession()->lex->ident.str, 
86
 
                     getSession()->lex->ident.length,
 
84
                     (unsigned char *) lex().ident.str, 
 
85
                     lex().ident.length,
87
86
                     (unsigned char *) first_savepoint_name.c_str(), 
88
87
                     first_savepoint_name.size()) == 0)
89
88
    {
90
89
      /* Found the named savepoint we want to rollback to */
91
 
      (void) transaction_services.rollbackToSavepoint(*getSession(), first_savepoint);
 
90
      (void) TransactionServices::rollbackToSavepoint(session(), first_savepoint);
92
91
 
93
 
      if (getSession()->transaction.all.hasModifiedNonTransData())
 
92
      if (transaction().all.hasModifiedNonTransData())
94
93
      {
95
 
        push_warning(getSession(), 
 
94
        push_warning(&session(), 
96
95
                     DRIZZLE_ERROR::WARN_LEVEL_WARN,
97
96
                     ER_WARNING_NOT_COMPLETE_ROLLBACK,
98
97
                     ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
99
98
      }
100
 
      getSession()->my_ok();
 
99
      session().my_ok();
101
100
      return false;
102
101
    }
103
102
  }
118
117
    const string &sv_name= sv.getName();
119
118
    if (! found && 
120
119
        my_strnncoll(system_charset_info,
121
 
                     (unsigned char *) getSession()->lex->ident.str, 
122
 
                     getSession()->lex->ident.length,
 
120
                     (unsigned char *) lex().ident.str, 
 
121
                     lex().ident.length,
123
122
                     (unsigned char *) sv_name.c_str(), 
124
123
                     sv_name.size()) == 0)
125
124
    {
126
125
      /* Found the named savepoint we want to rollback to */
127
126
      found= true;
128
127
 
129
 
      (void) transaction_services.rollbackToSavepoint(*getSession(), sv);
 
128
      (void) TransactionServices::rollbackToSavepoint(session(), sv);
130
129
    }
131
130
    if (found)
132
131
    {
141
140
  }
142
141
  if (found)
143
142
  {
144
 
    if (getSession()->transaction.all.hasModifiedNonTransData())
 
143
    if (transaction().all.hasModifiedNonTransData())
145
144
    {
146
 
      push_warning(getSession(), 
 
145
      push_warning(&session(), 
147
146
                   DRIZZLE_ERROR::WARN_LEVEL_WARN,
148
147
                   ER_WARNING_NOT_COMPLETE_ROLLBACK,
149
148
                   ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
150
149
    }
151
150
    /* Store new savepoints list */
152
 
    getSession()->transaction.savepoints= new_savepoints;
153
 
    getSession()->my_ok();
 
151
    transaction().savepoints= new_savepoints;
 
152
    session().my_ok();
154
153
  }
155
154
  else
156
155
  {
157
156
    /* restore the original savepoint list */
158
 
    getSession()->transaction.savepoints= copy_savepoints;
 
157
    transaction().savepoints= copy_savepoints;
159
158
    my_error(ER_SP_DOES_NOT_EXIST, 
160
159
             MYF(0), 
161
160
             "SAVEPOINT", 
162
 
             getSession()->lex->ident.str);
 
161
             lex().ident.str);
163
162
  }
164
163
  return false;
165
164
}