~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/release_savepoint.cc

  • Committer: clint at fewbar
  • Date: 2009-07-21 17:42:23 UTC
  • mto: (1093.1.33 captain)
  • mto: This revision was merged to the branch mainline in revision 1105.
  • Revision ID: clint@fewbar.com-20090721174223-s4srxyar028f3kl7
style/documentation cleanups and replacing copyright notices

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#include "config.h"
22
 
#include <drizzled/show.h>
23
 
#include <drizzled/session.h>
24
 
#include <drizzled/statement/release_savepoint.h>
25
 
#include "drizzled/transaction_services.h"
26
 
#include "drizzled/named_savepoint.h"
27
 
 
28
 
#include <string>
29
 
 
30
 
using namespace std;
31
 
 
32
 
namespace drizzled
33
 
{
34
 
 
35
 
bool statement::ReleaseSavepoint::execute()
36
 
{
37
 
  /*
38
 
   * Look through the deque of savepoints.  If we
39
 
   * find one with the same name, we release it and
40
 
   * unbind it from our deque.
41
 
   */
42
 
  TransactionServices &transaction_services= TransactionServices::singleton();
43
 
  deque<NamedSavepoint> &savepoints= session->transaction.savepoints;
44
 
  deque<NamedSavepoint>::iterator iter;
45
 
 
46
 
  for (iter= savepoints.begin();
47
 
       iter != savepoints.end();
48
 
       ++iter)
49
 
  {
50
 
    NamedSavepoint &sv= *iter;
51
 
    const string &sv_name= sv.getName();
52
 
    if (my_strnncoll(system_charset_info,
53
 
                     (unsigned char *) session->lex->ident.str,
54
 
                     session->lex->ident.length,
55
 
                     (unsigned char *) sv_name.c_str(),
56
 
                     sv_name.size()) == 0)
57
 
      break;
58
 
  }
59
 
  if (iter != savepoints.end())
60
 
  {
61
 
    NamedSavepoint &sv= *iter;
62
 
    (void) transaction_services.ha_release_savepoint(session, sv);
63
 
    savepoints.erase(iter);
64
 
    session->my_ok();
65
 
  }
66
 
  else
67
 
  {
68
 
    my_error(ER_SP_DOES_NOT_EXIST, 
69
 
             MYF(0), 
70
 
             "SAVEPOINT", 
71
 
             session->lex->ident.str);
72
 
  }
73
 
  return false;
74
 
}
75
 
 
76
 
} /* namespace drizzled */