Drizzled Public API Documentation

cursor_states.cc
1 /*
2  Copyright (C) 2010 Stewart Smith
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License
6  as published by the Free Software Foundation; either version 2
7  of the License, or (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #include <config.h>
20 #include <string>
21 #include <map>
22 #include <boost/unordered_map.hpp>
23 
24 using namespace std;
25 
26 typedef multimap<string, string> state_multimap;
27 typedef multimap<string, string>::value_type state_pair;
28 typedef multimap<string, string>::iterator state_multimap_iter;
29 void load_cursor_state_transitions(state_multimap &states);
30 
31 void load_cursor_state_transitions(state_multimap &states)
32 {
33  states.insert(state_pair("Cursor()", "Cursor()")); // dummy for constructor
34  states.insert(state_pair("Cursor()", "~Cursor()"));
35  states.insert(state_pair("Cursor()", "::doOpen()"));
36  states.insert(state_pair("::doOpen()", "::store_lock()"));
37 
38  // only in alter table
39  states.insert(state_pair("::doOpen()", "::external_lock()"));
40 
41  states.insert(state_pair("::doOpen()", "::close()"));
42  states.insert(state_pair("::close()", "Cursor()"));
43 
44  states.insert(state_pair("::reset()", "::doOpen()"));
45  states.insert(state_pair("::doEndTableScan()", "::reset()"));
46  states.insert(state_pair("locked", "::reset()"));
47  states.insert(state_pair("locked", "::scan_time()"));
48  states.insert(state_pair("::scan_time()", "locked"));
49  states.insert(state_pair("::scan_time()", "::scan_time()"));
50 
51 
52  // we can always set a new lock
53  states.insert(state_pair("::store_lock()", "::store_lock()"));
54  states.insert(state_pair("locked", "::store_lock()"));
55 
56  states.insert(state_pair("::store_lock()", "::external_lock()"));
57  states.insert(state_pair("::external_lock()", "locked"));
58  states.insert(state_pair("locked", "::external_lock()"));
59 
60  states.insert(state_pair("locked", "::info()"));
61  states.insert(state_pair("::info()", "locked"));
62 
63  states.insert(state_pair("locked", "::close()"));
64  states.insert(state_pair("locked", "::doStartTableScan()"));
65  states.insert(state_pair("::doStartTableScan()", "::rnd_next()"));
66  states.insert(state_pair("::doStartTableScan()", "::rnd_pos()"));
67 
68  states.insert(state_pair("::rnd_pos()", "::rnd_pos()"));
69  states.insert(state_pair("::rnd_pos()", "::doUpdateRecord()"));
70 
71  states.insert(state_pair("::rnd_pos()", "::doEndTableScan()"));
72  states.insert(state_pair("locked", "::doEndTableScan()"));
73 
74  states.insert(state_pair("::rnd_next()", "::doEndTableScan()"));
75  states.insert(state_pair("::rnd_next()", "::rnd_next()"));
76 
77  states.insert(state_pair("::doEndTableScan()", "::close()"));
78  states.insert(state_pair("::doEndTableScan()", "::doStartTableScan()"));
79 
80  // below two are bugs - sholud call endtablescan
81  states.insert(state_pair("::rnd_next()", "::store_lock()"));
82  states.insert(state_pair("::rnd_next()", "::close()"));
83 
84  states.insert(state_pair("::rnd_next()", "::position()"));
85  states.insert(state_pair("::position()", "::rnd_next()"));
86  states.insert(state_pair("::rnd_next()", "::doUpdateRecord()"));
87 
88  states.insert(state_pair("::doEndTableScan()", "Cursor()"));
89  states.insert(state_pair("::doEndTableScan()", "::store_lock()"));
90  states.insert(state_pair("locked", "::doInsertRecord()"));
91  states.insert(state_pair("::doInsertRecord()", "::external_lock()"));
92  states.insert(state_pair("::doInsertRecord()", "::doInsertRecord()"));
93  states.insert(state_pair("::doInsertRecord()", "::reset()"));
94 
95  states.insert(state_pair("::doUpdateRecord()", "::doEndTableScan()"));
96  states.insert(state_pair("::doUpdateRecord()", "::rnd_next()"));
97 
98  states.insert(state_pair("locked", "::doStartIndexScan()"));
99  states.insert(state_pair("::doStartIndexScan()", "::doEndIndexScan()"));
100  states.insert(state_pair("::doEndIndexScan()", "locked"));
101 
102  states.insert(state_pair("::doStartIndexScan()", "::index_first()"));
103  states.insert(state_pair("::doStartIndexScan()", "::index_last()"));
104  states.insert(state_pair("::doStartIndexScan()", "::index_next()"));
105  states.insert(state_pair("::doStartIndexScan()", "::index_prev()"));
106  states.insert(state_pair("::index_first()", "::doStartIndexScan()"));
107  states.insert(state_pair("::index_last()", "::doStartIndexScan()"));
108  states.insert(state_pair("::index_next()", "::doStartIndexScan()"));
109  states.insert(state_pair("::index_prev()", "::doStartIndexScan()"));
110  states.insert(state_pair("::doStartIndexScan()", "::doStartIndexScan() ERROR"));
111  states.insert(state_pair("::doStartIndexScan() ERROR", "locked"));
112 
113  states.insert(state_pair("::doStartIndexScan()", "::index_read()"));
114  states.insert(state_pair("::doStartIndexScan()", "::index_read_idx_map()"));
115  states.insert(state_pair("::index_read()", "::doStartIndexScan()"));
116  states.insert(state_pair("::index_read_idx_map()", "::doStartIndexScan()"));
117 
118 }