~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/savepoint.cc

  • Committer: Brian Aker
  • Date: 2010-10-28 17:12:01 UTC
  • mfrom: (1887.1.3 merge)
  • Revision ID: brian@tangent.org-20101028171201-baj6l1bnntn1s4ad
Merge in POTFILES changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
19
19
 */
20
20
 
21
21
#include "config.h"
22
 
#include "drizzled/show.h"
23
 
#include "drizzled/session.h"
24
 
#include "drizzled/statement/savepoint.h"
 
22
#include <drizzled/show.h>
 
23
#include <drizzled/session.h>
 
24
#include <drizzled/statement/savepoint.h>
25
25
#include "drizzled/transaction_services.h"
26
26
#include "drizzled/named_savepoint.h"
27
27
 
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
 
    /* AUTOCOMMIT is on and not in a BEGIN */
41
 
    getSession()->my_ok();
 
40
    session->my_ok();
42
41
  }
43
42
  else
44
43
  {
45
44
    /*
46
 
     * If AUTOCOMMIT is off and resource contexts are empty then we need
47
 
     * to start a transaction. It will be empty when SAVEPOINT starts the
48
 
     * transaction. Table affecting statements do this work in lockTables()
49
 
     * by calling startStatement().
50
 
     */
51
 
    if ( (getSession()->options & OPTION_NOT_AUTOCOMMIT) &&
52
 
         (getSession()->transaction.all.getResourceContexts().empty() == true) )
53
 
    {
54
 
      if (getSession()->startTransaction() == false)
55
 
      {
56
 
        return false;
57
 
      }
58
 
    }
59
 
 
60
 
    /*
61
45
     * Look through the savepoints.  If we find one with
62
46
     * the same name, delete it.
63
47
     */
64
48
    TransactionServices &transaction_services= TransactionServices::singleton();
65
 
    deque<NamedSavepoint> &savepoints= getSession()->transaction.savepoints;
 
49
    deque<NamedSavepoint> &savepoints= session->transaction.savepoints;
66
50
    deque<NamedSavepoint>::iterator iter;
67
51
 
68
52
    for (iter= savepoints.begin();
72
56
      NamedSavepoint &sv= *iter;
73
57
      const string &sv_name= sv.getName();
74
58
      if (my_strnncoll(system_charset_info,
75
 
                       (unsigned char *) getSession()->lex->ident.str,
76
 
                       getSession()->lex->ident.length,
 
59
                       (unsigned char *) session->lex->ident.str,
 
60
                       session->lex->ident.length,
77
61
                       (unsigned char *) sv_name.c_str(),
78
62
                       sv_name.size()) == 0)
79
63
        break;
81
65
    if (iter != savepoints.end())
82
66
    {
83
67
      NamedSavepoint &sv= *iter;
84
 
      (void) transaction_services.releaseSavepoint(*getSession(), sv);
 
68
      (void) transaction_services.releaseSavepoint(session, sv);
85
69
      savepoints.erase(iter);
86
70
    }
87
71
    
88
 
    NamedSavepoint newsv(getSession()->lex->ident.str, getSession()->lex->ident.length);
 
72
    NamedSavepoint newsv(session->lex->ident.str, session->lex->ident.length);
89
73
 
90
 
    if (transaction_services.setSavepoint(*getSession(), newsv))
 
74
    if (transaction_services.setSavepoint(session, newsv))
91
75
    {
92
76
      return true;
93
77
    }
94
78
    else
95
79
    {
96
80
      savepoints.push_front(newsv);
97
 
      getSession()->my_ok();
 
81
      session->my_ok();
98
82
    }
99
83
  }
100
84
  return false;