~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/savepoint.cc

edit

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/savepoint.h>
25
 
#include <drizzled/transaction_services.h>
26
 
#include <drizzled/named_savepoint.h>
 
21
#include "config.h"
 
22
#include "drizzled/show.h"
 
23
#include "drizzled/session.h"
 
24
#include "drizzled/statement/savepoint.h"
 
25
#include "drizzled/transaction_services.h"
 
26
#include "drizzled/named_savepoint.h"
27
27
 
28
28
#include <string>
29
29
#include <deque>
35
35
 
36
36
bool statement::Savepoint::execute()
37
37
{
38
 
  if (! (getSession()->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
 
38
  if (! (session->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
39
39
  {
40
40
    /* AUTOCOMMIT is on and not in a BEGIN */
41
 
    getSession()->my_ok();
 
41
    session->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 ( (getSession()->options & OPTION_NOT_AUTOCOMMIT) &&
52
 
         (getSession()->transaction.all.getResourceContexts().empty() == true) )
 
51
    if ( (session->options & OPTION_NOT_AUTOCOMMIT) &&
 
52
         (session->transaction.all.getResourceContexts().empty() == true) )
53
53
    {
54
 
      if (getSession()->startTransaction() == false)
 
54
      if (session->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= getSession()->transaction.savepoints;
 
65
    deque<NamedSavepoint> &savepoints= session->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 *) getSession()->getLex()->ident.str,
76
 
                       getSession()->getLex()->ident.length,
 
75
                       (unsigned char *) session->lex->ident.str,
 
76
                       session->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(*getSession(), sv);
 
84
      (void) transaction_services.releaseSavepoint(session, sv);
85
85
      savepoints.erase(iter);
86
86
    }
87
87
    
88
 
    NamedSavepoint newsv(getSession()->getLex()->ident.str, getSession()->getLex()->ident.length);
 
88
    NamedSavepoint newsv(session->lex->ident.str, session->lex->ident.length);
89
89
 
90
 
    if (transaction_services.setSavepoint(*getSession(), newsv))
 
90
    if (transaction_services.setSavepoint(session, newsv))
91
91
    {
92
92
      return true;
93
93
    }
94
94
    else
95
95
    {
96
96
      savepoints.push_front(newsv);
97
 
      getSession()->my_ok();
 
97
      session->my_ok();
98
98
    }
99
99
  }
100
100
  return false;