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()", "::doOpen()"));
00034   states.insert(state_pair("::doOpen()", "::store_lock()"));
00035 
00036   // only in alter table
00037   states.insert(state_pair("::doOpen()", "::external_lock()"));
00038 
00039   states.insert(state_pair("::doOpen()", "::close()"));
00040   states.insert(state_pair("::close()", "Cursor()"));
00041 
00042   states.insert(state_pair("::reset()", "::doOpen()"));
00043   states.insert(state_pair("::doEndTableScan()", "::reset()"));
00044   states.insert(state_pair("locked", "::reset()"));
00045   states.insert(state_pair("locked", "::scan_time()"));
00046   states.insert(state_pair("::scan_time()", "locked"));
00047   states.insert(state_pair("::scan_time()", "::scan_time()"));
00048 
00049 
00050   // we can always set a new lock
00051   states.insert(state_pair("::store_lock()", "::store_lock()"));
00052   states.insert(state_pair("locked", "::store_lock()"));
00053 
00054   states.insert(state_pair("::store_lock()", "::external_lock()"));
00055   states.insert(state_pair("::external_lock()", "locked"));
00056   states.insert(state_pair("locked", "::external_lock()"));
00057 
00058   states.insert(state_pair("locked", "::info()"));
00059   states.insert(state_pair("::info()", "locked"));
00060 
00061   states.insert(state_pair("locked", "::close()"));
00062   states.insert(state_pair("locked", "::doStartTableScan()"));
00063   states.insert(state_pair("::doStartTableScan()", "::rnd_next()"));
00064   states.insert(state_pair("::doStartTableScan()", "::rnd_pos()"));
00065 
00066   states.insert(state_pair("::rnd_pos()", "::rnd_pos()"));
00067   states.insert(state_pair("::rnd_pos()", "::doUpdateRecord()"));
00068 
00069   states.insert(state_pair("::rnd_pos()", "::doEndTableScan()"));
00070   states.insert(state_pair("locked", "::doEndTableScan()"));
00071 
00072   states.insert(state_pair("::rnd_next()", "::doEndTableScan()"));
00073   states.insert(state_pair("::rnd_next()", "::rnd_next()"));
00074 
00075   states.insert(state_pair("::doEndTableScan()", "::close()"));
00076   states.insert(state_pair("::doEndTableScan()", "::doStartTableScan()"));
00077 
00078   // below two are bugs - sholud call endtablescan
00079   states.insert(state_pair("::rnd_next()", "::store_lock()"));
00080   states.insert(state_pair("::rnd_next()", "::close()"));
00081 
00082   states.insert(state_pair("::rnd_next()", "::position()"));
00083   states.insert(state_pair("::position()", "::rnd_next()"));
00084   states.insert(state_pair("::rnd_next()", "::doUpdateRecord()"));
00085 
00086   states.insert(state_pair("::doEndTableScan()", "Cursor()"));
00087   states.insert(state_pair("::doEndTableScan()", "::store_lock()"));
00088   states.insert(state_pair("locked", "::doInsertRecord()"));
00089   states.insert(state_pair("::doInsertRecord()", "::external_lock()"));
00090   states.insert(state_pair("::doInsertRecord()", "::doInsertRecord()"));
00091   states.insert(state_pair("::doInsertRecord()", "::reset()"));
00092 
00093   states.insert(state_pair("::doUpdateRecord()", "::doEndTableScan()"));
00094   states.insert(state_pair("::doUpdateRecord()", "::rnd_next()"));
00095 
00096   states.insert(state_pair("locked", "::doStartIndexScan()"));
00097   states.insert(state_pair("::doStartIndexScan()", "::doEndIndexScan()"));
00098   states.insert(state_pair("::doEndIndexScan()", "locked"));
00099 
00100   states.insert(state_pair("::doStartIndexScan()", "::index_first()"));
00101   states.insert(state_pair("::doStartIndexScan()", "::index_last()"));
00102   states.insert(state_pair("::doStartIndexScan()", "::index_next()"));
00103   states.insert(state_pair("::doStartIndexScan()", "::index_prev()"));
00104   states.insert(state_pair("::index_first()", "::doStartIndexScan()"));
00105   states.insert(state_pair("::index_last()", "::doStartIndexScan()"));
00106   states.insert(state_pair("::index_next()", "::doStartIndexScan()"));
00107   states.insert(state_pair("::index_prev()", "::doStartIndexScan()"));
00108   states.insert(state_pair("::doStartIndexScan()", "::doStartIndexScan() ERROR"));
00109   states.insert(state_pair("::doStartIndexScan() ERROR", "locked"));
00110 
00111   states.insert(state_pair("::doStartIndexScan()", "::index_read()"));
00112   states.insert(state_pair("::doStartIndexScan()", "::index_read_idx_map()"));
00113   states.insert(state_pair("::index_read()", "::doStartIndexScan()"));
00114   states.insert(state_pair("::index_read_idx_map()", "::doStartIndexScan()"));
00115 
00116 }