Dbtup.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:103k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef DBTUP_H
  14. #define DBTUP_H
  15. #include <pc.hpp>
  16. #include <SimulatedBlock.hpp>
  17. #include <ndb_limits.h>
  18. #include <trigger_definitions.h>
  19. #include <ArrayList.hpp>
  20. #include <AttributeHeader.hpp>
  21. #include <Bitmask.hpp>
  22. #include <signaldata/TupKey.hpp>
  23. #include <signaldata/CreateTrig.hpp>
  24. #include <signaldata/DropTrig.hpp>
  25. #include <signaldata/TrigAttrInfo.hpp>
  26. #include <signaldata/BuildIndx.hpp>
  27. #define ZWORDS_ON_PAGE 8192          /* NUMBER OF WORDS ON A PAGE.      */
  28. #define ZATTRBUF_SIZE 32             /* SIZE OF ATTRIBUTE RECORD BUFFER */
  29. #define ZMIN_PAGE_LIMIT_TUPKEYREQ 5
  30. #define ZTUP_VERSION_BITS 15
  31. #ifdef DBTUP_C
  32. //------------------------------------------------------------------
  33. // Jam Handling:
  34. //
  35. // When DBTUP reports lines through jam in the trace files it has to
  36. // be interpreted. 4024 means as an example line 24 in DbtupCommit.cpp
  37. // Thus 4000 is added to the line number beacuse it is located in the
  38. // file DbtupCommit.cpp. The following is the exhaustive list of the
  39. // added value in the various files. ndbrequire, ptrCheckGuard still
  40. // only reports the line number in the file it currently is located in.
  41. // 
  42. // DbtupExecQuery.cpp         0
  43. // DbtupBuffer.cpp         2000
  44. // DbtupRoutines.cpp       3000
  45. // DbtupCommit.cpp         5000
  46. // DbtupFixAlloc.cpp       6000
  47. // DbtupTrigger.cpp        7000
  48. // DbtupAbort.cpp          9000
  49. // DbtupLCP.cpp           10000
  50. // DbtupUndoLog.cpp       12000
  51. // DbtupPageMap.cpp       14000
  52. // DbtupPagMan.cpp        16000
  53. // DbtupStoredProcDef.cpp 18000
  54. // DbtupMeta.cpp          20000
  55. // DbtupTabDesMan.cpp     22000
  56. // DbtupGen.cpp           24000
  57. // DbtupSystemRestart.cpp 26000
  58. // DbtupIndex.cpp         28000
  59. // DbtupDebug.cpp         30000
  60. //------------------------------------------------------------------
  61. /*
  62. 2.2 LOCAL SYMBOLS
  63. -----------------
  64. */
  65. /* ---------------------------------------------------------------- */
  66. /*       S I Z E              O F               R E C O R D S       */
  67. /* ---------------------------------------------------------------- */
  68. #define ZNO_OF_ATTRBUFREC 10000             /* SIZE   OF ATTRIBUTE INFO FILE   */
  69. #define ZNO_OF_CONCURRENT_OPEN_OP 40        /* NUMBER OF CONCURRENT OPENS      */
  70. #define ZNO_OF_CONCURRENT_WRITE_OP 80       /* NUMBER OF CONCURRENT DISK WRITES*/
  71. #define ZNO_OF_FRAGOPREC 20                 /* NUMBER OF CONCURRENT ADD FRAG.  */
  72. #define ZNO_OF_LCP_REC 10                   /* NUMBER OF CONCURRENT CHECKPOINTS*/
  73. #define TOT_PAGE_RECORD_SPACE 262144        /* SIZE OF PAGE RECORD FILE.       */
  74. #define ZNO_OF_PAGE TOT_PAGE_RECORD_SPACE/ZWORDS_ON_PAGE   
  75. #define ZNO_OF_PAGE_RANGE_REC 128           /* SIZE OF PAGE RANGE FILE         */
  76. #define ZNO_OF_PARALLELL_UNDO_FILES 16      /* NUMBER OF PARALLEL UNDO FILES   */
  77. #define ZNO_OF_RESTART_INFO_REC 10          /* MAXIMUM PARALLELL RESTART INFOS */
  78.     /* 24 SEGMENTS WITH 8 PAGES IN EACH*/
  79.                     /* PLUS ONE UNDO BUFFER CACHE      */
  80. // Undo record identifiers are 32-bits with page index 13-bits
  81. #define ZUNDO_RECORD_ID_PAGE_INDEX 13    /* 13 BITS = 8192 WORDS/PAGE       */
  82. #define ZUNDO_RECORD_ID_PAGE_INDEX_MASK (ZWORDS_ON_PAGE - 1) /* 1111111111111 */
  83. // Trigger constants
  84. #define ZDEFAULT_MAX_NO_TRIGGERS_PER_TABLE 16
  85. /* ---------------------------------------------------------------- */
  86. // VARIABLE NUMBERS OF PAGE_WORD, UNDO_WORD AND LOGIC_WORD FOR
  87. // COMMUNICATION WITH FILE SYSTEM
  88. /* ---------------------------------------------------------------- */
  89. #define ZBASE_ADDR_PAGE_WORD 1              /* BASE ADDRESS OF PAGE_WORD VAR   */
  90. #define ZBASE_ADDR_UNDO_WORD 2              /* BASE ADDRESS OF UNDO_WORD VAR   */
  91. #define ZBASE_ADDR_LOGIC_WORD 3             /* BASE ADDRESS OF LOGIC_WORD VAR  */
  92. /* ---------------------------------------------------------------- */
  93. // NUMBER OF PAGES SENT TO DISK IN DATA BUFFER AND UNDO BUFFER WHEN
  94. // OPTIMUM PERFORMANCE IS ACHIEVED.
  95. /* ---------------------------------------------------------------- */
  96. #define ZUB_SEGMENT_SIZE 8                  /* SEGMENT SIZE OF UNDO BUFFER     */
  97. #define ZDB_SEGMENT_SIZE 8                  /* SEGMENT SIZE OF DATA BUFFER     */
  98. /* ---------------------------------------------------------------- */
  99. /* A ATTRIBUTE MAY BE NULL, DYNAMIC OR NORMAL. A NORMAL ATTRIBUTE   */
  100. /* IS A ATTRIBUTE THAT IS NOT NULL OR DYNAMIC. A NULL ATTRIBUTE     */
  101. /* MAY HAVE NO VALUE. A DYNAMIC ATTRIBUTE IS A NULL ATTRIBUTE THAT  */
  102. /* DOES NOT HAVE TO BE A MEMBER OF EVERY TUPLE I A CERTAIN TABLE.   */
  103. /* ---------------------------------------------------------------- */
  104. /**
  105.  * #defines moved into include/kernel/Interpreter.hpp
  106.  */
  107. #define ZMAX_REGISTER 21
  108. #define ZINSERT_DELETE 0
  109. /* ---------------------------------------------------------------- */
  110. /* THE MINIMUM SIZE OF AN 'EMPTY' TUPLE HEADER IN R-WORDS           */
  111. /* ---------------------------------------------------------------- */
  112. #define ZTUP_HEAD_MINIMUM_SIZE 2
  113.           /* THE TUPLE HEADER FIELD 'SIZE OF NULL ATTR. FIELD' SPECIFYES    */
  114.           /* THE SIZE OF THE TUPLE HEADER FIELD 'NULL ATTR. FIELD'.         */
  115.           /* THE TUPLE HEADER FIELD 'TYPE' SPECIFYES THE TYPE OF THE TUPLE  */
  116.           /* HEADER.                                                        */
  117.                                /* TUPLE ATTRIBUTE INDEX CLUSTERS, ATTRIBUTE */
  118.                                /* CLUSTERS AND A DYNAMIC ATTRIBUTE HEADER.  */
  119.                                /* IT MAY ALSO CONTAIN SHORT ATTRIBUTES AND  */
  120.                                /* POINTERS TO LONG ATTRIBUTE HEADERS.       */
  121.                                /* TUPLE ATTRIBUTE INDEX CLUSTERS, ATTRIBUTE */
  122.                                /* CLUSTERS AND A DYNAMIC ATTRIBUTE HEADER.  */
  123. #define ZTH_TYPE3 2            /* TUPLE HEADER THAT MAY HAVE A POINTER TO   */
  124.                                /* A DYNAMIC ATTRIBUTE HEADER. IT MAY ALSO   */
  125.                                /* CONTAIN SHORT ATTRIBUTES AND POINTERS     */
  126.                                /* TO LONG ATTRIBUTE HEADERS.                */
  127.           /* DATA STRUCTURE TYPES */
  128.           /* WHEN ATTRIBUTE INFO IS SENT WITH A ATTRINFO-SIGNAL THE         */
  129.           /* VARIABLE TYPE IS SPECIFYED. THIS MUST BE DONE TO BE ABLE TO    */
  130.           /* NOW HOW MUCH DATA OF A ATTRIBUTE TO READ FROM ATTRINFO.        */
  131. #define ZFIXED_ARRAY 2                             /* ZFIXED  ARRAY FIELD.                  */
  132. #define ZNON_ARRAY 1                               /* NORMAL FIELD.                         */
  133. #define ZVAR_ARRAY 0                               /* VARIABLE ARRAY FIELD                  */
  134. #define ZNOT_STORE 3                               /* THE ATTR IS STORED IN THE INDEX BLOCK */
  135. #define ZMAX_SMALL_VAR_ARRAY 256
  136.           /* PLEASE OBSERVE THAT THEESE CONSTANTS CORRESPONDS TO THE NUMBER */
  137.           /* OF BITS NEEDED TO REPRESENT THEM    D O    N O T   C H A N G E */
  138. #define Z1BIT_VAR 0                                /* 1 BIT VARIABLE.                        */
  139. #define Z2BIT_VAR 1                                /* 2 BIT VARIABLE.                        */
  140. #define Z4BIT_VAR 2                                /* 4 BIT VARIABLE.                        */
  141. #define Z8BIT_VAR 3                                /* 8 BIT VARIABLE.                        */
  142. #define Z16BIT_VAR 4                               /* 16 BIT VARIABLE.                       */
  143. #define Z32BIT_VAR 5                               /* 32 BIT VARIABLE.                       */
  144. #define Z64BIT_VAR 6                               /* 64 BIT VARIABLE.                       */
  145. #define Z128BIT_VAR 7                              /* 128 BIT VARIABLE.                      */
  146.           /* WHEN A REQUEST CAN NOT BE EXECUTED BECAUSE OF A ERROR THE      */
  147.           /* ERROR MUST BE IDENTIFYED BY MEANS OF A ERROR CODE AND SENT TO  */
  148.           /* THE REQUESTER.                                                 */
  149. #define ZGET_OPREC_ERROR 804            // TUP_SEIZEREF
  150. #define ZEXIST_FRAG_ERROR 816           // Add fragment
  151. #define ZFULL_FRAGRECORD_ERROR 817      // Add fragment
  152. #define ZNO_FREE_PAGE_RANGE_ERROR 818   // Add fragment
  153. #define ZNOFREE_FRAGOP_ERROR 830        // Add fragment
  154. #define ZTOO_LARGE_TUPLE_ERROR 851      // Add fragment
  155. #define ZNO_FREE_TAB_ENTRY_ERROR 852    // Add fragment
  156. #define ZNO_PAGES_ALLOCATED_ERROR 881   // Add fragment
  157. #define ZGET_REALPID_ERROR 809
  158. #define ZNOT_IMPLEMENTED_ERROR 812
  159. #define ZSEIZE_ATTRINBUFREC_ERROR 805
  160. #define ZTOO_MUCH_ATTRINFO_ERROR 823
  161. #define ZMEM_NOTABDESCR_ERROR 826
  162. #define ZMEM_NOMEM_ERROR 827
  163. #define ZAI_INCONSISTENCY_ERROR 829
  164. #define ZNO_ILLEGAL_NULL_ATTR 839
  165. #define ZNOT_NULL_ATTR 840
  166. #define ZNO_INSTRUCTION_ERROR 871
  167. #define ZOUTSIDE_OF_PROGRAM_ERROR 876
  168. #define ZSTORED_PROC_ID_ERROR 877
  169. #define ZREGISTER_INIT_ERROR 878
  170. #define ZATTRIBUTE_ID_ERROR 879
  171. #define ZTRY_TO_READ_TOO_MUCH_ERROR 880
  172. #define ZTOTAL_LEN_ERROR 882
  173. #define ZATTR_INTERPRETER_ERROR 883
  174. #define ZSTACK_OVERFLOW_ERROR 884
  175. #define ZSTACK_UNDERFLOW_ERROR 885
  176. #define ZTOO_MANY_INSTRUCTIONS_ERROR 886
  177. #define ZTRY_TO_UPDATE_ERROR 888
  178. #define ZCALL_ERROR 890
  179. #define ZTEMPORARY_RESOURCE_FAILURE 891
  180. #define ZSTORED_SEIZE_ATTRINBUFREC_ERROR 873 // Part of Scan
  181. #define ZREAD_ONLY_CONSTRAINT_VIOLATION 893
  182. #define ZVAR_SIZED_NOT_SUPPORTED 894
  183. #define ZINCONSISTENT_NULL_ATTRIBUTE_COUNT 895
  184. #define ZTUPLE_CORRUPTED_ERROR 896
  185. #define ZTRY_UPDATE_PRIMARY_KEY 897
  186. #define ZMUST_BE_ABORTED_ERROR 898
  187. #define ZTUPLE_DELETED_ERROR 626
  188. #define ZINSERT_ERROR 630
  189.           /* SOME WORD POSITIONS OF FIELDS IN SOME HEADERS */
  190. #define ZPAGE_STATE_POS 0                 /* POSITION OF PAGE STATE            */
  191. #define ZPAGE_NEXT_POS 1                  /* POSITION OF THE NEXT POINTER WHEN IN FREELIST     */
  192. #define ZPAGE_PREV_POS 2                  /* POSITION OF THE PREVIOUS POINTER WHEN IN FREELIST */
  193. #define ZFREELIST_HEADER_POS 3            /* POSITION OF THE FIRST FREELIST        */
  194. #define ZPAGE_FRAG_PAGE_ID_POS 4          /* POSITION OF FRAG PAGE ID WHEN USED*/
  195. #define ZPAGE_NEXT_CLUST_POS 5            /* POSITION OF NEXT FREE SET OF PAGES    */
  196. #define ZPAGE_FIRST_CLUST_POS 2           /* POSITION OF THE POINTER TO THE FIRST PAGE IN A CLUSTER */
  197. #define ZPAGE_LAST_CLUST_POS 6            /* POSITION OF THE POINTER TO THE LAST PAGE IN A CLUSTER */
  198. #define ZPAGE_PREV_CLUST_POS 7            /* POSITION OF THE PREVIOUS POINTER  */
  199. #define ZPAGE_HEADER_SIZE 32              /* NUMBER OF WORDS IN MEM  PAGEHEADER        */
  200. #define ZDISK_PAGE_HEADER_SIZE 32         /* NUMBER OF WORDS IN DISK PAGEHEADER        */
  201. #define ZNO_OF_FREE_BLOCKS 3              /* NO OF FREE BLOCK IN THE DISK PAGE         */
  202. #define ZDISK_PAGE_ID 8                   /*  ID OF THE PAGE ON THE DISK               */
  203. #define ZBLOCK_LIST 9
  204. #define ZCOPY_OF_PAGE 10
  205. #define ZPAGE_PHYSICAL_INDEX 11
  206. #define ZNEXT_IN_PAGE_USED_LIST 12
  207. #define ZPREV_IN_PAGE_USED_LIST 13
  208. #define ZDISK_USED_TYPE 14
  209. #define ZFREE_COMMON 1                    /* PAGE STATE, PAGE IN COMMON AREA                   */
  210. #define ZEMPTY_MM 2                       /* PAGE STATE, PAGE IN EMPTY LIST                    */
  211. #define ZTH_MM_FREE 3                     /* PAGE STATE, TUPLE HEADER PAGE WITH FREE AREA      */
  212. #define ZTH_MM_FULL 4                     /* PAGE STATE, TUPLE HEADER PAGE WHICH IS FULL       */
  213. #define ZAC_MM_FREE 5                     /* PAGE STATE, ATTRIBUTE CLUSTER PAGE WITH FREE AREA */
  214. #define ZTH_MM_FREE_COPY 7                /* PAGE STATE, TH COPY PAGE WITH FREE AREA           */
  215. #define ZTH_MM_FULL_COPY 8                /* PAGE STATE, TH COPY PAGE WHICH IS FULL            */
  216. #define ZAC_MM_FREE_COPY 9                /* PAGE STATE, AC COPY PAGE WITH FREE AREA           */
  217. #define ZMAX_NO_COPY_PAGES 4              /* THE MAXIMUM NUMBER OF COPY PAGES ALLOWED PER FRAGMENT */
  218.           /* CONSTANTS USED TO HANDLE TABLE DESCRIPTOR RECORDS                   */
  219.           /* ALL POSITIONS AND SIZES IS BASED ON R-WORDS (32-BIT ON APZ 212)     */
  220. #define ZTD_HEADER 0                      /* HEADER POSITION                   */
  221. #define ZTD_DATASIZE 1                    /* SIZE OF THE DATA IN THIS CHUNK    */
  222. #define ZTD_SIZE 2                        /* TOTAL SIZE OF TABLE DESCRIPTOR    */
  223.           /* TRAILER POSITIONS FROM END OF TABLE DESCRIPTOR RECORD               */
  224. #define ZTD_TR_SIZE 1                     /* SIZE DESCRIPTOR POS FROM END+1    */
  225. #define ZTD_TR_TYPE 2
  226. #define ZTD_TRAILER_SIZE 2                /* TOTAL SIZE OF TABLE TRAILER       */
  227. #define ZAD_SIZE 2                        /* TOTAL SIZE OF ATTR DESCRIPTOR     */
  228. #define ZAD_LOG_SIZE 1                    /* TWO LOG OF TOTAL SIZE OF ATTR DESCRIPTOR     */
  229.           /* CONSTANTS USED TO HANDLE TABLE DESCRIPTOR AS A FREELIST             */
  230. #define ZTD_FL_HEADER 0                   /* HEADER POSITION                   */
  231. #define ZTD_FL_SIZE 1                     /* TOTAL SIZE OF THIS FREELIST ENTRY */
  232. #define ZTD_FL_PREV 2                     /* PREVIOUS RECORD IN FREELIST       */
  233. #define ZTD_FL_NEXT 3                     /* NEXT RECORD IN FREELIST           */
  234. #define ZTD_FREE_SIZE 16                  /* SIZE NEEDED TO HOLD ONE FL ENTRY  */
  235.           /* CONSTANTS USED IN LSB OF TABLE DESCRIPTOR HEADER DESCRIBING USAGE   */
  236. #define ZTD_TYPE_FREE 0                   /* RECORD LINKED INTO FREELIST       */
  237. #define ZTD_TYPE_NORMAL 1                 /* RECORD USED AS TABLE DESCRIPTOR   */
  238.           /* ATTRIBUTE OPERATION CONSTANTS */
  239. #define ZLEAF 1
  240. #define ZNON_LEAF 2
  241.           /* ATTRINBUFREC VARIABLE POSITIONS. */
  242. #define ZBUF_PREV 29                      /* POSITION OF 'PREV'-VARIABLE (USED BY INTERPRETED EXEC) */
  243. #define ZBUF_DATA_LEN 30                  /* POSITION OF 'DATA LENGTH'-VARIABLE. */
  244. #define ZBUF_NEXT 31                      /* POSITION OF 'NEXT'-VARIABLE.        */
  245. #define ZSAVE_BUF_NEXT 28
  246. #define ZSAVE_BUF_DATA_LEN 27
  247.           /* RETURN POINTS. */
  248.           /* RESTART PHASES */
  249. #define ZSTARTPHASE1 1
  250. #define ZSTARTPHASE2 2
  251. #define ZSTARTPHASE3 3
  252. #define ZSTARTPHASE4 4
  253. #define ZSTARTPHASE6 6
  254. #define ZADDFRAG 0
  255.           /* CHECKPOINT RECORD TYPES */
  256. #define ZLCPR_TYPE_INSERT_TH 0             /* INSERT TUPLE HEADER                             */
  257. #define ZLCPR_TYPE_DELETE_TH 1             /* DELETE TUPLE HEADER                             */
  258. #define ZLCPR_TYPE_UPDATE_TH 2             /* DON'T CREATE IT, JUST UPDETE                    */
  259. #define ZLCPR_TYPE_INSERT_TH_NO_DATA 3     /* INSERT TUPLE HEADER                             */
  260. #define ZLCPR_ABORT_UPDATE 4               /* UNDO AN UPDATE OPERATION THAT WAS ACTIVE IN LCP */
  261. #define ZLCPR_ABORT_INSERT 5               /* UNDO AN INSERT OPERATION THAT WAS ACTIVE IN LCP */
  262. #define ZTABLE_DESCRIPTOR 6                /* TABLE DESCRIPTOR                                */
  263. #define ZINDICATE_NO_OP_ACTIVE 7           /* ENSURE THAT NO OPERATION ACTIVE AFTER RESTART   */
  264. #define ZLCPR_UNDO_LOG_PAGE_HEADER 8       /* CHANGE IN PAGE HEADER IS UNDO LOGGED            */
  265. #define ZLCPR_TYPE_UPDATE_GCI 9            /* Update GCI at commit time                       */
  266. #define ZNO_CHECKPOINT_RECORDS 10          /* NUMBER OF CHECKPOINTRECORD TYPES                */
  267.           /* RESULT CODES            */
  268.           /* ELEMENT POSITIONS IN SYSTEM RESTART INFO PAGE OF THE DATA FILE */
  269. #define ZSRI_NO_OF_FRAG_PAGES_POS 10       /* NUMBER OF FRAGMENT PAGES WHEN CHECKPOINT STARTED   */
  270. #define ZSRI_TUP_RESERVED_SIZE_POS 11      /* RESERVED SIZE OF THE TUPLE WHEN CP STARTED         */
  271. #define ZSRI_TUP_FIXED_AREA_POS 12         /* SIZE OF THE TUPLE FIXED AREA WHEN CP STARTED       */
  272. #define ZSRI_TAB_DESCR_SIZE 13             /* SIZE OF THE TABLE DESCRIPTOR WHEN CP STARTED       */
  273. #define ZSRI_NO_OF_ATTRIBUTES_POS 14       /* NUMBER OF ATTRIBUTES                               */
  274. #define ZSRI_UNDO_LOG_END_REC_ID 15        /* LAST UNDO LOG RECORD ID FOR THIS CHECKPOINT        */
  275. #define ZSRI_UNDO_LOG_END_PAGE_ID 16       /* LAST USED LOG PAGE ID FOR THIS CHECKPOINT          */
  276. #define ZSRI_TH_FREE_FIRST 17              /* FIRST FREE PAGE OF TUPLE HEADERS                   */
  277. #define ZSRI_TH_FREE_COPY_FIRST 18         /* FIRST FREE PAGE OF TUPLE HEADER COPIES             */
  278. #define ZSRI_EMPTY_PRIM_PAGE 27            /* FIRST EMPTY PAGE                                   */
  279. #define ZSRI_NO_COPY_PAGES_ALLOC 28        /* NO COPY PAGES IN FRAGMENT AT LOCAL CHECKPOINT      */
  280. #define ZSRI_UNDO_FILE_VER 29              /* CHECK POINT ID OF THE UNDO FILE                    */
  281. #define ZSRI_NO_OF_INDEX_ATTR 30           /* No of index attributes                             */
  282. #define ZNO_OF_PAGES_CLUSTER_REC 0
  283. //------------------------------------------------------------
  284. // TUP_CONTINUEB codes
  285. //------------------------------------------------------------
  286. #define ZSTART_EXEC_UNDO_LOG 0
  287. #define ZCONT_START_SAVE_CL 1
  288. #define ZCONT_SAVE_DP 2
  289. #define ZCONT_EXECUTE_LC 3
  290. #define ZCONT_LOAD_DP 4
  291. #define ZLOAD_BAL_LCP_TIMER 5
  292. #define ZINITIALISE_RECORDS 6
  293. #define ZREL_FRAG 7
  294. #define ZREPORT_MEMORY_USAGE 8
  295. #define ZBUILD_INDEX 9
  296. #define ZINDEX_STORAGE 0
  297. #define ZDATA_WORD_AT_DISK_PAGE 2030
  298. #define ZALLOC_DISK_PAGE_LAST_INDEX 2047
  299. #define ZWORD_IN_BLOCK 127                 /* NO OF WORD IN A BLOCK */
  300. #define ZNO_DISK_PAGES_FILE_REC 100
  301. #define ZMASK_PAGE_INDEX 0x7ff
  302. #define ZBIT_PAGE_INDEX 11                 /* 8 KBYT PAGE = 2048 WORDS */
  303. #define ZSCAN_PROCEDURE 0
  304. #define ZCOPY_PROCEDURE 2
  305. #define ZSTORED_PROCEDURE_DELETE 3
  306. #define ZSTORED_PROCEDURE_FREE 0xffff
  307. #define ZMIN_PAGE_LIMIT_TUP_COMMITREQ 2
  308. #define ZUNDO_PAGE_HEADER_SIZE 2           /* SIZE OF UNDO PAGE HEADER     */
  309. #endif
  310. class Dbtup: public SimulatedBlock {
  311. public:
  312.   typedef bool (Dbtup::* ReadFunction)(Uint32*,
  313.                                        AttributeHeader*,
  314.                                        Uint32,
  315.                                        Uint32);
  316.   typedef bool (Dbtup::* UpdateFunction)(Uint32*,
  317.                                          Uint32,
  318.                                          Uint32);
  319. // State values
  320. enum State {
  321.   NOT_INITIALIZED = 0,
  322.   COMMON_AREA_PAGES = 1,
  323.   UNDO_RESTART_PAGES = 2,
  324.   UNDO_PAGES = 3,
  325.   READ_ONE_PAGE = 4,
  326.   CHECKPOINT_DATA_READ = 7,
  327.   CHECKPOINT_DATA_READ_PAGE_ZERO = 8,
  328.   CHECKPOINT_DATA_WRITE = 9,
  329.   CHECKPOINT_DATA_WRITE_LAST = 10,
  330.   CHECKPOINT_DATA_WRITE_FLUSH = 11,
  331.   CHECKPOINT_UNDO_READ = 12,
  332.   CHECKPOINT_UNDO_READ_FIRST = 13,
  333.   CHECKPOINT_UNDO_WRITE = 14,
  334.   CHECKPOINT_UNDO_WRITE_FLUSH = 15,
  335.   CHECKPOINT_TD_READ = 16,
  336.   IDLE = 17,
  337.   ACTIVE = 18,
  338.   SYSTEM_RESTART = 19,
  339.   NO_OTHER_OP = 20,
  340.   COMMIT_DELETE = 21,
  341.   TO_BE_COMMITTED = 22,
  342.   ABORTED = 23,
  343.   ALREADY_ABORTED_INSERT = 24,
  344.   ALREADY_ABORTED = 25,
  345.   ABORT_INSERT = 26,
  346.   ABORT_UPDATE = 27,
  347.   INIT = 28,
  348.   INITIAL_READ = 29,
  349.   INTERPRETED_EXECUTION = 30,
  350.   FINAL_READ = 31,
  351.   FINAL_UPDATE = 32,
  352.   DISCONNECTED = 33,
  353.   DEFINED = 34,
  354.   ERROR_WAIT_TUPKEYREQ = 35,
  355.   STARTED = 36,
  356.   NOT_DEFINED = 37,
  357.   COMPLETED = 38,
  358.   WAIT_ABORT = 39,
  359.   NORMAL_PAGE = 40,
  360.   COPY_PAGE = 41,
  361.   DELETE_BLOCK = 42,
  362.   WAIT_STORED_PROCEDURE_ATTR_INFO = 43,
  363.   DATA_FILE_READ = 45,
  364.   DATA_FILE_WRITE = 46,
  365.   LCP_DATA_FILE_READ = 47,
  366.   LCP_DATA_FILE_WRITE = 48,
  367.   LCP_DATA_FILE_WRITE_WITH_UNDO = 49,
  368.   LCP_DATA_FILE_CLOSE = 50,
  369.   LCP_UNDO_FILE_READ = 51,
  370.   LCP_UNDO_FILE_CLOSE = 52,
  371.   LCP_UNDO_FILE_WRITE = 53,
  372.   OPENING_DATA_FILE = 54,
  373.   INITIATING_RESTART_INFO = 55,
  374.   INITIATING_FRAGMENT = 56,
  375.   OPENING_UNDO_FILE = 57,
  376.   READING_RESTART_INFO = 58,
  377.   INIT_UNDO_SEGMENTS = 59,
  378.   READING_TAB_DESCR = 60,
  379.   READING_DATA_PAGES = 61,
  380.   WAIT_COPY_PROCEDURE = 62,
  381.   TOO_MUCH_AI = 63,
  382.   SAME_PAGE = 64,
  383.   DEFINING = 65,
  384.   TUPLE_BLOCKED = 66,
  385.   ERROR_WAIT_STORED_PROCREQ = 67
  386. };
  387. // Records
  388. /* ************** ATTRIBUTE INFO BUFFER RECORD ****************** */
  389. /* THIS RECORD IS USED AS A BUFFER FOR INCOMING AND OUTGOING DATA */
  390. /* ************************************************************** */
  391. struct Attrbufrec {
  392.   Uint32 attrbuf[ZATTRBUF_SIZE];
  393. }; /* p2c: size = 128 bytes */
  394. typedef Ptr<Attrbufrec> AttrbufrecPtr;
  395. /* ********** CHECKPOINT INFORMATION ************ */
  396. /* THIS RECORD HOLDS INFORMATION NEEDED TO        */
  397. /* PERFORM A CHECKPOINT. IT'S POSSIBLE TO RUN     */
  398. /* MULTIPLE CHECKPOINTS AT A TIME. THIS RECORD    */
  399. /* MAKES IT POSSIBLE TO DISTINGER BETWEEN THE     */
  400. /* DIFFERENT CHECKPOINTS.                         */
  401. /* ********************************************** */
  402. struct CheckpointInfo {
  403.   Uint32 lcpNextRec;                           /* NEXT RECORD IN FREELIST                          */
  404.   Uint32 lcpCheckpointVersion;                 /* VERSION OF THE CHECKPOINT                        */
  405.   Uint32 lcpLocalLogInfoP;                     /* POINTER TO A LOCAL LOG INFO RECORD               */
  406.   Uint32 lcpUserptr;                           /* USERPOINTER TO THE BLOCK REQUESTING THE CP       */
  407.   Uint32 lcpFragmentP;                         /* FRAGMENT POINTER TO WHICH THE CHECKPOINT APPLIES */
  408.   Uint32 lcpFragmentId;                        /* FRAGMENT ID                                      */
  409.   Uint32 lcpTabPtr;                            /* TABLE POINTER                                    */
  410.   Uint32 lcpDataBufferSegmentP;                /* POINTER TO A DISK BUFFER SEGMENT POINTER (DATA)  */
  411.   Uint32 lcpDataFileHandle;   /* FILE HANDLES FOR DATA FILE. LOG FILE HANDLE IN LOCAL_LOG_INFO_RECORD */
  412.                                               /* FILE HANDLE TO THE OPEN DATA FILE                */
  413.   Uint32 lcpNoOfPages;
  414.   Uint32 lcpThFreeFirst;
  415.   Uint32 lcpThFreeCopyFirst;
  416.   Uint32 lcpEmptyPrimPage;
  417.   Uint32 lcpNoCopyPagesAlloc;
  418.   Uint32 lcpTmpOperPtr;                        /* TEMPORARY STORAGE OF OPER_PTR DURING SAVE        */
  419.   BlockReference lcpBlockref;                       /* BLOCKREFERENCE TO THE BLOCK REQUESTING THE CP    */
  420. };
  421. typedef Ptr<CheckpointInfo> CheckpointInfoPtr;
  422. /* *********** DISK BUFFER SEGMENT INFO ********* */
  423. /* THIS RECORD HOLDS INFORMATION NEEDED DURING    */
  424. /* A WRITE OF THE DATA BUFFER TO DISK. WHEN THE   */
  425. /* WRITE SIGNAL IS SENT A POINTER TO THIS RECORD  */
  426. /* IS INCLUDED. WHEN THE WRITE IS COMPLETED AND   */
  427. /* CONFIRMED THE PTR TO THIS RECORD IS RETURNED   */
  428. /* AND THE BUFFER PAGES COULD EASILY BE LOCATED   */
  429. /* AND DEALLOCATED. THE CHECKPOINT_INFO_VERSION   */
  430. /* KEEPS TRACK OF THE CHECPOINT_INFO_RECORD THAT  */
  431. /* INITIATED THE WRITE AND THE CP_PAGE_TO_DISK    */
  432. /* ELEMENT COULD BE INCREASED BY THE NUMBER OF    */
  433. /* PAGES WRITTEN.                                 */
  434. /* ********************************************** */
  435. struct DiskBufferSegmentInfo {
  436.   Uint32 pdxDataPage[16];                     /* ARRAY OF DATA BUFFER PAGES */
  437.   Uint32 pdxUndoBufferSet[2];
  438.   Uint32 pdxNextRec;
  439.   State pdxBuffertype;
  440.   State pdxOperation;
  441.              /*---------------------------------------------------------------------------*/
  442.              /* PDX_FLAGS BITS AND THEIR USAGE:                                           */
  443.              /* BIT    0                    1                      COMMENT                */
  444.              /*---------------------------------------------------------------------------*/
  445.              /* 0      SEGMENT INVALID      SEGMENT VALID          USED DURING READS      */
  446.              /* 1-15                                               NOT USED               */
  447.              /*---------------------------------------------------------------------------*/
  448.   Uint32 pdxCheckpointInfoP;                  /* USED DURING LOCAL CHKP     */
  449.   Uint32 pdxRestartInfoP;                     /* USED DURING RESTART        */
  450.   Uint32 pdxLocalLogInfoP;                    /* POINTS TO A LOCAL LOG INFO */
  451.   Uint32 pdxFilePage;                         /* START PAGE IN FILE         */
  452.   Uint32 pdxNumDataPages;                     /* NUMBER OF DATA PAGES       */
  453. };
  454. typedef Ptr<DiskBufferSegmentInfo> DiskBufferSegmentInfoPtr;
  455. struct Fragoperrec {
  456.   bool   definingFragment;
  457.   Uint32 nextFragoprec;
  458.   Uint32 lqhPtrFrag;
  459.   Uint32 fragidFrag;
  460.   Uint32 tableidFrag;
  461.   Uint32 fragPointer;
  462.   Uint32 attributeCount;
  463.   Uint32 freeNullBit;
  464.   Uint32 noOfNewAttrCount;
  465.   Uint32 charsetIndex;
  466.   BlockReference lqhBlockrefFrag;
  467.   bool inUse;
  468. };
  469. typedef Ptr<Fragoperrec> FragoperrecPtr;
  470. struct Fragrecord {
  471.   Uint32 nextStartRange;
  472.   Uint32 currentPageRange;
  473.   Uint32 rootPageRange;
  474.   Uint32 noOfPages;
  475.   Uint32 emptyPrimPage;
  476.   Uint32 firstusedOprec;
  477.   Uint32 lastusedOprec;
  478.   Uint32 thFreeFirst;
  479.   Uint32 thFreeCopyFirst;
  480.   Uint32 noCopyPagesAlloc;
  481.   Uint32 checkpointVersion;
  482.   Uint32 minPageNotWrittenInCheckpoint;
  483.   Uint32 maxPageWrittenInCheckpoint;
  484.   State fragStatus;
  485.   Uint32 fragTableId;
  486.   Uint32 fragmentId;
  487.   Uint32 nextfreefrag;
  488. };
  489. typedef Ptr<Fragrecord> FragrecordPtr;
  490.           /* ************ LOCAL LOG FILE INFO ************* */
  491.           /* THIS RECORD HOLDS INFORMATION NEEDED DURING    */
  492.           /* CHECKPOINT AND RESTART. THERE ARE FOUR         */
  493.           /* PARALLELL UNDO LOG FILES, EACH ONE REPRESENTED */
  494.           /* BY AN ENTITY OF THIS RECORD.                   */
  495.           /* BECAUSE EACH FILE IS SHARED BETWEEN FOUR       */
  496.           /* TABLES AND HAS ITS OWN PAGEPOINTERS AND        */
  497.           /* WORDPOINTERS.                                  */
  498.           /* ********************************************** */
  499. struct LocalLogInfo {
  500.   Uint32 lliActiveLcp;                                   /* NUMBER OF ACTIVE LOCAL CHECKPOINTS ON THIS FILE */
  501.   Uint32 lliEndPageId;                                   /* PAGE IDENTIFIER OF LAST PAGE WITH LOG DATA      */
  502.   Uint32 lliPrevRecordId;                                /* PREVIOUS RECORD IN THIS LOGFILE                 */
  503.   Uint32 lliLogFilePage;                                 /* PAGE IN LOGFILE                                 */
  504.   Uint32 lliNumFragments;                                /* NO OF FRAGMENTS RESTARTING FROM THIS LOCAL LOG  */
  505.   Uint32 lliUndoBufferSegmentP;                          /* POINTER TO A DISK BUFFER SEGMENT POINTER (UNDO) */
  506.   Uint32 lliUndoFileHandle;                              /* FILE HANDLE OF UNDO LOG FILE                    */
  507.   Uint32 lliUndoPage;                                    /* UNDO PAGE IN BUFFER                             */
  508.   Uint32 lliUndoWord;
  509.   Uint32 lliUndoPagesToDiskWithoutSynch;
  510. };
  511. typedef Ptr<LocalLogInfo> LocalLogInfoPtr;
  512. struct Operationrec {
  513. // Easy to remove (2 words)
  514.   Uint32 attroutbufLen;
  515.   Uint32 logSize;
  516. // Needed (20 words)
  517.   State tupleState;
  518.   Uint32 prevActiveOp;
  519.   Uint32 nextActiveOp;
  520.   Uint32 nextOprecInList;
  521.   Uint32 prevOprecInList;
  522.   Uint32 tableRef;
  523.   Uint32 fragId;
  524.   Uint32 fragmentPtr;
  525.   Uint32 fragPageId;
  526.   Uint32 realPageId;
  527.   bool undoLogged;
  528.   Uint32 realPageIdC;
  529.   Uint32 fragPageIdC;
  530.   Uint32 firstAttrinbufrec;
  531.   Uint32 lastAttrinbufrec;
  532.   Uint32 attrinbufLen;
  533.   Uint32 currentAttrinbufLen;
  534.   Uint32 userpointer;
  535.   State transstate;
  536.   Uint32 savePointId;
  537. // Easy to remove (3 words)
  538.   Uint32 tcOperationPtr;
  539.   Uint32 transid1;
  540.   Uint32 transid2;
  541. // Needed (2 words)
  542.   Uint16 pageIndex;
  543.   Uint16 pageOffset;
  544.   Uint16 pageOffsetC;
  545.   Uint16 pageIndexC;
  546. // Hard to remove
  547.   Uint16 tupVersion;
  548. // Easy to remove (1.5 word)
  549.   BlockReference recBlockref;
  550.   BlockReference userblockref;
  551.   Uint16 storedProcedureId;
  552.   Uint8 inFragList;
  553.   Uint8 inActiveOpList;
  554.   Uint8 deleteInsertFlag;
  555. // Needed (1 word)
  556.   Uint8 dirtyOp;
  557.   Uint8 interpretedExec;
  558.   Uint8 optype;
  559.   Uint8 opSimple;
  560. // Used by triggers
  561.   Uint32 primaryReplica;
  562.   BlockReference coordinatorTC;
  563.   Uint32 tcOpIndex;
  564.   Uint32 gci;
  565.   Uint32 noFiredTriggers;
  566.   union {
  567.     Uint32 hashValue; // only used in TUP_COMMITREQ
  568.     Uint32 lastRow;
  569.   };
  570.   Bitmask<MAXNROFATTRIBUTESINWORDS> changeMask;
  571. };
  572. typedef Ptr<Operationrec> OperationrecPtr;
  573. struct Page {
  574.   Uint32 pageWord[ZWORDS_ON_PAGE];
  575. };
  576. typedef Ptr<Page> PagePtr;
  577.           /* ****************************** PAGE RANGE RECORD ************************** */
  578.           /* PAGE RANGES AND BASE PAGE ID. EACH RANGE HAS A  CORRESPONDING BASE PAGE ID  */
  579.           /* THAT IS USED TO  CALCULATE REAL PAGE ID FROM A FRAGMENT PAGE ID AND A TABLE */
  580.           /* REFERENCE.                                                                  */
  581.           /* THE PAGE RANGES ARE ORGANISED IN A B-TREE FASHION WHERE THE VARIABLE TYPE   */
  582.           /* SPECIFIES IF A LEAF NODE HAS BEEN REACHED. IF A LEAF NODE HAS BEEN REACHED  */
  583.           /* THEN BASE_PAGE_ID IS THE BASE_PAGE_ID OF THE SET OF PAGES THAT WAS          */
  584.           /* ALLOCATED IN THAT RANGE. OTHERWISE BASE_PAGE_ID IS THE POINTER TO THE NEXT  */
  585.           /* PAGE_RANGE RECORD.                                                          */
  586.           /* *************************************************************************** */
  587. struct PageRange {
  588.   Uint32 startRange[4];                                  /* START OF RANGE                                   */
  589.   Uint32 endRange[4];                                    /* END OF THIS RANGE                                */
  590.   Uint32 basePageId[4];                                  /* BASE PAGE ID.                                    */
  591. /*----               VARIABLE BASE_PAGE_ID2 (4) 8 DS NEEDED WHEN SUPPORTING 40 BIT PAGE ID           -------*/
  592.   Uint8 type[4];                                        /* TYPE OF BASE PAGE ID                             */
  593.   Uint32 nextFree;                                       /* NEXT FREE PAGE RANGE RECORD                      */
  594.   Uint32 parentPtr;                                      /* THE PARENT TO THE PAGE RANGE REC IN THE B-TREE   */
  595.   Uint8 currentIndexPos;
  596. };
  597. typedef Ptr<PageRange> PageRangePtr;
  598.           /* *********** PENDING UNDO WRITE INFO ********** */
  599.           /* THIS RECORD HOLDS INFORMATION NEEDED DURING    */
  600.           /* A FILE OPEN OPERATION                          */
  601.           /* IF THE FILE OPEN IS A PART OF A CHECKPOINT THE */
  602.           /* CHECKPOINT_INFO_P WILL HOLD A POINTER TO THE   */
  603.           /* CHECKPOINT_INFOR_PTR RECORD                    */
  604.           /* IF IT IS A PART OF RESTART THE PFO_RESTART_INFO*/
  605.           /* ELEMENT WILL POINT TO A RESTART INFO RECORD    */
  606.           /* ********************************************** */
  607. struct PendingFileOpenInfo {
  608.   Uint32 pfoNextRec;
  609.   State pfoOpenType;
  610.   Uint32 pfoCheckpointInfoP;
  611.   Uint32 pfoRestartInfoP;
  612. };
  613. typedef Ptr<PendingFileOpenInfo> PendingFileOpenInfoPtr;
  614. struct RestartInfoRecord {
  615.   Uint32 sriNextRec;
  616.   State sriState;                                       /* BLOCKREFERENCE TO THE REQUESTING BLOCK           */
  617.   Uint32 sriUserptr;                                     /* USERPOINTER TO THE REQUESTING BLOCK              */
  618.   Uint32 sriDataBufferSegmentP;                          /* POINTER TO A DISK BUFFER SEGMENT POINTER (DATA)  */
  619.   Uint32 sriDataFileHandle;                              /* FILE HANDLE TO THE OPEN DATA FILE                */
  620.   Uint32 sriCheckpointVersion;                           /* CHECKPOINT VERSION TO RESTART FROM               */
  621.   Uint32 sriFragid;                                      /* FRAGMENT ID                                      */
  622.   Uint32 sriFragP;                                       /* FRAGMENT POINTER                                 */
  623.   Uint32 sriTableId;                                     /* TABLE ID                                         */
  624.   Uint32 sriLocalLogInfoP;                               /* POINTER TO A LOCAL LOG INFO RECORD               */
  625.   Uint32 sriNumDataPages;                                /* NUMBER OF DATA PAGES TO READ                     */
  626.   Uint32 sriCurDataPageFromBuffer;                       /* THE CHECKPOINT IS COMPLETED                      */
  627.   BlockReference sriBlockref;
  628. };
  629. typedef Ptr<RestartInfoRecord> RestartInfoRecordPtr;
  630.   /* ************* TRIGGER DATA ************* */
  631.   /* THIS RECORD FORMS LISTS OF ACTIVE       */
  632.   /* TRIGGERS FOR EACH TABLE.                 */
  633.   /* THE RECORDS ARE MANAGED BY A TRIGGER     */
  634.   /* POOL wHERE A TRIGGER RECORD IS SEIZED    */
  635.   /* WHEN A TRIGGER IS ACTIVATED AND RELEASED */
  636.   /* WHEN THE TRIGGER IS DEACTIVATED.         */
  637.   /* **************************************** */
  638. struct TupTriggerData {
  639.   
  640.   /**
  641.    * Trigger id, used by DICT/TRIX to identify the trigger
  642.    */
  643.   Uint32 triggerId;
  644.   /**
  645.    * Index id is needed for ordered index.
  646.    */
  647.   Uint32 indexId;
  648.   /**
  649.    * Trigger type etc, defines what the trigger is used for
  650.    */
  651.   TriggerType::Value triggerType;
  652.   TriggerActionTime::Value triggerActionTime;
  653.   TriggerEvent::Value triggerEvent;
  654.   /**
  655.    * Receiver block
  656.    */
  657.   Uint32 m_receiverBlock;
  658.   
  659.   /**
  660.    * Monitor all replicas, i.e. trigger will fire on all nodes where tuples
  661.    * are stored
  662.    */
  663.   bool monitorReplicas;
  664.   /**
  665.    * Monitor all attributes, the trigger monitors all changes to attributes 
  666.    * in the table
  667.    */
  668.   bool monitorAllAttributes;
  669.   /**
  670.    * Send only changed attributes at trigger firing time.
  671.    */
  672.   bool sendOnlyChangedAttributes;
  673.   /**
  674.    * Send also before values at trigger firing time.
  675.    */
  676.   bool sendBeforeValues;
  677.   /**
  678.    * Attribute mask, defines what attributes are to be monitored
  679.    * Can be seen as a compact representation of SQL column name list
  680.    */
  681.   Bitmask<MAXNROFATTRIBUTESINWORDS> attributeMask;
  682.   
  683.   /**
  684.    * Next ptr (used in pool/list)
  685.    */
  686.   union {
  687.     Uint32 nextPool;
  688.     Uint32 nextList;
  689.   };
  690.   
  691.   /**
  692.    * Prev pointer (used in list)
  693.    */
  694.   Uint32 prevList;
  695.   inline void print(NdbOut & s) const { s << "[TriggerData = " << triggerId << "]"; };
  696. };
  697. typedef Ptr<TupTriggerData> TriggerPtr;
  698.   
  699. /**
  700.  * Pool of trigger data record
  701.  */
  702. ArrayPool<TupTriggerData> c_triggerPool;
  703.           /* ************ TABLE RECORD ************ */
  704.           /* THIS RECORD FORMS A LIST OF TABLE      */
  705.           /* REFERENCE INFORMATION. ONE RECORD      */
  706.           /* PER TABLE REFERENCE.                   */
  707.           /* ************************************** */
  708. struct Tablerec {
  709.   Tablerec(ArrayPool<TupTriggerData> & triggerPool) : 
  710.     afterInsertTriggers(triggerPool),
  711.     afterDeleteTriggers(triggerPool),
  712.     afterUpdateTriggers(triggerPool),
  713.     subscriptionInsertTriggers(triggerPool),
  714.     subscriptionDeleteTriggers(triggerPool),
  715.     subscriptionUpdateTriggers(triggerPool),
  716.     constraintUpdateTriggers(triggerPool),
  717.     tuxCustomTriggers(triggerPool)
  718.   {}
  719.   Bitmask<MAXNROFATTRIBUTESINWORDS> notNullAttributeMask;
  720.   ReadFunction* readFunctionArray;
  721.   UpdateFunction* updateFunctionArray;
  722.   CHARSET_INFO** charsetArray;
  723.   Uint32 readKeyArray;
  724.   Uint32 tabDescriptor;
  725.   Uint32 attributeGroupDescriptor;
  726.   bool   GCPIndicator;
  727.   bool   checksumIndicator;
  728.   Uint16 tupheadsize;
  729.   Uint16 noOfAttr;
  730.   Uint16 noOfKeyAttr;
  731.   Uint16 noOfCharsets;
  732.   Uint16 noOfNewAttr;
  733.   Uint16 noOfNullAttr;
  734.   Uint16 noOfAttributeGroups;
  735.   Uint8  tupChecksumIndex;
  736.   Uint8  tupNullIndex;
  737.   Uint8  tupNullWords;
  738.   Uint8  tupGCPIndex;
  739.   // Lists of trigger data for active triggers
  740.   ArrayList<TupTriggerData> afterInsertTriggers;
  741.   ArrayList<TupTriggerData> afterDeleteTriggers;
  742.   ArrayList<TupTriggerData> afterUpdateTriggers;
  743.   ArrayList<TupTriggerData> subscriptionInsertTriggers;
  744.   ArrayList<TupTriggerData> subscriptionDeleteTriggers;
  745.   ArrayList<TupTriggerData> subscriptionUpdateTriggers;
  746.   ArrayList<TupTriggerData> constraintUpdateTriggers;
  747.   // List of ordered indexes
  748.   ArrayList<TupTriggerData> tuxCustomTriggers;
  749.   Uint32 fragid[2 * MAX_FRAG_PER_NODE];
  750.   Uint32 fragrec[2 * MAX_FRAG_PER_NODE];
  751.   struct {
  752.     Uint32 tabUserPtr;
  753.     Uint32 tabUserRef;
  754.   } m_dropTable;
  755.   State tableStatus;
  756. };
  757. typedef Ptr<Tablerec> TablerecPtr;
  758. struct storedProc {
  759.   Uint32 storedLinkFirst;
  760.   Uint32 storedLinkLast;
  761.   Uint32 storedCounter;
  762.   Uint32 nextPool;
  763.   Uint16 storedCode;
  764.   Uint16 storedProcLength;
  765. };
  766. typedef Ptr<storedProc> StoredProcPtr;
  767. ArrayPool<storedProc> c_storedProcPool;
  768. /* **************************** TABLE_DESCRIPTOR RECORD ******************************** */
  769. /* THIS VARIABLE IS USED TO STORE TABLE DESCRIPTIONS. A TABLE DESCRIPTION IS STORED AS A */
  770. /* CONTIGUOS ARRAY IN THIS VARIABLE. WHEN A NEW TABLE IS ADDED A CHUNK IS ALLOCATED IN   */
  771. /* THIS RECORD. WHEN ATTRIBUTES ARE ADDED TO THE TABLE, A NEW CHUNK OF PROPER SIZE IS    */
  772. /* ALLOCATED AND ALL DATA IS COPIED TO THIS NEW CHUNK AND THEN THE OLD CHUNK IS PUT IN   */
  773. /* THE FREE LIST. EACH TABLE IS DESCRIBED BY A NUMBER OF TABLE DESCRIPTIVE ATTRIBUTES    */
  774. /* AND A NUMBER OF ATTRIBUTE DESCRIPTORS AS SHOWN IN FIGURE BELOW                        */
  775. /*                                                                                       */
  776. /* WHEN ALLOCATING A TABLE DESCRIPTOR THE SIZE IS ALWAYS A MULTIPLE OF 16 WORDS.         */
  777. /*                                                                                       */
  778. /*               ----------------------------------------------                          */
  779. /*               |    TRAILER USED FOR ALLOC/DEALLOC          |                          */
  780. /*               ----------------------------------------------                          */
  781. /*               |    TABLE DESCRIPTIVE ATTRIBUTES            |                          */
  782. /*               ----------------------------------------------                          */
  783. /*               |    ATTRIBUTE DESCRIPTION 1                 |                          */
  784. /*               ----------------------------------------------                          */
  785. /*               |    ATTRIBUTE DESCRIPTION 2                 |                          */
  786. /*               ----------------------------------------------                          */
  787. /*               |                                            |                          */
  788. /*               |                                            |                          */
  789. /*               |                                            |                          */
  790. /*               ----------------------------------------------                          */
  791. /*               |    ATTRIBUTE DESCRIPTION N                 |                          */
  792. /*               ----------------------------------------------                          */
  793. /*                                                                                       */
  794. /* THE TABLE DESCRIPTIVE ATTRIBUTES CONTAINS THE FOLLOWING ATTRIBUTES:                   */
  795. /*                                                                                       */
  796. /*               ----------------------------------------------                          */
  797. /*               |    HEADER (TYPE OF INFO)                   |                          */
  798. /*               ----------------------------------------------                          */
  799. /*               |    SIZE OF WHOLE CHUNK (INCL. TRAILER)     |                          */
  800. /*               ----------------------------------------------                          */
  801. /*               |    TABLE IDENTITY                          |                          */
  802. /*               ----------------------------------------------                          */
  803. /*               |    FRAGMENT IDENTITY                       |                          */
  804. /*               ----------------------------------------------                          */
  805. /*               |    NUMBER OF ATTRIBUTES                    |                          */
  806. /*               ----------------------------------------------                          */
  807. /*               |    SIZE OF FIXED ATTRIBUTES                |                          */
  808. /*               ----------------------------------------------                          */
  809. /*               |    NUMBER OF NULL FIELDS                   |                          */
  810. /*               ----------------------------------------------                          */
  811. /*               |    NOT USED                                |                          */
  812. /*               ----------------------------------------------                          */
  813. /*                                                                                       */
  814. /* THESE ATTRIBUTES ARE ALL ONE R-VARIABLE IN THE RECORD.                                */
  815. /* NORMALLY ONLY ONE TABLE DESCRIPTOR IS USED. DURING SCHEMA CHANGES THERE COULD         */
  816. /* HOWEVER EXIST MORE THAN ONE TABLE DESCRIPTION SINCE THE SCHEMA CHANGE OF VARIOUS      */
  817. /* FRAGMENTS ARE NOT SYNCHRONISED. THIS MEANS THAT ALTHOUGH THE SCHEMA HAS CHANGED       */
  818. /* IN ALL FRAGMENTS, BUT THE FRAGMENTS HAVE NOT REMOVED THE ATTRIBUTES IN THE SAME       */
  819. /* TIME-FRAME. THEREBY SOME ATTRIBUTE INFORMATION MIGHT DIFFER BETWEEN FRAGMENTS.        */
  820. /* EXAMPLES OF ATTRIBUTES THAT MIGHT DIFFER ARE SIZE OF FIXED ATTRIBUTES, NUMBER OF      */
  821. /* ATTRIBUTES, FIELD START WORD, START BIT.                                              */
  822. /*                                                                                       */
  823. /* AN ATTRIBUTE DESCRIPTION CONTAINS THE FOLLOWING ATTRIBUTES:                           */
  824. /*                                                                                       */
  825. /*               ----------------------------------------------                          */
  826. /*               |    Field Type, 4 bits (LSB Bits)           |                          */
  827. /*               ----------------------------------------------                          */
  828. /*               |    Attribute Size, 4 bits                  |                          */
  829. /*               ----------------------------------------------                          */
  830. /*               |    NULL indicator 1 bit                    |                          */
  831. /*               ----------------------------------------------                          */
  832. /*               |    Indicator if TUP stores attr. 1 bit     |                          */
  833. /*               ----------------------------------------------                          */
  834. /*               |    Not used 6 bits                         |                          */
  835. /*               ----------------------------------------------                          */
  836. /*               |    No. of elements in fixed array 16 bits  |                          */
  837. /*               ----------------------------------------------                          */
  838. /*               ----------------------------------------------                          */
  839. /*               |    Field Start Word, 21 bits (LSB Bits)    |                          */
  840. /*               ----------------------------------------------                          */
  841. /*               |    NULL Bit, 11 bits                       |                          */
  842. /*               ----------------------------------------------                          */
  843. /*                                                                                       */
  844. /* THE ATTRIBUTE SIZE CAN BE 1,2,4,8,16,32,64 AND 128 BITS.                              */
  845. /*                                                                                       */
  846. /* THE UNUSED PARTS OF THE RECORDS ARE PUT IN A LINKED LIST OF FREE PARTS. EACH OF       */
  847. /* THOSE FREE PARTS HAVE THREE RECORDS ASSIGNED AS SHOWN IN THIS STRUCTURE               */
  848. /* ALL FREE PARTS ARE SET INTO A CHUNK LIST WHERE EACH CHUNK IS AT LEAST 16 WORDS        */
  849. /*                                                                                       */
  850. /*               ----------------------------------------------                          */
  851. /*               |    HEADER = RNIL                           |                          */
  852. /*               ----------------------------------------------                          */
  853. /*               |    SIZE OF FREE AREA                       |                          */
  854. /*               ----------------------------------------------                          */
  855. /*               |    POINTER TO PREVIOUS FREE AREA           |                          */
  856. /*               ----------------------------------------------                          */
  857. /*               |    POINTER TO NEXT FREE AREA               |                          */
  858. /*               ----------------------------------------------                          */
  859. /*                                                                                       */
  860. /* IF THE POINTER TO THE NEXT AREA IS RNIL THEN THIS IS THE LAST FREE AREA.              */
  861. /*                                                                                       */
  862. /*****************************************************************************************/
  863. struct TableDescriptor {
  864.   Uint32 tabDescr;
  865. };
  866. typedef Ptr<TableDescriptor> TableDescriptorPtr;
  867. struct HostBuffer {
  868.   bool  inPackedList;
  869.   Uint32 packetLenTA;
  870.   Uint32 noOfPacketsTA;
  871.   Uint32 packetBufferTA[30];
  872. };
  873. typedef Ptr<HostBuffer> HostBufferPtr;
  874.           /* **************** UNDO PAGE RECORD ******************* */
  875.           /* THIS RECORD FORMS AN UNDO PAGE CONTAINING A NUMBER OF */
  876.           /* DATA WORDS. CURRENTLY THERE ARE 2048 WORDS ON A PAGE  */
  877.           /* EACH OF 32 BITS (4 BYTES) WHICH FORMS AN UNDO PAGE    */
  878.           /* WITH A TOTAL OF 8192 BYTES                            */
  879.           /* ***************************************************** */
  880. struct UndoPage {
  881.   Uint32 undoPageWord[ZWORDS_ON_PAGE]; /* 32 KB */
  882. };
  883. typedef Ptr<UndoPage> UndoPagePtr;
  884.   /*
  885.    * Build index operation record.
  886.    */
  887.   struct BuildIndexRec {
  888.     // request cannot use signal class due to extra members
  889.     Uint32 m_request[BuildIndxReq::SignalLength];
  890.     Uint32 m_triggerPtrI;       // the index trigger
  891.     Uint32 m_fragNo;            // fragment number under Tablerec
  892.     Uint32 m_pageId;            // logical fragment page id
  893.     Uint32 m_tupleNo;           // tuple number on page (pageIndex >> 1)
  894.     BuildIndxRef::ErrorCode m_errorCode;
  895.     union {
  896.       Uint32 nextPool;
  897.       Uint32 nextList;
  898.     };
  899.     Uint32 prevList;
  900.   };
  901.   typedef Ptr<BuildIndexRec> BuildIndexPtr;
  902.   ArrayPool<BuildIndexRec> c_buildIndexPool;
  903.   ArrayList<BuildIndexRec> c_buildIndexList;
  904.   Uint32 c_noOfBuildIndexRec;
  905. public:
  906.   Dbtup(const class Configuration &);
  907.   virtual ~Dbtup();
  908.   /*
  909.    * TUX uses logical tuple address when talking to ACC and LQH.
  910.    */
  911.   void tuxGetTupAddr(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32& tupAddr);
  912.   /*
  913.    * TUX index in TUP has single Uint32 array attribute which stores an
  914.    * index node.  TUX reads and writes the node directly via pointer.
  915.    */
  916.   int tuxAllocNode(Signal* signal, Uint32 fragPtrI, Uint32& pageId, Uint32& pageOffset, Uint32*& node);
  917.   void tuxFreeNode(Signal* signal, Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32* node);
  918.   void tuxGetNode(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32*& node);
  919.   /*
  920.    * TUX reads primary table attributes for index keys.  Tuple is
  921.    * specified by location of original tuple and version number.  Input
  922.    * is attribute ids in AttributeHeader format.  Output is attribute
  923.    * data with headers.  Uses readAttributes with xfrm option set.
  924.    * Returns number of words or negative (-terrorCode) on error.
  925.    */
  926.   int tuxReadAttrs(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32 tupVersion, const Uint32* attrIds, Uint32 numAttrs, Uint32* dataOut);
  927.   /*
  928.    * TUX reads primary key without headers into an array of words.  Used
  929.    * for md5 summing and when returning keyinfo.  Returns number of
  930.    * words or negative (-terrorCode) on error.
  931.    */
  932.   int tuxReadPk(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32* dataOut);
  933.   /*
  934.    * TUX checks if tuple is visible to scan.
  935.    */
  936.   bool tuxQueryTh(Uint32 fragPtrI, Uint32 tupAddr, Uint32 tupVersion, Uint32 transId1, Uint32 transId2, Uint32 savePointId);
  937. private:
  938.   BLOCK_DEFINES(Dbtup);
  939.   // Transit signals
  940.   void execDEBUG_SIG(Signal* signal);
  941.   void execCONTINUEB(Signal* signal);
  942.   // Received signals
  943.   void execDUMP_STATE_ORD(Signal* signal);
  944.   void execSEND_PACKED(Signal* signal);
  945.   void execSTTOR(Signal* signal);
  946.   void execTUP_LCPREQ(Signal* signal);
  947.   void execEND_LCPREQ(Signal* signal);
  948.   void execSTART_RECREQ(Signal* signal);
  949.   void execMEMCHECKREQ(Signal* signal);
  950.   void execTUPSEIZEREQ(Signal* signal);
  951.   void execTUPRELEASEREQ(Signal* signal);
  952.   void execSTORED_PROCREQ(Signal* signal);
  953.   void execTUPFRAGREQ(Signal* signal);
  954.   void execTUP_ADD_ATTRREQ(Signal* signal);
  955.   void execTUP_COMMITREQ(Signal* signal);
  956.   void execTUP_ABORTREQ(Signal* signal);
  957.   void execTUP_SRREQ(Signal* signal);
  958.   void execTUP_PREPLCPREQ(Signal* signal);
  959.   void execFSOPENCONF(Signal* signal);
  960.   void execFSCLOSECONF(Signal* signal);
  961.   void execFSWRITECONF(Signal* signal);
  962.   void execFSREADCONF(Signal* signal);
  963.   void execNDB_STTOR(Signal* signal);
  964.   void execREAD_CONFIG_REQ(Signal* signal);
  965.   void execSET_VAR_REQ(Signal* signal);
  966.   void execDROP_TAB_REQ(Signal* signal);
  967.   void execALTER_TAB_REQ(Signal* signal);
  968.   void execFSREMOVECONF(Signal* signal);
  969.   void execTUP_ALLOCREQ(Signal* signal);
  970.   void execTUP_DEALLOCREQ(Signal* signal);
  971.   void execTUP_WRITELOG_REQ(Signal* signal);
  972.   // Ordered index related
  973.   void execBUILDINDXREQ(Signal* signal);
  974.   void buildIndex(Signal* signal, Uint32 buildPtrI);
  975.   void buildIndexReply(Signal* signal, const BuildIndexRec* buildRec);
  976. //------------------------------------------------------------------
  977. //------------------------------------------------------------------
  978. // Methods to handle execution of TUPKEYREQ + ATTRINFO.
  979. //
  980. // Module Execution Manager
  981. //
  982. // The TUPKEYREQ signal is central to this block. This signal is used
  983. // by everybody that needs to read data residing in DBTUP. The data is
  984. // read using an interpreter approach.
  985. //
  986. // Operations only needing to read execute a simplified version of the
  987. // interpreter where the only instruction is read Attribute to send.
  988. // Operations only needing to update the record (insert or update)
  989. // execute a simplified version of the interpreter where the only
  990. // instruction is write Attribute.
  991. //
  992. // Currently TUPKEYREQ is used in the following situations.
  993. // 1) Normal transaction execution. Can be any of the types described
  994. //    below.
  995. // 2) Execution of fragment redo log during system restart.
  996. //    In this situation there will only be normal updates, inserts
  997. //    and deletes performed.
  998. // 3) A special type of normal transaction execution is to write the
  999. //    records arriving from the primary replica in the node restart
  1000. //    processing. This will always be normal write operations which
  1001. //    are translated to inserts or updates before arriving to TUP.
  1002. // 4) Scan processing. The scan processing will use normal reads or
  1003. //    interpreted reads in their execution. There will be one TUPKEYREQ
  1004. //    signal for each record processed.
  1005. // 5) Copy fragment processing. This is a special type of scan used in the
  1006. //    primary replica at system restart. It reads the entire reads and
  1007. //    converts those to writes to the starting node. In this special case
  1008. //    LQH acts as an API node and receives also the ATTRINFO sent in the
  1009. //    TRANSID_AI signals.
  1010. //
  1011. // Signal Diagram:
  1012. //
  1013. // In Signals:
  1014. // -----------
  1015. //
  1016. // Logically there is one request TUPKEYREQ which requests to read/write data
  1017. // of one tuple in the database. Since the definition of what to read and write
  1018. // can be bigger than the maximum signal size we segment the signal. The definition
  1019. // of what to read/write/interpreted program is sent before the TUPKEYREQ signal.
  1020. //
  1021. // ---> ATTRINFO
  1022. // ...
  1023. // ---> ATTRINFO
  1024. // ---> TUPKEYREQ
  1025. // The number of ATTRINFO signals can be anything between 0 and upwards.
  1026. // The total size of the ATTRINFO is not allowed to be more than 16384 words.
  1027. // There is always one and only one TUPKEYREQ.
  1028. //
  1029. // Response Signals (successful case):
  1030. //
  1031. // Simple/Dirty Read Operation
  1032. // ---------------------------
  1033. //
  1034. // <---- TRANSID_AI (to API)
  1035. // ...
  1036. // <---- TRANSID_AI (to API)
  1037. // <---- READCONF   (to API)
  1038. // <---- TUPKEYCONF (to LQH)
  1039. // There is always exactly one READCONF25 sent last. The number of
  1040. // TRANSID_AI is dependent on how much that was read. The maximum size
  1041. // of the ATTRINFO sent back is 16384 words. The signals are sent
  1042. // directly to the application with an address provided by the
  1043. // TUPKEYREQ signal.
  1044. // A positive response signal is also sent to LQH.
  1045. //
  1046. // Normal Read Operation
  1047. // ---------------------
  1048. //
  1049. // <---- TRANSID_AI (to API)
  1050. // ...
  1051. // <---- TRANSID_AI (to API)
  1052. // <---- TUPKEYCONF (to LQH)
  1053. // The number of TRANSID_AI is dependent on how much that was read.
  1054. // The maximum size of the ATTRINFO sent back is 16384 words. The
  1055. // signals are sent directly to the application with an address
  1056. // provided by the TUPKEYREQ signal.
  1057. // A positive response signal is also sent to LQH.
  1058. //
  1059. // Normal update/insert/delete operation
  1060. // -------------------------------------
  1061. //
  1062. // <---- TUPKEYCONF
  1063. // After successful updating of the tuple LQH is informed of this.
  1064. //
  1065. // Delete with read
  1066. // ----------------
  1067. //
  1068. // Will behave as a normal read although it also prepares the
  1069. // deletion of the tuple.
  1070. //
  1071. // Interpreted Update
  1072. // ------------------
  1073. //
  1074. // <---- TRANSID_AI (to API)
  1075. // ...
  1076. // <---- TRANSID_AI (to API)
  1077. // <---- TUP_ATTRINFO (to LQH)
  1078. // ...
  1079. // <---- TUP_ATTRINFO (to LQH)
  1080. // <---- TUPKEYCONF (to LQH)
  1081. //
  1082. // The interpreted Update contains five sections:
  1083. // The first section performs read Attribute operations
  1084. // that send results back to the API.
  1085. //
  1086. // The second section executes the interpreted program
  1087. // where data from attributes can be updated and it
  1088. // can also read attribute values into the registers.
  1089. //
  1090. // The third section performs unconditional updates of
  1091. // attributes.
  1092. //
  1093. // The fourth section can read the attributes to be sent to the
  1094. // API after updating the record.
  1095. //
  1096. // The fifth section contains subroutines used by the interpreter
  1097. // in the second section.
  1098. //
  1099. // All types of interpreted programs contains the same five sections.
  1100. // The only difference is that only interpreted updates can update
  1101. // attributes. Interpreted inserts are not allowed.
  1102. //
  1103. // Interpreted Updates have to send back the information about the
  1104. // attributes they have updated. This information will be shipped to
  1105. // the log and also to any other replicas. Thus interpreted updates
  1106. // are only performed in the primary replica. The fragment redo log
  1107. // in LQH will contain information so that normal update/inserts/deletes
  1108. // can be performed using TUPKEYREQ.
  1109. //
  1110. // Interpreted Read
  1111. // ----------------
  1112. //
  1113. // From a signalling point of view the Interpreted Read behaves as
  1114. // as a Normal Read. The interpreted Read is often used by Scan's.
  1115. //
  1116. // Interpreted Delete
  1117. // ------------------
  1118. //
  1119. // <---- TUPKEYCONF
  1120. // After successful prepartion to delete the tuple LQH is informed
  1121. // of this.
  1122. //
  1123. // Interpreted Delete with Read
  1124. // ----------------------------
  1125. //
  1126. // From a signalling point of view an interpreted delete with read
  1127. // behaves as a normal read.
  1128. //
  1129. // Continuation after successful case:
  1130. //
  1131. // After a read of any kind the operation record is ready to be used
  1132. // again by a new operation.
  1133. //
  1134. // Any updates, inserts or deletes waits for either of two messages.
  1135. // A commit specifying that the operation is to be performed for real
  1136. // or an abort specifying that the operation is to be rolled back and
  1137. // the record to be restored in its original format.
  1138. // 
  1139. // This is handled by the module Transaction Manager.
  1140. //
  1141. // Response Signals (unsuccessful case):
  1142. //
  1143. // <---- TUPKEYREF (to LQH)
  1144. // A signal is sent back to LQH informing about the unsuccessful
  1145. // operation. In this case TUP waits for an abort signal to arrive
  1146. // before the operation record is ready for the next operation.
  1147. // This is handled by the Transaction Manager.
  1148. //------------------------------------------------------------------
  1149. //------------------------------------------------------------------
  1150. // *****************************************************************
  1151. // Signal Reception methods.
  1152. // *****************************************************************
  1153. //------------------------------------------------------------------
  1154. //------------------------------------------------------------------
  1155.   void execTUPKEYREQ(Signal* signal);
  1156. //------------------------------------------------------------------
  1157. //------------------------------------------------------------------
  1158.   void execATTRINFO(Signal* signal);
  1159. // Trigger signals
  1160. //------------------------------------------------------------------
  1161. //------------------------------------------------------------------
  1162.   void execCREATE_TRIG_REQ(Signal* signal);
  1163. //------------------------------------------------------------------
  1164. //------------------------------------------------------------------
  1165.   void execDROP_TRIG_REQ(Signal* signal);
  1166. // *****************************************************************
  1167. // Support methods for ATTRINFO.
  1168. // *****************************************************************
  1169. //------------------------------------------------------------------
  1170. //------------------------------------------------------------------
  1171.   void handleATTRINFOforTUPKEYREQ(Signal* signal,
  1172.                                   Uint32 length,
  1173.                                   Operationrec * const regOperPtr);
  1174. // *****************************************************************
  1175. // Setting up the environment for reads, inserts, updates and deletes.
  1176. // *****************************************************************
  1177. //------------------------------------------------------------------
  1178. //------------------------------------------------------------------
  1179.   int handleReadReq(Signal* signal,
  1180.                     Operationrec* const regOperPtr,
  1181.                     Tablerec* const regTabPtr,
  1182.                     Page* pagePtr);
  1183. //------------------------------------------------------------------
  1184. //------------------------------------------------------------------
  1185.   int handleUpdateReq(Signal* signal,
  1186.                       Operationrec* const regOperPtr,
  1187.                       Fragrecord* const regFragPtr,
  1188.                       Tablerec* const regTabPtr,
  1189.                       Page* const pagePtr);
  1190. //------------------------------------------------------------------
  1191. //------------------------------------------------------------------
  1192.   int handleInsertReq(Signal* signal,
  1193.                       Operationrec* const regOperPtr,
  1194.                       Fragrecord* const regFragPtr,
  1195.                       Tablerec* const regTabPtr,
  1196.                       Page* const pagePtr);
  1197. //------------------------------------------------------------------
  1198. //------------------------------------------------------------------
  1199.   int handleDeleteReq(Signal* signal,
  1200.                       Operationrec* const regOperPtr,
  1201.                       Fragrecord* const regFragPtr,
  1202.                       Tablerec* const regTabPtr,
  1203.                       Page* const pagePtr);
  1204. //------------------------------------------------------------------
  1205. //------------------------------------------------------------------
  1206.   int  updateStartLab(Signal* signal,
  1207.                       Operationrec* const regOperPtr,
  1208.                       Tablerec* const regTabPtr,
  1209.                       Page* const pagePtr);
  1210. // *****************************************************************
  1211. // Interpreter Handling methods.
  1212. // *****************************************************************
  1213. //------------------------------------------------------------------
  1214. //------------------------------------------------------------------
  1215.   int interpreterStartLab(Signal* signal,
  1216.                           Page* const pagePtr,
  1217.                           Uint32 TupHeadOffset);
  1218. //------------------------------------------------------------------
  1219. //------------------------------------------------------------------
  1220.   int interpreterNextLab(Signal* signal,
  1221.                          Page* const pagePtr,
  1222.                          Uint32 TupHeadOffset,
  1223.                          Uint32* logMemory,
  1224.                          Uint32* mainProgram,
  1225.                          Uint32 TmainProgLen,
  1226.                          Uint32* subroutineProg,
  1227.                          Uint32 TsubroutineLen,
  1228.  Uint32 * tmpArea,
  1229.  Uint32 tmpAreaSz);
  1230. // *****************************************************************
  1231. // Signal Sending methods.
  1232. // *****************************************************************
  1233. //------------------------------------------------------------------
  1234. //------------------------------------------------------------------
  1235.   void sendReadAttrinfo(Signal* signal,
  1236.                         Uint32 TnoOfData,
  1237.                         const Operationrec * const regOperPtr);
  1238. //------------------------------------------------------------------
  1239. //------------------------------------------------------------------
  1240.   void sendLogAttrinfo(Signal* signal,
  1241.                        Uint32 TlogSize,
  1242.                        Operationrec * const regOperPtr);
  1243. //------------------------------------------------------------------
  1244. //------------------------------------------------------------------
  1245.   void sendTUPKEYCONF(Signal* signal, Operationrec * 
  1246.                       const regOperPtr, 
  1247.                       Uint32 TlogSize);
  1248. //------------------------------------------------------------------
  1249. //------------------------------------------------------------------
  1250. // *****************************************************************
  1251. // The methods that perform the actual read and update of attributes
  1252. // in the tuple.
  1253. // *****************************************************************
  1254. //------------------------------------------------------------------
  1255. //------------------------------------------------------------------
  1256.   int readAttributes(Page* const pagePtr,
  1257.                      Uint32   TupHeadOffset,
  1258.                      const Uint32*  inBuffer,
  1259.                      Uint32   inBufLen,
  1260.                      Uint32*  outBuffer,
  1261.                      Uint32   TmaxRead,
  1262.                      bool     xfrmFlag);
  1263. //------------------------------------------------------------------
  1264. //------------------------------------------------------------------
  1265.   int readAttributesWithoutHeader(Page* const pagePtr,
  1266.                                   Uint32   TupHeadOffset,
  1267.                                   Uint32*  inBuffer,
  1268.                                   Uint32   inBufLen,
  1269.                                   Uint32*  outBuffer,
  1270.                                   Uint32*  attrBuffer,
  1271.                                   Uint32   TmaxRead);
  1272. //------------------------------------------------------------------
  1273. //------------------------------------------------------------------
  1274.   int updateAttributes(Page* const pagePtr,
  1275.                        Uint32      TupHeadOffset,
  1276.                        Uint32*     inBuffer,
  1277.                        Uint32      inBufLen);
  1278. //------------------------------------------------------------------
  1279. //------------------------------------------------------------------
  1280.   bool readFixedSizeTHOneWordNotNULL(Uint32* outBuffer,
  1281.                                      AttributeHeader* ahOut,
  1282.                                      Uint32  attrDescriptor,
  1283.                                      Uint32  attrDes2);
  1284. //------------------------------------------------------------------
  1285. //------------------------------------------------------------------
  1286.   bool updateFixedSizeTHOneWordNotNULL(Uint32* inBuffer,
  1287.                                        Uint32  attrDescriptor,
  1288.                                        Uint32  attrDes2);
  1289. //------------------------------------------------------------------
  1290. //------------------------------------------------------------------
  1291.   bool readFixedSizeTHTwoWordNotNULL(Uint32* outBuffer,
  1292.                                      AttributeHeader* ahOut,
  1293.                                      Uint32  attrDescriptor,
  1294.                                      Uint32  attrDes2);
  1295. //------------------------------------------------------------------
  1296. //------------------------------------------------------------------
  1297.   bool updateFixedSizeTHTwoWordNotNULL(Uint32* inBuffer,
  1298.                                        Uint32  attrDescriptor,
  1299.                                        Uint32  attrDes2);
  1300. //------------------------------------------------------------------
  1301. //------------------------------------------------------------------
  1302.   bool readFixedSizeTHManyWordNotNULL(Uint32* outBuffer,
  1303.                                       AttributeHeader* ahOut,
  1304.                                       Uint32  attrDescriptor,
  1305.                                       Uint32  attrDes2);
  1306. //------------------------------------------------------------------
  1307. //------------------------------------------------------------------
  1308.   bool updateFixedSizeTHManyWordNotNULL(Uint32* inBuffer,
  1309.                                         Uint32  attrDescriptor,
  1310.                                         Uint32  attrDes2);
  1311. //------------------------------------------------------------------
  1312. //------------------------------------------------------------------
  1313.   bool readFixedSizeTHOneWordNULLable(Uint32* outBuffer,
  1314.                                       AttributeHeader* ahOut,
  1315.                                       Uint32  attrDescriptor,
  1316.                                       Uint32  attrDes2);
  1317. //------------------------------------------------------------------
  1318. //------------------------------------------------------------------
  1319.   bool updateFixedSizeTHOneWordNULLable(Uint32* inBuffer,
  1320.                                         Uint32  attrDescriptor,
  1321.                                         Uint32  attrDes2);
  1322. //------------------------------------------------------------------
  1323. //------------------------------------------------------------------
  1324.   bool readFixedSizeTHTwoWordNULLable(Uint32* outBuffer,
  1325.                                       AttributeHeader* ahOut,
  1326.                                       Uint32  attrDescriptor,
  1327.                                       Uint32  attrDes2);
  1328. //------------------------------------------------------------------
  1329. //------------------------------------------------------------------
  1330.   bool updateFixedSizeTHTwoWordNULLable(Uint32* inBuffer,
  1331.                                         Uint32  attrDescriptor,
  1332.                                         Uint32  attrDes2);
  1333. //------------------------------------------------------------------
  1334. //------------------------------------------------------------------
  1335.   bool readFixedSizeTHManyWordNULLable(Uint32* outBuffer,
  1336.                                        AttributeHeader* ahOut,
  1337.                                        Uint32  attrDescriptor,
  1338.                                        Uint32  attrDes2);
  1339. //------------------------------------------------------------------
  1340. //------------------------------------------------------------------
  1341.   bool readFixedSizeTHZeroWordNULLable(Uint32* outBuffer,
  1342.                                        AttributeHeader* ahOut,
  1343.                                        Uint32  attrDescriptor,
  1344.                                        Uint32  attrDes2);
  1345. //------------------------------------------------------------------
  1346. //------------------------------------------------------------------
  1347.   bool updateFixedSizeTHManyWordNULLable(Uint32* inBuffer,
  1348.                                          Uint32  attrDescriptor,
  1349.                                          Uint32  attrDes2);
  1350. //------------------------------------------------------------------
  1351. //------------------------------------------------------------------
  1352.   bool readVariableSizedAttr(Uint32* outBuffer,
  1353.                              AttributeHeader* ahOut,
  1354.                              Uint32  attrDescriptor,
  1355.                              Uint32  attrDes2);
  1356. //------------------------------------------------------------------
  1357. //------------------------------------------------------------------
  1358.   bool updateVariableSizedAttr(Uint32* inBuffer,
  1359.                                Uint32  attrDescriptor,
  1360.                                Uint32  attrDes2);
  1361. //------------------------------------------------------------------
  1362. //------------------------------------------------------------------
  1363.   bool readVarSizeUnlimitedNotNULL(Uint32* outBuffer,
  1364.                                    AttributeHeader* ahOut,
  1365.                                    Uint32  attrDescriptor,
  1366.                                    Uint32  attrDes2);
  1367. //------------------------------------------------------------------
  1368. //------------------------------------------------------------------
  1369.   bool updateVarSizeUnlimitedNotNULL(Uint32* inBuffer,
  1370.                                      Uint32  attrDescriptor,
  1371.                                      Uint32  attrDes2);
  1372. //------------------------------------------------------------------
  1373. //------------------------------------------------------------------
  1374.   bool readVarSizeUnlimitedNULLable(Uint32* outBuffer,
  1375.                                     AttributeHeader* ahOut,
  1376.                                     Uint32  attrDescriptor,
  1377.                                     Uint32  attrDes2);
  1378. //------------------------------------------------------------------
  1379. //------------------------------------------------------------------
  1380.   bool updateVarSizeUnlimitedNULLable(Uint32* inBuffer,
  1381.                                       Uint32  attrDescriptor,
  1382.                                       Uint32  attrDes2);
  1383. //------------------------------------------------------------------
  1384. //------------------------------------------------------------------
  1385.   bool readBigVarSizeNotNULL(Uint32* outBuffer,
  1386.                              AttributeHeader* ahOut,
  1387.                              Uint32  attrDescriptor,
  1388.                              Uint32  attrDes2);
  1389. //------------------------------------------------------------------
  1390. //------------------------------------------------------------------
  1391.   bool updateBigVarSizeNotNULL(Uint32* inBuffer,
  1392.                                Uint32  attrDescriptor,
  1393.                                Uint32  attrDes2);
  1394. //------------------------------------------------------------------
  1395. //------------------------------------------------------------------
  1396.   bool readBigVarSizeNULLable(Uint32* outBuffer,
  1397.                               AttributeHeader* ahOut,
  1398.                               Uint32  attrDescriptor,
  1399.                               Uint32  attrDes2);
  1400. //------------------------------------------------------------------
  1401. //------------------------------------------------------------------
  1402.   bool updateBigVarSizeNULLable(Uint32* inBuffer,
  1403.                                 Uint32  attrDescriptor,
  1404.                                 Uint32  attrDes2);
  1405. //------------------------------------------------------------------
  1406. //------------------------------------------------------------------
  1407.   bool readSmallVarSizeNotNULL(Uint32* outBuffer,
  1408.                                AttributeHeader* ahOut,
  1409.                                Uint32  attrDescriptor,
  1410.                                Uint32  attrDes2);
  1411. //------------------------------------------------------------------
  1412. //------------------------------------------------------------------
  1413.   bool updateSmallVarSizeNotNULL(Uint32* inBuffer,
  1414.                                  Uint32  attrDescriptor,
  1415.                                  Uint32  attrDes2);
  1416. //------------------------------------------------------------------
  1417. //------------------------------------------------------------------
  1418.   bool readSmallVarSizeNULLable(Uint32* outBuffer,
  1419.                                 AttributeHeader* ahOut,
  1420.                                 Uint32  attrDescriptor,
  1421.                                 Uint32  attrDes2);
  1422. //------------------------------------------------------------------
  1423. //------------------------------------------------------------------
  1424.   bool updateSmallVarSizeNULLable(Uint32* inBuffer,
  1425.                                   Uint32  attrDescriptor,
  1426.                                   Uint32  attrDes2);
  1427. //------------------------------------------------------------------
  1428. //------------------------------------------------------------------
  1429.   bool readDynFixedSize(Uint32* outBuffer,
  1430.                         AttributeHeader* ahOut,
  1431.                         Uint32  attrDescriptor,
  1432.                         Uint32  attrDes2);
  1433. //------------------------------------------------------------------
  1434. //------------------------------------------------------------------
  1435.   bool updateDynFixedSize(Uint32* inBuffer,
  1436.                           Uint32  attrDescriptor,
  1437.                           Uint32  attrDes2);
  1438. //------------------------------------------------------------------
  1439. //------------------------------------------------------------------
  1440.   bool readDynVarSizeUnlimited(Uint32* outBuffer,
  1441.                                AttributeHeader* ahOut,
  1442.                                Uint32  attrDescriptor,
  1443.                                Uint32  attrDes2);
  1444. //------------------------------------------------------------------
  1445. //------------------------------------------------------------------
  1446.   bool updateDynVarSizeUnlimited(Uint32* inBuffer,
  1447.                                  Uint32  attrDescriptor,
  1448.                                  Uint32  attrDes2);
  1449. //------------------------------------------------------------------
  1450. //------------------------------------------------------------------
  1451.   bool readDynBigVarSize(Uint32* outBuffer,
  1452.                          AttributeHeader* ahOut,
  1453.                          Uint32  attrDescriptor,
  1454.                          Uint32  attrDes2);
  1455. //------------------------------------------------------------------
  1456. //------------------------------------------------------------------
  1457.   bool updateDynBigVarSize(Uint32* inBuffer,
  1458.                            Uint32  attrDescriptor,
  1459.                            Uint32  attrDes2);
  1460. //------------------------------------------------------------------
  1461. //------------------------------------------------------------------
  1462.   bool readDynSmallVarSize(Uint32* outBuffer,
  1463.                            AttributeHeader* ahOut,
  1464.                            Uint32  attrDescriptor,
  1465.                            Uint32  attrDes2);
  1466. //------------------------------------------------------------------
  1467. //------------------------------------------------------------------
  1468.   bool updateDynSmallVarSize(Uint32* inBuffer,
  1469.                              Uint32  attrDescriptor,
  1470.                              Uint32  attrDes2);
  1471. // *****************************************************************
  1472. // Read char routines optionally (tXfrmFlag) apply strxfrm
  1473. // *****************************************************************
  1474.   bool readCharNotNULL(Uint32* outBuffer,
  1475.                        AttributeHeader* ahOut,
  1476.                        Uint32  attrDescriptor,
  1477.                        Uint32  attrDes2);
  1478.   bool readCharNULLable(Uint32* outBuffer,
  1479.                         AttributeHeader* ahOut,
  1480.                         Uint32  attrDescriptor,
  1481.                         Uint32  attrDes2);
  1482. //------------------------------------------------------------------
  1483. //------------------------------------------------------------------
  1484.   bool nullFlagCheck(Uint32  attrDes2);
  1485.   Uint32 read_psuedo(Uint32 attrId, Uint32* outBuffer);
  1486. //------------------------------------------------------------------
  1487. //------------------------------------------------------------------
  1488.   void setUpQueryRoutines(Tablerec* const regTabPtr);
  1489. // *****************************************************************
  1490. // Service methods.
  1491. // *****************************************************************
  1492. //------------------------------------------------------------------
  1493. //------------------------------------------------------------------
  1494.   void copyAttrinfo(Signal* signal, Operationrec * const regOperPtr, Uint32*  inBuffer);
  1495. //------------------------------------------------------------------
  1496. //------------------------------------------------------------------
  1497.   void initOpConnection(Operationrec* regOperPtr, Fragrecord*);
  1498. //------------------------------------------------------------------
  1499. //------------------------------------------------------------------
  1500.   void initOperationrec(Signal* signal);
  1501. //------------------------------------------------------------------
  1502. //------------------------------------------------------------------
  1503.   int initStoredOperationrec(Operationrec* const regOperPtr,
  1504.                              Uint32 storedId);
  1505. //------------------------------------------------------------------
  1506. //------------------------------------------------------------------
  1507.   void insertActiveOpList(Signal* signal, 
  1508.                           OperationrecPtr regOperPtr,
  1509.                           Page * const pagePtr,
  1510.                           Uint32 pageOffset);
  1511. //------------------------------------------------------------------
  1512. //------------------------------------------------------------------
  1513.   void linkOpIntoFragList(OperationrecPtr regOperPtr,
  1514.                           Fragrecord* const regFragPtr);
  1515. //------------------------------------------------------------------
  1516. //------------------------------------------------------------------
  1517.   void bufferTRANSID_AI(Signal* signal, BlockReference aRef, Uint32 Tlen);
  1518. //------------------------------------------------------------------
  1519. // Trigger handling routines
  1520. //------------------------------------------------------------------
  1521.   ArrayList<TupTriggerData>* findTriggerList(Tablerec* table,
  1522.                                              TriggerType::Value ttype,
  1523.                                              TriggerActionTime::Value ttime,
  1524.                                              TriggerEvent::Value tevent);
  1525.   bool createTrigger(Tablerec* table, const CreateTrigReq* req);
  1526.   Uint32 dropTrigger(Tablerec* table, const DropTrigReq* req);
  1527.   void checkImmediateTriggersAfterInsert(Signal* signal, 
  1528.                                          Operationrec* const regOperPtr, 
  1529.                                          Tablerec* const tablePtr);
  1530.   void checkImmediateTriggersAfterUpdate(Signal* signal, 
  1531.                                          Operationrec* const regOperPtr, 
  1532.                                          Tablerec* const tablePtr);
  1533.   void checkImmediateTriggersAfterDelete(Signal* signal, 
  1534.                                          Operationrec* const regOperPtr, 
  1535.                                          Tablerec* const tablePtr);
  1536. #if 0
  1537.   void checkDeferredTriggers(Signal* signal, 
  1538.                              Operationrec* const regOperPtr,
  1539.                              Tablerec* const regTablePtr);
  1540. #endif
  1541.   void checkDetachedTriggers(Signal* signal, 
  1542.                              Operationrec* const regOperPtr,
  1543.                              Tablerec* const regTablePtr);
  1544.   void fireImmediateTriggers(Signal* signal, 
  1545.                              ArrayList<TupTriggerData>& triggerList, 
  1546.                              Operationrec* const regOperPtr);
  1547.   void fireDeferredTriggers(Signal* signal, 
  1548.                             ArrayList<TupTriggerData>& triggerList,
  1549.                             Operationrec* const regOperPtr);
  1550.   void fireDetachedTriggers(Signal* signal,
  1551.                             ArrayList<TupTriggerData>& triggerList,
  1552.                             Operationrec* const regOperPtr);
  1553.   void executeTriggers(Signal* signal,
  1554.                        ArrayList<TupTriggerData>& triggerList,
  1555.                        Operationrec* const regOperPtr);
  1556.   void executeTrigger(Signal* signal, 
  1557.                       TupTriggerData* const trigPtr, 
  1558.                       Operationrec* const regOperPtr);
  1559.   bool readTriggerInfo(TupTriggerData* const trigPtr,
  1560.                        Operationrec* const regOperPtr, 
  1561.                        Uint32* const keyBuffer,
  1562.                        Uint32& noPrimKey,
  1563.                        Uint32* const mainBuffer,
  1564.                        Uint32& noMainWords,
  1565.                        Uint32* const copyBuffer,
  1566.                        Uint32& noCopyWords,
  1567.        bool xfrm);
  1568.   void sendTrigAttrInfo(Signal*        signal, 
  1569.                         Uint32*        data, 
  1570.                         Uint32         dataLen,
  1571.                         bool           executeDirect,
  1572.                         BlockReference receiverReference);
  1573.   Uint32 setAttrIds(Bitmask<MAXNROFATTRIBUTESINWORDS>& attributeMask, 
  1574.                     Uint32 noOfAttributes, 
  1575.                     Uint32* inBuffer);
  1576.   void sendFireTrigOrd(Signal* signal, 
  1577.                        Operationrec * const regOperPtr, 
  1578.                        TupTriggerData* const trigPtr,
  1579.                        Uint32 noPrimKeySignals, 
  1580.                        Uint32 noBeforeSignals, 
  1581.                        Uint32 noAfterSignals);
  1582.   bool primaryKey(Tablerec* const, Uint32);
  1583.   // these set terrorCode and return non-zero on error
  1584.   int executeTuxInsertTriggers(Signal* signal, 
  1585.                                 Operationrec* const regOperPtr,
  1586.                                 Tablerec* const regTabPtr);
  1587.   int executeTuxUpdateTriggers(Signal* signal, 
  1588.                                 Operationrec* const regOperPtr,
  1589.                                 Tablerec* const regTabPtr);
  1590.   int executeTuxDeleteTriggers(Signal* signal, 
  1591.                                 Operationrec* const regOperPtr,
  1592.                                 Tablerec* const regTabPtr);
  1593.   int addTuxEntries(Signal* signal,
  1594.                     Operationrec* regOperPtr,
  1595.                     Tablerec* regTabPtr);
  1596.   // these crash the node on error
  1597.   void executeTuxCommitTriggers(Signal* signal, 
  1598.                                 Operationrec* regOperPtr,
  1599.                                 Tablerec* const regTabPtr);
  1600.   void executeTuxAbortTriggers(Signal* signal, 
  1601.                                Operationrec* regOperPtr,
  1602.                                Tablerec* const regTabPtr);
  1603.   void removeTuxEntries(Signal* signal,
  1604.                         Operationrec* regOperPtr,
  1605.                         Tablerec* regTabPtr);
  1606. // *****************************************************************
  1607. // Error Handling routines.
  1608. // *****************************************************************
  1609. //------------------------------------------------------------------
  1610. //------------------------------------------------------------------
  1611.   int TUPKEY_abort(Signal* signal, int error_type);
  1612. //------------------------------------------------------------------
  1613. //------------------------------------------------------------------
  1614.   void tupkeyErrorLab(Signal* signal);
  1615. //------------------------------------------------------------------
  1616. //------------------------------------------------------------------
  1617. // Methods to handle execution of TUP_COMMITREQ + TUP_ABORTREQ.
  1618. //
  1619. // Module Transaction Manager
  1620. //
  1621. // The Transaction Manager module is responsible for the commit
  1622. // and abort of operations started by the Execution Manager.
  1623. //
  1624. // Commit Operation:
  1625. // ----------------
  1626. //
  1627. // Failures in commit processing is not allowed since that would
  1628. // leave the database in an unreliable state. Thus the only way
  1629. // to handle failures in commit processing is to crash the node.
  1630. //
  1631. // TUP_COMMITREQ can only be received in the wait state after a
  1632. // successful TUPKEYREQ which was not a read operation.
  1633. // 
  1634. // Commit of Delete:
  1635. // -----------------
  1636. //
  1637. // This will actually perform the deletion of the record unless
  1638. // other operations also are connected to the record. In this case
  1639. // we will set the delete state on the record that becomes the owner
  1640. // of the record.
  1641. //
  1642. // Commit of Update:
  1643. // ----------------
  1644. //
  1645. // We will release the copy record where the original record was kept.
  1646. // Also here we will take special care if more operations are updating
  1647. // the record simultaneously.
  1648. //
  1649. // Commit of Insert:
  1650. // -----------------
  1651. //
  1652. // Will simply reset the state of the operation record.
  1653. //
  1654. // Signal Diagram:
  1655. // --->  TUP_COMMITREQ (from LQH)
  1656. // <---- TUP_COMMITCONF (to LQH)
  1657. //
  1658. //
  1659. // Abort Operation:
  1660. // ----------------
  1661. //
  1662. // Signal Diagram:
  1663. // --->  TUP_ABORTREQ (from LQH)
  1664. // <---- TUP_ABORTCONF (to LQH)
  1665. //
  1666. // Failures in abort processing is not allowed since that would
  1667. // leave the database in an unreliable state. Thus the only way
  1668. // to handle failures in abort processing is to crash the node.
  1669. //
  1670. // Abort messages can arrive at any time. It can arrive even before
  1671. // anything at all have arrived of the operation. It can arrive after
  1672. // receiving a number of ATTRINFO but before TUPKEYREQ has been received.
  1673. // It must arrive after that we sent TUPKEYREF in response to TUPKEYREQ
  1674. // and finally it can arrive after successfully performing the TUPKEYREQ
  1675. // in all cases including the read case.
  1676. //------------------------------------------------------------------
  1677. //------------------------------------------------------------------
  1678. #if 0
  1679.   void checkPages(Fragrecord* const regFragPtr);
  1680. #endif
  1681.   void printoutTuplePage(Uint32 fragid, Uint32 pageid, Uint32 printLimit);
  1682.   bool checkUpdateOfPrimaryKey(Uint32* updateBuffer, Tablerec* const regTabPtr);
  1683.   void setNullBits(Page* const regPage, Tablerec* const regTabPtr, Uint32 pageOffset);
  1684.   bool checkNullAttributes(Operationrec* const, Tablerec* const);
  1685.   bool getPage(PagePtr& pagePtr,
  1686.                Operationrec* const regOperPtr,
  1687.                Fragrecord* const regFragPtr,
  1688.                Tablerec* const regTabPtr);
  1689.   bool getPageLastCommitted(Operationrec* const regOperPtr,
  1690.                             Operationrec* const leaderOpPtr);
  1691.   bool getPageThroughSavePoint(Operationrec* const regOperPtr,
  1692.                                Operationrec* const leaderOpPtr);
  1693.   Uint32 calculateChecksum(Page* const pagePtr, Uint32 tupHeadOffset, Uint32 tupHeadSize);
  1694.   void setChecksum(Page* const pagePtr, Uint32 tupHeadOffset, Uint32 tupHeadSize);
  1695.   void commitSimple(Signal* signal,
  1696.                     Operationrec* const regOperPtr,
  1697.                     Fragrecord* const regFragPtr,
  1698.                     Tablerec* const regTabPtr);
  1699.   void commitRecord(Signal* signal,
  1700.                     Operationrec* const regOperPtr,
  1701.                     Fragrecord* const regFragPtr,
  1702.                     Tablerec* const regTabPtr);
  1703.   void setTupleStatesSetOpType(Operationrec* const regOperPtr,
  1704.                                Page* const pagePtr,
  1705.                                Uint32& opType,
  1706.                                OperationrecPtr& firstOpPtr);
  1707.   void findBeforeValueOperation(OperationrecPtr& befOpPtr,
  1708.                                 OperationrecPtr firstOpPtr);
  1709.   void calculateChangeMask(Page* const PagePtr,
  1710.                            Tablerec* const regTabPtr,
  1711.                            Uint32 pageOffset,
  1712.                            Bitmask<MAXNROFATTRIBUTESINWORDS>& attributeMask);
  1713.   void updateGcpId(Signal* signal,
  1714.                    Operationrec* const regOperPtr,
  1715.                    Fragrecord* const regFragPtr,
  1716.                    Tablerec* const regTabPtr);
  1717.   void abortUpdate(Signal* signal,
  1718.                    Operationrec*  const regOperPtr,
  1719.                    Fragrecord* const regFragPtr,
  1720.                    Tablerec* const regTabPtr);
  1721.   void commitUpdate(Signal* signal,
  1722.                     Operationrec*  const regOperPtr,
  1723.                     Fragrecord* const regFragPtr,
  1724.                     Tablerec* const regTabPtr);
  1725.   void setTupleStateOnPreviousOps(Uint32 prevOpIndex);
  1726.   void copyMem(Signal* signal, Uint32 sourceIndex, Uint32 destIndex);
  1727.   void freeAllAttrBuffers(Operationrec*  const regOperPtr);
  1728.   void freeAttrinbufrec(Uint32 anAttrBufRec);
  1729.   void removeActiveOpList(Operationrec*  const regOperPtr);
  1730.   void updatePackedList(Signal* signal, Uint16 ahostIndex);
  1731.   void setUpDescriptorReferences(Uint32 descriptorReference,
  1732.                                  Tablerec* const regTabPtr,
  1733.                                  const Uint32* offset);
  1734.   void setUpKeyArray(Tablerec* const regTabPtr);
  1735.   bool addfragtotab(Tablerec* const regTabPtr, Uint32 fragId, Uint32 fragIndex);
  1736.   void deleteFragTab(Tablerec* const regTabPtr, Uint32 fragId);
  1737.   void abortAddFragOp(Signal* signal);
  1738.   void releaseTabDescr(Tablerec* const regTabPtr);
  1739.   void getFragmentrec(FragrecordPtr& regFragPtr, Uint32 fragId, Tablerec* const regTabPtr);
  1740.   void initialiseRecordsLab(Signal* signal, Uint32 switchData, Uint32, Uint32);
  1741.   void initializeAttrbufrec();
  1742.   void initializeCheckpointInfoRec();
  1743.   void initializeDiskBufferSegmentRecord();
  1744.   void initializeFragoperrec();
  1745.   void initializeFragrecord();
  1746.   void initializeHostBuffer();
  1747.   void initializeLocalLogInfo();
  1748.   void initializeOperationrec();
  1749.   void initializePendingFileOpenInfoRecord();
  1750.   void initializeRestartInfoRec();
  1751.   void initializeTablerec();
  1752.   void initializeTabDescr();
  1753.   void initializeUndoPage();
  1754.   void initTab(Tablerec* const regTabPtr);
  1755.   void startphase3Lab(Signal* signal, Uint32 config1, Uint32 config2);
  1756.   void fragrefuseLab(Signal* signal, FragoperrecPtr fragOperPtr);
  1757.   void fragrefuse1Lab(Signal* signal, FragoperrecPtr fragOperPtr);
  1758.   void fragrefuse2Lab(Signal* signal, FragoperrecPtr fragOperPtr, FragrecordPtr regFragPtr);
  1759.   void fragrefuse3Lab(Signal* signal,
  1760.                       FragoperrecPtr fragOperPtr,
  1761.                       FragrecordPtr regFragPtr,
  1762.                       Tablerec* const regTabPtr,
  1763.                       Uint32 fragId);
  1764.   void fragrefuse4Lab(Signal* signal,
  1765.                       FragoperrecPtr fragOperPtr,
  1766.                       FragrecordPtr regFragPtr,
  1767.                       Tablerec* const regTabPtr,
  1768.                       Uint32 fragId);
  1769.   void addattrrefuseLab(Signal* signal,
  1770.                         FragrecordPtr regFragPtr,
  1771.                         FragoperrecPtr fragOperPtr,
  1772.                         Tablerec* const regTabPtr,
  1773.                         Uint32 fragId);
  1774.   void checkLcpActiveBufferPage(Uint32 minPageNotWrittenInCheckpoint, DiskBufferSegmentInfoPtr dbsiPtr);
  1775.   void lcpWriteListDataPageSegment(Signal* signal,
  1776.                                    DiskBufferSegmentInfoPtr dbsiPtr,
  1777.                                    CheckpointInfoPtr ciPtr,
  1778.                                    bool flushFlag);
  1779.   void lcpFlushLogLab(Signal* signal, CheckpointInfoPtr ciPtr);
  1780.   void lcpClosedDataFileLab(Signal* signal, CheckpointInfoPtr ciPtr);
  1781.   void lcpEndconfLab(Signal* signal);
  1782.   void lcpSaveDataPageLab(Signal* signal, Uint32 ciIndex);
  1783.   void lcpCompletedLab(Signal* signal, Uint32 ciIndex);
  1784.   void lcpFlushRestartInfoLab(Signal* signal, Uint32 ciIndex);
  1785.   void lcpSaveCopyListLab(Signal* signal, CheckpointInfoPtr ciPtr);
  1786.   void sendFSREMOVEREQ(Signal* signal, TablerecPtr tabPtr);
  1787.   void releaseFragment(Signal* signal, Uint32 tableId);
  1788.   void allocDataBufferSegment(Signal* signal, DiskBufferSegmentInfoPtr& dbsiPtr);
  1789.   void allocRestartUndoBufferSegment(Signal* signal, DiskBufferSegmentInfoPtr& dbsiPtr, LocalLogInfoPtr lliPtr);
  1790.   void freeDiskBufferSegmentRecord(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr);
  1791.   void freeUndoBufferPages(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr);
  1792.   void releaseCheckpointInfoRecord(CheckpointInfoPtr ciPtr);
  1793.   void releaseDiskBufferSegmentRecord(DiskBufferSegmentInfoPtr dbsiPtr);
  1794.   void releaseFragoperrec(FragoperrecPtr fragOperPtr);
  1795.   void releaseFragrec(FragrecordPtr regFragPtr);
  1796.   void releasePendingFileOpenInfoRecord(PendingFileOpenInfoPtr pfoPtr);
  1797.   void releaseRestartInfoRecord(RestartInfoRecordPtr riPtr);
  1798.   void seizeDiskBufferSegmentRecord(DiskBufferSegmentInfoPtr& dbsiPtr);
  1799.   void seizeCheckpointInfoRecord(CheckpointInfoPtr& ciPtr);
  1800.   void seizeFragoperrec(FragoperrecPtr& fragOperPtr);
  1801.   void seizeFragrecord(FragrecordPtr& regFragPtr);
  1802.   void seizeOpRec(OperationrecPtr& regOperPtr);
  1803.   void seizePendingFileOpenInfoRecord(PendingFileOpenInfoPtr& pfoiPtr);
  1804.   void seizeRestartInfoRecord(RestartInfoRecordPtr& riPtr);
  1805.   // Initialisation
  1806.   void initData();
  1807.   void initRecords();
  1808.   void rfrClosedDataFileLab(Signal* signal, Uint32 restartIndex);
  1809.   void rfrCompletedLab(Signal* signal, RestartInfoRecordPtr riPtr);
  1810.   void rfrInitRestartInfoLab(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr);
  1811.   void rfrLoadDataPagesLab(Signal* signal, RestartInfoRecordPtr riPtr, DiskBufferSegmentInfoPtr dbsiPtr);
  1812.   void rfrReadFirstUndoSegment(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr, LocalLogInfoPtr lliPtr);
  1813.   void rfrReadNextDataSegment(Signal* signal, RestartInfoRecordPtr riPtr, DiskBufferSegmentInfoPtr dbsiPtr);
  1814.   void rfrReadNextUndoSegment(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr, LocalLogInfoPtr lliPtr);
  1815.   void rfrReadRestartInfoLab(Signal* signal, RestartInfoRecordPtr riPtr);
  1816.   void rfrReadSecondUndoLogLab(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr);
  1817.   void startExecUndoLogLab(Signal* signal, Uint32 lliIndex);
  1818.   void readExecUndoLogLab(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr, LocalLogInfoPtr lliPtr);
  1819.   void closeExecUndoLogLab(Signal* signal, LocalLogInfoPtr lliPtr);
  1820.   void endExecUndoLogLab(Signal* signal, Uint32 lliIndex);
  1821.   struct XlcStruct {
  1822.     Uint32 PageId;
  1823.     Uint32 PageIndex;
  1824.     Uint32 LogRecordType;
  1825.     Uint32 FragId;
  1826.     FragrecordPtr FragPtr;
  1827.     LocalLogInfoPtr LliPtr;
  1828.     DiskBufferSegmentInfoPtr DbsiPtr;
  1829.     UndoPagePtr UPPtr;
  1830.     TablerecPtr TabPtr;
  1831.   };
  1832.   void xlcGetNextRecordLab(Signal* signal, DiskBufferSegmentInfoPtr dbsiPtr, LocalLogInfoPtr lliPtr);
  1833.   void xlcRestartCompletedLab(Signal* signal);
  1834.   void xlcCopyData(XlcStruct& xlcStruct, Uint32 pageOffset, Uint32 noOfWords, PagePtr pagePtr);
  1835.   void xlcGetLogHeader(XlcStruct& xlcStruct);
  1836.   Uint32 xlcGetLogWord(XlcStruct& xlcStruct);
  1837.   void xlcAbortInsert(Signal* signal, XlcStruct& xlcStruct);
  1838.   void xlcAbortUpdate(Signal* signal, XlcStruct& xlcStruct);
  1839.   void xlcDeleteTh(XlcStruct& xlcStruct);
  1840.   void xlcIndicateNoOpActive(XlcStruct& xlcStruct);
  1841.   void xlcInsertTh(XlcStruct& xlcStruct);
  1842.   void xlcTableDescriptor(XlcStruct& xlcStruct);
  1843.   void xlcUndoLogPageHeader(XlcStruct& xlcStruct);
  1844.   void xlcUpdateTh(XlcStruct& xlcStruct);
  1845.   void xlcUpdateGCI(XlcStruct& xlcStruct);
  1846.   void cprAddData(Signal* signal,
  1847.                   Fragrecord* const regFragPtr,
  1848.                   Uint32 pageIndex,
  1849.                   Uint32 noOfWords,
  1850.                   Uint32 startOffset);
  1851.   void cprAddGCIUpdate(Signal* signal,
  1852.                        Uint32 prevGCI,
  1853.                        Fragrecord* const regFragPtr);
  1854.   void cprAddLogHeader(Signal* signal,
  1855.                        LocalLogInfo* const lliPtr,
  1856.                        Uint32 recordType,
  1857.                        Uint32 tableId,
  1858.                        Uint32 fragId);
  1859.   void cprAddUndoLogPageHeader(Signal* signal,
  1860.                                Page* const regPagePtr,
  1861.                                Fragrecord* const regFragPtr);
  1862.   void cprAddUndoLogRecord(Signal* signal,
  1863.                            Uint32 recordType,
  1864.                            Uint32 pageId,
  1865.                            Uint32 pageIndex,
  1866.                            Uint32 tableId,
  1867.                            Uint32 fragId,
  1868.                            Uint32 localLogIndex);
  1869.   void cprAddAbortUpdate(Signal* signal,
  1870.                          LocalLogInfo* const lliPtr,
  1871.                          Operationrec* const regOperPtr);
  1872.   void cprAddUndoLogWord(Signal* signal,
  1873.                          LocalLogInfo* const lliPtr,
  1874.                          Uint32 undoWord);
  1875.   bool isUndoLoggingNeeded(Fragrecord* const regFragPtr, Uint32 pageId);
  1876.   bool isUndoLoggingActive(Fragrecord* const regFragPtr);
  1877.   bool isUndoLoggingBlocked(Fragrecord* const regFragPtr);
  1878.   bool isPageUndoLogged(Fragrecord* const regFragPtr, Uint32 pageId);
  1879.   void seizeUndoBufferSegment(Signal* signal, UndoPagePtr& regUndoPagePtr);
  1880.   void lcpWriteUndoSegment(Signal* signal, LocalLogInfo* const lliPtr, bool flushFlag);
  1881.   void deleteScanProcedure(Signal* signal, Operationrec* regOperPtr);
  1882.   void copyProcedure(Signal* signal,
  1883.                      TablerecPtr regTabPtr,
  1884.                      Operationrec* regOperPtr);
  1885.   void scanProcedure(Signal* signal,
  1886.                      Operationrec* regOperPtr,
  1887.                      Uint32 lenAttrInfo);
  1888.   void storedSeizeAttrinbufrecErrorLab(Signal* signal,
  1889.                                        Operationrec* regOperPtr);
  1890.   bool storedProcedureAttrInfo(Signal* signal,
  1891.                                Operationrec* regOperPtr,
  1892.                                Uint32 length,
  1893.                                Uint32 firstWord,
  1894.                                bool copyProc);
  1895. //-----------------------------------------------------------------------------
  1896. // Table Descriptor Memory Manager
  1897. //-----------------------------------------------------------------------------
  1898. // Public methods
  1899.   Uint32 getTabDescrOffsets(const Tablerec* regTabPtr, Uint32* offset);
  1900.   Uint32 allocTabDescr(const Tablerec* regTabPtr, Uint32* offset);
  1901.   void freeTabDescr(Uint32 retRef, Uint32 retNo);
  1902.   Uint32 getTabDescrWord(Uint32 index);
  1903.   void setTabDescrWord(Uint32 index, Uint32 word);
  1904. // Private methods
  1905.   Uint32 sizeOfReadFunction();
  1906.   void   removeTdArea(Uint32 tabDesRef, Uint32 list);
  1907.   void   insertTdArea(Uint32 sizeOfChunk, Uint32 tabDesRef, Uint32 list);
  1908.   Uint32 itdaMergeTabDescr(Uint32 retRef, Uint32 retNo);
  1909. //------------------------------------------------------------------------------------------------------
  1910. // Page Memory Manager
  1911. //------------------------------------------------------------------------------------------------------
  1912. // Public methods
  1913.   void allocConsPages(Uint32 noOfPagesToAllocate,
  1914.                       Uint32& noOfPagesAllocated,
  1915.                       Uint32& allocPageRef);
  1916.   void returnCommonArea(Uint32 retPageRef, Uint32 retNo);
  1917.   void initializePage();
  1918. // Private methods
  1919.   void removeCommonArea(Uint32 remPageRef, Uint32 list);
  1920.   void insertCommonArea(Uint32 insPageRef, Uint32 list);
  1921.   void findFreeLeftNeighbours(Uint32& allocPageRef, Uint32& noPagesAllocated, Uint32 noPagesToAllocate);
  1922.   void findFreeRightNeighbours(Uint32& allocPageRef, Uint32& noPagesAllocated, Uint32 noPagesToAllocate);
  1923.   Uint32 nextHigherTwoLog(Uint32 input);
  1924. // Private data
  1925.   Uint32 cfreepageList[16];
  1926. //------------------------------------------------------------------------------------------------------
  1927. // Page Mapper, convert logical page id's to physical page id's
  1928. // The page mapper also handles the pages allocated to the fragment.
  1929. //------------------------------------------------------------------------------------------------------
  1930. //
  1931. // Public methods
  1932.   Uint32 getRealpid(Fragrecord* const regFragPtr, Uint32 logicalPageId);
  1933.   Uint32 getNoOfPages(Fragrecord* const regFragPtr);
  1934.   void initPageRangeSize(Uint32 size);
  1935.   bool insertPageRangeTab(Fragrecord* const regFragPtr,
  1936.                           Uint32 startPageId,
  1937.                           Uint32 noPages);
  1938.   void releaseFragPages(Fragrecord* const regFragPtr);
  1939.   void initFragRange(Fragrecord* const regFragPtr);
  1940.   void initializePageRange();
  1941.   Uint32 getEmptyPage(Fragrecord* const regFragPtr);
  1942.   Uint32 allocFragPages(Fragrecord* const regFragPtr, Uint32 noOfPagesAllocated);
  1943. // Private methods
  1944.   Uint32 leafPageRangeFull(Fragrecord* const regFragPtr, PageRangePtr currPageRangePtr);
  1945.   void releasePagerange(PageRangePtr regPRPtr);
  1946.   void seizePagerange(PageRangePtr& regPageRangePtr);
  1947.   void errorHandler(Uint32 errorCode);
  1948.   void allocMoreFragPages(Fragrecord* const regFragPtr);
  1949. // Private data
  1950.   Uint32 cfirstfreerange;
  1951.   PageRange *pageRange;
  1952.   Uint32 c_noOfFreePageRanges;
  1953.   Uint32 cnoOfPageRangeRec;
  1954. //------------------------------------------------------------------------------------------------------
  1955. // Fixed Allocator
  1956. // Allocates and deallocates tuples of fixed size on a fragment.
  1957. //------------------------------------------------------------------------------------------------------
  1958. //
  1959. // Public methods
  1960.   bool allocTh(Fragrecord* const regFragPtr,
  1961.                Tablerec* const regTabPtr,
  1962.                Uint32 pageType,
  1963.                Signal* signal,
  1964.                Uint32& pageOffset,
  1965.                PagePtr& pagePtr);
  1966.   void freeThSr(Tablerec*  const regTabPtr,
  1967.                 Page*  const regPagePtr,
  1968.                 Uint32 freePageOffset);
  1969.   void freeTh(Fragrecord*  const regFragPtr,
  1970.               Tablerec* const regTabPtr,
  1971.               Signal* signal,
  1972.               Page*  const regPagePtr,
  1973.               Uint32 freePageOffset);
  1974.   void getThAtPageSr(Page* const regPagePtr,
  1975.                      Uint32& pageOffset);
  1976. // Private methods
  1977.   void convertThPage(Uint32 Tupheadsize,
  1978.                      Page*  const regPagePtr);
  1979.   void getThAtPage(Fragrecord* const regFragPtr,
  1980.                    Page* const regPagePtr,
  1981.                    Signal* signal,
  1982.                    Uint32& pageOffset);
  1983.   void getEmptyPageThCopy(Fragrecord* const regFragPtr,
  1984.                           Signal* signal,
  1985.                           Page* const regPagePtr);
  1986.   void getEmptyPageTh(Fragrecord* const regFragPtr,
  1987.                       Signal* signal,
  1988.                       Page* const regPagePtr);
  1989. //------------------------------------------------------------------------------------------------------
  1990. // Temporary variables used for storing commonly used variables in certain modules
  1991. //------------------------------------------------------------------------------------------------------
  1992.   FragrecordPtr   fragptr;
  1993.   OperationrecPtr operPtr;
  1994.   TablerecPtr     tabptr;
  1995. // readAttributes and updateAttributes module
  1996.   Uint32          tCheckOffset;
  1997.   Uint32          tMaxRead;
  1998.   Uint32          tOutBufIndex;
  1999.   Uint32*         tTupleHeader;
  2000.   bool            tXfrmFlag;
  2001. // updateAttributes module
  2002.   Uint32          tInBufIndex;
  2003.   Uint32          tInBufLen;
  2004.   Uint32          terrorCode;
  2005. //------------------------------------------------------------------------------------------------------
  2006. // Common stored variables. Variables that have a valid value always.
  2007. //------------------------------------------------------------------------------------------------------
  2008.   Uint32 cnoOfLcpRec;
  2009.   Uint32 cnoOfParallellUndoFiles;
  2010.   Uint32 cnoOfUndoPage;
  2011.   Attrbufrec *attrbufrec;
  2012.   Uint32 cfirstfreeAttrbufrec;
  2013.   Uint32 cnoOfAttrbufrec;
  2014.   Uint32 cnoFreeAttrbufrec;
  2015.   CheckpointInfo *checkpointInfo;
  2016.   Uint32 cfirstfreeLcp;
  2017.   DiskBufferSegmentInfo *diskBufferSegmentInfo;
  2018.   Uint32 cfirstfreePdx;
  2019.   Uint32 cnoOfConcurrentWriteOp;
  2020.   Fragoperrec *fragoperrec;
  2021.   Uint32 cfirstfreeFragopr;
  2022.   Uint32 cnoOfFragoprec;
  2023.   Fragrecord *fragrecord;
  2024.   Uint32 cfirstfreefrag;
  2025.   Uint32 cnoOfFragrec;
  2026.   HostBuffer *hostBuffer;
  2027.   LocalLogInfo *localLogInfo;
  2028.   Uint32 cnoOfLocalLogInfo;
  2029.   Uint32 cfirstfreeOprec;
  2030.   Operationrec *operationrec;
  2031.   Uint32 cnoOfOprec;
  2032.   Page *page;
  2033.   Uint32 cnoOfPage;
  2034.   Uint32 cnoOfAllocatedPages;
  2035.   
  2036.   PendingFileOpenInfo *pendingFileOpenInfo;
  2037.   Uint32 cfirstfreePfo;
  2038.   Uint32 cnoOfConcurrentOpenOp;
  2039.   RestartInfoRecord *restartInfoRecord;
  2040.   Uint32 cfirstfreeSri;
  2041.   Uint32 cnoOfRestartInfoRec;
  2042.   Tablerec *tablerec;
  2043.   Uint32 cnoOfTablerec;
  2044.   TableDescriptor *tableDescriptor;
  2045.   Uint32 cnoOfTabDescrRec;
  2046.   UndoPage *undoPage;
  2047.   Uint32 cfirstfreeUndoSeg;
  2048.   Int32 cnoFreeUndoSeg;
  2049.   Uint32 cnoOfDataPagesToDiskWithoutSynch;
  2050.   Uint32 cdata[32];
  2051.   Uint32 cdataPages[16];
  2052.   Uint32 cpackedListIndex;
  2053.   Uint32 cpackedList[MAX_NODES];
  2054.   Uint32 cfreeTdList[16];
  2055.   Uint32 clastBitMask;
  2056.   Uint32 clblPageCounter;
  2057.   Uint32 clblPagesPerTick;
  2058.   Uint32 clblPagesPerTickAfterSr;
  2059.   BlockReference clqhBlockref;
  2060.   Uint32 clqhUserpointer;
  2061.   Uint32 cminusOne;
  2062.   BlockReference cndbcntrRef;
  2063.   Uint32 cundoFileVersion;
  2064.   BlockReference cownref;
  2065.   Uint32 cownNodeId;
  2066.   Uint32 czero;
  2067.  // A little bit bigger to cover overwrites in copy algorithms (16384 real size).
  2068. #define ZATTR_BUFFER_SIZE 16384
  2069.   Uint32 clogMemBuffer[ZATTR_BUFFER_SIZE + 16];
  2070.   Uint32 coutBuffer[ZATTR_BUFFER_SIZE + 16];
  2071.   Uint32 cinBuffer[ZATTR_BUFFER_SIZE + 16];
  2072.   Uint32 totNoOfPagesAllocated;
  2073.   // Trigger variables
  2074.   Uint32 c_maxTriggersPerTable;
  2075.   // Counters for num UNDO log records executed
  2076.   Uint32 cSrUndoRecords[9];
  2077.   STATIC_CONST(MAX_PARALLELL_TUP_SRREQ = 2); 
  2078.   Uint32 c_sr_free_page_0;
  2079.   Uint32 c_errorInsert4000TableId;
  2080.   void initGlobalTemporaryVars();
  2081.   void reportMemoryUsage(Signal* signal, int incDec);
  2082.   
  2083. #ifdef VM_TRACE
  2084.   struct Th {
  2085.     Uint32 data[1];
  2086.   };
  2087.   friend class NdbOut& operator<<(NdbOut&, const Operationrec&);
  2088.   friend class NdbOut& operator<<(NdbOut&, const Th&);
  2089. #endif
  2090. };
  2091. inline
  2092. bool Dbtup::isUndoLoggingNeeded(Fragrecord* const regFragPtr,
  2093.                                 Uint32 pageId)
  2094. {
  2095.   if ((regFragPtr->checkpointVersion != RNIL) &&
  2096.       (pageId >= regFragPtr->minPageNotWrittenInCheckpoint) &&
  2097.       (pageId < regFragPtr->maxPageWrittenInCheckpoint)) {
  2098.     return true;
  2099.   }//if
  2100.   return false;
  2101. }//Dbtup::isUndoLoggingNeeded()
  2102. inline
  2103. bool Dbtup::isUndoLoggingActive(Fragrecord* const regFragPtr)
  2104. {
  2105.   if (regFragPtr->checkpointVersion != RNIL) {
  2106.     return true;
  2107.   }//if
  2108.   return false;
  2109. }//Dbtup::isUndoLoggingNeeded()
  2110. inline
  2111. bool Dbtup::isUndoLoggingBlocked(Fragrecord* const regFragPtr)
  2112. {
  2113.   if ((regFragPtr->checkpointVersion != RNIL) &&
  2114.       (cnoFreeUndoSeg < ZMIN_PAGE_LIMIT_TUPKEYREQ)) {
  2115.     return true;
  2116.   }//if
  2117.   return false;
  2118. }//Dbtup::isUndoLoggingNeeded()
  2119. inline
  2120. bool Dbtup::isPageUndoLogged(Fragrecord* const regFragPtr,
  2121.                              Uint32 pageId)
  2122. {
  2123.   if ((pageId >= regFragPtr->minPageNotWrittenInCheckpoint) &&
  2124.       (pageId < regFragPtr->maxPageWrittenInCheckpoint)) {
  2125.     return true;
  2126.   }//if
  2127.   return false;
  2128. }//Dbtup::isUndoLoggingNeeded()
  2129. #endif