MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DbaccInit.cpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
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 St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 
19 
20 #define DBACC_C
21 #include "Dbacc.hpp"
22 
23 #define DEBUG(x) { ndbout << "ACC::" << x << endl; }
24 
25 void Dbacc::initData()
26 {
27  cdirarraysize = ZDIRARRAY;
28  coprecsize = ZOPRECSIZE;
29  cpagesize = ZPAGESIZE;
30  ctablesize = ZTABLESIZE;
31  cfragmentsize = ZFRAGMENTSIZE;
32  cdirrangesize = ZDIRRANGESIZE;
33  coverflowrecsize = ZOVERFLOWRECSIZE;
34  cscanRecSize = ZSCAN_REC_SIZE;
35 
36 
37  dirRange = 0;
38  directoryarray = 0;
39  fragmentrec = 0;
40  operationrec = 0;
41  overflowRecord = 0;
42  page8 = 0;
43  scanRec = 0;
44  tabrec = 0;
45 
46  cnoOfAllocatedPagesMax = cnoOfAllocatedPages = cpagesize = cpageCount = 0;
47  // Records with constant sizes
48 
49  RSS_OP_COUNTER_INIT(cnoOfFreeFragrec);
50 
51 }//Dbacc::initData()
52 
53 void Dbacc::initRecords()
54 {
55  {
56  AllocChunk chunks[16];
57  const Uint32 pages = (cpagesize + 3) / 4;
58  const Uint32 chunkcnt = allocChunks(chunks, 16, RT_DBTUP_PAGE, pages,
59  CFG_DB_INDEX_MEM);
60 
64  Ptr<GlobalPage> pagePtr;
65  m_shared_page_pool.getPtr(pagePtr, chunks[0].ptrI);
66  page8 = (Page8*)pagePtr.p;
67 
72  cfirstfreepage = RNIL;
73  cpagesize = 0;
74  cpageCount = 0;
75  for (Int32 i = chunkcnt - 1; i >= 0; i--)
76  {
77  Ptr<GlobalPage> pagePtr;
78  m_shared_page_pool.getPtr(pagePtr, chunks[i].ptrI);
79  const Uint32 cnt = 4 * chunks[i].cnt; // 4 8k per 32k
80  Page8* base = (Page8*)pagePtr.p;
81  ndbrequire(base >= page8);
82  const Uint32 ptrI = Uint32(base - page8);
83  for (Uint32 j = 0; j < cnt; j++)
84  {
86  base[j].word32[0] = ptrI + j + 1;
87  }
88 
89  base[cnt-1].word32[0] = cfirstfreepage;
90  cfirstfreepage = ptrI;
91 
92  cpageCount += cnt;
93  if (ptrI + cnt > cpagesize)
94  cpagesize = ptrI + cnt;
95  }
96  }
97 
98  operationrec = (Operationrec*)allocRecord("Operationrec",
99  sizeof(Operationrec),
100  coprecsize);
101 
102  dirRange = (DirRange*)allocRecord("DirRange",
103  sizeof(DirRange),
104  cdirrangesize);
105 
106  directoryarray = (Directoryarray*)allocRecord("Directoryarray",
107  sizeof(Directoryarray),
108  cdirarraysize);
109 
110  fragmentrec = (Fragmentrec*)allocRecord("Fragmentrec",
111  sizeof(Fragmentrec),
112  cfragmentsize);
113 
114  overflowRecord = (OverflowRecord*)allocRecord("OverflowRecord",
115  sizeof(OverflowRecord),
116  coverflowrecsize);
117 
118  scanRec = (ScanRec*)allocRecord("ScanRec",
119  sizeof(ScanRec),
120  cscanRecSize);
121 
122  tabrec = (Tabrec*)allocRecord("Tabrec",
123  sizeof(Tabrec),
124  ctablesize);
125 }//Dbacc::initRecords()
126 
127 Dbacc::Dbacc(Block_context& ctx, Uint32 instanceNumber):
128  SimulatedBlock(DBACC, ctx, instanceNumber),
129  c_tup(0)
130 {
131  BLOCK_CONSTRUCTOR(Dbacc);
132 
133  // Transit signals
134  addRecSignal(GSN_DUMP_STATE_ORD, &Dbacc::execDUMP_STATE_ORD);
135  addRecSignal(GSN_DEBUG_SIG, &Dbacc::execDEBUG_SIG);
136  addRecSignal(GSN_CONTINUEB, &Dbacc::execCONTINUEB);
137  addRecSignal(GSN_ACC_CHECK_SCAN, &Dbacc::execACC_CHECK_SCAN);
138  addRecSignal(GSN_EXPANDCHECK2, &Dbacc::execEXPANDCHECK2);
139  addRecSignal(GSN_SHRINKCHECK2, &Dbacc::execSHRINKCHECK2);
140  addRecSignal(GSN_READ_PSEUDO_REQ, &Dbacc::execREAD_PSEUDO_REQ);
141 
142  // Received signals
143  addRecSignal(GSN_STTOR, &Dbacc::execSTTOR);
144  addRecSignal(GSN_ACCKEYREQ, &Dbacc::execACCKEYREQ);
145  addRecSignal(GSN_ACCSEIZEREQ, &Dbacc::execACCSEIZEREQ);
146  addRecSignal(GSN_ACCFRAGREQ, &Dbacc::execACCFRAGREQ);
147  addRecSignal(GSN_NEXT_SCANREQ, &Dbacc::execNEXT_SCANREQ);
148  addRecSignal(GSN_ACC_ABORTREQ, &Dbacc::execACC_ABORTREQ);
149  addRecSignal(GSN_ACC_SCANREQ, &Dbacc::execACC_SCANREQ);
150  addRecSignal(GSN_ACCMINUPDATE, &Dbacc::execACCMINUPDATE);
151  addRecSignal(GSN_ACC_COMMITREQ, &Dbacc::execACC_COMMITREQ);
152  addRecSignal(GSN_ACC_TO_REQ, &Dbacc::execACC_TO_REQ);
153  addRecSignal(GSN_ACC_LOCKREQ, &Dbacc::execACC_LOCKREQ);
154  addRecSignal(GSN_NDB_STTOR, &Dbacc::execNDB_STTOR);
155  addRecSignal(GSN_DROP_TAB_REQ, &Dbacc::execDROP_TAB_REQ);
156  addRecSignal(GSN_READ_CONFIG_REQ, &Dbacc::execREAD_CONFIG_REQ, true);
157  addRecSignal(GSN_DROP_FRAG_REQ, &Dbacc::execDROP_FRAG_REQ);
158 
159  addRecSignal(GSN_DBINFO_SCANREQ, &Dbacc::execDBINFO_SCANREQ);
160 
161  initData();
162 
163 #ifdef VM_TRACE
164  {
165  void* tmp[] = { &expDirRangePtr,
166  &gnsDirRangePtr,
167  &newDirRangePtr,
168  &rdDirRangePtr,
169  &nciOverflowrangeptr,
170  &expDirptr,
171  &rdDirptr,
172  &sdDirptr,
173  &nciOverflowDirptr,
174  &fragrecptr,
175  &operationRecPtr,
176  &idrOperationRecPtr,
177  &mlpqOperPtr,
178  &queOperPtr,
179  &readWriteOpPtr,
180  &iopOverflowRecPtr,
181  &tfoOverflowRecPtr,
182  &porOverflowRecPtr,
183  &priOverflowRecPtr,
184  &rorOverflowRecPtr,
185  &sorOverflowRecPtr,
186  &troOverflowRecPtr,
187  &ancPageptr,
188  &colPageptr,
189  &ccoPageptr,
190  &datapageptr,
191  &delPageptr,
192  &excPageptr,
193  &expPageptr,
194  &gdiPageptr,
195  &gePageptr,
196  &gflPageptr,
197  &idrPageptr,
198  &ilcPageptr,
199  &inpPageptr,
200  &iopPageptr,
201  &lastPageptr,
202  &lastPrevpageptr,
203  &lcnPageptr,
204  &lcnCopyPageptr,
205  &lupPageptr,
206  &ciPageidptr,
207  &gsePageidptr,
208  &isoPageptr,
209  &nciPageidptr,
210  &rsbPageidptr,
211  &rscPageidptr,
212  &slPageidptr,
213  &sscPageidptr,
214  &rlPageptr,
215  &rlpPageptr,
216  &ropPageptr,
217  &rpPageptr,
218  &slPageptr,
219  &spPageptr,
220  &scanPtr,
221  &tabptr
222  };
223  init_globals_list(tmp, sizeof(tmp)/sizeof(tmp[0]));
224  }
225 #endif
226 }//Dbacc::Dbacc()
227 
228 Dbacc::~Dbacc()
229 {
230  deallocRecord((void **)&dirRange, "DirRange",
231  sizeof(DirRange),
232  cdirrangesize);
233 
234  deallocRecord((void **)&directoryarray, "Directoryarray",
235  sizeof(Directoryarray),
236  cdirarraysize);
237 
238  deallocRecord((void **)&fragmentrec, "Fragmentrec",
239  sizeof(Fragmentrec),
240  cfragmentsize);
241 
242  deallocRecord((void **)&operationrec, "Operationrec",
243  sizeof(Operationrec),
244  coprecsize);
245 
246  deallocRecord((void **)&overflowRecord, "OverflowRecord",
247  sizeof(OverflowRecord),
248  coverflowrecsize);
249 
250  deallocRecord((void **)&scanRec, "ScanRec",
251  sizeof(ScanRec),
252  cscanRecSize);
253 
254  deallocRecord((void **)&tabrec, "Tabrec",
255  sizeof(Tabrec),
256  ctablesize);
257  }//Dbacc::~Dbacc()
258 
259 BLOCK_FUNCTIONS(Dbacc)