MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Dbacc.hpp
1 
2 /*
3  Copyright (C) 2003-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
4  All rights reserved. Use is subject to license terms.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; version 2 of the License.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #ifndef DBACC_H
21 #define DBACC_H
22 
23 #if defined (VM_TRACE) && !defined(ACC_SAFE_QUEUE)
24 #define ACC_SAFE_QUEUE
25 #endif
26 
27 #include <pc.hpp>
28 #include <SimulatedBlock.hpp>
29 
30 #ifdef DBACC_C
31 // Debug Macros
32 #define dbgWord32(ptr, ind, val)
33 
34 /*
35 #define dbgWord32(ptr, ind, val) \
36 if(debug_jan){ \
37 tmp_val = val; \
38 switch(ind){ \
39 case 1: strcpy(tmp_string, "ZPOS_PAGE_TYPE "); \
40 break; \
41 case 2: strcpy(tmp_string, "ZPOS_NO_ELEM_IN_PAGE"); \
42 break; \
43 case 3: strcpy(tmp_string, "ZPOS_CHECKSUM "); \
44 break; \
45 case 4: strcpy(tmp_string, "ZPOS_OVERFLOWREC "); \
46 break; \
47 case 5: strcpy(tmp_string, "ZPOS_FREE_AREA_IN_PAGE"); \
48 break; \
49 case 6: strcpy(tmp_string, "ZPOS_LAST_INDEX "); \
50 break; \
51 case 7: strcpy(tmp_string, "ZPOS_INSERT_INDEX "); \
52 break; \
53 case 8: strcpy(tmp_string, "ZPOS_ARRAY_POS "); \
54 break; \
55 case 9: strcpy(tmp_string, "ZPOS_NEXT_FREE_INDEX"); \
56 break; \
57 case 10: strcpy(tmp_string, "ZPOS_NEXT_PAGE "); \
58 break; \
59 case 11: strcpy(tmp_string, "ZPOS_PREV_PAGE "); \
60 break; \
61 default: sprintf(tmp_string, "%-20d", ind);\
62 } \
63 ndbout << "Ptr: " << ptr.p->word32 << " \tIndex: " << tmp_string << " \tValue: " << tmp_val << " \tLINE: " << __LINE__ << endl; \
64 }\
65 */
66 
67 // Constants
73 #define ZHEAD_SIZE 32
74 #define ZCON_HEAD_SIZE 2
75 #define ZBUF_SIZE 28
76 #define ZEMPTYLIST 72
77 #define ZUP_LIMIT 14
78 #define ZDOWN_LIMIT 12
79 #define ZSHIFT_PLUS 5
80 #define ZSHIFT_MINUS 2
81 #define ZFREE_LIMIT 65
82 #define ZNO_CONTAINERS 64
83 #define ZELEM_HEAD_SIZE 1
84 /* ------------------------------------------------------------------------- */
85 /* THESE CONSTANTS DEFINE THE USE OF THE PAGE HEADER IN THE INDEX PAGES. */
86 /* ------------------------------------------------------------------------- */
87 #define ZPOS_PAGE_ID 0
88 #define ZPOS_PAGE_TYPE 1
89 #define ZPOS_PAGE_TYPE_BIT 14
90 #define ZPOS_EMPTY_LIST 1
91 #define ZPOS_ALLOC_CONTAINERS 2
92 #define ZPOS_CHECKSUM 3
93 #define ZPOS_OVERFLOWREC 4
94 #define ZPOS_NO_ELEM_IN_PAGE 2
95 #define ZPOS_FREE_AREA_IN_PAGE 5
96 #define ZPOS_LAST_INDEX 6
97 #define ZPOS_INSERT_INDEX 7
98 #define ZPOS_ARRAY_POS 8
99 #define ZPOS_NEXT_FREE_INDEX 9
100 #define ZPOS_NEXT_PAGE 10
101 #define ZPOS_PREV_PAGE 11
102 #define ZNORMAL_PAGE_TYPE 0
103 #define ZOVERFLOW_PAGE_TYPE 1
104 #define ZDEFAULT_LIST 3
105 #define ZWORDS_IN_PAGE 2048
106 #define ZADDFRAG 0
107 #define ZDIRARRAY 68
108 #define ZDIRRANGESIZE 65
109 //#define ZEMPTY_FRAGMENT 0
110 #define ZFRAGMENTSIZE 64
111 #define ZFIRSTTIME 1
112 #define ZFS_CONNECTSIZE 300
113 #define ZFS_OPSIZE 100
114 #define ZKEYINKEYREQ 4
115 #define ZLEFT 1
116 #define ZLOCALLOGFILE 2
117 #define ZLOCKED 0
118 #define ZMAXSCANSIGNALLEN 20
119 #define ZMAINKEYLEN 8
120 #define ZNO_OF_DISK_VERSION 3
121 #define ZNO_OF_OP_PER_SIGNAL 20
122 //#define ZNOT_EMPTY_FRAGMENT 1
123 #define ZOP_HEAD_INFO_LN 3
124 #define ZOPRECSIZE 740
125 #define ZOVERFLOWRECSIZE 5
126 #define ZPAGE8_BASE_ADD 1
127 #define ZPAGESIZE 128
128 #define ZPARALLEL_QUEUE 1
129 #define ZPDIRECTORY 1
130 #define ZSCAN_MAX_LOCK 4
131 #define ZSERIAL_QUEUE 2
132 #define ZSPH1 1
133 #define ZSPH2 2
134 #define ZSPH3 3
135 #define ZSPH6 6
136 #define ZREADLOCK 0
137 #define ZRIGHT 2
138 #define ZROOTFRAGMENTSIZE 32
139 #define ZSCAN_LOCK_ALL 3
140 
143 #define ZSCAN_OP 8
144 #define ZSCAN_REC_SIZE 256
145 #define ZSTAND_BY 2
146 #define ZTABLESIZE 16
147 #define ZTABMAXINDEX 3
148 #define ZUNDEFINED_OP 6
149 #define ZUNLOCKED 1
150 
151 /* --------------------------------------------------------------------------------- */
152 /* CONTINUEB CODES */
153 /* --------------------------------------------------------------------------------- */
154 #define ZINITIALISE_RECORDS 1
155 #define ZREL_ROOT_FRAG 5
156 #define ZREL_FRAG 6
157 #define ZREL_DIR 7
158 
159 /* ------------------------------------------------------------------------- */
160 /* ERROR CODES */
161 /* ------------------------------------------------------------------------- */
162 #define ZLIMIT_OF_ERROR 600 // Limit check for error codes
163 #define ZCHECKROOT_ERROR 601 // Delete fragment error code
164 #define ZCONNECT_SIZE_ERROR 602 // ACC_SEIZEREF
165 #define ZDIR_RANGE_ERROR 603 // Add fragment error code
166 #define ZFULL_FRAGRECORD_ERROR 604 // Add fragment error code
167 #define ZFULL_ROOTFRAGRECORD_ERROR 605 // Add fragment error code
168 #define ZROOTFRAG_STATE_ERROR 606 // Add fragment
169 #define ZOVERTAB_REC_ERROR 607 // Add fragment
170 
171 #define ZSCAN_REFACC_CONNECT_ERROR 608 // ACC_SCANREF
172 #define ZFOUR_ACTIVE_SCAN_ERROR 609 // ACC_SCANREF
173 #define ZNULL_SCAN_REC_ERROR 610 // ACC_SCANREF
174 
175 #define ZDIRSIZE_ERROR 623
176 #define ZOVER_REC_ERROR 624 // Insufficient Space
177 #define ZPAGESIZE_ERROR 625
178 #define ZTUPLE_DELETED_ERROR 626
179 #define ZREAD_ERROR 626
180 #define ZWRITE_ERROR 630
181 #define ZTO_OP_STATE_ERROR 631
182 #define ZTOO_EARLY_ACCESS_ERROR 632
183 #define ZDIR_RANGE_FULL_ERROR 633 // on fragment
184 #endif
185 
199 public:
200  STATIC_CONST( HASH_VALUE_PART_MASK = 0xFFFF );
201 
202  static bool getLocked(Uint32 data);
203  static bool getUnlocked(Uint32 data);
204  static Uint32 getScanBits(Uint32 data);
205  static Uint32 getHashValuePart(Uint32 data);
206  static Uint32 getOpPtrI(Uint32 data);
207 
208  static Uint32 setLocked(Uint32 opPtrI);
209  static Uint32 setUnlocked(Uint32 hashValuePart, Uint32 scanBits);
210  static Uint32 setScanBit(Uint32 header, Uint32 scanBit);
211  static Uint32 clearScanBit(Uint32 header, Uint32 scanBit);
212 };
213 
214 inline
215 bool
216 ElementHeader::getLocked(Uint32 data){
217  return (data & 1) == 0;
218 }
219 
220 inline
221 bool
222 ElementHeader::getUnlocked(Uint32 data){
223  return (data & 1) == 1;
224 }
225 
226 inline
227 Uint32
228 ElementHeader::getScanBits(Uint32 data){
229  assert(getUnlocked(data));
230  return (data >> 1) & ((1 << MAX_PARALLEL_SCANS_PER_FRAG) - 1);
231 }
232 
233 inline
234 Uint32
235 ElementHeader::getHashValuePart(Uint32 data){
236  assert(getUnlocked(data));
237  return data >> 16;
238 }
239 
240 inline
241 Uint32
242 ElementHeader::getOpPtrI(Uint32 data){
243  assert(getLocked(data));
244  return data >> 1;
245 }
246 
247 inline
248 Uint32
249 ElementHeader::setLocked(Uint32 opPtrI){
250  return (opPtrI << 1) + 0;
251 }
252 inline
253 Uint32
254 ElementHeader::setUnlocked(Uint32 hashValue, Uint32 scanBits){
255  return (hashValue << 16) + (scanBits << 1) + 1;
256 }
257 
258 inline
259 Uint32
260 ElementHeader::setScanBit(Uint32 header, Uint32 scanBit){
261  assert(getUnlocked(header));
262  return header | (scanBit << 1);
263 }
264 
265 inline
266 Uint32
267 ElementHeader::clearScanBit(Uint32 header, Uint32 scanBit){
268  assert(getUnlocked(header));
269  return header & (~(scanBit << 1));
270 }
271 
272 
273 class Dbacc: public SimulatedBlock {
274  friend class DbaccProxy;
275 
276 public:
277 // State values
278 enum State {
279  FREEFRAG = 0,
280  ACTIVEFRAG = 1,
281  //SEND_QUE_OP = 2,
282  WAIT_NOTHING = 10,
283  WAIT_ONE_CONF = 26,
284  FREE_OP = 30,
285  WAIT_EXE_OP = 32,
286  WAIT_IN_QUEUE = 34,
287  EXE_OP = 35,
288  SCAN_ACTIVE = 36,
289  SCAN_WAIT_IN_QUEUE = 37,
290  IDLE = 39,
291  ACTIVE = 40,
292  WAIT_COMMIT_ABORT = 41,
293  ABORT = 42,
294  ABORTADDFRAG = 43,
295  REFUSEADDFRAG = 44,
296  DELETEFRAG = 45,
297  DELETETABLE = 46,
298  UNDEFINEDROOT = 47,
299  ADDFIRSTFRAG = 48,
300  ADDSECONDFRAG = 49,
301  DELETEFIRSTFRAG = 50,
302  DELETESECONDFRAG = 51,
303  ACTIVEROOT = 52
304 };
305 
306 // Records
307 
308 /* --------------------------------------------------------------------------------- */
309 /* DIRECTORY RANGE */
310 /* --------------------------------------------------------------------------------- */
311  struct DirRange {
312  Uint32 dirArray[256];
313  }; /* p2c: size = 1024 bytes */
314 
315  typedef Ptr<DirRange> DirRangePtr;
316 
317 /* --------------------------------------------------------------------------------- */
318 /* DIRECTORYARRAY */
319 /* --------------------------------------------------------------------------------- */
321  Uint32 pagep[256];
322 }; /* p2c: size = 1024 bytes */
323 
325 
326 /* --------------------------------------------------------------------------------- */
327 /* FRAGMENTREC. ALL INFORMATION ABOUT FRAMENT AND HASH TABLE IS SAVED IN FRAGMENT */
328 /* REC A POINTER TO FRAGMENT RECORD IS SAVED IN ROOTFRAGMENTREC FRAGMENT */
329 /* --------------------------------------------------------------------------------- */
330 struct Fragmentrec {
331  Uint32 scan[MAX_PARALLEL_SCANS_PER_FRAG];
332  union {
333  Uint32 mytabptr;
334  Uint32 myTableId;
335  };
336  union {
337  Uint32 fragmentid;
338  Uint32 myfid;
339  };
340  Uint32 roothashcheck;
341  Uint32 noOfElements;
342  Uint32 m_commit_count;
343  State rootState;
344 
345 //-----------------------------------------------------------------------------
346 // These variables keep track of allocated pages, the number of them and the
347 // start file page of them. Used during local checkpoints.
348 //-----------------------------------------------------------------------------
349  Uint32 datapages[8];
350  Uint32 activeDataPage;
351 
352 //-----------------------------------------------------------------------------
353 // Temporary variables used during shrink and expand process.
354 //-----------------------------------------------------------------------------
355  Uint32 expReceivePageptr;
356  Uint32 expReceiveIndex;
357  Uint32 expReceiveForward;
358  Uint32 expSenderDirIndex;
359  Uint32 expSenderDirptr;
360  Uint32 expSenderIndex;
361  Uint32 expSenderPageptr;
362 
363 //-----------------------------------------------------------------------------
364 // List of lock owners and list of lock waiters to support LCP handling
365 //-----------------------------------------------------------------------------
366  Uint32 lockOwnersList;
367 
368 //-----------------------------------------------------------------------------
369 // References to Directory Ranges (which in turn references directories, which
370 // in its turn references the pages) for the bucket pages and the overflow
371 // bucket pages.
372 //-----------------------------------------------------------------------------
373  Uint32 directory;
374  Uint32 dirsize;
375  Uint32 overflowdir;
376  Uint32 lastOverIndex;
377 
378 //-----------------------------------------------------------------------------
379 // We have a list of overflow pages with free areas. We have a special record,
380 // the overflow record representing these pages. The reason is that the
381 // same record is also used to represent pages in the directory array that have
382 // been released since they were empty (there were however higher indexes with
383 // data in them). These are put in the firstFreeDirIndexRec-list.
384 // An overflow record representing a page can only be in one of these lists.
385 //-----------------------------------------------------------------------------
386  Uint32 firstOverflowRec;
387  Uint32 lastOverflowRec;
388  Uint32 firstFreeDirindexRec;
389 
390 //-----------------------------------------------------------------------------
391 // Counter keeping track of how many times we have expanded. We need to ensure
392 // that we do not shrink so many times that this variable becomes negative.
393 //-----------------------------------------------------------------------------
394  Uint32 expandCounter;
395 
396 //-----------------------------------------------------------------------------
397 // These variables are important for the linear hashing algorithm.
398 // localkeylen is the size of the local key (1 and 2 is currently supported)
399 // maxloadfactor is the factor specifying when to expand
400 // minloadfactor is the factor specifying when to shrink (hysteresis model)
401 // maxp and p
402 // maxp and p is the variables most central to linear hashing. p + maxp + 1 is the
403 // current number of buckets. maxp is the largest value of the type 2**n - 1
404 // which is smaller than the number of buckets. These values are used to find
405 // correct bucket with the aid of the hash value.
406 //
407 // slack is the variable keeping track of whether we have inserted more than
408 // the current size is suitable for or less. Slack together with the boundaries
409 // set by maxloadfactor and minloadfactor decides when to expand/shrink
410 // slackCheck When slack goes over this value it is time to expand.
411 // slackCheck = (maxp + p + 1)*(maxloadfactor - minloadfactor) or
412 // bucketSize * hysteresis
413 //-----------------------------------------------------------------------------
414  Uint32 localkeylen;
415  Uint32 maxp;
416  Uint32 maxloadfactor;
417  Uint32 minloadfactor;
418  Uint32 p;
419  Uint32 slack;
420  Uint32 slackCheck;
421 
422 //-----------------------------------------------------------------------------
423 // nextfreefrag is the next free fragment if linked into a free list
424 //-----------------------------------------------------------------------------
425  Uint32 nextfreefrag;
426 
427 //-----------------------------------------------------------------------------
428 // This variable is used during restore to keep track of page id of read pages.
429 // During read of bucket pages this is used to calculate the page id and also
430 // to verify that the page id of the read page is correct. During read of over-
431 // flow pages it is only used to keep track of the number of pages read.
432 //-----------------------------------------------------------------------------
433  Uint32 nextAllocPage;
434 
435 //-----------------------------------------------------------------------------
436 // Number of pages read from file during restore
437 //-----------------------------------------------------------------------------
438  Uint32 noOfExpectedPages;
439 
440 //-----------------------------------------------------------------------------
441 // Fragment State, mostly applicable during LCP and restore
442 //-----------------------------------------------------------------------------
443  State fragState;
444 
445 //-----------------------------------------------------------------------------
446 // elementLength: Length of element in bucket and overflow pages
447 // keyLength: Length of key
448 //-----------------------------------------------------------------------------
449  Uint8 elementLength;
450  Uint16 keyLength;
451 
452 //-----------------------------------------------------------------------------
453 // This flag is used to avoid sending a big number of expand or shrink signals
454 // when simultaneously committing many inserts or deletes.
455 //-----------------------------------------------------------------------------
456  Uint8 expandFlag;
457 
458 //-----------------------------------------------------------------------------
459 // hashcheckbit is the bit to check whether to send element to split bucket or not
460 // k (== 6) is the number of buckets per page
461 // lhfragbits is the number of bits used to calculate the fragment id
462 // lhdirbits is the number of bits used to calculate the page id
463 //-----------------------------------------------------------------------------
464  Uint8 hashcheckbit;
465  Uint8 k;
466  Uint8 lhfragbits;
467  Uint8 lhdirbits;
468 
469 //-----------------------------------------------------------------------------
470 // nodetype can only be STORED in this release. Is currently only set, never read
471 //-----------------------------------------------------------------------------
472  Uint8 nodetype;
473 
474 //-----------------------------------------------------------------------------
475 // flag to avoid accessing table record if no char attributes
476 //-----------------------------------------------------------------------------
477  Uint8 hasCharAttr;
478 
479 //-----------------------------------------------------------------------------
480 // flag to mark that execEXPANDCHECK2 has failed due to DirRange full
481 //-----------------------------------------------------------------------------
482  Uint8 dirRangeFull;
483 };
484 
486 
487 /* --------------------------------------------------------------------------------- */
488 /* OPERATIONREC */
489 /* --------------------------------------------------------------------------------- */
490 struct Operationrec {
491  Uint32 m_op_bits;
492  Uint32 localdata[2];
493  Uint32 elementIsforward;
494  Uint32 elementPage;
495  Uint32 elementPointer;
496  Uint32 fid;
497  Uint32 fragptr;
498  Uint32 hashvaluePart;
499  Uint32 hashValue;
500  Uint32 nextLockOwnerOp;
501  Uint32 nextOp;
502  Uint32 nextParallelQue;
503  union {
504  Uint32 nextSerialQue;
505  Uint32 m_lock_owner_ptr_i; // if nextParallelQue = RNIL, else undefined
506  };
507  Uint32 prevOp;
508  Uint32 prevLockOwnerOp;
509  union {
510  Uint32 prevParallelQue;
511  Uint32 m_lo_last_parallel_op_ptr_i;
512  };
513  union {
514  Uint32 prevSerialQue;
515  Uint32 m_lo_last_serial_op_ptr_i;
516  };
517  Uint32 scanRecPtr;
518  Uint32 transId1;
519  Uint32 transId2;
520  Uint32 userptr;
521  Uint16 elementContainer;
522  Uint16 tupkeylen;
523  Uint32 xfrmtupkeylen;
524  Uint32 userblockref;
525  Uint32 scanBits;
526 
527  enum OpBits {
528  OP_MASK = 0x0000F // 4 bits for operation type
529  ,OP_LOCK_MODE = 0x00010 // 0 - shared lock, 1 = exclusive lock
530  ,OP_ACC_LOCK_MODE = 0x00020 // Or:de lock mode of all operation
531  // before me
532  ,OP_LOCK_OWNER = 0x00040
533  ,OP_RUN_QUEUE = 0x00080 // In parallell queue of lock owner
534  ,OP_DIRTY_READ = 0x00100
535  ,OP_LOCK_REQ = 0x00200 // isAccLockReq
536  ,OP_COMMIT_DELETE_CHECK = 0x00400
537  ,OP_INSERT_IS_DONE = 0x00800
538  ,OP_ELEMENT_DISAPPEARED = 0x01000
539 
540  ,OP_STATE_MASK = 0xF0000
541  ,OP_STATE_IDLE = 0xF0000
542  ,OP_STATE_WAITING = 0x00000
543  ,OP_STATE_RUNNING = 0x10000
544  ,OP_STATE_EXECUTED = 0x30000
545 
546  ,OP_EXECUTED_DIRTY_READ = 0x3050F
547  ,OP_INITIAL = ~(Uint32)0
548  };
549 
550  Operationrec() {}
551  bool is_same_trans(const Operationrec* op) const {
552  return
553  transId1 == op->transId1 && transId2 == op->transId2;
554  }
555 
556 }; /* p2c: size = 168 bytes */
557 
559 
560 /* --------------------------------------------------------------------------------- */
561 /* OVERFLOW_RECORD */
562 /* --------------------------------------------------------------------------------- */
564  Uint32 dirindex;
565  Uint32 nextOverRec;
566  Uint32 nextOverList;
567  Uint32 prevOverRec;
568  Uint32 prevOverList;
569  Uint32 overpage;
570  Uint32 nextfreeoverrec;
571 };
572 
574 
575 /* --------------------------------------------------------------------------------- */
576 /* PAGE8 */
577 /* --------------------------------------------------------------------------------- */
578 struct Page8 {
579  Uint32 word32[2048];
580 }; /* p2c: size = 8192 bytes */
581 
582  typedef Ptr<Page8> Page8Ptr;
583 
584 /* --------------------------------------------------------------------------------- */
585 /* SCAN_REC */
586 /* --------------------------------------------------------------------------------- */
587 struct ScanRec {
588  enum ScanState {
589  WAIT_NEXT,
590  SCAN_DISCONNECT
591  };
592  enum ScanBucketState {
593  FIRST_LAP,
594  SECOND_LAP,
595  SCAN_COMPLETED
596  };
597  Uint32 activeLocalFrag;
598  Uint32 nextBucketIndex;
599  Uint32 scanNextfreerec;
600  Uint32 scanFirstActiveOp;
601  Uint32 scanFirstLockedOp;
602  Uint32 scanLastLockedOp;
603  Uint32 scanFirstQueuedOp;
604  Uint32 scanLastQueuedOp;
605  Uint32 scanUserptr;
606  Uint32 scanTrid1;
607  Uint32 scanTrid2;
608  Uint32 startNoOfBuckets;
609  Uint32 minBucketIndexToRescan;
610  Uint32 maxBucketIndexToRescan;
611  Uint32 scanOpsAllocated;
612  ScanBucketState scanBucketState;
613  ScanState scanState;
614  Uint16 scanLockHeld;
615  Uint32 scanUserblockref;
616  Uint32 scanMask;
617  Uint8 scanLockMode;
618  Uint8 scanReadCommittedFlag;
619 };
620 
621  typedef Ptr<ScanRec> ScanRecPtr;
622 
623 
624 /* --------------------------------------------------------------------------------- */
625 /* TABREC */
626 /* --------------------------------------------------------------------------------- */
627 struct Tabrec {
628  Uint32 fragholder[MAX_FRAG_PER_NODE];
629  Uint32 fragptrholder[MAX_FRAG_PER_NODE];
630  Uint32 tabUserPtr;
631  BlockReference tabUserRef;
632  Uint32 tabUserGsn;
633 };
634  typedef Ptr<Tabrec> TabrecPtr;
635 
636 public:
637  Dbacc(Block_context&, Uint32 instanceNumber = 0);
638  virtual ~Dbacc();
639 
640  // pointer to TUP instance in this thread
641  class Dbtup* c_tup;
642  class Dblqh* c_lqh;
643 
644  void execACCMINUPDATE(Signal* signal);
645  void removerow(Uint32 op, const Local_key*);
646 
647 private:
648  BLOCK_DEFINES(Dbacc);
649 
650  // Transit signals
651  void execDEBUG_SIG(Signal* signal);
652  void execCONTINUEB(Signal* signal);
653  void execACC_CHECK_SCAN(Signal* signal);
654  void execEXPANDCHECK2(Signal* signal);
655  void execSHRINKCHECK2(Signal* signal);
656  void execACC_OVER_REC(Signal* signal);
657  void execNEXTOPERATION(Signal* signal);
658  void execREAD_PSEUDO_REQ(Signal* signal);
659 
660  // Received signals
661  void execSTTOR(Signal* signal);
662  void execACCKEYREQ(Signal* signal);
663  void execACCSEIZEREQ(Signal* signal);
664  void execACCFRAGREQ(Signal* signal);
665  void execNEXT_SCANREQ(Signal* signal);
666  void execACC_ABORTREQ(Signal* signal);
667  void execACC_SCANREQ(Signal* signal);
668  void execACC_COMMITREQ(Signal* signal);
669  void execACC_TO_REQ(Signal* signal);
670  void execACC_LOCKREQ(Signal* signal);
671  void execNDB_STTOR(Signal* signal);
672  void execDROP_TAB_REQ(Signal* signal);
673  void execREAD_CONFIG_REQ(Signal* signal);
674  void execDUMP_STATE_ORD(Signal* signal);
675 
676  void execDROP_FRAG_REQ(Signal*);
677 
678  void execDBINFO_SCANREQ(Signal *signal);
679 
680  // Statement blocks
681  void ACCKEY_error(Uint32 fromWhere);
682 
683  void commitDeleteCheck();
684  void report_dealloc(Signal* signal, const Operationrec* opPtrP);
685 
686  typedef void * RootfragmentrecPtr;
687  void initRootFragPageZero(FragmentrecPtr, Page8Ptr);
688  void initFragAdd(Signal*, FragmentrecPtr);
689  void initFragPageZero(FragmentrecPtr, Page8Ptr);
690  void initFragGeneral(FragmentrecPtr);
691  void verifyFragCorrect(FragmentrecPtr regFragPtr);
692  void releaseFragResources(Signal* signal, Uint32 fragIndex);
693  void releaseRootFragRecord(Signal* signal, RootfragmentrecPtr rootPtr);
694  void releaseRootFragResources(Signal* signal, Uint32 tableId);
695  void releaseDirResources(Signal* signal,
696  Uint32 fragIndex,
697  Uint32 dirIndex,
698  Uint32 startIndex);
699  void releaseDirectoryResources(Signal* signal,
700  Uint32 fragIndex,
701  Uint32 dirIndex,
702  Uint32 startIndex,
703  Uint32 directoryIndex);
704  void releaseOverflowResources(Signal* signal, FragmentrecPtr regFragPtr);
705  void releaseDirIndexResources(Signal* signal, FragmentrecPtr regFragPtr);
706  void releaseFragRecord(Signal* signal, FragmentrecPtr regFragPtr);
707  void initScanFragmentPart(Signal* signal);
708  Uint32 checkScanExpand(Signal* signal);
709  Uint32 checkScanShrink(Signal* signal);
710  void initialiseDirRec(Signal* signal);
711  void initialiseDirRangeRec(Signal* signal);
712  void initialiseFragRec(Signal* signal);
713  void initialiseFsConnectionRec(Signal* signal);
714  void initialiseFsOpRec(Signal* signal);
715  void initialiseOperationRec(Signal* signal);
716  void initialiseOverflowRec(Signal* signal);
717  void initialisePageRec(Signal* signal);
718  void initialiseRootfragRec(Signal* signal);
719  void initialiseScanRec(Signal* signal);
720  void initialiseTableRec(Signal* signal);
721  bool addfragtotab(Signal* signal, Uint32 rootIndex, Uint32 fragId);
722  void initOpRec(Signal* signal);
723  void sendAcckeyconf(Signal* signal);
724  Uint32 getNoParallelTransaction(const Operationrec*);
725 
726 #ifdef VM_TRACE
727  Uint32 getNoParallelTransactionFull(const Operationrec*);
728 #endif
729 #ifdef ACC_SAFE_QUEUE
730  bool validate_lock_queue(OperationrecPtr opPtr);
731  Uint32 get_parallel_head(OperationrecPtr opPtr);
732  void dump_lock_queue(OperationrecPtr loPtr);
733 #else
734  bool validate_lock_queue(OperationrecPtr) { return true;}
735 #endif
736 
737 public:
738  void execACCKEY_ORD(Signal* signal, Uint32 opPtrI);
739  void startNext(Signal* signal, OperationrecPtr lastOp);
740 
741 private:
742  Uint32 placeReadInLockQueue(OperationrecPtr lockOwnerPtr);
743  Uint32 placeWriteInLockQueue(OperationrecPtr lockOwnerPtr);
744  void placeSerialQueue(OperationrecPtr lockOwner, OperationrecPtr op);
745  void abortSerieQueueOperation(Signal* signal, OperationrecPtr op);
746  void abortParallelQueueOperation(Signal* signal, OperationrecPtr op);
747 
748  void expandcontainer(Signal* signal);
749  void shrinkcontainer(Signal* signal);
750  void nextcontainerinfoExp(Signal* signal);
751  void releaseAndCommitActiveOps(Signal* signal);
752  void releaseAndCommitQueuedOps(Signal* signal);
753  void releaseAndAbortLockedOps(Signal* signal);
754  void containerinfo(Signal* signal);
755  bool getScanElement(Signal* signal);
756  void initScanOpRec(Signal* signal);
757  void nextcontainerinfo(Signal* signal);
758  void putActiveScanOp(Signal* signal);
759  void putOpScanLockQue();
760  void putReadyScanQueue(Signal* signal, Uint32 scanRecIndex);
761  void releaseScanBucket(Signal* signal);
762  void releaseScanContainer(Signal* signal);
763  void releaseScanRec(Signal* signal);
764  bool searchScanContainer(Signal* signal);
765  void sendNextScanConf(Signal* signal);
766  void setlock(Signal* signal);
767  void takeOutActiveScanOp(Signal* signal);
768  void takeOutScanLockQueue(Uint32 scanRecIndex);
769  void takeOutReadyScanQueue(Signal* signal);
770  void insertElement(Signal* signal);
771  void insertContainer(Signal* signal);
772  void addnewcontainer(Signal* signal);
773  void getfreelist(Signal* signal);
774  void increaselistcont(Signal* signal);
775  void seizeLeftlist(Signal* signal);
776  void seizeRightlist(Signal* signal);
777  Uint32 readTablePk(Uint32 lkey1, Uint32 lkey2, Uint32 eh, OperationrecPtr);
778  Uint32 getElement(Signal* signal, OperationrecPtr& lockOwner);
779  void getdirindex(Signal* signal);
780  void commitdelete(Signal* signal);
781  void deleteElement(Signal* signal);
782  void getLastAndRemove(Signal* signal);
783  void releaseLeftlist(Signal* signal);
784  void releaseRightlist(Signal* signal);
785  void checkoverfreelist(Signal* signal);
786  void abortOperation(Signal* signal);
787  void commitOperation(Signal* signal);
788  void copyOpInfo(OperationrecPtr dst, OperationrecPtr src);
789  Uint32 executeNextOperation(Signal* signal);
790  void releaselock(Signal* signal);
791  void release_lockowner(Signal* signal, OperationrecPtr, bool commit);
792  void startNew(Signal* signal, OperationrecPtr newOwner);
793  void abortWaitingOperation(Signal*, OperationrecPtr);
794  void abortExecutedOperation(Signal*, OperationrecPtr);
795 
796  void takeOutFragWaitQue(Signal* signal);
797  void check_lock_upgrade(Signal* signal, OperationrecPtr release_op, bool lo);
798  void check_lock_upgrade(Signal* signal, OperationrecPtr lock_owner,
799  OperationrecPtr release_op);
800  void allocOverflowPage(Signal* signal);
801  bool getfragmentrec(Signal* signal, FragmentrecPtr&, Uint32 fragId);
802  void insertLockOwnersList(Signal* signal, const OperationrecPtr&);
803  void takeOutLockOwnersList(Signal* signal, const OperationrecPtr&);
804 
805  void initFsOpRec(Signal* signal);
806  void initOverpage(Signal* signal);
807  void initPage(Signal* signal);
808  void initRootfragrec(Signal* signal);
809  void putOpInFragWaitQue(Signal* signal);
810  void putOverflowRecInFrag(Signal* signal);
811  void putRecInFreeOverdir(Signal* signal);
812  void releaseDirectory(Signal* signal);
813  void releaseDirrange(Signal* signal);
814  void releaseFsConnRec(Signal* signal);
815  void releaseFsOpRec(Signal* signal);
816  void releaseOpRec(Signal* signal);
817  void releaseOverflowRec(Signal* signal);
818  void releaseOverpage(Signal* signal);
819  void releasePage(Signal* signal);
820  void releaseLogicalPage(Fragmentrec * fragP, Uint32 logicalPageId);
821  void seizeDirectory(Signal* signal);
822  void seizeDirrange(Signal* signal);
823  void seizeFragrec(Signal* signal);
824  void seizeFsConnectRec(Signal* signal);
825  void seizeFsOpRec(Signal* signal);
826  void seizeOpRec(Signal* signal);
827  void seizeOverRec(Signal* signal);
828  void seizePage(Signal* signal);
829  void seizeRootfragrec(Signal* signal);
830  void seizeScanRec(Signal* signal);
831  void sendSystemerror(Signal* signal, int line);
832  void takeRecOutOfFreeOverdir(Signal* signal);
833  void takeRecOutOfFreeOverpage(Signal* signal);
834 
835  void addFragRefuse(Signal* signal, Uint32 errorCode);
836  void ndbsttorryLab(Signal* signal);
837  void acckeyref1Lab(Signal* signal, Uint32 result_code);
838  void insertelementLab(Signal* signal);
839  void checkNextFragmentLab(Signal* signal);
840  void endofexpLab(Signal* signal);
841  void endofshrinkbucketLab(Signal* signal);
842  void senddatapagesLab(Signal* signal);
843  void sttorrysignalLab(Signal* signal);
844  void sendholdconfsignalLab(Signal* signal);
845  void accIsLockedLab(Signal* signal, OperationrecPtr lockOwnerPtr);
846  void insertExistElemLab(Signal* signal, OperationrecPtr lockOwnerPtr);
847  void refaccConnectLab(Signal* signal);
848  void releaseScanLab(Signal* signal);
849  void ndbrestart1Lab(Signal* signal);
850  void initialiseRecordsLab(Signal* signal, Uint32 ref, Uint32 data);
851  void checkNextBucketLab(Signal* signal);
852  void storeDataPageInDirectoryLab(Signal* signal);
853 
854  void zpagesize_error(const char* where);
855 
856  void reenable_expand_after_redo_log_exection_complete(Signal*);
857 
858  // charsets
859  void xfrmKeyData(Signal* signal);
860 
861  // Initialisation
862  void initData();
863  void initRecords();
864 
865 #ifdef VM_TRACE
866  void debug_lh_vars(const char* where);
867 #else
868  void debug_lh_vars(const char* where) {}
869 #endif
870 
871  // Variables
872 /* --------------------------------------------------------------------------------- */
873 /* DIRECTORY RANGE */
874 /* --------------------------------------------------------------------------------- */
875  DirRange *dirRange;
876  DirRangePtr expDirRangePtr;
877  DirRangePtr gnsDirRangePtr;
878  DirRangePtr newDirRangePtr;
879  DirRangePtr rdDirRangePtr;
880  DirRangePtr nciOverflowrangeptr;
881  Uint32 cdirrangesize;
882  Uint32 cfirstfreeDirrange;
883 /* --------------------------------------------------------------------------------- */
884 /* DIRECTORYARRAY */
885 /* --------------------------------------------------------------------------------- */
886  Directoryarray *directoryarray;
887  DirectoryarrayPtr expDirptr;
888  DirectoryarrayPtr rdDirptr;
889  DirectoryarrayPtr sdDirptr;
890  DirectoryarrayPtr nciOverflowDirptr;
891  Uint32 cdirarraysize;
892  Uint32 cdirmemory;
893  Uint32 cfirstfreedir;
894 /* --------------------------------------------------------------------------------- */
895 /* FRAGMENTREC. ALL INFORMATION ABOUT FRAMENT AND HASH TABLE IS SAVED IN FRAGMENT */
896 /* REC A POINTER TO FRAGMENT RECORD IS SAVED IN ROOTFRAGMENTREC FRAGMENT */
897 /* --------------------------------------------------------------------------------- */
898  Fragmentrec *fragmentrec;
899  FragmentrecPtr fragrecptr;
900  Uint32 cfirstfreefrag;
901  Uint32 cfragmentsize;
902  RSS_OP_COUNTER(cnoOfFreeFragrec);
903  RSS_OP_SNAPSHOT(cnoOfFreeFragrec);
904 
905 
906 /* --------------------------------------------------------------------------------- */
907 /* FS_CONNECTREC */
908 /* --------------------------------------------------------------------------------- */
909 /* OPERATIONREC */
910 /* --------------------------------------------------------------------------------- */
911  Operationrec *operationrec;
912  OperationrecPtr operationRecPtr;
913  OperationrecPtr idrOperationRecPtr;
914  OperationrecPtr mlpqOperPtr;
915  OperationrecPtr queOperPtr;
916  OperationrecPtr readWriteOpPtr;
917  Uint32 cfreeopRec;
918  Uint32 coprecsize;
919 /* --------------------------------------------------------------------------------- */
920 /* OVERFLOW_RECORD */
921 /* --------------------------------------------------------------------------------- */
922  OverflowRecord *overflowRecord;
923  OverflowRecordPtr iopOverflowRecPtr;
924  OverflowRecordPtr tfoOverflowRecPtr;
925  OverflowRecordPtr porOverflowRecPtr;
926  OverflowRecordPtr priOverflowRecPtr;
927  OverflowRecordPtr rorOverflowRecPtr;
928  OverflowRecordPtr sorOverflowRecPtr;
929  OverflowRecordPtr troOverflowRecPtr;
930  Uint32 cfirstfreeoverrec;
931  Uint32 coverflowrecsize;
932 
933 /* --------------------------------------------------------------------------------- */
934 /* PAGE8 */
935 /* --------------------------------------------------------------------------------- */
936  Page8 *page8;
937  /* 8 KB PAGE */
938  Page8Ptr ancPageptr;
939  Page8Ptr colPageptr;
940  Page8Ptr ccoPageptr;
941  Page8Ptr datapageptr;
942  Page8Ptr delPageptr;
943  Page8Ptr excPageptr;
944  Page8Ptr expPageptr;
945  Page8Ptr gdiPageptr;
946  Page8Ptr gePageptr;
947  Page8Ptr gflPageptr;
948  Page8Ptr idrPageptr;
949  Page8Ptr ilcPageptr;
950  Page8Ptr inpPageptr;
951  Page8Ptr iopPageptr;
952  Page8Ptr lastPageptr;
953  Page8Ptr lastPrevpageptr;
954  Page8Ptr lcnPageptr;
955  Page8Ptr lcnCopyPageptr;
956  Page8Ptr lupPageptr;
957  Page8Ptr ciPageidptr;
958  Page8Ptr gsePageidptr;
959  Page8Ptr isoPageptr;
960  Page8Ptr nciPageidptr;
961  Page8Ptr rsbPageidptr;
962  Page8Ptr rscPageidptr;
963  Page8Ptr slPageidptr;
964  Page8Ptr sscPageidptr;
965  Page8Ptr rlPageptr;
966  Page8Ptr rlpPageptr;
967  Page8Ptr ropPageptr;
968  Page8Ptr rpPageptr;
969  Page8Ptr slPageptr;
970  Page8Ptr spPageptr;
971  Uint32 cfirstfreepage;
972  Uint32 cpagesize;
973  Uint32 cpageCount;
974  Uint32 cnoOfAllocatedPages;
975  Uint32 cnoOfAllocatedPagesMax;
976 /* --------------------------------------------------------------------------------- */
977 /* ROOTFRAGMENTREC */
978 /* DURING EXPAND FRAGMENT PROCESS, EACH FRAGMEND WILL BE EXPAND INTO TWO */
979 /* NEW FRAGMENTS.TO MAKE THIS PROCESS EASIER, DURING ADD FRAGMENT PROCESS */
980 /* NEXT FRAGMENT IDENTIIES WILL BE CALCULATED, AND TWO FRAGMENTS WILL BE */
981 /* ADDED IN (NDBACC). THEREBY EXPAND OF FRAGMENT CAN BE PERFORMED QUICK AND */
982 /* EASY.THE NEW FRAGMENT ID SENDS TO TUP MANAGER FOR ALL OPERATION PROCESS. */
983 /* --------------------------------------------------------------------------------- */
984 /* --------------------------------------------------------------------------------- */
985 /* SCAN_REC */
986 /* --------------------------------------------------------------------------------- */
987  ScanRec *scanRec;
988  ScanRecPtr scanPtr;
989  Uint32 cscanRecSize;
990  Uint32 cfirstFreeScanRec;
991 /* --------------------------------------------------------------------------------- */
992 /* TABREC */
993 /* --------------------------------------------------------------------------------- */
994  Tabrec *tabrec;
995  TabrecPtr tabptr;
996  Uint32 ctablesize;
997  Uint32 tgseElementptr;
998  Uint32 tgseContainerptr;
999  Uint32 trlHead;
1000  Uint32 trlRelCon;
1001  Uint32 trlNextused;
1002  Uint32 trlPrevused;
1003  Uint32 tlcnChecksum;
1004  Uint32 tlupElemIndex;
1005  Uint32 tlupIndex;
1006  Uint32 tlupForward;
1007  Uint32 tancNext;
1008  Uint32 tancBufType;
1009  Uint32 tancContainerptr;
1010  Uint32 tancPageindex;
1011  Uint32 tancPageid;
1012  Uint32 tidrResult;
1013  Uint32 tidrElemhead;
1014  Uint32 tidrForward;
1015  Uint32 tidrPageindex;
1016  Uint32 tidrContainerptr;
1017  Uint32 tidrContainerhead;
1018  Uint32 tlastForward;
1019  Uint32 tlastPageindex;
1020  Uint32 tlastContainerlen;
1021  Uint32 tlastElementptr;
1022  Uint32 tlastContainerptr;
1023  Uint32 tlastContainerhead;
1024  Uint32 trlPageindex;
1025  Uint32 tdelContainerptr;
1026  Uint32 tdelElementptr;
1027  Uint32 tdelForward;
1028  Uint32 tiopPageId;
1029  Uint32 tipPageId;
1030  Uint32 tgeContainerptr;
1031  Uint32 tgeElementptr;
1032  Uint32 tgeForward;
1033  Uint32 texpReceivedBucket;
1034  Uint32 texpDirInd;
1035  Uint32 texpDirRangeIndex;
1036  Uint32 texpDirPageIndex;
1037  Uint32 tdata0;
1038  Uint32 tcheckpointid;
1039  Uint32 tciContainerptr;
1040  Uint32 tnciContainerptr;
1041  Uint32 tisoContainerptr;
1042  Uint32 trscContainerptr;
1043  Uint32 tsscContainerptr;
1044  Uint32 tciContainerlen;
1045  Uint32 trscContainerlen;
1046  Uint32 tsscContainerlen;
1047  Uint32 tciContainerhead;
1048  Uint32 tnciContainerhead;
1049  Uint32 tslElementptr;
1050  Uint32 tisoElementptr;
1051  Uint32 tsscElementptr;
1052  Uint32 tfid;
1053  Uint32 tscanFlag;
1054  Uint32 tgflBufType;
1055  Uint32 tgseIsforward;
1056  Uint32 tsscIsforward;
1057  Uint32 trscIsforward;
1058  Uint32 tciIsforward;
1059  Uint32 tnciIsforward;
1060  Uint32 tisoIsforward;
1061  Uint32 tgseIsLocked;
1062  Uint32 tsscIsLocked;
1063  Uint32 tkeylen;
1064  Uint32 tmp;
1065  Uint32 tmpP;
1066  Uint32 tmpP2;
1067  Uint32 tmp1;
1068  Uint32 tmp2;
1069  Uint32 tgflPageindex;
1070  Uint32 tmpindex;
1071  Uint32 tslNextfree;
1072  Uint32 tslPageindex;
1073  Uint32 tgsePageindex;
1074  Uint32 tnciNextSamePage;
1075  Uint32 tslPrevfree;
1076  Uint32 tciPageindex;
1077  Uint32 trsbPageindex;
1078  Uint32 tnciPageindex;
1079  Uint32 tlastPrevconptr;
1080  Uint32 tresult;
1081  Uint32 tslUpdateHeader;
1082  Uint32 tuserptr;
1083  BlockReference tuserblockref;
1084  Uint32 tlqhPointer;
1085  Uint32 tholdSentOp;
1086  Uint32 tholdMore;
1087  Uint32 tgdiPageindex;
1088  Uint32 tiopIndex;
1089  Uint32 tnciTmp;
1090  Uint32 tullIndex;
1091  Uint32 turlIndex;
1092  Uint32 tlfrTmp1;
1093  Uint32 tlfrTmp2;
1094  Uint32 tscanTrid1;
1095  Uint32 tscanTrid2;
1096 
1097  Uint32 ctest;
1098  Uint32 clqhPtr;
1099  BlockReference clqhBlockRef;
1100  Uint32 cminusOne;
1101  NodeId cmynodeid;
1102  BlockReference cownBlockref;
1103  BlockReference cndbcntrRef;
1104  Uint16 csignalkey;
1105  Uint32 czero;
1106  Uint32 cexcForward;
1107  Uint32 cexcPageindex;
1108  Uint32 cexcContainerptr;
1109  Uint32 cexcContainerhead;
1110  Uint32 cexcContainerlen;
1111  Uint32 cexcElementptr;
1112  Uint32 cexcPrevconptr;
1113  Uint32 cexcMovedLen;
1114  Uint32 cexcPrevpageptr;
1115  Uint32 cexcPrevpageindex;
1116  Uint32 cexcPrevforward;
1117  Uint32 clocalkey[32];
1118  union {
1119  Uint32 ckeys[2048 * MAX_XFRM_MULTIPLY];
1120  Uint64 ckeys_align;
1121  };
1122 
1123  Uint32 c_errorInsert3000_TableId;
1124  Uint32 c_memusage_report_frequency;
1125 };
1126 
1127 #endif