Drizzled Public API Documentation

cursor_states.cc
00001 /*
00002   Copyright (C) 2010 Stewart Smith
00003 
00004   This program is free software; you can redistribute it and/or
00005   modify it under the terms of the GNU General Public License
00006   as published by the Free Software Foundation; either version 2
00007   of the License, or (at your option) any later version.
00008 
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 */
00018 
00019 #include <config.h>
00020 #include <string>
00021 #include <map>
00022 #include <boost/unordered_map.hpp>
00023 
00024 using namespace std;
00025 
00026 typedef multimap<string, string> state_multimap;
00027 typedef multimap<string, string>::value_type state_pair;
00028 typedef multimap<string, string>::iterator state_multimap_iter;
00029 void load_cursor_state_transitions(state_multimap &states);
00030 
00031 void load_cursor_state_transitions(state_multimap &states)
00032 {
00033   states.insert(state_pair("Cursor()", "Cursor()")); // dummy for constructor
00034   states.insert(state_pair("Cursor()", "~Cursor()"));
00035   states.insert(state_pair("Cursor()", "::doOpen()"));
00036   states.insert(state_pair("::doOpen()", "::store_lock()"));
00037 
00038   // only in alter table
00039   states.insert(state_pair("::doOpen()", "::external_lock()"));
00040 
00041   states.insert(state_pair("::doOpen()", "::close()"));
00042   states.insert(state_pair("::close()", "Cursor()"));
00043 
00044   states.insert(state_pair("::reset()", "::doOpen()"));
00045   states.insert(state_pair("::doEndTableScan()", "::reset()"));
00046   states.insert(state_pair("locked", "::reset()"));
00047   states.insert(state_pair("locked", "::scan_time()"));
00048   states.insert(state_pair("::scan_time()", "locked"));
00049   states.insert(state_pair("::scan_time()", "::scan_time()"));
00050 
00051 
00052   // we can always set a new lock
00053   states.insert(state_pair("::store_lock()", "::store_lock()"));
00054   states.insert(state_pair("locked", "::store_lock()"));
00055 
00056   states.insert(state_pair("::store_lock()", "::external_lock()"));
00057   states.insert(state_pair("::external_lock()", "locked"));
00058   states.insert(state_pair("locked", "::external_lock()"));
00059 
00060   states.insert(state_pair("locked", "::info()"));
00061   states.insert(state_pair("::info()", "locked"));
00062 
00063   states.insert(state_pair("locked", "::close()"));
00064   states.insert(state_pair("locked", "::doStartTableScan()"));
00065   states.insert(state_pair("::doStartTableScan()", "::rnd_next()"));
00066   states.insert(state_pair("::doStartTableScan()", "::rnd_pos()"));
00067 
00068   states.insert(state_pair("::rnd_pos()", "::rnd_pos()"));
00069   states.insert(state_pair("::rnd_pos()", "::doUpdateRecord()"));
00070 
00071   states.insert(state_pair("::rnd_pos()", "::doEndTableScan()"));
00072   states.insert(state_pair("locked", "::doEndTableScan()"));
00073 
00074   states.insert(state_pair("::rnd_next()", "::doEndTableScan()"));
00075   states.insert(state_pair("::rnd_next()", "::rnd_next()"));
00076 
00077   states.insert(state_pair("::doEndTableScan()", "::close()"));
00078   states.insert(state_pair("::doEndTableScan()", "::doStartTableScan()"));
00079 
00080   // below two are bugs - sholud call endtablescan
00081   states.insert(state_pair("::rnd_next()", "::store_lock()"));
00082   states.insert(state_pair("::rnd_next()", "::close()"));
00083 
00084   states.insert(state_pair("::rnd_next()", "::position()"));
00085   states.insert(state_pair("::position()", "::rnd_next()"));
00086   states.insert(state_pair("::rnd_next()", "::doUpdateRecord()"));
00087 
00088   states.insert(state_pair("::doEndTableScan()", "Cursor()"));
00089   states.insert(state_pair("::doEndTableScan()", "::store_lock()"));
00090   states.insert(state_pair("locked", "::doInsertRecord()"));
00091   states.insert(state_pair("::doInsertRecord()", "::external_lock()"));
00092   states.insert(state_pair("::doInsertRecord()", "::doInsertRecord()"));
00093   states.insert(state_pair("::doInsertRecord()", "::reset()"));
00094 
00095   states.insert(state_pair("::doUpdateRecord()", "::doEndTableScan()"));
00096   states.insert(state_pair("::doUpdateRecord()", "::rnd_next()"));
00097 
00098   states.insert(state_pair("locked", "::doStartIndexScan()"));
00099   states.insert(state_pair("::doStartIndexScan()", "::doEndIndexScan()"));
00100   states.insert(state_pair("::doEndIndexScan()", "locked"));
00101 
00102   states.insert(state_pair("::doStartIndexScan()", "::index_first()"));
00103   states.insert(state_pair("::doStartIndexScan()", "::index_last()"));
00104   states.insert(state_pair("::doStartIndexScan()", "::index_next()"));
00105   states.insert(state_pair("::doStartIndexScan()", "::index_prev()"));
00106   states.insert(state_pair("::index_first()", "::doStartIndexScan()"));
00107   states.insert(state_pair("::index_last()", "::doStartIndexScan()"));
00108   states.insert(state_pair("::index_next()", "::doStartIndexScan()"));
00109   states.insert(state_pair("::index_prev()", "::doStartIndexScan()"));
00110   states.insert(state_pair("::doStartIndexScan()", "::doStartIndexScan() ERROR"));
00111   states.insert(state_pair("::doStartIndexScan() ERROR", "locked"));
00112 
00113   states.insert(state_pair("::doStartIndexScan()", "::index_read()"));
00114   states.insert(state_pair("::doStartIndexScan()", "::index_read_idx_map()"));
00115   states.insert(state_pair("::index_read()", "::doStartIndexScan()"));
00116   states.insert(state_pair("::index_read_idx_map()", "::doStartIndexScan()"));
00117 
00118 }