Drizzled Public API Documentation

trx0sys.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #pragma once
27 #ifndef trx0sys_h
28 #define trx0sys_h
29 
30 #include "univ.i"
31 
32 #include "trx0types.h"
33 #include "fsp0types.h"
34 #include "fil0fil.h"
35 #include "buf0buf.h"
36 #ifndef UNIV_HOTBACKUP
37 #include "mtr0mtr.h"
38 #include "ut0byte.h"
39 #include "mem0mem.h"
40 #include "sync0sync.h"
41 #include "ut0lst.h"
42 #include "read0types.h"
43 #include "page0types.h"
44 
45 #include <drizzled/atomics.h>
46 
49 
51 extern trx_sys_t* trx_sys;
52 
64 
65 /****************************************************************/
68 UNIV_INTERN
69 void
71 /*================================*/
72 /****************************************************************/
79 UNIV_INTERN
80 void
82 /*======================================*/
83  ibool restore_corrupt_pages);
84 /****************************************************************/
87 UNIV_INTERN
88 void
90 /*===============================================*/
91 /****************************************************************/
95 UNIV_INTERN
96 ibool
98 /*========================*/
99  ulint page_no);
100 /***************************************************************/
103 UNIV_INLINE
104 ibool
106 /*=============*/
107  ulint space,
108  ulint page_no);
109 /*****************************************************************/
112 UNIV_INTERN
113 void
115 /*==========================*/
116 /*****************************************************************/
118 UNIV_INTERN
119 void
120 trx_sys_create(void);
121 /*================*/
122 /****************************************************************/
125 UNIV_INTERN
126 ulint
128 /*====================*/
129  mtr_t* mtr);
130 /***************************************************************/
133 UNIV_INLINE
134 trx_rseg_t*
136 /*=================*/
137  trx_sys_t* sys,
138  ulint n);
139 /***************************************************************/
141 UNIV_INLINE
142 void
144 /*=================*/
145  trx_sys_t* sys,
146  ulint n,
147  trx_rseg_t* rseg);
149 /**********************************************************************/
152 UNIV_INLINE
153 trx_sysf_t*
155 /*=========*/
156  mtr_t* mtr);
157 /*****************************************************************/
161 UNIV_INLINE
162 ulint
164 /*====================*/
165  trx_sysf_t* sys_header,
166  ulint i,
167  mtr_t* mtr);
168 /*****************************************************************/
172 UNIV_INLINE
173 ulint
175 /*======================*/
176  trx_sysf_t* sys_header,
177  ulint i,
178  mtr_t* mtr);
179 /*****************************************************************/
182 UNIV_INLINE
183 void
185 /*====================*/
186  trx_sysf_t* sys_header,
187  ulint i,
188  ulint space,
189  mtr_t* mtr);
190 /*****************************************************************/
193 UNIV_INLINE
194 void
196 /*======================*/
197  trx_sysf_t* sys_header,
198  ulint i,
199  ulint page_no,
201  mtr_t* mtr);
202 /*****************************************************************/
205 UNIV_INLINE
206 trx_id_t
208 /*========================*/
209 /*****************************************************************/
212 UNIV_INLINE
213 trx_id_t
215 /*========================*/
216 #endif /* !UNIV_HOTBACKUP */
217 /*****************************************************************/
221 UNIV_INLINE
222 void
224 /*=============*/
225  byte* ptr,
226  trx_id_t id);
227 #ifndef UNIV_HOTBACKUP
228 /*****************************************************************/
233 UNIV_INLINE
234 trx_id_t
236 /*============*/
237  const byte* ptr);
238 /****************************************************************/
241 UNIV_INLINE
242 trx_t*
244 /*==========*/
245  trx_id_t trx_id);
246 /****************************************************************/
252 UNIV_INLINE
253 trx_id_t
255 /*=========================*/
256 /****************************************************************/
259 UNIV_INLINE
260 ibool
262 /*==========*/
263  trx_id_t trx_id);
264 /****************************************************************/
267 UNIV_INTERN
268 ibool
270 /*============*/
271  trx_t* in_trx);
272 /*****************************************************************/
274 UNIV_INTERN
275 void
276 trx_sys_flush_commit_id(uint64_t commit_id, ulint field, mtr_t* mtr);
277 /*****************************************************************/
279 UNIV_INTERN
280 void
282 /*****************************************************************/
285 UNIV_INTERN
286 void
288 /*====================================*/
289 /*****************************************************************/
291 UNIV_INTERN
292 void
294 /*==========================*/
295 /*****************************************************************/
297 UNIV_INTERN
298 void
300 /*===========================*/
301 /********************************************************************/
306 UNIV_INTERN
307 void
309 /*==============================*/
310 #ifndef UNIV_HOTBACKUP
311 /*****************************************************************/
313 UNIV_INTERN
314 void
315 trx_sys_close(void);
316 /*===============*/
317 #endif /* !UNIV_HOTBACKUP */
318 /*****************************************************************/
321 UNIV_INTERN
322 const char*
324 /*===========================*/
325  const ulint id);
326 /*****************************************************************/
330 UNIV_INTERN
331 ibool
333 /*========================*/
334  ulint format_id,
335  const char** name);
337 /*****************************************************************/
340 UNIV_INTERN
341 const char*
343 /*=============================*/
344 /*****************************************************************/
347 UNIV_INTERN
348 ulint
350 /*==========================*/
351  ulint max_format_id);
352 /********************************************************************/
356 UNIV_INTERN
357 ibool
359 /*============================*/
360  const char** name,
361  ulint format_id);
362 #else /* !UNIV_HOTBACKUP */
363 /*****************************************************************/
369 UNIV_INTERN
370 ibool
371 trx_sys_read_file_format_id(
372 /*========================*/
373  const char *pathname,
375  ulint *format_id);
377 /*****************************************************************/
380 UNIV_INTERN
381 ibool
382 trx_sys_read_pertable_file_format_id(
383 /*=================================*/
384  const char *pathname,
386  ulint *format_id);
388 /*****************************************************************/
391 UNIV_INTERN
392 const char*
394 /*===========================*/
395  const ulint id);
397 #endif /* !UNIV_HOTBACKUP */
398 /*********************************************************************
399 Creates the rollback segments */
400 UNIV_INTERN
401 void
403 /*=================*/
404  ulint n_rsegs);
406 /* The automatically created system rollback segment has this id */
407 #define TRX_SYS_SYSTEM_RSEG_ID 0
408 
409 /* Space id and page no where the trx system file copy resides */
410 #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
411 #include "fsp0fsp.h"
412 #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
413 
414 /* The offset of the transaction system header on the page */
415 #define TRX_SYS FSEG_PAGE_DATA
416 
418 /*------------------------------------------------------------- @{ */
419 #define TRX_SYS_TRX_ID_STORE 0
431 #define TRX_SYS_FSEG_HEADER 8
434 #define TRX_SYS_RSEGS (8 + FSEG_HEADER_SIZE)
435 
438 /*------------------------------------------------------------- @} */
439 
440 /* Max number of rollback segments: the number of segment specification slots
441 in the transaction system array; rollback segment id must fit in one (signed)
442 byte, therefore 128; each slot is currently 8 bytes in size. If you want
443 to raise the level to 256 then you will need to fix some assertions that
444 impose the 7 bit restriction. e.g., mach_write_to_3() */
445 #define TRX_SYS_N_RSEGS 128
446 /* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one
447 rollback segment. It initialized some arrays with this number of entries.
448 We must remember this limit in order to keep file compatibility. */
449 #define TRX_SYS_OLD_N_RSEGS 256
450 
454 #define TRX_SYS_MYSQL_LOG_NAME_LEN 512
455 
456 #define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
457 
460 #define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000)
461 
463 #define TRX_SYS_DRIZZLE_LOG_INFO (UNIV_PAGE_SIZE - 1000)
464 #define TRX_SYS_DRIZZLE_MAX_COMMIT_ID 8
466 #define TRX_SYS_DRIZZLE_LOG_NAME 12
469 /* @{ */
470 
471 #define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200)
472 /*-------------------------------------------------------------*/
473 #define TRX_SYS_DOUBLEWRITE_FSEG 0
476 #define TRX_SYS_DOUBLEWRITE_MAGIC FSEG_HEADER_SIZE
477 
481 #define TRX_SYS_DOUBLEWRITE_BLOCK1 (4 + FSEG_HEADER_SIZE)
482 
488 #define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE)
489 
494 #define TRX_SYS_DOUBLEWRITE_REPEAT 12
507 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE)
508 
509 /*-------------------------------------------------------------*/
511 #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855
512 
513 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386
514 
516 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE
517 /* @} */
518 
519 #ifndef UNIV_HOTBACKUP
520 
521 /* @{ */
524 #define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16)
525 
528 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL
529 
530 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH 2745987765UL
531 
533 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N \
534  ((ib_uint64_t) TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH << 32 \
535  | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW)
536 /* @} */
537 
542  ulint block1;
544  ulint block2;
545  ulint first_free;
547  byte* write_buf;
551  byte* write_buf_unaligned;
553  buf_page_t**
556 };
557 
565  UT_LIST_BASE_NODE_T(trx_t) trx_list;
569  UT_LIST_BASE_NODE_T(trx_t) mysql_trx_list;
572  UT_LIST_BASE_NODE_T(trx_rseg_t) rseg_list;
578  trx_rseg_t* rseg_array[TRX_SYS_N_RSEGS];
585  UT_LIST_BASE_NODE_T(read_view_t) view_list;
588 };
589 
593 #define TRX_SYS_TRX_ID_WRITE_MARGIN 256
594 #endif /* !UNIV_HOTBACKUP */
595 
596 #ifndef UNIV_NONINL
597 #include "trx0sys.ic"
598 #endif
599 
600 #endif