1 /* Copyright (c) 2003-2007 MySQL AB
2    Use is subject to license terms
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; version 2 of the License.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */
16 
17 
18 
19 #define DBACC_C
20 #include "Dbacc.hpp"
21 
22 #define DEBUG(x) { ndbout << "ACC::" << x << endl; }
23 
initData()24 void Dbacc::initData()
25 {
26   cdirarraysize = ZDIRARRAY;
27   coprecsize = ZOPRECSIZE;
28   cpagesize = ZPAGESIZE;
29   ctablesize = ZTABLESIZE;
30   cfragmentsize = ZFRAGMENTSIZE;
31   cdirrangesize = ZDIRRANGESIZE;
32   coverflowrecsize = ZOVERFLOWRECSIZE;
33   cscanRecSize = ZSCAN_REC_SIZE;
34 
35 
36   dirRange = 0;
37   directoryarray = 0;
38   fragmentrec = 0;
39   operationrec = 0;
40   overflowRecord = 0;
41   page8 = 0;
42   scanRec = 0;
43   tabrec = 0;
44 
45   cnoOfAllocatedPages = cpagesize = 0;
46   // Records with constant sizes
47 }//Dbacc::initData()
48 
initRecords()49 void Dbacc::initRecords()
50 {
51   // Records with dynamic sizes
52   page8 = (Page8*)allocRecord("Page8",
53 			      sizeof(Page8),
54 			      cpagesize,
55 			      false,
56             CFG_DB_INDEX_MEM);
57 
58   operationrec = (Operationrec*)allocRecord("Operationrec",
59 					    sizeof(Operationrec),
60 					    coprecsize);
61 
62   dirRange = (DirRange*)allocRecord("DirRange",
63 				    sizeof(DirRange),
64 				    cdirrangesize);
65 
66   directoryarray = (Directoryarray*)allocRecord("Directoryarray",
67 						sizeof(Directoryarray),
68 						cdirarraysize);
69 
70   fragmentrec = (Fragmentrec*)allocRecord("Fragmentrec",
71 					  sizeof(Fragmentrec),
72 					  cfragmentsize);
73 
74   overflowRecord = (OverflowRecord*)allocRecord("OverflowRecord",
75 						sizeof(OverflowRecord),
76 						coverflowrecsize);
77 
78   scanRec = (ScanRec*)allocRecord("ScanRec",
79 				  sizeof(ScanRec),
80 				  cscanRecSize);
81 
82   tabrec = (Tabrec*)allocRecord("Tabrec",
83 				sizeof(Tabrec),
84 				ctablesize);
85 }//Dbacc::initRecords()
86 
Dbacc(Block_context & ctx)87 Dbacc::Dbacc(Block_context& ctx):
88   SimulatedBlock(DBACC, ctx),
89   c_tup(0)
90 {
91   BLOCK_CONSTRUCTOR(Dbacc);
92 
93   // Transit signals
94   addRecSignal(GSN_DUMP_STATE_ORD, &Dbacc::execDUMP_STATE_ORD);
95   addRecSignal(GSN_DEBUG_SIG, &Dbacc::execDEBUG_SIG);
96   addRecSignal(GSN_CONTINUEB, &Dbacc::execCONTINUEB);
97   addRecSignal(GSN_ACC_CHECK_SCAN, &Dbacc::execACC_CHECK_SCAN);
98   addRecSignal(GSN_EXPANDCHECK2, &Dbacc::execEXPANDCHECK2);
99   addRecSignal(GSN_SHRINKCHECK2, &Dbacc::execSHRINKCHECK2);
100   addRecSignal(GSN_READ_PSEUDO_REQ, &Dbacc::execREAD_PSEUDO_REQ);
101 
102   // Received signals
103   addRecSignal(GSN_STTOR, &Dbacc::execSTTOR);
104   addRecSignal(GSN_ACCKEYREQ, &Dbacc::execACCKEYREQ);
105   addRecSignal(GSN_ACCSEIZEREQ, &Dbacc::execACCSEIZEREQ);
106   addRecSignal(GSN_ACCFRAGREQ, &Dbacc::execACCFRAGREQ);
107   addRecSignal(GSN_NEXT_SCANREQ, &Dbacc::execNEXT_SCANREQ);
108   addRecSignal(GSN_ACC_ABORTREQ, &Dbacc::execACC_ABORTREQ);
109   addRecSignal(GSN_ACC_SCANREQ, &Dbacc::execACC_SCANREQ);
110   addRecSignal(GSN_ACCMINUPDATE, &Dbacc::execACCMINUPDATE);
111   addRecSignal(GSN_ACC_COMMITREQ, &Dbacc::execACC_COMMITREQ);
112   addRecSignal(GSN_ACC_TO_REQ, &Dbacc::execACC_TO_REQ);
113   addRecSignal(GSN_ACC_LOCKREQ, &Dbacc::execACC_LOCKREQ);
114   addRecSignal(GSN_NDB_STTOR, &Dbacc::execNDB_STTOR);
115   addRecSignal(GSN_DROP_TAB_REQ, &Dbacc::execDROP_TAB_REQ);
116   addRecSignal(GSN_READ_CONFIG_REQ, &Dbacc::execREAD_CONFIG_REQ, true);
117 
118   initData();
119 
120 #ifdef VM_TRACE
121   {
122     void* tmp[] = { &expDirRangePtr,
123 		    &gnsDirRangePtr,
124 		    &newDirRangePtr,
125 		    &rdDirRangePtr,
126 		    &nciOverflowrangeptr,
127                     &expDirptr,
128                     &rdDirptr,
129                     &sdDirptr,
130                     &nciOverflowDirptr,
131                     &fragrecptr,
132                     &operationRecPtr,
133                     &idrOperationRecPtr,
134                     &mlpqOperPtr,
135                     &queOperPtr,
136                     &readWriteOpPtr,
137                     &iopOverflowRecPtr,
138                     &tfoOverflowRecPtr,
139                     &porOverflowRecPtr,
140                     &priOverflowRecPtr,
141                     &rorOverflowRecPtr,
142                     &sorOverflowRecPtr,
143                     &troOverflowRecPtr,
144                     &ancPageptr,
145                     &colPageptr,
146                     &ccoPageptr,
147                     &datapageptr,
148                     &delPageptr,
149                     &excPageptr,
150                     &expPageptr,
151                     &gdiPageptr,
152                     &gePageptr,
153                     &gflPageptr,
154                     &idrPageptr,
155                     &ilcPageptr,
156                     &inpPageptr,
157                     &iopPageptr,
158                     &lastPageptr,
159                     &lastPrevpageptr,
160                     &lcnPageptr,
161                     &lcnCopyPageptr,
162                     &lupPageptr,
163                     &ciPageidptr,
164                     &gsePageidptr,
165                     &isoPageptr,
166                     &nciPageidptr,
167                     &rsbPageidptr,
168                     &rscPageidptr,
169                     &slPageidptr,
170                     &sscPageidptr,
171                     &rlPageptr,
172                     &rlpPageptr,
173                     &ropPageptr,
174                     &rpPageptr,
175                     &slPageptr,
176                     &spPageptr,
177                     &scanPtr,
178                     &tabptr
179     };
180     init_globals_list(tmp, sizeof(tmp)/sizeof(tmp[0]));
181   }
182 #endif
183 }//Dbacc::Dbacc()
184 
~Dbacc()185 Dbacc::~Dbacc()
186 {
187   deallocRecord((void **)&dirRange, "DirRange",
188 		sizeof(DirRange),
189 		cdirrangesize);
190 
191   deallocRecord((void **)&directoryarray, "Directoryarray",
192 		sizeof(Directoryarray),
193 		cdirarraysize);
194 
195   deallocRecord((void **)&fragmentrec, "Fragmentrec",
196 		sizeof(Fragmentrec),
197 		cfragmentsize);
198 
199   deallocRecord((void **)&operationrec, "Operationrec",
200 		sizeof(Operationrec),
201 		coprecsize);
202 
203   deallocRecord((void **)&overflowRecord, "OverflowRecord",
204 		sizeof(OverflowRecord),
205 		coverflowrecsize);
206 
207   deallocRecord((void **)&page8, "Page8",
208 		sizeof(Page8),
209 		cpagesize);
210 
211   deallocRecord((void **)&scanRec, "ScanRec",
212 		sizeof(ScanRec),
213 		cscanRecSize);
214 
215   deallocRecord((void **)&tabrec, "Tabrec",
216 		sizeof(Tabrec),
217 		ctablesize);
218   }//Dbacc::~Dbacc()
219 
220 BLOCK_FUNCTIONS(Dbacc)
221