Drizzled Public API Documentation

trx0sys.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2011, 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 "ut0bh.h"
43 #include "read0types.h"
44 #include "page0types.h"
45 
46 #include <drizzled/atomics.h>
47 
50 
52 extern trx_sys_t* trx_sys;
53 
65 
66 /****************************************************************/
69 UNIV_INTERN
70 void
72 /*================================*/
73 /****************************************************************/
80 UNIV_INTERN
81 void
83 /*======================================*/
84  ibool restore_corrupt_pages);
85 /****************************************************************/
88 UNIV_INTERN
89 void
91 /*===============================================*/
92 /****************************************************************/
96 UNIV_INTERN
97 ibool
99 /*========================*/
100  ulint page_no);
101 /***************************************************************/
104 UNIV_INLINE
105 ibool
107 /*=============*/
108  ulint space,
109  ulint page_no);
110 /*****************************************************************/
113 UNIV_INTERN
114 void
116 /*==========================*/
117 /*****************************************************************/
119 UNIV_INTERN
120 void
121 trx_sys_create(void);
122 /*================*/
123 /****************************************************************/
126 UNIV_INTERN
127 ulint
129 /*====================*/
130  mtr_t* mtr);
131 /***************************************************************/
134 UNIV_INLINE
135 trx_rseg_t*
137 /*=================*/
138  trx_sys_t* sys,
139  ulint n);
140 /***************************************************************/
142 UNIV_INLINE
143 void
145 /*=================*/
146  trx_sys_t* sys,
147  ulint n,
148  trx_rseg_t* rseg);
150 /**********************************************************************/
153 UNIV_INLINE
154 trx_sysf_t*
156 /*=========*/
157  mtr_t* mtr);
158 /*****************************************************************/
162 UNIV_INLINE
163 ulint
165 /*====================*/
166  trx_sysf_t* sys_header,
167  ulint i,
168  mtr_t* mtr);
169 /*****************************************************************/
173 UNIV_INLINE
174 ulint
176 /*======================*/
177  trx_sysf_t* sys_header,
178  ulint i,
179  mtr_t* mtr);
180 /*****************************************************************/
183 UNIV_INLINE
184 void
186 /*====================*/
187  trx_sysf_t* sys_header,
188  ulint i,
189  ulint space,
190  mtr_t* mtr);
191 /*****************************************************************/
194 UNIV_INLINE
195 void
197 /*======================*/
198  trx_sysf_t* sys_header,
199  ulint i,
200  ulint page_no,
202  mtr_t* mtr);
203 /*****************************************************************/
206 UNIV_INLINE
207 trx_id_t
209 /*========================*/
210 #endif /* !UNIV_HOTBACKUP */
211 /*****************************************************************/
215 UNIV_INLINE
216 void
218 /*=============*/
219  byte* ptr,
220  trx_id_t id);
221 #ifndef UNIV_HOTBACKUP
222 /*****************************************************************/
227 UNIV_INLINE
228 trx_id_t
230 /*============*/
231  const byte* ptr);
232 /****************************************************************/
235 UNIV_INLINE
236 trx_t*
238 /*==========*/
239  trx_id_t trx_id);
240 /****************************************************************/
246 UNIV_INLINE
247 trx_id_t
249 /*=========================*/
250 /****************************************************************/
253 UNIV_INLINE
254 ibool
256 /*==========*/
257  trx_id_t trx_id);
258 /****************************************************************/
261 UNIV_INTERN
262 ibool
264 /*============*/
265  trx_t* in_trx);
266 /*****************************************************************/
268 UNIV_INTERN
269 void
270 trx_sys_flush_commit_id(uint64_t commit_id, ulint field, mtr_t* mtr);
271 /*****************************************************************/
273 UNIV_INTERN
274 void
276 /*****************************************************************/
279 UNIV_INTERN
280 void
282 /*====================================*/
283 /*****************************************************************/
285 UNIV_INTERN
286 void
288 /*==========================*/
289 /*****************************************************************/
291 UNIV_INTERN
292 void
294 /*===========================*/
295 /********************************************************************/
300 UNIV_INTERN
301 void
303 /*==============================*/
304 #ifndef UNIV_HOTBACKUP
305 /*****************************************************************/
307 UNIV_INTERN
308 void
309 trx_sys_close(void);
310 /*===============*/
311 #endif /* !UNIV_HOTBACKUP */
312 /*****************************************************************/
315 UNIV_INTERN
316 const char*
318 /*===========================*/
319  const ulint id);
320 /*****************************************************************/
324 UNIV_INTERN
325 ibool
327 /*========================*/
328  ulint format_id,
329  const char** name);
331 /*****************************************************************/
334 UNIV_INTERN
335 const char*
337 /*=============================*/
338 /*****************************************************************/
341 UNIV_INTERN
342 ulint
344 /*==========================*/
345  ulint max_format_id);
346 /********************************************************************/
350 UNIV_INTERN
351 ibool
353 /*============================*/
354  const char** name,
355  ulint format_id);
356 #else /* !UNIV_HOTBACKUP */
357 /*****************************************************************/
363 UNIV_INTERN
364 ibool
365 trx_sys_read_file_format_id(
366 /*========================*/
367  const char *pathname,
369  ulint *format_id);
371 /*****************************************************************/
374 UNIV_INTERN
375 ibool
376 trx_sys_read_pertable_file_format_id(
377 /*=================================*/
378  const char *pathname,
380  ulint *format_id);
382 /*****************************************************************/
385 UNIV_INTERN
386 const char*
388 /*===========================*/
389  const ulint id);
391 #endif /* !UNIV_HOTBACKUP */
392 /*********************************************************************
393 Creates the rollback segments */
394 UNIV_INTERN
395 void
397 /*=================*/
398  ulint n_rsegs);
400 /* The automatically created system rollback segment has this id */
401 #define TRX_SYS_SYSTEM_RSEG_ID 0
402 
403 /* Space id and page no where the trx system file copy resides */
404 #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
405 #include "fsp0fsp.h"
406 #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
407 
408 /* The offset of the transaction system header on the page */
409 #define TRX_SYS FSEG_PAGE_DATA
410 
412 /*------------------------------------------------------------- @{ */
413 #define TRX_SYS_TRX_ID_STORE 0
425 #define TRX_SYS_FSEG_HEADER 8
428 #define TRX_SYS_RSEGS (8 + FSEG_HEADER_SIZE)
429 
432 /*------------------------------------------------------------- @} */
433 
434 /* Max number of rollback segments: the number of segment specification slots
435 in the transaction system array; rollback segment id must fit in one (signed)
436 byte, therefore 128; each slot is currently 8 bytes in size. If you want
437 to raise the level to 256 then you will need to fix some assertions that
438 impose the 7 bit restriction. e.g., mach_write_to_3() */
439 #define TRX_SYS_N_RSEGS 128
440 /* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one
441 rollback segment. It initialized some arrays with this number of entries.
442 We must remember this limit in order to keep file compatibility. */
443 #define TRX_SYS_OLD_N_RSEGS 256
444 
448 #define TRX_SYS_MYSQL_LOG_NAME_LEN 512
449 
450 #define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
451 
454 #define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000)
455 
457 #define TRX_SYS_DRIZZLE_LOG_INFO (UNIV_PAGE_SIZE - 1000)
458 #define TRX_SYS_DRIZZLE_MAX_COMMIT_ID 8
460 #define TRX_SYS_DRIZZLE_LOG_NAME 12
463 /* @{ */
464 
465 #define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200)
466 /*-------------------------------------------------------------*/
467 #define TRX_SYS_DOUBLEWRITE_FSEG 0
470 #define TRX_SYS_DOUBLEWRITE_MAGIC FSEG_HEADER_SIZE
475 #define TRX_SYS_DOUBLEWRITE_BLOCK1 (4 + FSEG_HEADER_SIZE)
476 
482 #define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE)
483 
488 #define TRX_SYS_DOUBLEWRITE_REPEAT 12
501 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE)
502 
503 /*-------------------------------------------------------------*/
505 #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855
506 
507 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386
508 
510 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE
511 /* @} */
512 
513 #ifndef UNIV_HOTBACKUP
514 
515 /* @{ */
518 #define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16)
519 
522 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL
523 
524 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH 2745987765UL
527 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N \
528  ((ib_uint64_t) TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH << 32 \
529  | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW)
530 /* @} */
536  ulint block1;
538  ulint block2;
539  ulint first_free;
541  byte* write_buf;
545  byte* write_buf_unaligned;
547  buf_page_t**
550 };
554 struct trx_sys_struct{
559  UT_LIST_BASE_NODE_T(trx_t) trx_list;
563  UT_LIST_BASE_NODE_T(trx_t) mysql_trx_list;
566  UT_LIST_BASE_NODE_T(trx_rseg_t) rseg_list;
572  trx_rseg_t* rseg_array[TRX_SYS_N_RSEGS];
575  ulint rseg_history_len;
582 };
583 
587 #define TRX_SYS_TRX_ID_WRITE_MARGIN 256
588 #endif /* !UNIV_HOTBACKUP */
589 
590 #ifndef UNIV_NONINL
591 #include "trx0sys.ic"
592 #endif
594 #endif