Drizzled Public API Documentation

release_savepoint.cc
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2009 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #include <config.h>
00022 #include <drizzled/show.h>
00023 #include <drizzled/session.h>
00024 #include <drizzled/statement/release_savepoint.h>
00025 #include <drizzled/transaction_services.h>
00026 #include <drizzled/named_savepoint.h>
00027 #include <drizzled/sql_lex.h>
00028 #include <drizzled/session/transactions.h>
00029 #include <string>
00030 
00031 using namespace std;
00032 
00033 namespace drizzled {
00034 
00035 bool statement::ReleaseSavepoint::execute()
00036 {
00037   /*
00038    * Look through the deque of savepoints.  If we
00039    * find one with the same name, we release it and
00040    * unbind it from our deque.
00041    */
00042   deque<NamedSavepoint> &savepoints= transaction().savepoints;
00043   deque<NamedSavepoint>::iterator iter;
00044 
00045   for (iter= savepoints.begin(); iter != savepoints.end(); ++iter)
00046   {
00047     NamedSavepoint &sv= *iter;
00048     const string &sv_name= sv.getName();
00049     if (my_strnncoll(system_charset_info, (unsigned char *) lex().ident.data(), 
00050       lex().ident.size(), (unsigned char *) sv_name.c_str(), sv_name.size()) == 0)
00051       break;
00052   }
00053   if (iter != savepoints.end())
00054   {
00055     NamedSavepoint &sv= *iter;
00056     (void) TransactionServices::releaseSavepoint(session(), sv);
00057     savepoints.erase(iter);
00058     session().my_ok();
00059   }
00060   else
00061   {
00062     my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "SAVEPOINT", lex().ident.data());
00063   }
00064   return false;
00065 }
00066 
00067 } /* namespace drizzled */