1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
20
#include <SimulatedBlock.hpp>
21
#include <ndb_limits.h>
22
#include <trigger_definitions.h>
23
#include <AttributeHeader.hpp>
24
#include <Bitmask.hpp>
25
#include <signaldata/TupKey.hpp>
26
#include <signaldata/CreateTrig.hpp>
27
#include <signaldata/DropTrig.hpp>
28
#include <signaldata/TrigAttrInfo.hpp>
29
#include <signaldata/BuildIndx.hpp>
30
#include "Undo_buffer.hpp"
31
#include "tuppage.hpp"
32
#include <../pgman.hpp>
33
#include <../tsman.hpp>
38
#ifdef DBTUP_BUFFER_CPP
39
#define jam() jamLine(10000 + __LINE__)
40
#define jamEntry() jamEntryLine(10000 + __LINE__)
42
#ifdef DBTUP_ROUTINES_CPP
43
#define jam() jamLine(15000 + __LINE__)
44
#define jamEntry() jamEntryLine(15000 + __LINE__)
46
#ifdef DBTUP_COMMIT_CPP
47
#define jam() jamLine(20000 + __LINE__)
48
#define jamEntry() jamEntryLine(20000 + __LINE__)
50
#ifdef DBTUP_FIXALLOC_CPP
51
#define jam() jamLine(25000 + __LINE__)
52
#define jamEntry() jamEntryLine(25000 + __LINE__)
54
#ifdef DBTUP_TRIGGER_CPP
55
#define jam() jamLine(30000 + __LINE__)
56
#define jamEntry() jamEntryLine(30000 + __LINE__)
58
#ifdef DBTUP_ABORT_CPP
59
#define jam() jamLine(35000 + __LINE__)
60
#define jamEntry() jamEntryLine(35000 + __LINE__)
62
#ifdef DBTUP_PAGE_MAP_CPP
63
#define jam() jamLine(40000 + __LINE__)
64
#define jamEntry() jamEntryLine(40000 + __LINE__)
66
#ifdef DBTUP_PAG_MAN_CPP
67
#define jam() jamLine(45000 + __LINE__)
68
#define jamEntry() jamEntryLine(45000 + __LINE__)
70
#ifdef DBTUP_STORE_PROC_DEF_CPP
71
#define jam() jamLine(50000 + __LINE__)
72
#define jamEntry() jamEntryLine(50000 + __LINE__)
75
#define jam() jamLine(55000 + __LINE__)
76
#define jamEntry() jamEntryLine(55000 + __LINE__)
78
#ifdef DBTUP_TAB_DES_MAN_CPP
79
#define jam() jamLine(60000 + __LINE__)
80
#define jamEntry() jamEntryLine(60000 + __LINE__)
83
#define jam() jamLine(65000 + __LINE__)
84
#define jamEntry() jamEntryLine(65000 + __LINE__)
86
#ifdef DBTUP_INDEX_CPP
87
#define jam() jamLine(70000 + __LINE__)
88
#define jamEntry() jamEntryLine(70000 + __LINE__)
90
#ifdef DBTUP_DEBUG_CPP
91
#define jam() jamLine(75000 + __LINE__)
92
#define jamEntry() jamEntryLine(75000 + __LINE__)
94
#ifdef DBTUP_VAR_ALLOC_CPP
95
#define jam() jamLine(80000 + __LINE__)
96
#define jamEntry() jamEntryLine(80000 + __LINE__)
99
#define jam() jamLine(85000 + __LINE__)
100
#define jamEntry() jamEntryLine(85000 + __LINE__)
102
#ifdef DBTUP_DISK_ALLOC_CPP
103
#define jam() jamLine(90000 + __LINE__)
104
#define jamEntry() jamEntryLine(90000 + __LINE__)
107
#define jam() jamLine(__LINE__)
108
#define jamEntry() jamEntryLine(__LINE__)
112
inline const char* dbgmask(const Bitmask<MAXNROFATTRIBUTESINWORDS>& bm) {
113
static int i=0; static char buf[5][200];
114
bm.getText(buf[i%5]); return buf[i++%5]; }
115
inline const char* dbgmask(const Uint32 bm[2]) {
116
static int i=0; static char buf[5][200];
117
sprintf(buf[i%5],"%08x%08x",bm[1],bm[0]); return buf[i++%5]; }
120
#define ZWORDS_ON_PAGE 8192 /* NUMBER OF WORDS ON A PAGE. */
121
#define ZATTRBUF_SIZE 32 /* SIZE OF ATTRIBUTE RECORD BUFFER */
122
#define ZMIN_PAGE_LIMIT_TUPKEYREQ 5
123
#define ZTUP_VERSION_BITS 15
124
#define ZTUP_VERSION_MASK ((1 << ZTUP_VERSION_BITS) - 1)
125
#define MAX_FREE_LIST 4
127
inline Uint32* ALIGN_WORD(void * ptr)
129
return (Uint32*)(((UintPtr(ptr) + 3) >> 2) << 2);
132
inline const Uint32* ALIGN_WORD(const void* ptr)
134
return (Uint32*)(((UintPtr(ptr) + 3) >> 2) << 2);
138
//------------------------------------------------------------------
141
// When DBTUP reports lines through jam in the trace files it has to
142
// be interpreted. 4024 means as an example line 24 in DbtupCommit.cpp
143
// Thus 4000 is added to the line number beacuse it is located in the
144
// file DbtupCommit.cpp. The following is the exhaustive list of the
145
// added value in the various files. ndbrequire, ptrCheckGuard still
146
// only reports the line number in the file it currently is located in.
148
// DbtupExecQuery.cpp 0
149
// DbtupBuffer.cpp 10000
150
// DbtupRoutines.cpp 15000
151
// DbtupCommit.cpp 20000
152
// DbtupFixAlloc.cpp 25000
153
// DbtupTrigger.cpp 30000
154
// DbtupAbort.cpp 35000
155
// DbtupPageMap.cpp 40000
156
// DbtupPagMan.cpp 45000
157
// DbtupStoredProcDef.cpp 50000
158
// DbtupMeta.cpp 55000
159
// DbtupTabDesMan.cpp 60000
160
// DbtupGen.cpp 65000
161
// DbtupIndex.cpp 70000
162
// DbtupDebug.cpp 75000
163
// DbtupVarAlloc.cpp 80000
164
// DbtupScan.cpp 85000
165
// DbtupDiskAlloc.cpp 90000
166
//------------------------------------------------------------------
172
/* ---------------------------------------------------------------- */
173
/* S I Z E O F R E C O R D S */
174
/* ---------------------------------------------------------------- */
175
#define ZNO_OF_ATTRBUFREC 10000 /* SIZE OF ATTRIBUTE INFO FILE */
176
#define ZNO_OF_CONCURRENT_OPEN_OP 40 /* NUMBER OF CONCURRENT OPENS */
177
#define ZNO_OF_CONCURRENT_WRITE_OP 80 /* NUMBER OF CONCURRENT DISK WRITES*/
178
#define ZNO_OF_FRAGOPREC 20 /* NUMBER OF CONCURRENT ADD FRAG. */
179
#define TOT_PAGE_RECORD_SPACE 262144 /* SIZE OF PAGE RECORD FILE. */
180
#define ZNO_OF_PAGE TOT_PAGE_RECORD_SPACE/ZWORDS_ON_PAGE
181
#define ZNO_OF_PAGE_RANGE_REC 128 /* SIZE OF PAGE RANGE FILE */
183
#define ZDEFAULT_MAX_NO_TRIGGERS_PER_TABLE 16
185
/* ---------------------------------------------------------------- */
186
/* A ATTRIBUTE MAY BE NULL, DYNAMIC OR NORMAL. A NORMAL ATTRIBUTE */
187
/* IS A ATTRIBUTE THAT IS NOT NULL OR DYNAMIC. A NULL ATTRIBUTE */
188
/* MAY HAVE NO VALUE. A DYNAMIC ATTRIBUTE IS A NULL ATTRIBUTE THAT */
189
/* DOES NOT HAVE TO BE A MEMBER OF EVERY TUPLE I A CERTAIN TABLE. */
190
/* ---------------------------------------------------------------- */
192
* #defines moved into include/kernel/Interpreter.hpp
194
#define ZINSERT_DELETE 0
195
#define ZUPDATE_ALL 8
196
/* ---------------------------------------------------------------- */
197
/* THE MINIMUM SIZE OF AN 'EMPTY' TUPLE HEADER IN R-WORDS */
198
/* ---------------------------------------------------------------- */
199
/* THE TUPLE HEADER FIELD 'SIZE OF NULL ATTR. FIELD' SPECIFYES */
200
/* THE SIZE OF THE TUPLE HEADER FIELD 'NULL ATTR. FIELD'. */
201
/* THE TUPLE HEADER FIELD 'TYPE' SPECIFYES THE TYPE OF THE TUPLE */
203
/* TUPLE ATTRIBUTE INDEX CLUSTERS, ATTRIBUTE */
204
/* CLUSTERS AND A DYNAMIC ATTRIBUTE HEADER. */
205
/* IT MAY ALSO CONTAIN SHORT ATTRIBUTES AND */
206
/* POINTERS TO LONG ATTRIBUTE HEADERS. */
207
/* TUPLE ATTRIBUTE INDEX CLUSTERS, ATTRIBUTE */
208
/* CLUSTERS AND A DYNAMIC ATTRIBUTE HEADER. */
210
/* DATA STRUCTURE TYPES */
211
/* WHEN ATTRIBUTE INFO IS SENT WITH A ATTRINFO-SIGNAL THE */
212
/* VARIABLE TYPE IS SPECIFYED. THIS MUST BE DONE TO BE ABLE TO */
213
/* NOW HOW MUCH DATA OF A ATTRIBUTE TO READ FROM ATTRINFO. */
215
/* WHEN A REQUEST CAN NOT BE EXECUTED BECAUSE OF A ERROR THE */
216
/* ERROR MUST BE IDENTIFYED BY MEANS OF A ERROR CODE AND SENT TO */
218
#define ZGET_OPREC_ERROR 804 // TUP_SEIZEREF
220
#define ZEXIST_FRAG_ERROR 816 // Add fragment
221
#define ZFULL_FRAGRECORD_ERROR 817 // Add fragment
222
#define ZNO_FREE_PAGE_RANGE_ERROR 818 // Add fragment
223
#define ZNOFREE_FRAGOP_ERROR 830 // Add fragment
224
#define ZTOO_LARGE_TUPLE_ERROR 851 // Add fragment
225
#define ZNO_FREE_TAB_ENTRY_ERROR 852 // Add fragment
226
#define ZNO_PAGES_ALLOCATED_ERROR 881 // Add fragment
228
#define ZGET_REALPID_ERROR 809
229
#define ZNOT_IMPLEMENTED_ERROR 812
230
#define ZSEIZE_ATTRINBUFREC_ERROR 805
231
#define ZTOO_MUCH_ATTRINFO_ERROR 823
232
#define ZMEM_NOTABDESCR_ERROR 826
233
#define ZMEM_NOMEM_ERROR 827
234
#define ZAI_INCONSISTENCY_ERROR 829
235
#define ZNO_ILLEGAL_NULL_ATTR 839
236
#define ZNOT_NULL_ATTR 840
237
#define ZNO_INSTRUCTION_ERROR 871
238
#define ZOUTSIDE_OF_PROGRAM_ERROR 876
239
#define ZSTORED_PROC_ID_ERROR 877
240
#define ZREGISTER_INIT_ERROR 878
241
#define ZATTRIBUTE_ID_ERROR 879
242
#define ZTRY_TO_READ_TOO_MUCH_ERROR 880
243
#define ZTOTAL_LEN_ERROR 882
244
#define ZATTR_INTERPRETER_ERROR 883
245
#define ZSTACK_OVERFLOW_ERROR 884
246
#define ZSTACK_UNDERFLOW_ERROR 885
247
#define ZTOO_MANY_INSTRUCTIONS_ERROR 886
248
#define ZTRY_TO_UPDATE_ERROR 888
249
#define ZCALL_ERROR 890
250
#define ZTEMPORARY_RESOURCE_FAILURE 891
251
#define ZUNSUPPORTED_BRANCH 892
253
#define ZSTORED_SEIZE_ATTRINBUFREC_ERROR 873 // Part of Scan
254
#define ZSTORED_TOO_MUCH_ATTRINFO_ERROR 874
256
#define ZREAD_ONLY_CONSTRAINT_VIOLATION 893
257
#define ZVAR_SIZED_NOT_SUPPORTED 894
258
#define ZINCONSISTENT_NULL_ATTRIBUTE_COUNT 895
259
#define ZTUPLE_CORRUPTED_ERROR 896
260
#define ZTRY_UPDATE_PRIMARY_KEY 897
261
#define ZMUST_BE_ABORTED_ERROR 898
262
#define ZTUPLE_DELETED_ERROR 626
263
#define ZINSERT_ERROR 630
265
#define ZINVALID_CHAR_FORMAT 744
266
#define ZROWID_ALLOCATED 899
268
/* SOME WORD POSITIONS OF FIELDS IN SOME HEADERS */
270
#define ZFREE_COMMON 1 /* PAGE STATE, PAGE IN COMMON AREA */
271
#define ZEMPTY_MM 2 /* PAGE STATE, PAGE IN EMPTY LIST */
272
#define ZTH_MM_FREE 3 /* PAGE STATE, TUPLE HEADER PAGE WITH FREE AREA */
273
#define ZTH_MM_FULL 4 /* PAGE STATE, TUPLE HEADER PAGE WHICH IS FULL */
275
#define ZTD_HEADER 0 /* HEADER POSITION */
276
#define ZTD_DATASIZE 1 /* SIZE OF THE DATA IN THIS CHUNK */
277
#define ZTD_SIZE 2 /* TOTAL SIZE OF TABLE DESCRIPTOR */
279
/* TRAILER POSITIONS FROM END OF TABLE DESCRIPTOR RECORD */
280
#define ZTD_TR_SIZE 1 /* SIZE DESCRIPTOR POS FROM END+1 */
281
#define ZTD_TR_TYPE 2
282
#define ZTD_TRAILER_SIZE 2 /* TOTAL SIZE OF TABLE TRAILER */
283
#define ZAD_SIZE 2 /* TOTAL SIZE OF ATTR DESCRIPTOR */
284
#define ZAD_LOG_SIZE 1 /* TWO LOG OF TOTAL SIZE OF ATTR DESCRIPTOR */
286
/* CONSTANTS USED TO HANDLE TABLE DESCRIPTOR AS A FREELIST */
287
#define ZTD_FL_HEADER 0 /* HEADER POSITION */
288
#define ZTD_FL_SIZE 1 /* TOTAL SIZE OF THIS FREELIST ENTRY */
289
#define ZTD_FL_PREV 2 /* PREVIOUS RECORD IN FREELIST */
290
#define ZTD_FL_NEXT 3 /* NEXT RECORD IN FREELIST */
291
#define ZTD_FREE_SIZE 16 /* SIZE NEEDED TO HOLD ONE FL ENTRY */
293
/* CONSTANTS USED IN LSB OF TABLE DESCRIPTOR HEADER DESCRIBING USAGE */
294
#define ZTD_TYPE_FREE 0 /* RECORD LINKED INTO FREELIST */
295
#define ZTD_TYPE_NORMAL 1 /* RECORD USED AS TABLE DESCRIPTOR */
296
/* ATTRIBUTE OPERATION CONSTANTS */
300
/* ATTRINBUFREC VARIABLE POSITIONS. */
301
#define ZBUF_PREV 29 /* POSITION OF 'PREV'-VARIABLE (USED BY INTERPRETED EXEC) */
302
#define ZBUF_DATA_LEN 30 /* POSITION OF 'DATA LENGTH'-VARIABLE. */
303
#define ZBUF_NEXT 31 /* POSITION OF 'NEXT'-VARIABLE. */
304
#define ZSAVE_BUF_NEXT 28
305
#define ZSAVE_BUF_DATA_LEN 27
309
#define ZSTARTPHASE1 1
310
#define ZSTARTPHASE2 2
311
#define ZSTARTPHASE3 3
312
#define ZSTARTPHASE4 4
313
#define ZSTARTPHASE6 6
317
//------------------------------------------------------------
318
// TUP_CONTINUEB codes
319
//------------------------------------------------------------
320
#define ZINITIALISE_RECORDS 6
322
#define ZREPORT_MEMORY_USAGE 8
323
#define ZBUILD_INDEX 9
325
#define ZFREE_EXTENT 11
326
#define ZUNMAP_PAGES 12
327
#define ZFREE_VAR_PAGES 13
329
#define ZSCAN_PROCEDURE 0
330
#define ZCOPY_PROCEDURE 2
331
#define ZSTORED_PROCEDURE_DELETE 3
332
#define ZSTORED_PROCEDURE_FREE 0xffff
333
#define ZMIN_PAGE_LIMIT_TUP_COMMITREQ 2
335
#define ZSKIP_TUX_TRIGGERS 0x1 // flag for TUP_ABORTREQ
339
class Dbtup: public SimulatedBlock {
343
friend struct KeyReqStruct; // CC
344
typedef bool (Dbtup::* ReadFunction)(Uint32*,
348
typedef bool (Dbtup::* UpdateFunction)(Uint32*,
353
typedef Tup_fixsize_page Fix_page;
354
typedef Tup_varsize_page Var_page;
360
Page_cache_client m_pgman;
363
enum ChangeMaskState {
366
USE_SAVED_CHANGE_MASK = 2,
367
RECALCULATE_CHANGE_MASK = 3
373
TRANS_WAIT_STORED_PROCEDURE_ATTR_INFO = 2,
374
TRANS_ERROR_WAIT_STORED_PROCREQ = 3,
375
TRANS_ERROR_WAIT_TUPKEYREQ = 4,
376
TRANS_TOO_MUCH_AI = 5,
377
TRANS_DISCONNECTED = 6
382
TUPLE_ALREADY_ABORTED = 2,
383
TUPLE_TO_BE_COMMITTED = 3
399
/* ************** ATTRIBUTE INFO BUFFER RECORD ****************** */
400
/* THIS RECORD IS USED AS A BUFFER FOR INCOMING AND OUTGOING DATA */
401
/* ************************************************************** */
403
Uint32 attrbuf[ZATTRBUF_SIZE];
404
}; /* p2c: size = 128 bytes */
406
typedef Ptr<Attrbufrec> AttrbufrecPtr;
413
Uint32 nextFragoprec;
418
Uint32 attributeCount;
420
Uint32 m_null_bits[2];
421
Uint32 m_fix_attributes_size[2]; // In words
422
Uint32 m_var_attributes_size[2]; // In bytes
423
BlockReference lqhBlockrefFrag;
425
bool definingFragment;
427
typedef Ptr<Fragoperrec> FragoperrecPtr;
430
typedef Tup_page Page;
431
typedef Ptr<Page> PagePtr;
448
Get m_get; // entry point in scanNext
449
Local_key m_key; // scan position pointer MM or DD
450
Page* m_page; // scanned MM or DD (cache) page
451
Local_key m_key_mm; // MM local key returned
452
Uint32 m_realpid_mm; // MM real page id
453
Uint32 m_extent_info_ptr_i;
465
typedef Ptr<ScanLock> ScanLockPtr;
466
ArrayPool<ScanLock> c_scanLockPool;
468
// Tup scan, similar to Tux scan. Later some of this could
469
// be moved to common superclass.
477
m_fragId(~(Uint32)0),
487
First = 1, // before first entry
488
Current = 2, // at current before locking
489
Blocked = 3, // at current waiting for ACC lock
490
Locked = 4, // at current and locked or no lock needed
491
Next = 5, // looking for next extry
492
Last = 6, // after last entry
493
Aborting = 7, // lock wait at scan close
494
Invalid = 9 // cannot return REF to LQH currently
499
SCAN_DD = 0x01, // scan disk pages
500
SCAN_VS = 0x02, // page format is var size
501
SCAN_LCP = 0x04, // LCP mem page scan
502
SCAN_LOCK_SH = 0x10, // lock mode shared
503
SCAN_LOCK_EX = 0x20, // lock mode exclusive
504
SCAN_LOCK_WAIT = 0x40, // lock wait
506
SCAN_LOCK = SCAN_LOCK_SH | SCAN_LOCK_EX,
507
SCAN_NR = 0x80 // Node recovery scan
511
Uint32 m_userPtr; // scanptr.i in LQH
519
Uint32 m_savePointId;
523
// lock waited for or obtained and not yet passed to LQH
528
DLFifoList<ScanLock>::Head m_accLockOps;
536
typedef Ptr<ScanOp> ScanOpPtr;
537
ArrayPool<ScanOp> c_scanOpPool;
539
void scanReply(Signal*, ScanOpPtr scanPtr);
540
void scanFirst(Signal*, ScanOpPtr scanPtr);
541
bool scanNext(Signal*, ScanOpPtr scanPtr);
542
void scanCont(Signal*, ScanOpPtr scanPtr);
543
void disk_page_tup_scan_callback(Signal*, Uint32 scanPtrI, Uint32 page_i);
544
void scanClose(Signal*, ScanOpPtr scanPtr);
545
void addAccLockOp(ScanOp& scan, Uint32 accLockOp);
546
void removeAccLockOp(ScanOp& scan, Uint32 accLockOp);
547
void releaseScanOp(ScanOpPtr& scanPtr);
549
// for md5 of key (could maybe reuse existing temp buffer)
550
Uint64 c_dataBuffer[ZWORDS_ON_PAGE/2 + 1];
556
Uint32 m_extent_info_ptr;
557
Uint16 m_estimated_free_space; // in bytes/records
558
Uint16 m_list_index; // in Disk_alloc_info.m_page_requests
559
Uint16 m_ref_count; // Waiters for page
560
Uint16 m_uncommitted_used_space;
566
typedef RecordPool<Page_request, WOPool> Page_request_pool;
567
typedef DLFifoListImpl<Page_request_pool, Page_request> Page_request_list;
568
typedef LocalDLFifoListImpl<Page_request_pool, Page_request> Local_page_request_list;
570
STATIC_CONST( EXTENT_SEARCH_MATRIX_COLS = 4 ); // Guarantee size
571
STATIC_CONST( EXTENT_SEARCH_MATRIX_ROWS = 5 ); // Total size
572
STATIC_CONST( EXTENT_SEARCH_MATRIX_SIZE = 20 );
579
struct Extent_info : public Extent_list_t
582
Uint32 m_first_page_no;
585
Uint32 m_free_matrix_pos;
586
Uint16 m_free_page_count[EXTENT_SEARCH_MATRIX_COLS];
592
Uint32 nextHash, prevHash;
594
Uint32 hashValue() const {
595
return (m_key.m_file_no << 16) ^ m_key.m_page_idx;
599
bool equal(const Extent_info & rec) const {
600
return m_key.m_file_no == rec.m_key.m_file_no &&
601
m_key.m_page_idx == rec.m_key.m_page_idx;
605
typedef RecordPool<Extent_info, RWPool> Extent_info_pool;
606
typedef DLListImpl<Extent_info_pool, Extent_info> Extent_info_list;
607
typedef LocalDLListImpl<Extent_info_pool, Extent_info> Local_extent_info_list;
608
typedef DLHashTableImpl<Extent_info_pool, Extent_info> Extent_info_hash;
609
typedef SLListImpl<Extent_info_pool, Extent_info, Extent_list_t> Fragment_extent_list;
610
typedef LocalSLListImpl<Extent_info_pool, Extent_info, Extent_list_t> Local_fragment_extent_list;
612
struct Disk_alloc_info
615
Disk_alloc_info(const Tablerec* tabPtrP,
616
Uint32 extent_size_in_pages);
617
Uint32 m_extent_size;
622
* 1) Allocate space on pages that already are dirty
623
* (4 free lists for different requests)
624
* 2) Allocate space on pages waiting to maped that will be dirty
625
* (4 free lists for different requests)
626
* 3) Check if "current" extent can accommodate request
627
* If so, allocate page from there
628
* Else put "current" into free matrix
629
* 4) Search free matrix for extent with greatest amount of free space
630
* while still accommodating current request
631
* (20 free lists for different requests)
635
* Free list of pages in different size
638
DLList<Page>::Head m_dirty_pages[MAX_FREE_LIST]; // In real page id's
641
* Requests (for update) that have sufficient space left after request
642
* these are currently being "mapped"
644
Page_request_list::Head m_page_requests[MAX_FREE_LIST];
646
DLList<Page>::Head m_unmap_pages;
651
Uint32 m_curr_extent_info_ptr_i;
656
STATIC_CONST( SZ = EXTENT_SEARCH_MATRIX_SIZE );
657
Extent_info_list::Head m_free_extents[SZ];
658
Uint32 m_total_extent_free_space_thresholds[EXTENT_SEARCH_MATRIX_ROWS];
659
Uint32 m_page_free_bits_map[EXTENT_SEARCH_MATRIX_COLS];
661
Uint32 find_extent(Uint32 sz) const;
662
Uint32 calc_extent_pos(const Extent_info*) const;
665
* Compute minimum free space on page given bits
667
Uint32 calc_page_free_space(Uint32 bits) const {
668
return m_page_free_bits_map[bits];
672
* Compute page free bits, given free space
674
Uint32 calc_page_free_bits(Uint32 free) const {
675
for(Uint32 i = 0; i<EXTENT_SEARCH_MATRIX_COLS-1; i++)
676
if(free >= m_page_free_bits_map[i])
678
return EXTENT_SEARCH_MATRIX_COLS - 1;
681
Fragment_extent_list::Head m_extent_list;
684
void dump_disk_alloc(Disk_alloc_info&);
687
Uint32 nextStartRange;
688
Uint32 currentPageRange;
689
Uint32 rootPageRange;
692
Uint32 noOfPagesToGrow;
694
DLList<Page>::Head emptyPrimPage; // allocated pages (not init)
695
DLFifoList<Page>::Head thFreeFirst; // pages with atleast 1 free record
696
SLList<Page>::Head m_empty_pages; // Empty pages not in logical/physical map
698
Uint32 m_lcp_scan_op;
699
Uint32 m_lcp_keep_list;
705
DLList<Page>::Head free_var_page_array[MAX_FREE_LIST];
707
DLList<ScanOp>::Head m_scanList;
709
enum { UC_LCP = 1, UC_CREATE = 2, UC_SET_LCP = 3 };
710
Uint32 m_restore_lcp_id;
711
Uint32 m_undo_complete;
712
Uint32 m_tablespace_id;
713
Uint32 m_logfile_group_id;
714
Disk_alloc_info m_disk_alloc_info;
715
Uint32 m_var_page_chunks;
717
typedef Ptr<Fragrecord> FragrecordPtr;
720
struct Operationrec {
722
* To handle Attrinfo signals and buffer them up we need to
723
* a simple list with first and last and we also need to keep track
724
* of how much we received for security check.
725
* Will most likely disappear with introduction of long signals.
726
* These variables are used before TUPKEYREQ is received and not
727
* thereafter and is disposed with after calling copyAttrinfo
728
* which is called before putting the operation into its lists.
729
* Thus we can use union declarations for these variables.
733
* Used by scans to find the Attrinfo buffers.
734
* This is only until returning from copyAttrinfo and
735
* can thus reuse the same memory as needed by the
736
* active operation list variables.
740
* Doubly linked list with anchor on tuple.
741
* This is to handle multiple updates on the same tuple
742
* by the same transaction.
746
Uint32 storedProcedureId; //Used until copyAttrinfo
750
Uint32 currentAttrinbufLen; //Used until copyAttrinfo
754
bool is_first_operation() const { return prevActiveOp == RNIL;}
755
bool is_last_operation() const { return nextActiveOp == RNIL;}
757
Uint32 m_undo_buffer_space; // In words
759
Uint32 firstAttrinbufrec; //Used until copyAttrinfo
763
Uint32 lastAttrinbufrec; //Used until copyAttrinfo
766
Uint32 attrinbufLen; //only used during STORED_PROCDEF phase
767
Uint32 storedProcPtr; //only used during STORED_PROCDEF phase
770
* From fragment i-value we can find fragment and table record
775
* We need references to both the original tuple and the copy tuple.
776
* We keep the page's real i-value and its index and from there we
777
* can find out about the fragment page id and the page offset.
779
Local_key m_tuple_location;
780
Local_key m_copy_tuple_location;
783
* We keep the record linked to the operation record in LQH.
784
* This is needed due to writing of REDO log must be performed
785
* in correct order, which is the same order as the writes
786
* occurred. LQH can receive the records in different order.
791
* When responding to queries in the same transaction they will see
792
* a result from the save point id the query was started. Again
793
* functionality for multi-updates of the same record in one
798
Uint32 m_commit_disk_callback_page;
802
* We use 64 bits to save change mask for the most common cases.
804
Uint32 saved_change_mask[2];
807
* State variables on connection.
808
* State variable on tuple after multi-updates
809
* Is operation undo logged or not
810
* Is operation in fragment list
811
* Is operation in multi-update list
812
* Operation type (READ, UPDATE, etc)
813
* Is record primary replica
814
* Is delete or insert performed
817
unsigned int trans_state : 3;
818
unsigned int tuple_state : 2;
819
unsigned int in_active_list : 1;
821
unsigned int op_type : 3;
822
unsigned int delete_insert_flag : 1;
823
unsigned int primary_replica : 1;
824
unsigned int change_mask_state : 2;
825
unsigned int m_disk_preallocated : 1;
826
unsigned int m_load_diskpage_on_commit : 1;
827
unsigned int m_wait_log_buffer : 1;
830
OpBitFields op_struct;
831
Uint16 op_bit_fields;
835
* TUX needs to know the tuple version of the tuple since it
836
* keeps an entry for both the committed and all versions in
837
* a transaction currently. So each update will create a new
838
* version even if in the same transaction.
842
typedef Ptr<Operationrec> OperationrecPtr;
844
/* ****************************** PAGE RANGE RECORD ************************** */
845
/* PAGE RANGES AND BASE PAGE ID. EACH RANGE HAS A CORRESPONDING BASE PAGE ID */
846
/* THAT IS USED TO CALCULATE REAL PAGE ID FROM A FRAGMENT PAGE ID AND A TABLE */
848
/* THE PAGE RANGES ARE ORGANISED IN A B-TREE FASHION WHERE THE VARIABLE TYPE */
849
/* SPECIFIES IF A LEAF NODE HAS BEEN REACHED. IF A LEAF NODE HAS BEEN REACHED */
850
/* THEN BASE_PAGE_ID IS THE BASE_PAGE_ID OF THE SET OF PAGES THAT WAS */
851
/* ALLOCATED IN THAT RANGE. OTHERWISE BASE_PAGE_ID IS THE POINTER TO THE NEXT */
852
/* PAGE_RANGE RECORD. */
853
/* *************************************************************************** */
855
Uint32 startRange[4]; /* START OF RANGE */
856
Uint32 endRange[4]; /* END OF THIS RANGE */
857
Uint32 basePageId[4]; /* BASE PAGE ID. */
858
/*---- VARIABLE BASE_PAGE_ID2 (4) 8 DS NEEDED WHEN SUPPORTING 40 BIT PAGE ID -------*/
859
Uint8 type[4]; /* TYPE OF BASE PAGE ID */
860
Uint32 nextFree; /* NEXT FREE PAGE RANGE RECORD */
861
Uint32 parentPtr; /* THE PARENT TO THE PAGE RANGE REC IN THE B-TREE */
862
Uint8 currentIndexPos;
864
typedef Ptr<PageRange> PageRangePtr;
867
/* ************* TRIGGER DATA ************* */
868
/* THIS RECORD FORMS LISTS OF ACTIVE */
869
/* TRIGGERS FOR EACH TABLE. */
870
/* THE RECORDS ARE MANAGED BY A TRIGGER */
871
/* POOL wHERE A TRIGGER RECORD IS SEIZED */
872
/* WHEN A TRIGGER IS ACTIVATED AND RELEASED */
873
/* WHEN THE TRIGGER IS DEACTIVATED. */
874
/* **************************************** */
875
struct TupTriggerData {
879
* Trigger id, used by DICT/TRIX to identify the trigger
881
* trigger Ids are unique per block for SUBSCRIPTION triggers.
882
* This is so that BACKUP can use TUP triggers directly and delete them
888
* Index id is needed for ordered index.
893
* Trigger type etc, defines what the trigger is used for
895
TriggerType::Value triggerType;
896
TriggerActionTime::Value triggerActionTime;
897
TriggerEvent::Value triggerEvent;
901
Uint32 m_receiverBlock;
904
* Monitor all replicas, i.e. trigger will fire on all nodes where tuples
907
bool monitorReplicas;
910
* Monitor all attributes, the trigger monitors all changes to attributes
913
bool monitorAllAttributes;
916
* Send only changed attributes at trigger firing time.
918
bool sendOnlyChangedAttributes;
921
* Send also before values at trigger firing time.
923
bool sendBeforeValues;
926
* Attribute mask, defines what attributes are to be monitored
927
* Can be seen as a compact representation of SQL column name list
929
Bitmask<MAXNROFATTRIBUTESINWORDS> attributeMask;
932
* Next ptr (used in pool/list)
940
* Prev pointer (used in list)
944
inline void print(NdbOut & s) const { s << "[TriggerData = " << triggerId << "]"; };
947
typedef Ptr<TupTriggerData> TriggerPtr;
950
* Pool of trigger data record
952
ArrayPool<TupTriggerData> c_triggerPool;
954
/* ************ TABLE RECORD ************ */
955
/* THIS RECORD FORMS A LIST OF TABLE */
956
/* REFERENCE INFORMATION. ONE RECORD */
957
/* PER TABLE REFERENCE. */
958
/* ************************************** */
959
STATIC_CONST( MM = 0 );
960
STATIC_CONST( DD = 1 );
963
Tablerec(ArrayPool<TupTriggerData> & triggerPool) :
964
afterInsertTriggers(triggerPool),
965
afterDeleteTriggers(triggerPool),
966
afterUpdateTriggers(triggerPool),
967
subscriptionInsertTriggers(triggerPool),
968
subscriptionDeleteTriggers(triggerPool),
969
subscriptionUpdateTriggers(triggerPool),
970
constraintUpdateTriggers(triggerPool),
971
tuxCustomTriggers(triggerPool)
974
Bitmask<MAXNROFATTRIBUTESINWORDS> notNullAttributeMask;
975
Bitmask<MAXNROFATTRIBUTESINWORDS> blobAttributeMask;
977
ReadFunction* readFunctionArray;
978
UpdateFunction* updateFunctionArray;
979
CHARSET_INFO** charsetArray;
982
Uint32 tabDescriptor;
983
Uint32 m_real_order_descriptor;
987
TR_Checksum = 0x1, // Need to be 1
989
TR_ForceVarPart = 0x4
992
Uint16 total_rec_size; // Max total size for entire tuple in words
997
Uint16 m_no_of_attributes;
998
Uint16 m_no_of_disk_attributes;
1000
Uint16 noOfCharsets;
1002
bool need_expand() const {
1003
return m_no_of_attributes > m_attributes[MM].m_no_of_fixsize;
1006
bool need_expand(bool disk) const {
1007
return m_attributes[MM].m_no_of_varsize > 0 ||
1008
(disk && m_no_of_disk_attributes > 0);
1011
bool need_shrink() const {
1013
m_attributes[MM].m_no_of_varsize > 0 ||
1014
m_attributes[DD].m_no_of_varsize > 0;
1017
bool need_shrink(bool disk) const {
1019
m_attributes[MM].m_no_of_varsize > 0 ||
1020
(disk && m_attributes[DD].m_no_of_varsize > 0);
1024
* Descriptors for MM and DD part
1026
struct Tuple_offsets {
1028
Uint8 m_null_offset;
1029
Uint16 m_disk_ref_offset; // In words relative m_data
1030
Uint16 m_fix_header_size; // For fix size tuples= total rec size(part)
1031
Uint16 m_max_var_offset; // In bytes relative m_var_data.m_data_ptr
1034
Uint32 get_check_offset(Uint32 mm) const {
1035
return m_offsets[mm].m_fix_header_size;
1039
Uint16 m_no_of_fixsize;
1040
Uint16 m_no_of_varsize;
1043
// Lists of trigger data for active triggers
1044
DLList<TupTriggerData> afterInsertTriggers;
1045
DLList<TupTriggerData> afterDeleteTriggers;
1046
DLList<TupTriggerData> afterUpdateTriggers;
1047
DLList<TupTriggerData> subscriptionInsertTriggers;
1048
DLList<TupTriggerData> subscriptionDeleteTriggers;
1049
DLList<TupTriggerData> subscriptionUpdateTriggers;
1050
DLList<TupTriggerData> constraintUpdateTriggers;
1052
// List of ordered indexes
1053
DLList<TupTriggerData> tuxCustomTriggers;
1055
Uint32 fragid[MAX_FRAG_PER_NODE];
1056
Uint32 fragrec[MAX_FRAG_PER_NODE];
1071
UNDO_ALLOC = File_formats::Undofile::UNDO_TUP_ALLOC
1072
,UNDO_UPDATE = File_formats::Undofile::UNDO_TUP_UPDATE
1073
,UNDO_FREE = File_formats::Undofile::UNDO_TUP_FREE
1074
,UNDO_CREATE = File_formats::Undofile::UNDO_TUP_CREATE
1075
,UNDO_DROP = File_formats::Undofile::UNDO_TUP_DROP
1076
,UNDO_ALLOC_EXTENT = File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT
1077
,UNDO_FREE_EXTENT = File_formats::Undofile::UNDO_TUP_FREE_EXTENT
1082
Uint32 m_file_no_page_idx; // 16 bit file_no, 16 bit page_idx
1084
Uint32 m_type_length; // 16 bit type, 16 bit length
1089
Uint32 m_file_no_page_idx; // 16 bit file_no, 16 bit page_idx
1093
Uint32 m_type_length; // 16 bit type, 16 bit length
1098
Uint32 m_file_no_page_idx; // 16 bit file_no, 16 bit page_idx
1102
Uint32 m_type_length; // 16 bit type, 16 bit length
1108
Uint32 m_type_length; // 16 bit type, 16 bit length
1114
Uint32 m_type_length; // 16 bit type, 16 bit length
1123
Uint32 m_type_length;
1132
Uint32 m_type_length;
1136
Extent_info_pool c_extent_pool;
1137
Extent_info_hash c_extent_hash;
1138
Page_request_pool c_page_request_pool;
1140
typedef Ptr<Tablerec> TablerecPtr;
1143
Uint32 storedLinkFirst;
1144
Uint32 storedLinkLast;
1145
Uint32 storedCounter;
1148
Uint16 storedProcLength;
1151
typedef Ptr<storedProc> StoredProcPtr;
1153
ArrayPool<storedProc> c_storedProcPool;
1155
/* **************************** TABLE_DESCRIPTOR RECORD ******************************** */
1156
/* THIS VARIABLE IS USED TO STORE TABLE DESCRIPTIONS. A TABLE DESCRIPTION IS STORED AS A */
1157
/* CONTIGUOS ARRAY IN THIS VARIABLE. WHEN A NEW TABLE IS ADDED A CHUNK IS ALLOCATED IN */
1158
/* THIS RECORD. WHEN ATTRIBUTES ARE ADDED TO THE TABLE, A NEW CHUNK OF PROPER SIZE IS */
1159
/* ALLOCATED AND ALL DATA IS COPIED TO THIS NEW CHUNK AND THEN THE OLD CHUNK IS PUT IN */
1160
/* THE FREE LIST. EACH TABLE IS DESCRIBED BY A NUMBER OF TABLE DESCRIPTIVE ATTRIBUTES */
1161
/* AND A NUMBER OF ATTRIBUTE DESCRIPTORS AS SHOWN IN FIGURE BELOW */
1163
/* WHEN ALLOCATING A TABLE DESCRIPTOR THE SIZE IS ALWAYS A MULTIPLE OF 16 WORDS. */
1165
/* ---------------------------------------------- */
1166
/* | TRAILER USED FOR ALLOC/DEALLOC | */
1167
/* ---------------------------------------------- */
1168
/* | TABLE DESCRIPTIVE ATTRIBUTES | */
1169
/* ---------------------------------------------- */
1170
/* | ATTRIBUTE DESCRIPTION 1 | */
1171
/* ---------------------------------------------- */
1172
/* | ATTRIBUTE DESCRIPTION 2 | */
1173
/* ---------------------------------------------- */
1177
/* ---------------------------------------------- */
1178
/* | ATTRIBUTE DESCRIPTION N | */
1179
/* ---------------------------------------------- */
1181
/* THE TABLE DESCRIPTIVE ATTRIBUTES CONTAINS THE FOLLOWING ATTRIBUTES: */
1183
/* ---------------------------------------------- */
1184
/* | HEADER (TYPE OF INFO) | */
1185
/* ---------------------------------------------- */
1186
/* | SIZE OF WHOLE CHUNK (INCL. TRAILER) | */
1187
/* ---------------------------------------------- */
1188
/* | TABLE IDENTITY | */
1189
/* ---------------------------------------------- */
1190
/* | FRAGMENT IDENTITY | */
1191
/* ---------------------------------------------- */
1192
/* | NUMBER OF ATTRIBUTES | */
1193
/* ---------------------------------------------- */
1194
/* | SIZE OF FIXED ATTRIBUTES | */
1195
/* ---------------------------------------------- */
1196
/* | NUMBER OF NULL FIELDS | */
1197
/* ---------------------------------------------- */
1199
/* ---------------------------------------------- */
1201
/* THESE ATTRIBUTES ARE ALL ONE R-VARIABLE IN THE RECORD. */
1202
/* NORMALLY ONLY ONE TABLE DESCRIPTOR IS USED. DURING SCHEMA CHANGES THERE COULD */
1203
/* HOWEVER EXIST MORE THAN ONE TABLE DESCRIPTION SINCE THE SCHEMA CHANGE OF VARIOUS */
1204
/* FRAGMENTS ARE NOT SYNCHRONISED. THIS MEANS THAT ALTHOUGH THE SCHEMA HAS CHANGED */
1205
/* IN ALL FRAGMENTS, BUT THE FRAGMENTS HAVE NOT REMOVED THE ATTRIBUTES IN THE SAME */
1206
/* TIME-FRAME. THEREBY SOME ATTRIBUTE INFORMATION MIGHT DIFFER BETWEEN FRAGMENTS. */
1207
/* EXAMPLES OF ATTRIBUTES THAT MIGHT DIFFER ARE SIZE OF FIXED ATTRIBUTES, NUMBER OF */
1208
/* ATTRIBUTES, FIELD START WORD, START BIT. */
1210
/* AN ATTRIBUTE DESCRIPTION CONTAINS THE FOLLOWING ATTRIBUTES: */
1212
/* ---------------------------------------------- */
1213
/* | Field Type, 4 bits (LSB Bits) | */
1214
/* ---------------------------------------------- */
1215
/* | Attribute Size, 4 bits | */
1216
/* ---------------------------------------------- */
1217
/* | NULL indicator 1 bit | */
1218
/* ---------------------------------------------- */
1219
/* | Indicator if TUP stores attr. 1 bit | */
1220
/* ---------------------------------------------- */
1221
/* | Not used 6 bits | */
1222
/* ---------------------------------------------- */
1223
/* | No. of elements in fixed array 16 bits | */
1224
/* ---------------------------------------------- */
1225
/* ---------------------------------------------- */
1226
/* | Field Start Word, 21 bits (LSB Bits) | */
1227
/* ---------------------------------------------- */
1228
/* | NULL Bit, 11 bits | */
1229
/* ---------------------------------------------- */
1231
/* THE ATTRIBUTE SIZE CAN BE 1,2,4,8,16,32,64 AND 128 BITS. */
1233
/* THE UNUSED PARTS OF THE RECORDS ARE PUT IN A LINKED LIST OF FREE PARTS. EACH OF */
1234
/* THOSE FREE PARTS HAVE THREE RECORDS ASSIGNED AS SHOWN IN THIS STRUCTURE */
1235
/* ALL FREE PARTS ARE SET INTO A CHUNK LIST WHERE EACH CHUNK IS AT LEAST 16 WORDS */
1237
/* ---------------------------------------------- */
1238
/* | HEADER = RNIL | */
1239
/* ---------------------------------------------- */
1240
/* | SIZE OF FREE AREA | */
1241
/* ---------------------------------------------- */
1242
/* | POINTER TO PREVIOUS FREE AREA | */
1243
/* ---------------------------------------------- */
1244
/* | POINTER TO NEXT FREE AREA | */
1245
/* ---------------------------------------------- */
1247
/* IF THE POINTER TO THE NEXT AREA IS RNIL THEN THIS IS THE LAST FREE AREA. */
1249
/*****************************************************************************************/
1250
struct TableDescriptor {
1253
typedef Ptr<TableDescriptor> TableDescriptorPtr;
1258
Uint32 noOfPacketsTA;
1259
Uint32 packetBufferTA[30];
1261
typedef Ptr<HostBuffer> HostBufferPtr;
1264
* Build index operation record.
1266
struct BuildIndexRec {
1267
// request cannot use signal class due to extra members
1268
Uint32 m_request[BuildIndxReq::SignalLength];
1269
Uint8 m_build_vs; // varsize pages
1270
Uint32 m_indexId; // the index
1271
Uint32 m_fragNo; // fragment number under Tablerec
1272
Uint32 m_pageId; // logical fragment page id
1273
Uint32 m_tupleNo; // tuple number on page
1274
Uint32 m_buildRef; // Where to send tuples
1275
BuildIndxRef::ErrorCode m_errorCode;
1282
typedef Ptr<BuildIndexRec> BuildIndexPtr;
1283
ArrayPool<BuildIndexRec> c_buildIndexPool;
1284
DLList<BuildIndexRec> c_buildIndexList;
1285
Uint32 c_noOfBuildIndexRec;
1288
* Reference to variable part when a tuple is chained
1292
#ifdef NDB_32BIT_VAR_REF
1294
In versions prior to ndb 6.1.6, 6.2.1 and mysql 5.1.17
1295
Running this code limits DataMemory to 16G, also online
1296
upgrade not possible between versions
1299
STATIC_CONST( SZ32 = 1 );
1301
void copyout(Local_key* dst) const {
1302
dst->m_page_no = m_ref >> MAX_TUPLES_BITS;
1303
dst->m_page_idx = m_ref & MAX_TUPLES_PER_PAGE;
1306
void assign(const Local_key* src) {
1307
m_ref = (src->m_page_no << MAX_TUPLES_BITS) | src->m_page_idx;
1312
STATIC_CONST( SZ32 = 2 );
1314
void copyout(Local_key* dst) const {
1315
dst->m_page_no = m_page_no;
1316
dst->m_page_idx = m_page_idx;
1319
void assign(const Local_key* src) {
1320
m_page_no = src->m_page_no;
1321
m_page_idx = src->m_page_idx;
1326
struct Disk_part_ref
1328
STATIC_CONST( SZ32 = 2 );
1335
* List of prepared operations for this tuple.
1336
* Points to most recent/last operation, ie. to walk the list must follow
1337
* regOperPtr->prevActiveOp links.
1339
Uint32 m_operation_ptr_i; // OperationPtrI
1340
Uint32 m_base_record_ref; // For disk tuple, ref to MM tuple
1342
Uint32 m_header_bits; // Header word
1346
Uint32 m_null_bits[1];
1349
STATIC_CONST( HeaderSize = 2 );
1354
STATIC_CONST( TUP_VERSION_MASK = 0xFFFF );
1355
STATIC_CONST( CHAINED_ROW = 0x00010000 ); // Is var part on different page
1356
STATIC_CONST( DISK_PART = 0x00020000 ); // Is there a disk part
1357
STATIC_CONST( DISK_ALLOC = 0x00040000 ); // Is disk part allocated
1358
STATIC_CONST( DISK_INLINE = 0x00080000 ); // Is disk inline
1359
STATIC_CONST( ALLOC = 0x00100000 ); // Is record allocated now
1360
STATIC_CONST( MM_SHRINK = 0x00200000 ); // Has MM part shrunk
1361
STATIC_CONST( MM_GROWN = 0x00400000 ); // Has MM part grown
1362
STATIC_CONST( FREED = 0x00800000 ); // Is freed
1363
STATIC_CONST( LCP_SKIP = 0x01000000 ); // Should not be returned in LCP
1364
STATIC_CONST( LCP_KEEP = 0x02000000 ); // Should be returned in LCP
1365
STATIC_CONST( FREE = 0x02800000 ); // Is free
1368
Uint32 get_tuple_version() const {
1369
return m_header_bits & TUP_VERSION_MASK;
1371
void set_tuple_version(Uint32 version) {
1373
(m_header_bits & ~(Uint32)TUP_VERSION_MASK) |
1374
(version & TUP_VERSION_MASK);
1377
Uint32* get_null_bits(const Tablerec* tabPtrP) {
1378
return m_null_bits+tabPtrP->m_offsets[MM].m_null_offset;
1381
Uint32* get_null_bits(const Tablerec* tabPtrP, Uint32 mm) {
1382
return m_null_bits+tabPtrP->m_offsets[mm].m_null_offset;
1385
Var_part_ref* get_var_part_ref_ptr(const Tablerec* tabPtrP) {
1386
return (Var_part_ref*)(get_disk_ref_ptr(tabPtrP) + Disk_part_ref::SZ32);
1389
const Var_part_ref* get_var_part_ref_ptr(const Tablerec* tabPtrP) const {
1390
return (Var_part_ref*)(get_disk_ref_ptr(tabPtrP) + Disk_part_ref::SZ32);
1393
Uint32* get_end_of_fix_part_ptr(const Tablerec* tabPtrP) {
1394
return m_data + tabPtrP->m_offsets[MM].m_fix_header_size -
1395
Tuple_header::HeaderSize;
1398
const Uint32* get_end_of_fix_part_ptr(const Tablerec* tabPtrP) const {
1399
return m_data + tabPtrP->m_offsets[MM].m_fix_header_size -
1400
Tuple_header::HeaderSize;
1403
Uint32* get_disk_ref_ptr(const Tablerec* tabPtrP) {
1404
return m_data + tabPtrP->m_offsets[MM].m_disk_ref_offset;
1407
const Uint32* get_disk_ref_ptr(const Tablerec* tabPtrP) const {
1408
return m_data + tabPtrP->m_offsets[MM].m_disk_ref_offset;
1411
Uint32 *get_mm_gci(const Tablerec* tabPtrP){
1412
assert(tabPtrP->m_bits & Tablerec::TR_RowGCI);
1413
return m_data + (tabPtrP->m_bits & Tablerec::TR_Checksum);
1416
Uint32 *get_dd_gci(const Tablerec* tabPtrP, Uint32 mm){
1417
assert(tabPtrP->m_bits & Tablerec::TR_RowGCI);
1422
struct KeyReqStruct {
1424
* These variables are used as temporary storage during execution of the
1426
* The first set of variables defines a number of variables needed for
1427
* the fix part of the tuple.
1429
* The second part defines a number of commonly used meta data variables.
1431
* The third set of variables defines a set of variables needed for the
1434
* The fourth part is variables needed only for updates and inserts.
1436
* The fifth part is a long array of real lengths which is is put last
1437
* for cache memory reasons. This is part of the variable part and
1438
* contains the real allocated lengths whereas the tuple contains
1439
* the length of attribute stored.
1441
Tuple_header *m_tuple_ptr;
1443
Uint32 check_offset[2];
1445
TableDescriptor *attr_descr;
1447
Uint32 out_buf_index;
1448
Uint32 in_buf_index;
1450
Uint32 attr_descriptor;
1455
Uint16 *m_offset_array_ptr;
1456
Uint16 m_var_len_offset;
1457
Uint16 m_max_var_offset;
1460
Tuple_header *m_disk_ptr;
1462
PagePtr m_varpart_page_ptr; // could be same as m_page_ptr_p
1463
PagePtr m_disk_page_ptr; //
1467
bool interpreted_exec;
1472
Uint32 no_fired_triggers;
1473
Uint32 frag_page_id;
1478
Uint32 attrinfo_len;
1479
Uint32 tc_operation_ptr;
1483
// next 2 apply only to attrids >= 64 (zero otherwise)
1484
Uint32 max_attr_id_updated;
1485
Uint32 no_changed_attrs;
1486
BlockReference TC_ref;
1487
BlockReference rec_blockref;
1488
bool change_mask_calculated;
1490
* A bit mask where a bit set means that the update or insert
1491
* was updating this record.
1493
Bitmask<MAXNROFATTRIBUTESINWORDS> changeMask;
1494
Uint16 var_pos_array[2*MAX_ATTRIBUTES_IN_TABLE + 1];
1495
OperationrecPtr prevOpPtr;
1498
friend class Undo_buffer;
1499
Undo_buffer c_undo_buffer;
1503
Implemented by shift instructions in subroutines instead
1505
struct TupHeadInfo {
1507
unsigned int disk_indicator : 1;
1508
unsigned int var_part_loc_ind : 1;
1509
unsigned int initialised : 1;
1510
unsigned int not_used_yet : 5;
1511
unsigned int no_var_sized : 8;
1512
unsigned int tuple_version : 16;
1521
// updateAttributes module
1525
Dbtup(Block_context&, Pgman*);
1529
* TUX uses logical tuple address when talking to ACC and LQH.
1531
void tuxGetTupAddr(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32& tupAddr);
1534
* TUX index in TUP has single Uint32 array attribute which stores an
1535
* index node. TUX reads and writes the node directly via pointer.
1537
int tuxAllocNode(Signal* signal, Uint32 fragPtrI, Uint32& pageId, Uint32& pageOffset, Uint32*& node);
1538
void tuxFreeNode(Signal* signal, Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32* node);
1539
void tuxGetNode(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32*& node);
1542
* TUX reads primary table attributes for index keys. Tuple is
1543
* specified by location of original tuple and version number. Input
1544
* is attribute ids in AttributeHeader format. Output is attribute
1545
* data with headers. Uses readAttributes with xfrm option set.
1546
* Returns number of words or negative (-terrorCode) on error.
1548
int tuxReadAttrs(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32 tupVersion, const Uint32* attrIds, Uint32 numAttrs, Uint32* dataOut);
1551
* TUX reads primary key without headers into an array of words. Used
1552
* for md5 summing and when returning keyinfo. Returns number of
1553
* words or negative (-terrorCode) on error.
1555
int tuxReadPk(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32* dataOut, bool xfrmFlag);
1558
* ACC reads primary key without headers into an array of words. At
1559
* this point in ACC deconstruction, ACC still uses logical references
1560
* to fragment and tuple.
1562
int accReadPk(Uint32 tableId, Uint32 fragId, Uint32 fragPageId, Uint32 pageIndex, Uint32* dataOut, bool xfrmFlag);
1565
* TUX checks if tuple is visible to scan.
1567
bool tuxQueryTh(Uint32 fragPtrI, Uint32 pageId, Uint32 pageIndex, Uint32 tupVersion, Uint32 transId1, Uint32 transId2, bool dirty, Uint32 savepointId);
1569
int load_diskpage(Signal*, Uint32 opRec, Uint32 fragPtrI,
1570
Uint32 local_key, Uint32 flags);
1572
int load_diskpage_scan(Signal*, Uint32 opRec, Uint32 fragPtrI,
1573
Uint32 local_key, Uint32 flags);
1575
int alloc_page(Tablerec*, Fragrecord*, PagePtr*,Uint32 page_no);
1577
void start_restore_lcp(Uint32 tableId, Uint32 fragmentId);
1578
void complete_restore_lcp(Uint32 tableId, Uint32 fragmentId);
1580
int nr_read_pk(Uint32 fragPtr, const Local_key*, Uint32* dataOut, bool©);
1581
int nr_update_gci(Uint32 fragPtr, const Local_key*, Uint32 gci);
1582
int nr_delete(Signal*, Uint32, Uint32 fragPtr, const Local_key*, Uint32 gci);
1584
void nr_delete_page_callback(Signal*, Uint32 op, Uint32 page);
1585
void nr_delete_log_buffer_callback(Signal*, Uint32 op, Uint32 page);
1587
bool get_frag_info(Uint32 tableId, Uint32 fragId, Uint32* maxPage);
1589
BLOCK_DEFINES(Dbtup);
1592
void execDEBUG_SIG(Signal* signal);
1593
void execCONTINUEB(Signal* signal);
1596
void execLCP_FRAG_ORD(Signal*signal);
1597
void execDUMP_STATE_ORD(Signal* signal);
1598
void execSEND_PACKED(Signal* signal);
1599
void execSTTOR(Signal* signal);
1600
void execTUP_LCPREQ(Signal* signal);
1601
void execEND_LCPREQ(Signal* signal);
1602
void execSTART_RECREQ(Signal* signal);
1603
void execMEMCHECKREQ(Signal* signal);
1604
void execTUPSEIZEREQ(Signal* signal);
1605
void execTUPRELEASEREQ(Signal* signal);
1606
void execSTORED_PROCREQ(Signal* signal);
1607
void execTUPFRAGREQ(Signal* signal);
1608
void execTUP_ADD_ATTRREQ(Signal* signal);
1609
void execTUP_COMMITREQ(Signal* signal);
1610
void execTUP_ABORTREQ(Signal* signal);
1611
void execNDB_STTOR(Signal* signal);
1612
void execREAD_CONFIG_REQ(Signal* signal);
1613
void execDROP_TAB_REQ(Signal* signal);
1614
void execALTER_TAB_REQ(Signal* signal);
1615
void execTUP_DEALLOCREQ(Signal* signal);
1616
void execTUP_WRITELOG_REQ(Signal* signal);
1618
// Ordered index related
1619
void execBUILDINDXREQ(Signal* signal);
1620
void buildIndex(Signal* signal, Uint32 buildPtrI);
1621
void buildIndexReply(Signal* signal, const BuildIndexRec* buildRec);
1624
void execACC_SCANREQ(Signal* signal);
1625
void execNEXT_SCANREQ(Signal* signal);
1626
void execACC_CHECK_SCAN(Signal* signal);
1627
void execACCKEYCONF(Signal* signal);
1628
void execACCKEYREF(Signal* signal);
1629
void execACC_ABORTCONF(Signal* signal);
1633
void execFSREMOVEREF(Signal*);
1634
void execFSREMOVECONF(Signal*);
1636
//------------------------------------------------------------------
1637
//------------------------------------------------------------------
1638
// Methods to handle execution of TUPKEYREQ + ATTRINFO.
1640
// Module Execution Manager
1642
// The TUPKEYREQ signal is central to this block. This signal is used
1643
// by everybody that needs to read data residing in DBTUP. The data is
1644
// read using an interpreter approach.
1646
// Operations only needing to read execute a simplified version of the
1647
// interpreter where the only instruction is read Attribute to send.
1648
// Operations only needing to update the record (insert or update)
1649
// execute a simplified version of the interpreter where the only
1650
// instruction is write Attribute.
1652
// Currently TUPKEYREQ is used in the following situations.
1653
// 1) Normal transaction execution. Can be any of the types described
1655
// 2) Execution of fragment redo log during system restart.
1656
// In this situation there will only be normal updates, inserts
1657
// and deletes performed.
1658
// 3) A special type of normal transaction execution is to write the
1659
// records arriving from the primary replica in the node restart
1660
// processing. This will always be normal write operations which
1661
// are translated to inserts or updates before arriving to TUP.
1662
// 4) Scan processing. The scan processing will use normal reads or
1663
// interpreted reads in their execution. There will be one TUPKEYREQ
1664
// signal for each record processed.
1665
// 5) Copy fragment processing. This is a special type of scan used in the
1666
// primary replica at system restart. It reads the entire reads and
1667
// converts those to writes to the starting node. In this special case
1668
// LQH acts as an API node and receives also the ATTRINFO sent in the
1669
// TRANSID_AI signals.
1676
// Logically there is one request TUPKEYREQ which requests to read/write data
1677
// of one tuple in the database. Since the definition of what to read and write
1678
// can be bigger than the maximum signal size we segment the signal. The definition
1679
// of what to read/write/interpreted program is sent before the TUPKEYREQ signal.
1685
// The number of ATTRINFO signals can be anything between 0 and upwards.
1686
// The total size of the ATTRINFO is not allowed to be more than 16384 words.
1687
// There is always one and only one TUPKEYREQ.
1689
// Response Signals (successful case):
1691
// Simple/Dirty Read Operation
1692
// ---------------------------
1694
// <---- TRANSID_AI (to API)
1696
// <---- TRANSID_AI (to API)
1697
// <---- READCONF (to API)
1698
// <---- TUPKEYCONF (to LQH)
1699
// There is always exactly one READCONF25 sent last. The number of
1700
// TRANSID_AI is dependent on how much that was read. The maximum size
1701
// of the ATTRINFO sent back is 16384 words. The signals are sent
1702
// directly to the application with an address provided by the
1703
// TUPKEYREQ signal.
1704
// A positive response signal is also sent to LQH.
1706
// Normal Read Operation
1707
// ---------------------
1709
// <---- TRANSID_AI (to API)
1711
// <---- TRANSID_AI (to API)
1712
// <---- TUPKEYCONF (to LQH)
1713
// The number of TRANSID_AI is dependent on how much that was read.
1714
// The maximum size of the ATTRINFO sent back is 16384 words. The
1715
// signals are sent directly to the application with an address
1716
// provided by the TUPKEYREQ signal.
1717
// A positive response signal is also sent to LQH.
1719
// Normal update/insert/delete operation
1720
// -------------------------------------
1723
// After successful updating of the tuple LQH is informed of this.
1728
// Will behave as a normal read although it also prepares the
1729
// deletion of the tuple.
1731
// Interpreted Update
1732
// ------------------
1734
// <---- TRANSID_AI (to API)
1736
// <---- TRANSID_AI (to API)
1737
// <---- TUP_ATTRINFO (to LQH)
1739
// <---- TUP_ATTRINFO (to LQH)
1740
// <---- TUPKEYCONF (to LQH)
1742
// The interpreted Update contains five sections:
1743
// The first section performs read Attribute operations
1744
// that send results back to the API.
1746
// The second section executes the interpreted program
1747
// where data from attributes can be updated and it
1748
// can also read attribute values into the registers.
1750
// The third section performs unconditional updates of
1753
// The fourth section can read the attributes to be sent to the
1754
// API after updating the record.
1756
// The fifth section contains subroutines used by the interpreter
1757
// in the second section.
1759
// All types of interpreted programs contains the same five sections.
1760
// The only difference is that only interpreted updates can update
1761
// attributes. Interpreted inserts are not allowed.
1763
// Interpreted Updates have to send back the information about the
1764
// attributes they have updated. This information will be shipped to
1765
// the log and also to any other replicas. Thus interpreted updates
1766
// are only performed in the primary replica. The fragment redo log
1767
// in LQH will contain information so that normal update/inserts/deletes
1768
// can be performed using TUPKEYREQ.
1773
// From a signalling point of view the Interpreted Read behaves as
1774
// as a Normal Read. The interpreted Read is often used by Scan's.
1776
// Interpreted Delete
1777
// ------------------
1780
// After successful prepartion to delete the tuple LQH is informed
1783
// Interpreted Delete with Read
1784
// ----------------------------
1786
// From a signalling point of view an interpreted delete with read
1787
// behaves as a normal read.
1789
// Continuation after successful case:
1791
// After a read of any kind the operation record is ready to be used
1792
// again by a new operation.
1794
// Any updates, inserts or deletes waits for either of two messages.
1795
// A commit specifying that the operation is to be performed for real
1796
// or an abort specifying that the operation is to be rolled back and
1797
// the record to be restored in its original format.
1799
// This is handled by the module Transaction Manager.
1801
// Response Signals (unsuccessful case):
1803
// <---- TUPKEYREF (to LQH)
1804
// A signal is sent back to LQH informing about the unsuccessful
1805
// operation. In this case TUP waits for an abort signal to arrive
1806
// before the operation record is ready for the next operation.
1807
// This is handled by the Transaction Manager.
1808
//------------------------------------------------------------------
1809
//------------------------------------------------------------------
1811
// *****************************************************************
1812
// Signal Reception methods.
1813
// *****************************************************************
1814
//------------------------------------------------------------------
1815
//------------------------------------------------------------------
1816
void execTUPKEYREQ(Signal* signal);
1817
void disk_page_load_callback(Signal*, Uint32 op, Uint32 page);
1818
void disk_page_load_scan_callback(Signal*, Uint32 op, Uint32 page);
1820
//------------------------------------------------------------------
1821
//------------------------------------------------------------------
1822
void execATTRINFO(Signal* signal);
1824
void receive_attrinfo(Signal*, Uint32 op, const Uint32* data, Uint32 len);
1828
//------------------------------------------------------------------
1829
//------------------------------------------------------------------
1830
void execCREATE_TRIG_REQ(Signal* signal);
1832
//------------------------------------------------------------------
1833
//------------------------------------------------------------------
1834
void execDROP_TRIG_REQ(Signal* signal);
1836
// *****************************************************************
1837
// Support methods for ATTRINFO.
1838
// *****************************************************************
1839
//------------------------------------------------------------------
1840
//------------------------------------------------------------------
1841
void handleATTRINFOforTUPKEYREQ(Signal* signal,
1844
Operationrec * regOperPtr);
1846
// *****************************************************************
1847
// Setting up the environment for reads, inserts, updates and deletes.
1848
// *****************************************************************
1849
//------------------------------------------------------------------
1850
//------------------------------------------------------------------
1851
int handleReadReq(Signal* signal,
1852
Operationrec* regOperPtr,
1853
Tablerec* regTabPtr,
1854
KeyReqStruct* req_struct);
1856
//------------------------------------------------------------------
1857
//------------------------------------------------------------------
1858
int handleUpdateReq(Signal* signal,
1859
Operationrec* regOperPtr,
1860
Fragrecord* regFragPtr,
1861
Tablerec* regTabPtr,
1862
KeyReqStruct* req_struct,
1865
//------------------------------------------------------------------
1866
//------------------------------------------------------------------
1867
int handleInsertReq(Signal* signal,
1868
Ptr<Operationrec> regOperPtr,
1870
Tablerec* regTabPtr,
1871
KeyReqStruct* req_struct);
1873
//------------------------------------------------------------------
1874
//------------------------------------------------------------------
1875
int handleDeleteReq(Signal* signal,
1876
Operationrec* regOperPtr,
1877
Fragrecord* regFragPtr,
1878
Tablerec* regTabPtr,
1879
KeyReqStruct* req_struct,
1882
//------------------------------------------------------------------
1883
//------------------------------------------------------------------
1884
int updateStartLab(Signal* signal,
1885
Operationrec* regOperPtr,
1886
Fragrecord* regFragPtr,
1887
Tablerec* regTabPtr,
1888
KeyReqStruct* req_struct);
1890
// *****************************************************************
1891
// Interpreter Handling methods.
1892
// *****************************************************************
1894
//------------------------------------------------------------------
1895
//------------------------------------------------------------------
1896
int interpreterStartLab(Signal* signal,
1897
KeyReqStruct *req_struct);
1899
//------------------------------------------------------------------
1900
//------------------------------------------------------------------
1901
int interpreterNextLab(Signal* signal,
1902
KeyReqStruct *req_struct,
1904
Uint32* mainProgram,
1905
Uint32 TmainProgLen,
1906
Uint32* subroutineProg,
1907
Uint32 TsubroutineLen,
1911
// *****************************************************************
1912
// Signal Sending methods.
1913
// *****************************************************************
1914
//------------------------------------------------------------------
1915
//------------------------------------------------------------------
1916
void sendReadAttrinfo(Signal* signal,
1917
KeyReqStruct *req_struct,
1919
const Operationrec * regOperPtr);
1921
//------------------------------------------------------------------
1922
//------------------------------------------------------------------
1923
void sendLogAttrinfo(Signal* signal,
1925
Operationrec * regOperPtr);
1927
//------------------------------------------------------------------
1928
//------------------------------------------------------------------
1929
void sendTUPKEYCONF(Signal* signal,
1930
KeyReqStruct *req_struct,
1931
Operationrec * regOperPtr);
1933
//------------------------------------------------------------------
1934
//------------------------------------------------------------------
1935
// *****************************************************************
1936
// The methods that perform the actual read and update of attributes
1938
// *****************************************************************
1939
//------------------------------------------------------------------
1940
//------------------------------------------------------------------
1941
int readAttributes(KeyReqStruct* req_struct,
1942
const Uint32* inBuffer,
1948
//------------------------------------------------------------------
1949
//------------------------------------------------------------------
1950
int updateAttributes(KeyReqStruct *req_struct,
1954
//------------------------------------------------------------------
1955
//------------------------------------------------------------------
1956
bool readFixedSizeTHOneWordNotNULL(Uint32* outBuffer,
1957
KeyReqStruct *req_struct,
1958
AttributeHeader* ahOut,
1961
//------------------------------------------------------------------
1962
//------------------------------------------------------------------
1963
bool updateFixedSizeTHOneWordNotNULL(Uint32* inBuffer,
1964
KeyReqStruct *req_struct,
1967
//------------------------------------------------------------------
1968
//------------------------------------------------------------------
1969
bool readFixedSizeTHTwoWordNotNULL(Uint32* outBuffer,
1970
KeyReqStruct *req_struct,
1971
AttributeHeader* ahOut,
1974
//------------------------------------------------------------------
1975
//------------------------------------------------------------------
1976
bool updateFixedSizeTHTwoWordNotNULL(Uint32* inBuffer,
1977
KeyReqStruct *req_struct,
1980
//------------------------------------------------------------------
1981
//------------------------------------------------------------------
1982
bool readFixedSizeTHManyWordNotNULL(Uint32* outBuffer,
1983
KeyReqStruct *req_struct,
1984
AttributeHeader* ahOut,
1987
//------------------------------------------------------------------
1988
//------------------------------------------------------------------
1989
bool updateFixedSizeTHManyWordNotNULL(Uint32* inBuffer,
1990
KeyReqStruct *req_struct,
1993
//------------------------------------------------------------------
1994
//------------------------------------------------------------------
1995
bool readFixedSizeTHOneWordNULLable(Uint32* outBuffer,
1996
KeyReqStruct *req_struct,
1997
AttributeHeader* ahOut,
2000
//------------------------------------------------------------------
2001
//------------------------------------------------------------------
2002
bool updateFixedSizeTHOneWordNULLable(Uint32* inBuffer,
2003
KeyReqStruct *req_struct,
2006
//------------------------------------------------------------------
2007
//------------------------------------------------------------------
2008
bool readFixedSizeTHTwoWordNULLable(Uint32* outBuffer,
2009
KeyReqStruct *req_struct,
2010
AttributeHeader* ahOut,
2013
//------------------------------------------------------------------
2014
//------------------------------------------------------------------
2015
bool updateFixedSizeTHTwoWordNULLable(Uint32* inBuffer,
2016
KeyReqStruct *req_struct,
2019
//------------------------------------------------------------------
2020
//------------------------------------------------------------------
2021
bool readFixedSizeTHManyWordNULLable(Uint32* outBuffer,
2022
KeyReqStruct *req_struct,
2023
AttributeHeader* ahOut,
2026
//------------------------------------------------------------------
2027
//------------------------------------------------------------------
2028
bool readFixedSizeTHZeroWordNULLable(Uint32* outBuffer,
2029
KeyReqStruct *req_struct,
2030
AttributeHeader* ahOut,
2032
//------------------------------------------------------------------
2033
//------------------------------------------------------------------
2034
bool updateFixedSizeTHManyWordNULLable(Uint32* inBuffer,
2035
KeyReqStruct *req_struct,
2038
//------------------------------------------------------------------
2039
//------------------------------------------------------------------
2040
bool readVarSizeNotNULL(Uint32* outBuffer,
2041
KeyReqStruct *req_struct,
2042
AttributeHeader* ahOut,
2045
//------------------------------------------------------------------
2046
//------------------------------------------------------------------
2047
bool updateVarSizeNotNULL(Uint32* inBuffer,
2048
KeyReqStruct *req_struct,
2051
//------------------------------------------------------------------
2052
//------------------------------------------------------------------
2053
bool readVarSizeNULLable(Uint32* outBuffer,
2054
KeyReqStruct *req_struct,
2055
AttributeHeader* ahOut,
2058
//------------------------------------------------------------------
2059
//------------------------------------------------------------------
2060
bool updateVarSizeNULLable(Uint32* inBuffer,
2061
KeyReqStruct *req_struct,
2064
//------------------------------------------------------------------
2065
//------------------------------------------------------------------
2066
bool readDynFixedSize(Uint32* outBuffer,
2067
KeyReqStruct *req_struct,
2068
AttributeHeader* ahOut,
2071
//------------------------------------------------------------------
2072
//------------------------------------------------------------------
2073
bool updateDynFixedSize(Uint32* inBuffer,
2074
KeyReqStruct *req_struct,
2077
//------------------------------------------------------------------
2078
//------------------------------------------------------------------
2079
bool readDynVarSize(Uint32* outBuffer,
2080
KeyReqStruct *req_struct,
2081
AttributeHeader* ahOut,
2084
//------------------------------------------------------------------
2085
//------------------------------------------------------------------
2086
bool updateDynVarSize(Uint32* inBuffer,
2087
KeyReqStruct *req_struct,
2090
bool readCharNotNULL(Uint32* outBuffer,
2091
KeyReqStruct *req_struct,
2092
AttributeHeader* ahOut,
2095
bool readCharNULLable(Uint32* outBuffer,
2096
KeyReqStruct *req_struct,
2097
AttributeHeader* ahOut,
2100
bool readBitsNULLable(Uint32* outBuffer, KeyReqStruct *req_struct, AttributeHeader*, Uint32);
2101
bool updateBitsNULLable(Uint32* inBuffer, KeyReqStruct *req_struct, Uint32);
2102
bool readBitsNotNULL(Uint32* outBuffer, KeyReqStruct *req_struct, AttributeHeader*, Uint32);
2103
bool updateBitsNotNULL(Uint32* inBuffer, KeyReqStruct *req_struct, Uint32);
2105
bool updateFixedNULLable(Uint32* inBuffer, KeyReqStruct *req_struct, Uint32);
2106
bool updateFixedNotNull(Uint32* inBuffer, KeyReqStruct *req_struct, Uint32);
2108
bool updateVarNULLable(Uint32* inBuffer, KeyReqStruct *req_struct, Uint32);
2109
bool updateVarNotNull(Uint32* inBuffer, KeyReqStruct *req_struct, Uint32);
2112
bool readDiskFixedSizeNotNULL(Uint32* outBuffer,
2113
KeyReqStruct *req_struct,
2114
AttributeHeader* ahOut,
2117
bool readDiskFixedSizeNULLable(Uint32* outBuffer,
2118
KeyReqStruct *req_struct,
2119
AttributeHeader* ahOut,
2121
bool readDiskVarSizeNULLable(Uint32* outBuffer, KeyReqStruct *req_struct, AttributeHeader*, Uint32);
2122
bool readDiskVarSizeNotNULL(Uint32* outBuffer, KeyReqStruct *req_struct, AttributeHeader*, Uint32);
2124
bool updateDiskFixedSizeNULLable(Uint32*, KeyReqStruct*, Uint32);
2125
bool updateDiskFixedSizeNotNULL(Uint32*, KeyReqStruct*, Uint32);
2127
bool updateDiskVarSizeNULLable(Uint32*, KeyReqStruct *, Uint32);
2128
bool updateDiskVarSizeNotNULL(Uint32*, KeyReqStruct *, Uint32);
2130
bool readDiskBitsNULLable(Uint32*, KeyReqStruct*, AttributeHeader*, Uint32);
2131
bool readDiskBitsNotNULL(Uint32*, KeyReqStruct*, AttributeHeader*, Uint32);
2132
bool updateDiskBitsNULLable(Uint32*, KeyReqStruct*, Uint32);
2133
bool updateDiskBitsNotNULL(Uint32*, KeyReqStruct*, Uint32);
2136
//------------------------------------------------------------------
2137
//------------------------------------------------------------------
2138
bool nullFlagCheck(KeyReqStruct *req_struct, Uint32 attrDes2);
2139
bool disk_nullFlagCheck(KeyReqStruct *req_struct, Uint32 attrDes2);
2140
Uint32 read_pseudo(Uint32 attrId,
2141
KeyReqStruct *req_struct,
2144
//------------------------------------------------------------------
2145
//------------------------------------------------------------------
2146
void setUpQueryRoutines(Tablerec* regTabPtr);
2148
// *****************************************************************
2150
// *****************************************************************
2151
TransState get_trans_state(Operationrec * const);
2152
void set_trans_state(Operationrec * const, TransState);
2153
TupleState get_tuple_state(Operationrec * const);
2154
void set_tuple_state(Operationrec * const, TupleState);
2155
Uint32 get_frag_page_id(Uint32 real_page_id);
2156
Uint32 get_fix_page_offset(Uint32 page_index, Uint32 tuple_size);
2158
Uint32 decr_tup_version(Uint32 tuple_version);
2159
void set_change_mask_state(Operationrec * const, ChangeMaskState);
2160
ChangeMaskState get_change_mask_state(Operationrec * const);
2161
void update_change_mask_info(KeyReqStruct * const, Operationrec * const);
2162
void set_change_mask_info(KeyReqStruct * const, Operationrec * const);
2164
//------------------------------------------------------------------
2165
//------------------------------------------------------------------
2166
void copyAttrinfo(Operationrec * regOperPtr, Uint32* inBuffer);
2168
//------------------------------------------------------------------
2169
//------------------------------------------------------------------
2170
void initOpConnection(Operationrec* regOperPtr);
2172
//------------------------------------------------------------------
2173
//------------------------------------------------------------------
2174
void initOperationrec(Signal* signal);
2176
//------------------------------------------------------------------
2177
//------------------------------------------------------------------
2178
int initStoredOperationrec(Operationrec* regOperPtr,
2179
KeyReqStruct* req_struct,
2182
//------------------------------------------------------------------
2183
//------------------------------------------------------------------
2184
bool insertActiveOpList(OperationrecPtr, KeyReqStruct* req_struct);
2186
//------------------------------------------------------------------
2187
//------------------------------------------------------------------
2189
//------------------------------------------------------------------
2190
//------------------------------------------------------------------
2191
void bufferTRANSID_AI(Signal* signal, BlockReference aRef, Uint32 Tlen);
2193
//------------------------------------------------------------------
2194
// Trigger handling routines
2195
//------------------------------------------------------------------
2196
DLList<TupTriggerData>*
2197
findTriggerList(Tablerec* table,
2198
TriggerType::Value ttype,
2199
TriggerActionTime::Value ttime,
2200
TriggerEvent::Value tevent);
2202
bool createTrigger(Tablerec* table, const CreateTrigReq* req);
2204
Uint32 dropTrigger(Tablerec* table,
2205
const DropTrigReq* req,
2206
BlockNumber sender);
2209
checkImmediateTriggersAfterInsert(KeyReqStruct *req_struct,
2210
Operationrec* regOperPtr,
2215
checkImmediateTriggersAfterUpdate(KeyReqStruct *req_struct,
2216
Operationrec* regOperPtr,
2221
checkImmediateTriggersAfterDelete(KeyReqStruct *req_struct,
2222
Operationrec* regOperPtr,
2227
void checkDeferredTriggers(Signal* signal,
2228
Operationrec* regOperPtr,
2229
Tablerec* regTablePtr);
2231
void checkDetachedTriggers(KeyReqStruct *req_struct,
2232
Operationrec* regOperPtr,
2233
Tablerec* regTablePtr,
2236
void fireImmediateTriggers(KeyReqStruct *req_struct,
2237
DLList<TupTriggerData>& triggerList,
2238
Operationrec* regOperPtr,
2241
void fireDeferredTriggers(KeyReqStruct *req_struct,
2242
DLList<TupTriggerData>& triggerList,
2243
Operationrec* regOperPtr);
2245
void fireDetachedTriggers(KeyReqStruct *req_struct,
2246
DLList<TupTriggerData>& triggerList,
2247
Operationrec* regOperPtr,
2250
void executeTriggers(KeyReqStruct *req_struct,
2251
DLList<TupTriggerData>& triggerList,
2252
Operationrec* regOperPtr,
2255
void executeTrigger(KeyReqStruct *req_struct,
2256
TupTriggerData* trigPtr,
2257
Operationrec* regOperPtr,
2260
bool readTriggerInfo(TupTriggerData* trigPtr,
2261
Operationrec* regOperPtr,
2262
KeyReqStruct * req_struct,
2263
Fragrecord* regFragPtr,
2266
Uint32* afterBuffer,
2267
Uint32& noAfterWords,
2268
Uint32* beforeBuffer,
2269
Uint32& noBeforeWords,
2272
void sendTrigAttrInfo(Signal* signal,
2276
BlockReference receiverReference);
2278
Uint32 setAttrIds(Bitmask<MAXNROFATTRIBUTESINWORDS>& attributeMask,
2279
Uint32 noOfAttributes,
2282
void sendFireTrigOrd(Signal* signal,
2283
KeyReqStruct *req_struct,
2284
Operationrec * regOperPtr,
2285
TupTriggerData* trigPtr,
2287
Uint32 noPrimKeySignals,
2288
Uint32 noBeforeSignals,
2289
Uint32 noAfterSignals);
2291
bool primaryKey(Tablerec* const, Uint32);
2293
// these set terrorCode and return non-zero on error
2295
int executeTuxInsertTriggers(Signal* signal,
2296
Operationrec* regOperPtr,
2297
Fragrecord* regFragPtr,
2298
Tablerec* regTabPtr);
2300
int executeTuxUpdateTriggers(Signal* signal,
2301
Operationrec* regOperPtr,
2302
Fragrecord* regFragPtr,
2303
Tablerec* regTabPtr);
2305
int executeTuxDeleteTriggers(Signal* signal,
2306
Operationrec* regOperPtr,
2307
Fragrecord* regFragPtr,
2308
Tablerec* regTabPtr);
2310
int addTuxEntries(Signal* signal,
2311
Operationrec* regOperPtr,
2312
Tablerec* regTabPtr);
2314
// these crash the node on error
2316
void executeTuxCommitTriggers(Signal* signal,
2317
Operationrec* regOperPtr,
2318
Fragrecord* regFragPtr,
2319
Tablerec* regTabPtr);
2321
void executeTuxAbortTriggers(Signal* signal,
2322
Operationrec* regOperPtr,
2323
Fragrecord* regFragPtr,
2324
Tablerec* regTabPtr);
2326
void removeTuxEntries(Signal* signal,
2327
Tablerec* regTabPtr);
2329
// *****************************************************************
2330
// Error Handling routines.
2331
// *****************************************************************
2332
//------------------------------------------------------------------
2333
//------------------------------------------------------------------
2334
int TUPKEY_abort(Signal* signal, int error_type);
2336
//------------------------------------------------------------------
2337
//------------------------------------------------------------------
2338
void tupkeyErrorLab(Signal* signal);
2339
void do_tup_abortreq(Signal*, Uint32 flags);
2341
//------------------------------------------------------------------
2342
//------------------------------------------------------------------
2343
// Methods to handle execution of TUP_COMMITREQ + TUP_ABORTREQ.
2345
// Module Transaction Manager
2347
// The Transaction Manager module is responsible for the commit
2348
// and abort of operations started by the Execution Manager.
2350
// Commit Operation:
2353
// Failures in commit processing is not allowed since that would
2354
// leave the database in an unreliable state. Thus the only way
2355
// to handle failures in commit processing is to crash the node.
2357
// TUP_COMMITREQ can only be received in the wait state after a
2358
// successful TUPKEYREQ which was not a read operation.
2360
// Commit of Delete:
2361
// -----------------
2363
// This will actually perform the deletion of the record unless
2364
// other operations also are connected to the record. In this case
2365
// we will set the delete state on the record that becomes the ownerd
2368
// Commit of Update:
2371
// We will release the copy record where the original record was kept.
2372
// Also here we will take special care if more operations are updating
2373
// the record simultaneously.
2375
// Commit of Insert:
2376
// -----------------
2378
// Will simply reset the state of the operation record.
2381
// ---> TUP_COMMITREQ (from LQH)
2382
// <---- TUP_COMMITCONF (to LQH)
2389
// ---> TUP_ABORTREQ (from LQH)
2390
// <---- TUP_ABORTCONF (to LQH)
2392
// Failures in abort processing is not allowed since that would
2393
// leave the database in an unreliable state. Thus the only way
2394
// to handle failures in abort processing is to crash the node.
2396
// Abort messages can arrive at any time. It can arrive even before
2397
// anything at all have arrived of the operation. It can arrive after
2398
// receiving a number of ATTRINFO but before TUPKEYREQ has been received.
2399
// It must arrive after that we sent TUPKEYREF in response to TUPKEYREQ
2400
// and finally it can arrive after successfully performing the TUPKEYREQ
2401
// in all cases including the read case.
2402
//------------------------------------------------------------------
2403
//------------------------------------------------------------------
2406
void checkPages(Fragrecord* regFragPtr);
2408
Uint32 convert_byte_to_word_size(Uint32 byte_size)
2410
return ((byte_size + 3) >> 2);
2412
Uint32 convert_bit_to_word_size(Uint32 bit_size)
2414
return ((bit_size + 31) >> 5);
2417
void prepare_initial_insert(KeyReqStruct*, Operationrec*, Tablerec*);
2418
void fix_disk_insert_no_mem_insert(KeyReqStruct*, Operationrec*, Tablerec*);
2419
void setup_fixed_part(KeyReqStruct* req_struct,
2420
Operationrec* regOperPtr,
2421
Tablerec* regTabPtr);
2423
void send_TUPKEYREF(Signal* signal,
2424
Operationrec* regOperPtr);
2425
void early_tupkey_error(Signal* signal);
2427
void printoutTuplePage(Uint32 fragid, Uint32 pageid, Uint32 printLimit);
2429
bool checkUpdateOfPrimaryKey(KeyReqStruct *req_struct,
2430
Uint32* updateBuffer,
2431
Tablerec* regTabPtr);
2433
void setNullBits(Uint32*, Tablerec* regTabPtr);
2434
bool checkNullAttributes(KeyReqStruct * const, Tablerec* const);
2435
bool find_savepoint(OperationrecPtr& loopOpPtr, Uint32 savepointId);
2436
bool setup_read(KeyReqStruct* req_struct,
2437
Operationrec* regOperPtr,
2438
Fragrecord* regFragPtr,
2439
Tablerec* regTabPtr,
2442
Uint32 calculateChecksum(Tuple_header*, Tablerec* regTabPtr);
2443
void setChecksum(Tuple_header*, Tablerec* regTabPtr);
2445
void complexTrigger(Signal* signal,
2446
KeyReqStruct *req_struct,
2447
Operationrec* regOperPtr,
2448
Fragrecord* regFragPtr,
2449
Tablerec* regTabPtr);
2451
void setTupleStatesSetOpType(Operationrec* regOperPtr,
2452
KeyReqStruct *req_struct,
2455
OperationrecPtr& firstOpPtr);
2457
void findBeforeValueOperation(OperationrecPtr& befOpPtr,
2458
OperationrecPtr firstOpPtr);
2460
void calculateChangeMask(Page* PagePtr,
2461
Tablerec* regTabPtr,
2462
KeyReqStruct * req_struct);
2464
void updateGcpId(KeyReqStruct *req_struct,
2465
Operationrec* regOperPtr,
2466
Fragrecord* regFragPtr,
2467
Tablerec* regTabPtr);
2469
void setTupleStateOnPreviousOps(Uint32 prevOpIndex);
2470
void copyMem(Signal* signal, Uint32 sourceIndex, Uint32 destIndex);
2472
void freeAllAttrBuffers(Operationrec* const regOperPtr);
2473
void freeAttrinbufrec(Uint32 anAttrBufRec);
2474
void removeActiveOpList(Operationrec* const regOperPtr, Tuple_header*);
2476
void updatePackedList(Signal* signal, Uint16 ahostIndex);
2478
void setUpDescriptorReferences(Uint32 descriptorReference,
2479
Tablerec* regTabPtr,
2480
const Uint32* offset);
2481
void setUpKeyArray(Tablerec* regTabPtr);
2482
bool addfragtotab(Tablerec* regTabPtr, Uint32 fragId, Uint32 fragIndex);
2483
void deleteFragTab(Tablerec* regTabPtr, Uint32 fragId);
2484
void abortAddFragOp(Signal* signal);
2485
void releaseTabDescr(Tablerec* regTabPtr);
2486
void getFragmentrec(FragrecordPtr& regFragPtr, Uint32 fragId, Tablerec* regTabPtr);
2488
void initialiseRecordsLab(Signal* signal, Uint32 switchData, Uint32, Uint32);
2489
void initializeAttrbufrec();
2490
void initializeCheckpointInfoRec();
2491
void initializeDiskBufferSegmentRecord();
2492
void initializeFragoperrec();
2493
void initializeFragrecord();
2494
void initializeHostBuffer();
2495
void initializeLocalLogInfo();
2496
void initializeOperationrec();
2497
void initializePendingFileOpenInfoRecord();
2498
void initializeRestartInfoRec();
2499
void initializeTablerec();
2500
void initializeTabDescr();
2501
void initializeUndoPage();
2503
void initTab(Tablerec* regTabPtr);
2505
void startphase3Lab(Signal* signal, Uint32 config1, Uint32 config2);
2507
void fragrefuseLab(Signal* signal, FragoperrecPtr fragOperPtr);
2508
void fragrefuse1Lab(Signal* signal, FragoperrecPtr fragOperPtr);
2509
void fragrefuse2Lab(Signal* signal, FragoperrecPtr fragOperPtr, FragrecordPtr regFragPtr);
2510
void fragrefuse3Lab(Signal* signal,
2511
FragoperrecPtr fragOperPtr,
2512
FragrecordPtr regFragPtr,
2513
Tablerec* regTabPtr,
2515
void fragrefuse4Lab(Signal* signal,
2516
FragoperrecPtr fragOperPtr,
2517
FragrecordPtr regFragPtr,
2518
Tablerec* regTabPtr,
2520
void addattrrefuseLab(Signal* signal,
2521
FragrecordPtr regFragPtr,
2522
FragoperrecPtr fragOperPtr,
2523
Tablerec* regTabPtr,
2527
void releaseFragment(Signal* signal, Uint32 tableId, Uint32);
2528
void drop_fragment_free_var_pages(Signal*);
2529
void drop_fragment_free_extent(Signal*, TablerecPtr, FragrecordPtr, Uint32);
2530
void drop_fragment_free_extent_log_buffer_callback(Signal*, Uint32, Uint32);
2531
void drop_fragment_unmap_pages(Signal*, TablerecPtr, FragrecordPtr, Uint32);
2532
void drop_fragment_unmap_page_callback(Signal* signal, Uint32, Uint32);
2533
void drop_fragment_fsremove(Signal*, TablerecPtr, FragrecordPtr);
2534
void drop_fragment_fsremove_done(Signal*, TablerecPtr, FragrecordPtr);
2540
void deleteScanProcedure(Signal* signal, Operationrec* regOperPtr);
2541
void copyProcedure(Signal* signal,
2542
TablerecPtr regTabPtr,
2543
Operationrec* regOperPtr);
2544
void scanProcedure(Signal* signal,
2545
Operationrec* regOperPtr,
2546
Uint32 lenAttrInfo);
2547
void storedSeizeAttrinbufrecErrorLab(Signal* signal,
2548
Operationrec* regOperPtr,
2550
bool storedProcedureAttrInfo(Signal* signal,
2551
Operationrec* regOperPtr,
2556
//-----------------------------------------------------------------------------
2557
// Table Descriptor Memory Manager
2558
//-----------------------------------------------------------------------------
2561
Uint32 getTabDescrOffsets(const Tablerec* regTabPtr, Uint32* offset);
2562
Uint32 allocTabDescr(const Tablerec* regTabPtr, Uint32* offset);
2563
void freeTabDescr(Uint32 retRef, Uint32 retNo, bool normal = true);
2564
Uint32 getTabDescrWord(Uint32 index);
2565
void setTabDescrWord(Uint32 index, Uint32 word);
2568
Uint32 sizeOfReadFunction();
2569
void removeTdArea(Uint32 tabDesRef, Uint32 list);
2570
void insertTdArea(Uint32 tabDesRef, Uint32 list);
2571
void itdaMergeTabDescr(Uint32& retRef, Uint32& retNo, bool normal);
2573
void verifytabdes();
2576
void seizeOpRec(OperationrecPtr& regOperPtr);
2577
void seizeFragrecord(FragrecordPtr& regFragPtr);
2578
void seizeFragoperrec(FragoperrecPtr& fragOperPtr);
2579
void releaseFragoperrec(FragoperrecPtr fragOperPtr);
2580
void releaseFragrec(FragrecordPtr);
2581
//----------------------------------------------------------------------------
2582
// Page Memory Manager
2583
//----------------------------------------------------------------------------
2586
void allocConsPages(Uint32 noOfPagesToAllocate,
2587
Uint32& noOfPagesAllocated,
2588
Uint32& allocPageRef);
2589
void returnCommonArea(Uint32 retPageRef, Uint32 retNo);
2590
void initializePage();
2593
void removeCommonArea(Uint32 remPageRef, Uint32 list);
2594
void insertCommonArea(Uint32 insPageRef, Uint32 list);
2595
void findFreeLeftNeighbours(Uint32& allocPageRef, Uint32& noPagesAllocated, Uint32 noPagesToAllocate);
2596
void findFreeRightNeighbours(Uint32& allocPageRef, Uint32& noPagesAllocated, Uint32 noPagesToAllocate);
2597
Uint32 nextHigherTwoLog(Uint32 input);
2600
Uint32 cfreepageList[16];
2602
//------------------------------------------------------------------------------------------------------
2603
// Page Mapper, convert logical page id's to physical page id's
2604
// The page mapper also handles the pages allocated to the fragment.
2605
//------------------------------------------------------------------------------------------------------
2608
Uint32 getRealpid(Fragrecord* regFragPtr, Uint32 logicalPageId);
2609
Uint32 getNoOfPages(Fragrecord* regFragPtr);
2610
void initPageRangeSize(Uint32 size);
2611
bool insertPageRangeTab(Fragrecord* regFragPtr,
2614
void releaseFragPages(Fragrecord* regFragPtr);
2615
void initFragRange(Fragrecord* regFragPtr);
2616
void initializePageRange();
2617
Uint32 getEmptyPage(Fragrecord* regFragPtr);
2618
Uint32 allocFragPages(Fragrecord* regFragPtr, Uint32 noOfPagesAllocated);
2619
Uint32 get_empty_var_page(Fragrecord* frag_ptr);
2622
Uint32 leafPageRangeFull(Fragrecord* regFragPtr, PageRangePtr currPageRangePtr);
2623
void releasePagerange(PageRangePtr regPRPtr);
2624
void seizePagerange(PageRangePtr& regPageRangePtr);
2625
void errorHandler(Uint32 errorCode);
2626
void allocMoreFragPages(Fragrecord* regFragPtr);
2629
Uint32 cfirstfreerange;
2630
PageRange *pageRange;
2631
Uint32 c_noOfFreePageRanges;
2632
Uint32 cnoOfPageRangeRec;
2634
//---------------------------------------------------------------
2635
// Variable Allocator
2636
// Allocates and deallocates tuples of fixed size on a fragment.
2637
//---------------------------------------------------------------
2641
void init_list_sizes(void);
2645
Uint32 get_alloc_page(Fragrecord* const, Uint32);
2646
void update_free_page_list(Fragrecord* const, Ptr<Page>);
2649
Uint32 calc_free_list(const Tablerec* regTabPtr, Uint32 sz) const {
2650
return regTabPtr->m_disk_alloc_info.calc_page_free_bits(sz);
2654
Uint32 calculate_free_list_impl(Uint32) const ;
2655
void remove_free_page(Fragrecord*, Var_page*, Uint32);
2656
void insert_free_page(Fragrecord*, Var_page*, Uint32);
2658
//---------------------------------------------------------------
2660
// Allocates and deallocates tuples of fixed size on a fragment.
2661
//---------------------------------------------------------------
2664
Uint32* alloc_var_rec(Fragrecord*, Tablerec*, Uint32, Local_key*, Uint32*);
2665
void free_var_rec(Fragrecord*, Tablerec*, Local_key*, Ptr<Page>);
2666
Uint32* alloc_var_part(Fragrecord*, Tablerec*, Uint32, Local_key*);
2667
int realloc_var_part(Fragrecord*, Tablerec*,
2668
PagePtr, Var_part_ref*, Uint32, Uint32);
2670
void validate_page(Tablerec*, Var_page* page);
2672
Uint32* alloc_fix_rec(Fragrecord*const, Tablerec*const, Local_key*,
2674
void free_fix_rec(Fragrecord*, Tablerec*, Local_key*, Fix_page*);
2676
Uint32* alloc_fix_rowid(Fragrecord*, Tablerec*, Local_key*, Uint32 *);
2677
Uint32* alloc_var_rowid(Fragrecord*, Tablerec*, Uint32, Local_key*, Uint32*);
2679
void convertThPage(Fix_page* regPagePtr,
2686
Uint32 alloc_tuple_from_page(Fragrecord* regFragPtr,
2687
Fix_page* regPagePtr);
2689
//---------------------------------------------------------------
2690
// Temporary variables used for storing commonly used variables
2691
// in certain modules
2692
//---------------------------------------------------------------
2694
Uint32 c_lcp_scan_op;
2695
FragrecordPtr fragptr;
2696
OperationrecPtr operPtr;
2699
// readAttributes and updateAttributes module
2700
//------------------------------------------------------------------------------------------------------
2701
// Common stored variables. Variables that have a valid value always.
2702
//------------------------------------------------------------------------------------------------------
2703
Attrbufrec *attrbufrec;
2704
Uint32 cfirstfreeAttrbufrec;
2705
Uint32 cnoOfAttrbufrec;
2706
Uint32 cnoFreeAttrbufrec;
2708
Fragoperrec *fragoperrec;
2709
Uint32 cfirstfreeFragopr;
2710
Uint32 cnoOfFragoprec;
2712
Fragrecord *fragrecord;
2713
Uint32 cfirstfreefrag;
2714
Uint32 cnoOfFragrec;
2716
HostBuffer *hostBuffer;
2718
ArrayPool<Operationrec> c_operation_pool;
2720
ArrayPool<Page> c_page_pool;
2721
Uint32 cnoOfAllocatedPages;
2722
Uint32 m_max_allocate_pages;
2724
/* read ahead in pages during disk order scan */
2725
Uint32 m_max_page_read_ahead;
2728
Uint32 cnoOfTablerec;
2730
TableDescriptor *tableDescriptor;
2731
Uint32 cnoOfTabDescrRec;
2734
Uint32 cdataPages[16];
2735
Uint32 cpackedListIndex;
2736
Uint32 cpackedList[MAX_NODES];
2737
Uint32 cfreeTdList[16];
2738
Uint32 clastBitMask;
2739
Uint32 clblPageCounter;
2740
Uint32 clblPagesPerTick;
2741
Uint32 clblPagesPerTickAfterSr;
2742
BlockReference clqhBlockref;
2743
Uint32 clqhUserpointer;
2745
BlockReference cndbcntrRef;
2746
BlockReference cownref;
2750
// A little bit bigger to cover overwrites in copy algorithms (16384 real size).
2751
#define ZATTR_BUFFER_SIZE 16384
2752
Uint32 clogMemBuffer[ZATTR_BUFFER_SIZE + 16];
2753
Uint32 coutBuffer[ZATTR_BUFFER_SIZE + 16];
2754
Uint32 cinBuffer[ZATTR_BUFFER_SIZE + 16];
2755
Uint32 ctemp_page[ZWORDS_ON_PAGE];
2756
Uint32 ctemp_var_record[ZWORDS_ON_PAGE];
2757
Uint32 totNoOfPagesAllocated;
2759
// Trigger variables
2760
Uint32 c_maxTriggersPerTable;
2761
Uint32 c_memusage_report_frequency;
2763
Uint32 c_errorInsert4000TableId;
2764
Uint32 c_min_list_size[MAX_FREE_LIST + 1];
2765
Uint32 c_max_list_size[MAX_FREE_LIST + 1];
2767
void initGlobalTemporaryVars();
2768
void reportMemoryUsage(Signal* signal, int incDec);
2775
friend class NdbOut& operator<<(NdbOut&, const Operationrec&);
2776
friend class NdbOut& operator<<(NdbOut&, const Th&);
2779
void expand_tuple(KeyReqStruct*, Uint32 sizes[4], Tuple_header*org,
2780
const Tablerec*, bool disk);
2781
void shrink_tuple(KeyReqStruct*, Uint32 sizes[2], const Tablerec*,
2784
Uint32* get_ptr(Var_part_ref);
2785
Uint32* get_ptr(PagePtr*, Var_part_ref);
2786
Uint32* get_ptr(PagePtr*, const Local_key*, const Tablerec*);
2787
Uint32* get_dd_ptr(PagePtr*, const Local_key*, const Tablerec*);
2790
* prealloc space from disk
2791
* key.m_file_no contains file no
2792
* key.m_page_no contains disk page
2793
* key.m_page_idx contains byte preallocated
2795
int disk_page_prealloc(Signal*, Ptr<Fragrecord>, Local_key*, Uint32);
2796
void disk_page_prealloc_dirty_page(Disk_alloc_info&,
2797
Ptr<Page>, Uint32, Uint32);
2798
void disk_page_prealloc_transit_page(Disk_alloc_info&,
2799
Ptr<Page_request>, Uint32, Uint32);
2801
void disk_page_abort_prealloc(Signal*, Fragrecord*,Local_key*, Uint32);
2802
void disk_page_abort_prealloc_callback(Signal*, Uint32, Uint32);
2803
void disk_page_abort_prealloc_callback_1(Signal*, Fragrecord*,
2806
void disk_page_prealloc_callback(Signal*, Uint32, Uint32);
2807
void disk_page_prealloc_initial_callback(Signal*, Uint32, Uint32);
2808
void disk_page_prealloc_callback_common(Signal*,
2813
void disk_page_alloc(Signal*,
2814
Tablerec*, Fragrecord*, Local_key*, PagePtr, Uint32);
2815
void disk_page_free(Signal*,
2816
Tablerec*, Fragrecord*, Local_key*, PagePtr, Uint32);
2818
void disk_page_commit_callback(Signal*, Uint32 opPtrI, Uint32 page_id);
2820
void disk_page_log_buffer_callback(Signal*, Uint32 opPtrI, Uint32);
2822
void disk_page_alloc_extent_log_buffer_callback(Signal*, Uint32, Uint32);
2823
void disk_page_free_extent_log_buffer_callback(Signal*, Uint32, Uint32);
2825
Uint64 disk_page_undo_alloc(Page*, const Local_key*,
2826
Uint32 sz, Uint32 gci, Uint32 logfile_group_id);
2828
Uint64 disk_page_undo_update(Page*, const Local_key*,
2829
const Uint32*, Uint32,
2830
Uint32 gci, Uint32 logfile_group_id);
2832
Uint64 disk_page_undo_free(Page*, const Local_key*,
2833
const Uint32*, Uint32 sz,
2834
Uint32 gci, Uint32 logfile_group_id);
2836
void undo_createtable_callback(Signal* signal, Uint32 opPtrI, Uint32 unused);
2837
void undo_createtable_logsync_callback(Signal* signal, Uint32, Uint32);
2839
void drop_table_log_buffer_callback(Signal*, Uint32, Uint32);
2840
void drop_table_logsync_callback(Signal*, Uint32, Uint32);
2842
void disk_page_set_dirty(Ptr<Page>);
2843
void restart_setup_page(Disk_alloc_info&, Ptr<Page>);
2844
void update_extent_pos(Disk_alloc_info&, Ptr<Extent_info>);
2850
int disk_page_load_hook(Uint32 page_id);
2852
void disk_page_unmap_callback(Uint32 when, Uint32 page, Uint32 dirty_count);
2854
int disk_restart_alloc_extent(Uint32 tableId, Uint32 fragId,
2855
const Local_key* key, Uint32 pages);
2856
void disk_restart_page_bits(Uint32 tableId, Uint32 fragId,
2857
const Local_key*, Uint32 bits);
2858
void disk_restart_undo(Signal* signal, Uint64 lsn,
2859
Uint32 type, const Uint32 * ptr, Uint32 len);
2863
Uint32 m_type, m_len;
2864
const Uint32* m_ptr;
2866
Ptr<Tablerec> m_table_ptr;
2867
Ptr<Fragrecord> m_fragment_ptr;
2868
Ptr<Page> m_page_ptr;
2869
Ptr<Extent_info> m_extent_ptr;
2873
void disk_restart_lcp_id(Uint32 table, Uint32 frag, Uint32 lcpId);
2876
void disk_restart_undo_next(Signal*);
2877
void disk_restart_undo_lcp(Uint32, Uint32, Uint32 flag, Uint32 lcpId);
2878
void disk_restart_undo_callback(Signal* signal, Uint32, Uint32);
2879
void disk_restart_undo_alloc(Apply_undo*);
2880
void disk_restart_undo_update(Apply_undo*);
2881
void disk_restart_undo_free(Apply_undo*);
2882
void disk_restart_undo_page_bits(Signal*, Apply_undo*);
2885
void verify_page_lists(Disk_alloc_info&);
2887
void verify_page_lists(Disk_alloc_info&) {}
2890
void findFirstOp(OperationrecPtr&);
2891
void commit_operation(Signal*, Uint32, Tuple_header*, PagePtr,
2892
Operationrec*, Fragrecord*, Tablerec*);
2894
void dealloc_tuple(Signal* signal, Uint32, Page*, Tuple_header*,
2895
Operationrec*, Fragrecord*, Tablerec*);
2897
int handle_size_change_after_update(KeyReqStruct* req_struct,
2900
Fragrecord* regFragPtr,
2901
Tablerec* regTabPtr,
2905
* Setup all pointer on keyreqstruct to prepare for read
2906
* req_struct->m_tuple_ptr is set to tuple to read
2908
void prepare_read(KeyReqStruct*, Tablerec* const, bool disk);
2914
Dbtup::get_frag_page_id(Uint32 real_page_id)
2916
PagePtr real_page_ptr;
2917
real_page_ptr.i= real_page_id;
2918
ptrCheckGuard(real_page_ptr, cnoOfPage, cpage);
2919
return real_page_ptr.p->frag_page_id;
2925
Dbtup::get_trans_state(Operationrec * regOperPtr)
2927
return (Dbtup::TransState)regOperPtr->op_struct.trans_state;
2932
Dbtup::set_trans_state(Operationrec* regOperPtr,
2933
Dbtup::TransState trans_state)
2935
regOperPtr->op_struct.trans_state= (Uint32)trans_state;
2940
Dbtup::get_tuple_state(Operationrec * regOperPtr)
2942
return (Dbtup::TupleState)regOperPtr->op_struct.tuple_state;
2947
Dbtup::set_tuple_state(Operationrec* regOperPtr,
2948
Dbtup::TupleState tuple_state)
2950
regOperPtr->op_struct.tuple_state= (Uint32)tuple_state;
2956
Dbtup::decr_tup_version(Uint32 tup_version)
2958
return (tup_version - 1) & ZTUP_VERSION_MASK;
2962
Dbtup::ChangeMaskState
2963
Dbtup::get_change_mask_state(Operationrec * regOperPtr)
2965
return (Dbtup::ChangeMaskState)regOperPtr->op_struct.change_mask_state;
2970
Dbtup::set_change_mask_state(Operationrec * regOperPtr,
2971
ChangeMaskState new_state)
2973
regOperPtr->op_struct.change_mask_state= (Uint32)new_state;
2978
Dbtup::update_change_mask_info(KeyReqStruct * req_struct,
2979
Operationrec * regOperPtr)
2981
if (req_struct->max_attr_id_updated == 0) {
2982
if (get_change_mask_state(regOperPtr) == USE_SAVED_CHANGE_MASK) {
2984
regOperPtr->saved_change_mask[0] |= req_struct->changeMask.getWord(0);
2985
regOperPtr->saved_change_mask[1] |= req_struct->changeMask.getWord(1);
2988
if (req_struct->no_changed_attrs < 16) {
2989
set_change_mask_state(regOperPtr, RECALCULATE_CHANGE_MASK);
2991
set_change_mask_state(regOperPtr, SET_ALL_MASK);
2998
Dbtup::get_ptr(Var_part_ref ref)
3001
return get_ptr(&tmp, ref);
3006
Dbtup::get_ptr(Ptr<Page>* pagePtr, Var_part_ref ref)
3011
tmp.i = key.m_page_no;
3013
c_page_pool.getPtr(tmp);
3014
memcpy(pagePtr, &tmp, sizeof(tmp));
3015
return ((Var_page*)tmp.p)->get_ptr(key.m_page_idx);
3020
Dbtup::get_ptr(PagePtr* pagePtr,
3021
const Local_key* key, const Tablerec* regTabPtr)
3024
tmp.i= key->m_page_no;
3025
c_page_pool.getPtr(tmp);
3026
memcpy(pagePtr, &tmp, sizeof(tmp));
3028
return ((Fix_page*)tmp.p)->
3029
get_ptr(key->m_page_idx, regTabPtr->m_offsets[MM].m_fix_header_size);
3034
Dbtup::get_dd_ptr(PagePtr* pagePtr,
3035
const Local_key* key, const Tablerec* regTabPtr)
3038
tmp.i= key->m_page_no;
3039
tmp.p= (Page*)m_global_page_pool.getPtr(tmp.i);
3040
memcpy(pagePtr, &tmp, sizeof(tmp));
3042
if(regTabPtr->m_attributes[DD].m_no_of_varsize)
3043
return ((Var_page*)tmp.p)->get_ptr(key->m_page_idx);
3045
return ((Fix_page*)tmp.p)->
3046
get_ptr(key->m_page_idx, regTabPtr->m_offsets[DD].m_fix_header_size);
3050
operator<<(NdbOut&, const Dbtup::Tablerec&);
3053
bool Dbtup::find_savepoint(OperationrecPtr& loopOpPtr, Uint32 savepointId)
3056
if (savepointId > loopOpPtr.p->savepointId) {
3060
loopOpPtr.i = loopOpPtr.p->prevActiveOp;
3061
if (loopOpPtr.i == RNIL) {
3064
c_operation_pool.getPtr(loopOpPtr);